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