tests/auto/qml/ecmascripttests/test262/test/language/expressions/object/dstr-async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js
raw symbols SCIP| 1 | // This file was procedurally generated from the following sources: |
| 2 | // - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case |
| 3 | // - src/dstr-binding/default/async-gen-method-dflt.template |
| 4 | /*--- |
| 5 | description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method (default parameter)) |
| 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 | |
| 26 | SingleNameBinding : BindingIdentifier Initializeropt |
| 27 | |
| 28 | [...] |
| 29 | 6. If Initializer is present and v is undefined, then |
| 30 | [...] |
| 31 | 7. If environment is undefined, return PutValue(lhs, v). |
| 32 | 8. Return InitializeReferencedBinding(lhs, v). |
| 33 | ---*/ |
| 34 | var initCount = 0; |
| 35 | function counter() { |
| 36 | initCount += 1; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | var callCount = 0; |
| 41 | var obj = { |
| 42 | async *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { |
| 43 | assert.sameValue(w, null); |
| 44 | assert.sameValue(x, 0); |
| 45 | assert.sameValue(y, false); |
| 46 | assert.sameValue(z, ''); |
| 47 | assert.sameValue(initCount, 0); |
| 48 | callCount = callCount + 1; |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | obj.method().next().then(() => { |
| 53 | assert.sameValue(callCount, 1, 'invoked exactly once'); |
| 54 | }).then($DONE, $DONE); |