Debian Codegraph @

js/src/tests/test262/language/statements/try/dstr/ary-ptrn-rest-id-iter-step-err.js

raw
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/try.template
4 /*---
5 description: Error forwarding when IteratorStep returns an abrupt completion (try statement)
6 esid: sec-runtime-semantics-catchclauseevaluation
7 features: [generators, destructuring-binding]
8 flags: [generated]
9 info: |
10 Catch : catch ( CatchParameter ) Block
11
12 [...]
13 5. Let status be the result of performing BindingInitialization for
14 CatchParameter passing thrownValue and catchEnv as arguments.
15 [...]
16
17 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
18 BindingRestElement : ... BindingIdentifier
19 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
20 environment).
21 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
22 a. If iteratorRecord.[[done]] is false,
23 i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
24 ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
25 true.
26 iii. ReturnIfAbrupt(next).
27
28 ---*/
29 var first = 0;
30 var second = 0;
31 var iter = function*() {
32 first += 1;
33 throw new Test262Error();
34 second += 1;
35 }();
36
37 assert.throws(Test262Error, function() {
38 try {
39 throw iter;
40 } catch ([...x]) {}
41 });
42
43 iter.next();
44 assert.sameValue(first, 1);
45 assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.');
46
47 reportCompare(0, 0);