summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/try-finally-3.js
blob: 98811486dbcfc3536c61d42d74b376b55eb647c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var target = undefined;
function throwOn(x) {
  with ({}) {}
  if (x === target) {
    throw x;
  }
}

// Test nested try-finally
function foo() {
  let result = 0;
  try {
    throwOn(1);
    result += 1;
    try {
      throwOn(2);
      result += 2;
    } finally {
      result += 3;
    }
  } finally {
    return result;
  }
}

with ({}) {}
for (var i = 0; i < 100; i++) {
  assertEq(foo(), 6);
}

target = 1;
assertEq(foo(), 0);

target = 2;
assertEq(foo(), 4);