Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/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: 25.2.1
5 description: >
6 super must be called to initialize GeneratorFunction internal slots
7 info: |
8 25.2.1 The GeneratorFunction Constructor
9
10 ...
11
12 GeneratorFunction is designed to be subclassable. It may be used as the value
13 of an extends clause of a class definition. Subclass constructors that intend
14 to inherit the specified GeneratorFunction behaviour must include a super call
15 to the GeneratorFunction constructor to create and initialize subclass
16 instances with the internal slots necessary for built-in GeneratorFunction
17 behaviour.
18 ...
19 ---*/
20
21 var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
22
23 class GFn1 extends GeneratorFunction {
24 constructor() {}
25 }
26
27 assert.throws(ReferenceError, function() {
28 new GFn1();
29 });
30
31 class GFn2 extends GeneratorFunction {
32 constructor() {
33 super();
34 }
35 }
36
37 var fn = new GFn2();
38 assert(fn instanceof GeneratorFunction);
39
40 reportCompare(0, 0);