summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/baseline/try-finally-3.js
blob: 23bfacbeb59a7c0de30c70421348d96f4fcda97a (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
// Test optimized RetSub stubs.
var count = 0;
function f(x) {
    try {
	if (x < 0)
	    throw "negative";
	if (x & 1)
	    return "odd";
	count++;
    } finally {
	count += 3;
    }

    return "even";
}
for (var i=0; i<15; i++) {
    var res = f(i);
    if ((i % 2) === 0)
	assertEq(res, "even");
    else
	assertEq(res, "odd");
}
try {
    f(-1);
    assertEq(0, 1);
} catch(e) {
    assertEq(e, "negative");
}

assertEq(count, 56);