Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-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-async-meth.template
4 /*---
5 description: Use of initializer when argument value is not `undefined` (class expression async method)
6 esid: sec-class-definitions-runtime-semantics-evaluation
7 features: [default-parameters]
8 flags: [generated, async]
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 Runtime Semantics: PropertyDefinitionEvaluation
28
29 AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }
30
31 1. Let propKey be the result of evaluating PropertyName.
32 2. ReturnIfAbrupt(propKey).
33 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise
34 let strict be false.
35 4. Let scope be the LexicalEnvironment of the running execution context.
36 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody,
37 scope, strict).
38 [...]
39
40
41 14.1.19 Runtime Semantics: IteratorBindingInitialization
42
43 FormalsList : FormalsList , FormalParameter
44
45 [...]
46 23. Let iteratorRecord be Record {[[Iterator]]:
47 CreateListIterator(argumentsList), [[Done]]: false}.
48 24. If hasDuplicates is true, then
49 [...]
50 25. Else,
51 a. Perform ? IteratorBindingInitialization for formals with
52 iteratorRecord and env as arguments.
53 [...]
54
55 ---*/
56 var obj = {};
57 var falseCount = 0;
58 var stringCount = 0;
59 var nanCount = 0;
60 var zeroCount = 0;
61 var nullCount = 0;
62 var objCount = 0;
63
64 var callCount = 0;
65 var C = class {
66 async method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) {
67 assert.sameValue(aFalse, false);
68 assert.sameValue(aString, '');
69 assert.sameValue(aNaN, NaN);
70 assert.sameValue(a0, 0);
71 assert.sameValue(aNull, null);
72 assert.sameValue(aObj, obj);
73 callCount = callCount + 1;
74 }
75 }
76
77 // Stores a reference `ref` for case evaluation
78 var ref = C.prototype.method;
79
80 ref(false, '', NaN, 0, null, obj).then(() => {
81 assert.sameValue(callCount, 1, 'method invoked exactly once');
82 }).then($DONE, $DONE);
83
84 assert.sameValue(falseCount, 0, 'initializer not evaluated: false');
85 assert.sameValue(stringCount, 0, 'initializer not evaluated: string');
86 assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN');
87 assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0');
88 assert.sameValue(nullCount, 0, 'initializer not evaluated: null');
89 assert.sameValue(objCount, 0, 'initializer not evaluated: object');