async-gen-yield-star-next-call-done-get-abrupt.js (1868B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-next-call-done-get-abrupt.case 4 // - src/async-generators/default/async-obj-method.template 5 /*--- 6 description: Abrupt completion while getting done (Async generator method) 7 esid: prod-AsyncGeneratorMethod 8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] 9 flags: [generated, async] 10 info: | 11 Async Generator Function Definitions 12 13 AsyncGeneratorMethod : 14 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } 15 16 17 YieldExpression: yield * AssignmentExpression 18 ... 19 6. Repeat 20 a. If received.[[Type]] is normal, then 21 ii. Let innerResult be ? Invoke(iterator, "next", 22 « received.[[Value]] »). 23 iii. If generatorKind is async, then set innerResult to 24 ? Await(innerResult). 25 ... 26 v. Let done be ? IteratorComplete(innerResult). 27 ... 28 29 ---*/ 30 var reason = {}; 31 var obj = { 32 get [Symbol.iterator]() { 33 throw new Test262Error('it should not get Symbol.iterator'); 34 }, 35 [Symbol.asyncIterator]() { 36 return { 37 next() { 38 return { 39 get done() { 40 throw reason; 41 } 42 }; 43 } 44 }; 45 } 46 }; 47 48 49 var callCount = 0; 50 51 var gen = { 52 async *method() { 53 callCount += 1; 54 yield* obj; 55 throw new Test262Error('abrupt completion closes iter'); 56 57 } 58 }.method; 59 60 var iter = gen(); 61 62 iter.next().then(() => { 63 throw new Test262Error('Promise incorrectly fulfilled.'); 64 }, v => { 65 assert.sameValue(v, reason, "reject reason"); 66 67 iter.next().then(({ done, value }) => { 68 assert.sameValue(done, true, 'the iterator is completed'); 69 assert.sameValue(value, undefined, 'value is undefined'); 70 }).then($DONE, $DONE); 71 }).catch($DONE); 72 73 assert.sameValue(callCount, 1);