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