Debian Codegraph @

js/src/jit-test/tests/warp/try-finally-2.js

raw
1 let catchCount = 0;
2
3 let target = 3;
4 function throwOn(x) {
5 with ({}) {}
6 if (x == target) {
7 throw 3;
8 }
9 }
10
11 // Test try-catch-finally
12 function foo() {
13 var x = 0;
14 try {
15 throwOn(0);
16 x = 1;
17 throwOn(1);
18 x = 2;
19 throwOn(2);
20 x = 3;
21 } catch {
22 catchCount++;
23 } finally {
24 assertEq(x, target);
25 }
26 }
27
28 with ({}) {}
29 for (var i = 0; i < 1000; i++) {
30 try {
31 foo();
32 } catch {}
33 }
34
35 for (var i = 0; i < 4; i++) {
36 target = i;
37 try {
38 foo();
39 } catch {}
40 }
41
42 assertEq(catchCount, 3);