diff options
Diffstat (limited to 'js/src/jit-test/tests/basic/testLoopingAccumulator.js')
-rw-r--r-- | js/src/jit-test/tests/basic/testLoopingAccumulator.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/testLoopingAccumulator.js b/js/src/jit-test/tests/basic/testLoopingAccumulator.js new file mode 100644 index 000000000..bacb29bea --- /dev/null +++ b/js/src/jit-test/tests/basic/testLoopingAccumulator.js @@ -0,0 +1,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); |