dflt-obj-ptrn-prop-id-init-skipped.js (1712B)
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-func-decl-dflt.template 5 /*--- 6 description: Destructuring initializer is not evaluated when value is not `undefined` (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.7 Runtime Semantics: KeyedBindingInitialization 21 22 BindingElement : BindingPattern Initializeropt 23 24 [...] 25 3. If Initializer is present and v is undefined, then 26 [...] 27 ---*/ 28 var initCount = 0; 29 function counter() { 30 initCount += 1; 31 } 32 33 34 var callCount = 0; 35 async function* f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { 36 assert.sameValue(t, null); 37 assert.sameValue(v, 0); 38 assert.sameValue(x, false); 39 assert.sameValue(z, ''); 40 assert.sameValue(initCount, 0); 41 42 assert.throws(ReferenceError, function() { 43 s; 44 }); 45 assert.throws(ReferenceError, function() { 46 u; 47 }); 48 assert.throws(ReferenceError, function() { 49 w; 50 }); 51 assert.throws(ReferenceError, function() { 52 y; 53 }); 54 callCount = callCount + 1; 55 }; 56 f().next().then(() => { 57 assert.sameValue(callCount, 1, 'invoked exactly once'); 58 }).then($DONE, $DONE);