Debian Codegraph @

js/src/tests/test262/built-ins/GeneratorFunction/instance-length.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 esid: sec-generatorfunction
5 description: Definition of instance `length` property
6 info: |
7 [...]
8 3. Return CreateDynamicFunction(C, NewTarget, "generator", args).
9
10 19.2.1.1.1 Runtime Semantics: CreateDynamicFunction
11
12 [...]
13 26. Perform FunctionInitialize(F, Normal, parameters, body, scope).
14 [...]
15
16 9.2.4 FunctionInitialize
17
18 [...]
19 3. Perform ! DefinePropertyOrThrow(F, "length",
20 PropertyDescriptor{[[Value]]: len, [[Writable]]: false, [[Enumerable]]:
21 false, [[Configurable]]: true}).
22 [...]
23 includes: [propertyHelper.js]
24 features: [generators]
25 ---*/
26
27 var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
28
29 assert.sameValue(GeneratorFunction().length, 0);
30 assert.sameValue(GeneratorFunction('').length, 0);
31 assert.sameValue(GeneratorFunction('x').length, 0);
32 assert.sameValue(GeneratorFunction('x', '').length, 1);
33 assert.sameValue(GeneratorFunction('x', 'y', '').length, 2);
34 assert.sameValue(GeneratorFunction('x, y', '').length, 2);
35
36 verifyNotEnumerable(GeneratorFunction(), 'length');
37 verifyNotWritable(GeneratorFunction(), 'length');
38 verifyConfigurable(GeneratorFunction(), 'length');
39
40 reportCompare(0, 0);