named-yield-star-getiter-async-get-abrupt.js (1898B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-getiter-async-get-abrupt.case 4 // - src/async-generators/default/async-expression-named.template 5 /*--- 6 description: Abrupt completion while getting [Symbol.asyncIterator] (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 1. Let exprRef be the result of evaluating AssignmentExpression. 21 2. Let value be ? GetValue(exprRef). 22 3. Let generatorKind be ! GetGeneratorKind(). 23 4. Let iterator be ? GetIterator(value, generatorKind). 24 ... 25 26 GetIterator ( obj [ , hint ] ) 27 28 ... 29 3. If hint is async, 30 a. Set method to ? GetMethod(obj, @@asyncIterator). 31 ... 32 33 GetMethod ( V, P ) 34 35 ... 36 2. Let func be ? GetV(V, P). 37 ... 38 39 ---*/ 40 var reason = {}; 41 var obj = { 42 get [Symbol.iterator]() { 43 throw new Test262Error('it should not get Symbol.iterator'); 44 }, 45 get [Symbol.asyncIterator]() { 46 throw reason; 47 } 48 }; 49 50 51 52 var callCount = 0; 53 54 var gen = async function *g() { 55 callCount += 1; 56 yield* obj; 57 throw new Test262Error('abrupt completion closes iter'); 58 59 }; 60 61 var iter = gen(); 62 63 iter.next().then(() => { 64 throw new Test262Error('Promise incorrectly fulfilled.'); 65 }, v => { 66 assert.sameValue(v, reason, "reject reason"); 67 68 iter.next().then(({ done, value }) => { 69 assert.sameValue(done, true, 'the iterator is completed'); 70 assert.sameValue(value, undefined, 'value is undefined'); 71 }).then($DONE, $DONE); 72 }).catch($DONE); 73 74 assert.sameValue(callCount, 1);