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