js/src/tests/test262/language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js
raw symbols SCIP| 1 | // |reftest| async |
| 2 | // This file was procedurally generated from the following sources: |
| 3 | // - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case |
| 4 | // - src/dstr-binding/default/async-gen-func-expr-dflt.template |
| 5 | /*--- |
| 6 | description: BindingElement with array binding pattern and initializer is used (async generator function expression (default parameter)) |
| 7 | esid: sec-asyncgenerator-definitions-evaluation |
| 8 | features: [generators, async-iteration] |
| 9 | flags: [generated, async] |
| 10 | info: | |
| 11 | AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { |
| 12 | AsyncGeneratorBody } |
| 13 | |
| 14 | [...] |
| 15 | 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, |
| 16 | AsyncGeneratorBody, scope, strict). |
| 17 | [...] |
| 18 | |
| 19 | |
| 20 | 13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 21 | |
| 22 | BindingElement : BindingPatternInitializer opt |
| 23 | |
| 24 | [...] |
| 25 | 2. If iteratorRecord.[[done]] is true, let v be undefined. |
| 26 | 3. If Initializer is present and v is undefined, then |
| 27 | a. Let defaultValue be the result of evaluating Initializer. |
| 28 | b. Let v be ? GetValue(defaultValue). |
| 29 | 4. Return the result of performing BindingInitialization of BindingPattern |
| 30 | with v and environment as the arguments. |
| 31 | |
| 32 | ---*/ |
| 33 | var first = 0; |
| 34 | var second = 0; |
| 35 | function* g() { |
| 36 | first += 1; |
| 37 | yield; |
| 38 | second += 1; |
| 39 | }; |
| 40 | |
| 41 | |
| 42 | var callCount = 0; |
| 43 | var f; |
| 44 | f = async function*([[,] = g()] = []) { |
| 45 | assert.sameValue(first, 1); |
| 46 | assert.sameValue(second, 0); |
| 47 | callCount = callCount + 1; |
| 48 | }; |
| 49 | |
| 50 | f().next().then(() => { |
| 51 | assert.sameValue(callCount, 1, 'invoked exactly once'); |
| 52 | }).then($DONE, $DONE); |