Debian Codegraph @

js/src/tests/test262/language/statements/try/dstr/ary-init-iter-close.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-binding/ary-init-iter-close.case
3 // - src/dstr-binding/default/try.template
4 /*---
5 description: Iterator is closed when not exhausted by pattern evaluation (try statement)
6 esid: sec-runtime-semantics-catchclauseevaluation
7 features: [Symbol.iterator, 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.5 Runtime Semantics: BindingInitialization
18
19 BindingPattern : ArrayBindingPattern
20
21 [...]
22 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
23 result).
24 [...]
25
26 ---*/
27 var doneCallCount = 0;
28 var iter = {};
29 iter[Symbol.iterator] = function() {
30 return {
31 next: function() {
32 return { value: null, done: false };
33 },
34 return: function() {
35 doneCallCount += 1;
36 return {};
37 }
38 };
39 };
40
41 var ranCatch = false;
42
43 try {
44 throw iter;
45 } catch ([x]) {
46 assert.sameValue(doneCallCount, 1);
47 ranCatch = true;
48 }
49
50 assert(ranCatch, 'executed `catch` block');
51
52 reportCompare(0, 0);