dflt-obj-ptrn-id-init-skipped.js (1481B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/dstr-binding/obj-ptrn-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 SingleNameBinding : BindingIdentifier Initializeropt 23 24 [...] 25 6. If Initializer is present and v is undefined, then 26 [...] 27 [...] 28 ---*/ 29 var initCount = 0; 30 function counter() { 31 initCount += 1; 32 } 33 34 35 var callCount = 0; 36 async function* f({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { 37 assert.sameValue(w, null); 38 assert.sameValue(x, 0); 39 assert.sameValue(y, false); 40 assert.sameValue(z, ''); 41 assert.sameValue(initCount, 0); 42 callCount = callCount + 1; 43 }; 44 f().next().then(() => { 45 assert.sameValue(callCount, 1, 'invoked exactly once'); 46 }).then($DONE, $DONE);