summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testBug529147.js
blob: 8b700879d8819e431b55e3ef5266ea38e30e45e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var magicNumbers = [1, -1, 0, 0];
var magicIndex = 0;

var sum = 0;

function foo(n) {
    for (var i = 0; i < n; ++i) {
        sum += 10;
        bar();
    }
}

function bar() {
    var q = magicNumbers[magicIndex++];
    if (q != -1) {
        sum += 1;
        foo(q);
    }
}

foo(3);
assertEq(sum, 43);