Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/gen-meth-dflt-params-arg-val-not-undefined.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/function-forms/dflt-params-arg-val-not-undefined.case
3 // - src/function-forms/default/cls-expr-gen-meth.template
4 /*---
5 description: Use of initializer when argument value is not `undefined` (class expression method)
6 esid: sec-class-definitions-runtime-semantics-evaluation
7 features: [default-parameters, generators]
8 flags: [generated]
9 info: |
10 ClassExpression : class BindingIdentifieropt ClassTail
11
12 1. If BindingIdentifieropt is not present, let className be undefined.
13 2. Else, let className be StringValue of BindingIdentifier.
14 3. Let value be the result of ClassDefinitionEvaluation of ClassTail
15 with argument className.
16 [...]
17
18 14.5.14 Runtime Semantics: ClassDefinitionEvaluation
19
20 21. For each ClassElement m in order from methods
21 a. If IsStatic of m is false, then
22 i. Let status be the result of performing
23 PropertyDefinitionEvaluation for m with arguments proto and
24 false.
25 [...]
26
27 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation
28
29 GeneratorMethod :
30 * PropertyName ( StrictFormalParameters ) { GeneratorBody }
31
32 1. Let propKey be the result of evaluating PropertyName.
33 2. ReturnIfAbrupt(propKey).
34 3. If the function code for this GeneratorMethod is strict mode code,
35 let strict be true. Otherwise let strict be false.
36 4. Let scope be the running execution context's LexicalEnvironment.
37 5. Let closure be GeneratorFunctionCreate(Method,
38 StrictFormalParameters, GeneratorBody, scope, strict).
39
40 9.2.1 [[Call]] ( thisArgument, argumentsList)
41
42 [...]
43 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
44 [...]
45
46 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
47
48 1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
49 [...]
50
51 9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
52
53 [...]
54 23. Let iteratorRecord be Record {[[iterator]]:
55 CreateListIterator(argumentsList), [[done]]: false}.
56 24. If hasDuplicates is true, then
57 [...]
58 25. Else,
59 b. Let formalStatus be IteratorBindingInitialization for formals with
60 iteratorRecord and env as arguments.
61 [...]
62
63
64 14.1.19 Runtime Semantics: IteratorBindingInitialization
65
66 FormalsList : FormalsList , FormalParameter
67
68 [...]
69 23. Let iteratorRecord be Record {[[Iterator]]:
70 CreateListIterator(argumentsList), [[Done]]: false}.
71 24. If hasDuplicates is true, then
72 [...]
73 25. Else,
74 a. Perform ? IteratorBindingInitialization for formals with
75 iteratorRecord and env as arguments.
76 [...]
77
78 ---*/
79 var obj = {};
80 var falseCount = 0;
81 var stringCount = 0;
82 var nanCount = 0;
83 var zeroCount = 0;
84 var nullCount = 0;
85 var objCount = 0;
86
87 var callCount = 0;
88 var C = class {
89 *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) {
90 assert.sameValue(aFalse, false);
91 assert.sameValue(aString, '');
92 assert.sameValue(aNaN, NaN);
93 assert.sameValue(a0, 0);
94 assert.sameValue(aNull, null);
95 assert.sameValue(aObj, obj);
96 callCount = callCount + 1;
97 }
98 };
99
100 C.prototype.method(false, '', NaN, 0, null, obj).next();
101
102 // Stores a reference `ref` for case evaluation
103 var ref = C.prototype.method;
104
105 assert.sameValue(callCount, 1, 'method invoked exactly once');
106
107 assert.sameValue(falseCount, 0, 'initializer not evaluated: false');
108 assert.sameValue(stringCount, 0, 'initializer not evaluated: string');
109 assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN');
110 assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0');
111 assert.sameValue(nullCount, 0, 'initializer not evaluated: null');
112 assert.sameValue(objCount, 0, 'initializer not evaluated: object');