~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/jit-test/tests/basic/testLoopingAccumulator.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function addAccumulations(f) {
 
2
  var a = f();
 
3
  var b = f();
 
4
  return a() + b();
 
5
}
 
6
 
 
7
function loopingAccumulator() {
 
8
  var x = 0;
 
9
  return function () {
 
10
    for (var i = 0; i < 10; ++i) {
 
11
      ++x;
 
12
    }
 
13
    return x;
 
14
  }
 
15
}
 
16
 
 
17
function testLoopingAccumulator() {
 
18
    var x = addAccumulations(loopingAccumulator);
 
19
    return x;
 
20
}
 
21
assertEq(testLoopingAccumulator(), 20);