| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-binding/ary-ptrn-rest-id-elision.case |
| 3 |
// - src/dstr-binding/default/async-gen-meth.template |
| 4 |
/*--- |
| 5 |
description: Rest element following elision elements (async generator method) |
| 6 |
esid: sec-asyncgenerator-definitions-propertydefinitionevaluation |
| 7 |
features: [async-iteration] |
| 8 |
flags: [generated, async] |
| 9 |
info: | |
| 10 |
AsyncGeneratorMethod : |
| 11 |
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) |
| 12 |
{ AsyncGeneratorBody } |
| 13 |
|
| 14 |
1. Let propKey be the result of evaluating PropertyName. |
| 15 |
2. ReturnIfAbrupt(propKey). |
| 16 |
3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. |
| 17 |
Otherwise let strict be false. |
| 18 |
4. Let scope be the running execution context's LexicalEnvironment. |
| 19 |
5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, |
| 20 |
AsyncGeneratorBody, scope, strict). |
| 21 |
[...] |
| 22 |
|
| 23 |
|
| 24 |
13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 25 |
ArrayBindingPattern : [ Elisionopt BindingRestElement ] |
| 26 |
1. If Elision is present, then |
| 27 |
a. Let status be the result of performing |
| 28 |
IteratorDestructuringAssignmentEvaluation of Elision with |
| 29 |
iteratorRecord as the argument. |
| 30 |
b. ReturnIfAbrupt(status). |
| 31 |
2. Return the result of performing IteratorBindingInitialization for |
| 32 |
BindingRestElement with iteratorRecord and environment as arguments. |
| 33 |
---*/ |
| 34 |
var values = [1, 2, 3, 4, 5]; |
| 35 |
|
| 36 |
|
| 37 |
var callCount = 0; |
| 38 |
var obj = { |
| 39 |
async *method([ , , ...x]) { |
| 40 |
assert(Array.isArray(x)); |
| 41 |
assert.sameValue(x.length, 3); |
| 42 |
assert.sameValue(x[0], 3); |
| 43 |
assert.sameValue(x[1], 4); |
| 44 |
assert.sameValue(x[2], 5); |
| 45 |
assert.notSameValue(x, values); |
| 46 |
callCount = callCount + 1; |
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
obj.method(values).next().then(() => { |
| 51 |
assert.sameValue(callCount, 1, 'invoked exactly once'); |
| 52 |
}).then($DONE, $DONE); |