summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/closures/lambda.js
blob: 7a90fdf77f3ec6788f0f54e533a5dd0bdf8ff3df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function f() {
  var k = 0;
  
  var g = function() {
    return ++k;
  }

  return g;
}

function h() {
  for (var i = 0; i < 10; ++i) {
    var vf = f();
    assertEq(vf(), 1);
    assertEq(vf(), 2);
    for (var j = 0; j < 10; ++j) {
      assertEq(vf(), j + 3);
    }
  }
}

h();