| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case |
| 3 |
// - src/dstr-binding/error/async-gen-method-dflt.template |
| 4 |
/*--- |
| 5 |
description: Error forwarding when IteratorStep returns an abrupt completion (async generator method (default parameter)) |
| 6 |
esid: sec-asyncgenerator-definitions-propertydefinitionevaluation |
| 7 |
features: [generators, async-iteration] |
| 8 |
flags: [generated] |
| 9 |
info: | |
| 10 |
AsyncGeneratorMethod : |
| 11 |
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) |
| 12 |
{ AsyncGeneratorBody } |
| 13 |
|
| 14 |
1. Let propKey be the result of evaluating PropertyName. |
| 15 |
2. ReturnIfAbrupt(propKey). |
| 16 |
3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. |
| 17 |
Otherwise let strict be false. |
| 18 |
4. Let scope be the running execution context's LexicalEnvironment. |
| 19 |
5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, |
| 20 |
AsyncGeneratorBody, scope, strict). |
| 21 |
[...] |
| 22 |
|
| 23 |
13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 24 |
BindingRestElement : ... BindingIdentifier |
| 25 |
1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, |
| 26 |
environment). |
| 27 |
2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, |
| 28 |
a. If iteratorRecord.[[done]] is false, |
| 29 |
i. Let next be IteratorStep(iteratorRecord.[[iterator]]). |
| 30 |
ii. If next is an abrupt completion, set iteratorRecord.[[done]] to |
| 31 |
true. |
| 32 |
iii. ReturnIfAbrupt(next). |
| 33 |
|
| 34 |
---*/ |
| 35 |
var first = 0; |
| 36 |
var second = 0; |
| 37 |
var iter = function*() { |
| 38 |
first += 1; |
| 39 |
throw new Test262Error(); |
| 40 |
second += 1; |
| 41 |
}(); |
| 42 |
|
| 43 |
|
| 44 |
var obj = { |
| 45 |
async *method([...x] = iter) { |
| 46 |
|
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
assert.throws(Test262Error, function() { |
| 51 |
obj.method(); |
| 52 |
}); |
| 53 |
|
| 54 |
iter.next(); |
| 55 |
assert.sameValue(first, 1); |
| 56 |
assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); |