summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testLoopingAccumulator.js
blob: bacb29bea5a595feede7b7e63663729c6d89405b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function addAccumulations(f) {
  var a = f();
  var b = f();
  return a() + b();
}

function loopingAccumulator() {
  var x = 0;
  return function () {
    for (var i = 0; i < 10; ++i) {
      ++x;
    }
    return x;
  }
}

function testLoopingAccumulator() {
    var x = addAccumulations(loopingAccumulator);
    return x;
}
assertEq(testLoopingAccumulator(), 20);