Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/meth-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-expr-meth-static.template
4 /*---
5 description: Use of initializer when argument value is not `undefined` (static class expression method)
6 esid: sec-class-definitions-runtime-semantics-evaluation
7 features: [default-parameters]
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 b. Else,
23 Let status be the result of performing PropertyDefinitionEvaluation for
24 m with arguments F and false.
25 [...]
26
27 14.3.8 Runtime Semantics: DefineMethod
28
29 MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody }
30
31 [...]
32 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody,
33 scope, strict). If functionPrototype was passed as a parameter then pass its
34 value as the functionPrototype optional argument of FunctionCreate.
35 [...]
36
37 9.2.1 [[Call]] ( thisArgument, argumentsList)
38
39 [...]
40 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
41 [...]
42
43 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
44
45 1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
46 [...]
47
48 9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
49
50 [...]
51 23. Let iteratorRecord be Record {[[iterator]]:
52 CreateListIterator(argumentsList), [[done]]: false}.
53 24. If hasDuplicates is true, then
54 [...]
55 25. Else,
56 b. Let formalStatus be IteratorBindingInitialization for formals with
57 iteratorRecord and env as arguments.
58 [...]
59
60 14.1.19 Runtime Semantics: IteratorBindingInitialization
61
62 FormalsList : FormalsList , FormalParameter
63
64 [...]
65 23. Let iteratorRecord be Record {[[Iterator]]:
66 CreateListIterator(argumentsList), [[Done]]: false}.
67 24. If hasDuplicates is true, then
68 [...]
69 25. Else,
70 a. Perform ? IteratorBindingInitialization for formals with
71 iteratorRecord and env as arguments.
72 [...]
73
74 ---*/
75 var obj = {};
76 var falseCount = 0;
77 var stringCount = 0;
78 var nanCount = 0;
79 var zeroCount = 0;
80 var nullCount = 0;
81 var objCount = 0;
82
83 var callCount = 0;
84 var C = class {
85 static method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) {
86 assert.sameValue(aFalse, false);
87 assert.sameValue(aString, '');
88 assert.sameValue(aNaN, NaN);
89 assert.sameValue(a0, 0);
90 assert.sameValue(aNull, null);
91 assert.sameValue(aObj, obj);
92 callCount = callCount + 1;
93 }
94 };
95
96 C.method(false, '', NaN, 0, null, obj);
97
98 // Stores a reference `ref` for case evaluation
99 var ref = C.method;
100
101 assert.sameValue(callCount, 1, 'method invoked exactly once');
102
103 assert.sameValue(falseCount, 0, 'initializer not evaluated: false');
104 assert.sameValue(stringCount, 0, 'initializer not evaluated: string');
105 assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN');
106 assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0');
107 assert.sameValue(nullCount, 0, 'initializer not evaluated: null');
108 assert.sameValue(objCount, 0, 'initializer not evaluated: object');