Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/super-must-be-called.js

raw
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: Super need to be called to initialize internals
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 M1 extends WeakMap {
21 constructor() {}
22 }
23
24 assert.throws(ReferenceError, function() {
25 new M1();
26 });
27
28 class M2 extends WeakMap {
29 constructor() {
30 super();
31 }
32 }
33
34 new M2();
35
36 reportCompare(0, 0);