async-gen-yield-star-next-get-abrupt.js (1628B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-next-get-abrupt.case 4 // - src/async-generators/default/async-obj-method.template 5 /*--- 6 description: Abrupt completion while getting next (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 ... 24 25 ---*/ 26 var reason = {}; 27 var obj = { 28 get [Symbol.iterator]() { 29 throw new Test262Error('it should not get Symbol.iterator'); 30 }, 31 [Symbol.asyncIterator]() { 32 return { 33 get next() { 34 throw reason; 35 } 36 }; 37 } 38 }; 39 40 41 var callCount = 0; 42 43 var gen = { 44 async *method() { 45 callCount += 1; 46 yield* obj; 47 throw new Test262Error('abrupt completion closes iter'); 48 49 } 50 }.method; 51 52 var iter = gen(); 53 54 iter.next().then(() => { 55 throw new Test262Error('Promise incorrectly fulfilled.'); 56 }, v => { 57 assert.sameValue(v, reason, "reject reason"); 58 59 iter.next().then(({ done, value }) => { 60 assert.sameValue(done, true, 'the iterator is completed'); 61 assert.sameValue(value, undefined, 'value is undefined'); 62 }).then($DONE, $DONE); 63 }).catch($DONE); 64 65 assert.sameValue(callCount, 1);