| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/async-generators/yield-star-expr-abrupt.case |
| 3 |
// - src/async-generators/default/async-expression.template |
| 4 |
/*--- |
| 5 |
description: Abrupt completion while getting yield* operand (Unnamed async generator expression) |
| 6 |
esid: prod-AsyncGeneratorExpression |
| 7 |
features: [async-iteration] |
| 8 |
flags: [generated, async] |
| 9 |
info: | |
| 10 |
Async Generator Function Definitions |
| 11 |
|
| 12 |
AsyncGeneratorExpression : |
| 13 |
async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { |
| 14 |
AsyncGeneratorBody } |
| 15 |
|
| 16 |
|
| 17 |
YieldExpression: yield * AssignmentExpression |
| 18 |
|
| 19 |
1. Let exprRef be the result of evaluating AssignmentExpression. |
| 20 |
2. Let value be ? GetValue(exprRef). |
| 21 |
... |
| 22 |
|
| 23 |
---*/ |
| 24 |
var obj = {}; |
| 25 |
var abrupt = function() { |
| 26 |
throw obj; |
| 27 |
}; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
var callCount = 0; |
| 32 |
|
| 33 |
var gen = async function *() { |
| 34 |
callCount += 1; |
| 35 |
yield* abrupt(); |
| 36 |
throw new Test262Error('abrupt completion closes iter'); |
| 37 |
|
| 38 |
}; |
| 39 |
|
| 40 |
var iter = gen(); |
| 41 |
|
| 42 |
iter.next().then(() => { |
| 43 |
throw new Test262Error('Promise incorrectly fulfilled.'); |
| 44 |
}, v => { |
| 45 |
assert.sameValue(v, obj, "reject reason"); |
| 46 |
|
| 47 |
iter.next().then(({ done, value }) => { |
| 48 |
assert.sameValue(done, true, 'the iterator is completed'); |
| 49 |
assert.sameValue(value, undefined, 'value is undefined'); |
| 50 |
}).then($DONE, $DONE); |
| 51 |
}).catch($DONE); |
| 52 |
|
| 53 |
assert.sameValue(callCount, 1); |