Debian Codegraph @

js/src/jit-test/tests/for-of/throw-during-break.js

raw
1 var whoCaught = "nobody"
2
3 function* wrapNoThrow() {
4 let iter = {
5 [Symbol.iterator]() {
6 return this;
7 },
8 next() {
9 return { value: 10, done: false };
10 },
11 return() { throw "nonsense"; }
12 };
13 for (const i of iter)
14 yield i;
15 }
16 function foo() {
17 try {
18 l2:
19 for (j of wrapNoThrow()) {
20 try {
21 for (i of [1,2,3]) {
22 try {
23 break l2;
24 } catch(e) {
25 whoCaught = "inner"
26 }
27 }
28 } catch (e) {
29 whoCaught = "inner2"
30 }
31 }
32 } catch (e) {
33 whoCaught = "correct"
34 }
35 }
36
37 try {
38 foo();
39 } catch (e) { whoCaught = "outer" }
40
41
42 assertEq(whoCaught, "correct");