regular-subclassing.js (898B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 23.3.1 5 description: Subclassing the WeakMap object 6 info: | 7 23.3.1 The WeakMap Constructor 8 9 ... 10 11 The WeakMap constructor is designed to be subclassable. It may be used as the 12 value in an extends clause of a class definition. Subclass constructors that 13 intend to inherit the specified WeakMap behaviour must include a super call to 14 the WeakMap constructor to create and initialize the subclass instance with 15 the internal state necessary to support the WeakMap.prototype built-in 16 methods. 17 features: [WeakMap] 18 ---*/ 19 20 class WM extends WeakMap {} 21 22 var map = new WM(); 23 var obj = {}; 24 25 assert.sameValue(map.has(obj), false); 26 27 map.set(obj, 42); 28 assert.sameValue(map.has(obj), true); 29 assert.sameValue(map.get(obj), 42); 30 31 reportCompare(0, 0);