js/src/tests/test262/language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js
raw symbols SCIP| 1 | // |reftest| async |
| 2 | // This file was procedurally generated from the following sources: |
| 3 | // - src/dstr-binding/ary-ptrn-rest-id-elision.case |
| 4 | // - src/dstr-binding/default/async-gen-func-decl-dflt.template |
| 5 | /*--- |
| 6 | description: Rest element following elision elements (async generator function declaration (default parameter)) |
| 7 | esid: sec-asyncgenerator-definitions-instantiatefunctionobject |
| 8 | features: [async-iteration] |
| 9 | flags: [generated, async] |
| 10 | info: | |
| 11 | AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier |
| 12 | ( FormalParameters ) { AsyncGeneratorBody } |
| 13 | |
| 14 | [...] |
| 15 | 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody, |
| 16 | scope, strict). |
| 17 | [...] |
| 18 | |
| 19 | |
| 20 | 13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 21 | ArrayBindingPattern : [ Elisionopt BindingRestElement ] |
| 22 | 1. If Elision is present, then |
| 23 | a. Let status be the result of performing |
| 24 | IteratorDestructuringAssignmentEvaluation of Elision with |
| 25 | iteratorRecord as the argument. |
| 26 | b. ReturnIfAbrupt(status). |
| 27 | 2. Return the result of performing IteratorBindingInitialization for |
| 28 | BindingRestElement with iteratorRecord and environment as arguments. |
| 29 | ---*/ |
| 30 | var values = [1, 2, 3, 4, 5]; |
| 31 | |
| 32 | |
| 33 | var callCount = 0; |
| 34 | async function* f([ , , ...x] = values) { |
| 35 | assert(Array.isArray(x)); |
| 36 | assert.sameValue(x.length, 3); |
| 37 | assert.sameValue(x[0], 3); |
| 38 | assert.sameValue(x[1], 4); |
| 39 | assert.sameValue(x[2], 5); |
| 40 | assert.notSameValue(x, values); |
| 41 | callCount = callCount + 1; |
| 42 | }; |
| 43 | f().next().then(() => { |
| 44 | assert.sameValue(callCount, 1, 'invoked exactly once'); |
| 45 | }).then($DONE, $DONE); |