Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.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: Subclassing GeneratorFunction
6 info: |
7 25.2.1 The GeneratorFunction Constructor
8
9 ...
10
11 GeneratorFunction is designed to be subclassable. It may be used as the value
12 of an extends clause of a class definition. Subclass constructors that intend
13 to inherit the specified GeneratorFunction behaviour must include a super call
14 to the GeneratorFunction constructor to create and initialize subclass
15 instances with the internal slots necessary for built-in GeneratorFunction
16 behaviour.
17 ...
18 ---*/
19
20 var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
21
22 class Gfn extends GeneratorFunction {}
23
24 var gfn = new Gfn('a', 'yield a; yield a * 2;');
25
26 var iter = gfn(42);
27
28 assert.sameValue(iter.next().value, 42);
29 assert.sameValue(iter.next().value, 84);
30
31 reportCompare(0, 0);