async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js (2044B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case 4 // - src/dstr-binding/default/async-gen-method-dflt.template 5 /*--- 6 description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method (default parameter)) 7 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation 8 features: [async-iteration] 9 flags: [generated, async] 10 info: | 11 AsyncGeneratorMethod : 12 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) 13 { AsyncGeneratorBody } 14 15 1. Let propKey be the result of evaluating PropertyName. 16 2. ReturnIfAbrupt(propKey). 17 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. 18 Otherwise let strict be false. 19 4. Let scope be the running execution context's LexicalEnvironment. 20 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, 21 AsyncGeneratorBody, scope, strict). 22 [...] 23 24 25 13.3.3.7 Runtime Semantics: KeyedBindingInitialization 26 27 BindingElement : BindingPattern Initializeropt 28 29 [...] 30 3. If Initializer is present and v is undefined, then 31 [...] 32 ---*/ 33 var initCount = 0; 34 function counter() { 35 initCount += 1; 36 } 37 38 39 var callCount = 0; 40 var obj = { 41 async *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { 42 assert.sameValue(t, null); 43 assert.sameValue(v, 0); 44 assert.sameValue(x, false); 45 assert.sameValue(z, ''); 46 assert.sameValue(initCount, 0); 47 48 assert.throws(ReferenceError, function() { 49 s; 50 }); 51 assert.throws(ReferenceError, function() { 52 u; 53 }); 54 assert.throws(ReferenceError, function() { 55 w; 56 }); 57 assert.throws(ReferenceError, function() { 58 y; 59 }); 60 callCount = callCount + 1; 61 } 62 }; 63 64 obj.method().next().then(() => { 65 assert.sameValue(callCount, 1, 'invoked exactly once'); 66 }).then($DONE, $DONE);