named-yield-star-next-then-non-callable-boolean-fulfillpromise.js (2170B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case 4 // - src/async-generators/default/async-expression-named.template 5 /*--- 6 description: FulfillPromise if next().then is not-callable (boolean) (Named 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 iv. If Type(innerResult) is not Object, throw a TypeError exception. 27 ... 28 29 Await 30 31 ... 32 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). 33 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). 34 ... 35 36 Promise Resolve Functions 37 38 ... 39 7. If Type(resolution) is not Object, then 40 a. Return FulfillPromise(promise, resolution). 41 8. Let then be Get(resolution, "then"). 42 ... 43 11. If IsCallable(thenAction) is false, then 44 a. Return FulfillPromise(promise, resolution). 45 ... 46 47 ---*/ 48 var obj = { 49 get [Symbol.iterator]() { 50 throw new Test262Error('it should not get Symbol.iterator'); 51 }, 52 [Symbol.asyncIterator]() { 53 return { 54 next() { 55 return { 56 then: true, 57 value: 42, 58 done: false 59 } 60 } 61 }; 62 } 63 }; 64 65 66 67 var callCount = 0; 68 69 var gen = async function *g() { 70 callCount += 1; 71 yield* obj; 72 throw new Test262Error('completion closes iter'); 73 74 }; 75 76 var iter = gen(); 77 78 iter.next().then(({ value, done }) => { 79 assert.sameValue(value, 42); 80 assert.sameValue(done, false); 81 }).then($DONE, $DONE); 82 83 assert.sameValue(callCount, 1);