Debian Codegraph @

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