yield-star-expr-abrupt.js (1386B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-expr-abrupt.case 4 // - src/async-generators/default/async-expression.template 5 /*--- 6 description: Abrupt completion while getting yield* operand (Unnamed async generator expression) 7 esid: prod-AsyncGeneratorExpression 8 features: [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 ... 23 24 ---*/ 25 var obj = {}; 26 var abrupt = function() { 27 throw obj; 28 }; 29 30 31 32 var callCount = 0; 33 34 var gen = async function *() { 35 callCount += 1; 36 yield* abrupt(); 37 throw new Test262Error('abrupt completion closes iter'); 38 39 }; 40 41 var iter = gen(); 42 43 iter.next().then(() => { 44 throw new Test262Error('Promise incorrectly fulfilled.'); 45 }, v => { 46 assert.sameValue(v, obj, "reject reason"); 47 48 iter.next().then(({ done, value }) => { 49 assert.sameValue(done, true, 'the iterator is completed'); 50 assert.sameValue(value, undefined, 'value is undefined'); 51 }).then($DONE, $DONE); 52 }).catch($DONE); 53 54 assert.sameValue(callCount, 1);