async-gen-meth-dflt-ary-ptrn-rest-id.js (1696B)
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-method-dflt.template 5 /*--- 6 description: Lone rest element (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.6 Runtime Semantics: IteratorBindingInitialization 26 BindingRestElement : ... BindingIdentifier 27 [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat 28 [...] 29 f. Let status be CreateDataProperty(A, ToString (n), nextValue). 30 [...] 31 ---*/ 32 var values = [1, 2, 3]; 33 34 35 var callCount = 0; 36 var obj = { 37 async *method([...x] = values) { 38 assert(Array.isArray(x)); 39 assert.sameValue(x.length, 3); 40 assert.sameValue(x[0], 1); 41 assert.sameValue(x[1], 2); 42 assert.sameValue(x[2], 3); 43 assert.notSameValue(x, values); 44 callCount = callCount + 1; 45 } 46 }; 47 48 obj.method().next().then(() => { 49 assert.sameValue(callCount, 1, 'invoked exactly once'); 50 }).then($DONE, $DONE);