dflt-ary-ptrn-rest-id.js (1366B)
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-expr-dflt.template 5 /*--- 6 description: Lone rest element (async generator function expression (default parameter)) 7 esid: sec-asyncgenerator-definitions-evaluation 8 features: [async-iteration] 9 flags: [generated, async] 10 info: | 11 AsyncGeneratorExpression : async [no LineTerminator here] function * ( FormalParameters ) { 12 AsyncGeneratorBody } 13 14 [...] 15 3. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, 16 AsyncGeneratorBody, 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 var f; 32 f = async function*([...x] = values) { 33 assert(Array.isArray(x)); 34 assert.sameValue(x.length, 3); 35 assert.sameValue(x[0], 1); 36 assert.sameValue(x[1], 2); 37 assert.sameValue(x[2], 3); 38 assert.notSameValue(x, values); 39 callCount = callCount + 1; 40 }; 41 42 f().next().then(() => { 43 assert.sameValue(callCount, 1, 'invoked exactly once'); 44 }).then($DONE, $DONE);