| 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/async-arrow-function.template |
| 4 |
/*--- |
| 5 |
description: Use of initializer when argument value is not `undefined` (async arrow function expression) |
| 6 |
esid: sec-async-arrow-function-definitions |
| 7 |
features: [default-parameters] |
| 8 |
flags: [generated, async] |
| 9 |
info: | |
| 10 |
14.7 Async Arrow Function Definitions |
| 11 |
|
| 12 |
AsyncArrowFunction : |
| 13 |
... |
| 14 |
CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody |
| 15 |
|
| 16 |
AsyncConciseBody : |
| 17 |
{ AsyncFunctionBody } |
| 18 |
|
| 19 |
... |
| 20 |
|
| 21 |
Supplemental Syntax |
| 22 |
|
| 23 |
When processing an instance of the production AsyncArrowFunction : |
| 24 |
CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody the interpretation of |
| 25 |
CoverCallExpressionAndAsyncArrowHead is refined using the following grammar: |
| 26 |
|
| 27 |
AsyncArrowHead : |
| 28 |
async ArrowFormalParameters |
| 29 |
|
| 30 |
|
| 31 |
14.1.19 Runtime Semantics: IteratorBindingInitialization |
| 32 |
|
| 33 |
FormalsList : FormalsList , FormalParameter |
| 34 |
|
| 35 |
[...] |
| 36 |
23. Let iteratorRecord be Record {[[Iterator]]: |
| 37 |
CreateListIterator(argumentsList), [[Done]]: false}. |
| 38 |
24. If hasDuplicates is true, then |
| 39 |
[...] |
| 40 |
25. Else, |
| 41 |
a. Perform ? IteratorBindingInitialization for formals with |
| 42 |
iteratorRecord and env as arguments. |
| 43 |
[...] |
| 44 |
|
| 45 |
---*/ |
| 46 |
var obj = {}; |
| 47 |
var falseCount = 0; |
| 48 |
var stringCount = 0; |
| 49 |
var nanCount = 0; |
| 50 |
var zeroCount = 0; |
| 51 |
var nullCount = 0; |
| 52 |
var objCount = 0; |
| 53 |
|
| 54 |
|
| 55 |
var callCount = 0; |
| 56 |
|
| 57 |
// Stores a reference `ref` for case evaluation |
| 58 |
var ref = async (aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) => { |
| 59 |
assert.sameValue(aFalse, false); |
| 60 |
assert.sameValue(aString, ''); |
| 61 |
assert.sameValue(aNaN, NaN); |
| 62 |
assert.sameValue(a0, 0); |
| 63 |
assert.sameValue(aNull, null); |
| 64 |
assert.sameValue(aObj, obj); |
| 65 |
callCount = callCount + 1; |
| 66 |
}; |
| 67 |
|
| 68 |
ref(false, '', NaN, 0, null, obj).then(() => { |
| 69 |
assert.sameValue(callCount, 1, 'async arrow function invoked exactly once') |
| 70 |
}).then($DONE, $DONE); |
| 71 |
|
| 72 |
assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); |
| 73 |
assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); |
| 74 |
assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); |
| 75 |
assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); |
| 76 |
assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); |
| 77 |
assert.sameValue(objCount, 0, 'initializer not evaluated: object'); |