ary-ptrn-rest-id.js (1358B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/dstr-binding/ary-ptrn-rest-id.case 4 // - src/dstr-binding/default/async-gen-func-decl.template 5 /*--- 6 description: Lone rest element (async generator function declaration) 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.6 Runtime Semantics: IteratorBindingInitialization 21 BindingRestElement : ... BindingIdentifier 22 [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat 23 [...] 24 f. Let status be CreateDataProperty(A, ToString (n), nextValue). 25 [...] 26 ---*/ 27 var values = [1, 2, 3]; 28 29 30 var callCount = 0; 31 async function* f([...x]) { 32 assert(Array.isArray(x)); 33 assert.sameValue(x.length, 3); 34 assert.sameValue(x[0], 1); 35 assert.sameValue(x[1], 2); 36 assert.sameValue(x[2], 3); 37 assert.notSameValue(x, values); 38 callCount = callCount + 1; 39 }; 40 f(values).next().then(() => { 41 assert.sameValue(callCount, 1, 'invoked exactly once'); 42 }).then($DONE, $DONE);