yield-star-next-call-value-get-abrupt.js (2064B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-next-call-value-get-abrupt.case 4 // - src/async-generators/default/async-class-decl-method.template 5 /*--- 6 description: Abrupt completion while getting value (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 iii. If generatorKind is async, then set innerResult to 30 ? Await(innerResult). 31 ... 32 vi. If done is true, then 33 1. Return ? IteratorValue(innerResult). 34 ... 35 36 ---*/ 37 var reason = {}; 38 var obj = { 39 get [Symbol.iterator]() { 40 throw new Test262Error('it should not get Symbol.iterator'); 41 }, 42 [Symbol.asyncIterator]() { 43 return { 44 next() { 45 return { 46 done: true, 47 get value() { 48 throw reason; 49 } 50 }; 51 } 52 }; 53 } 54 }; 55 56 57 58 var callCount = 0; 59 60 class C { async *gen() { 61 callCount += 1; 62 yield* obj; 63 throw new Test262Error('abrupt completion closes iter'); 64 65 }} 66 67 var gen = C.prototype.gen; 68 69 var iter = gen(); 70 71 iter.next().then(() => { 72 throw new Test262Error('Promise incorrectly fulfilled.'); 73 }, v => { 74 assert.sameValue(v, reason, "reject reason"); 75 76 iter.next().then(({ done, value }) => { 77 assert.sameValue(done, true, 'the iterator is completed'); 78 assert.sameValue(value, undefined, 'value is undefined'); 79 }).then($DONE, $DONE); 80 }).catch($DONE); 81 82 assert.sameValue(callCount, 1);