yield-star-next-call-done-get-abrupt.js (1887B)
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-expression.template 5 /*--- 6 description: Abrupt completion while getting done (Unnamed async generator expression) 7 esid: prod-AsyncGeneratorExpression 8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] 9 flags: [generated, async] 10 info: | 11 Async Generator Function Definitions 12 13 AsyncGeneratorExpression : 14 async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { 15 AsyncGeneratorBody } 16 17 18 YieldExpression: yield * AssignmentExpression 19 ... 20 6. Repeat 21 a. If received.[[Type]] is normal, then 22 ii. Let innerResult be ? Invoke(iterator, "next", 23 « received.[[Value]] »). 24 iii. If generatorKind is async, then set innerResult to 25 ? Await(innerResult). 26 ... 27 v. Let done be ? IteratorComplete(innerResult). 28 ... 29 30 ---*/ 31 var reason = {}; 32 var obj = { 33 get [Symbol.iterator]() { 34 throw new Test262Error('it should not get Symbol.iterator'); 35 }, 36 [Symbol.asyncIterator]() { 37 return { 38 next() { 39 return { 40 get done() { 41 throw reason; 42 } 43 }; 44 } 45 }; 46 } 47 }; 48 49 50 51 var callCount = 0; 52 53 var gen = async function *() { 54 callCount += 1; 55 yield* obj; 56 throw new Test262Error('abrupt completion closes iter'); 57 58 }; 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);