summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/arrayPopShift.js
blob: 9213f3c9ac9eb92917cdb64325c06e0d2bffe84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Test pop/shift compiler paths. */

function a() {
  var x = [];
  for (var i = 0; i < 50; i++)
    x.push(i);
  for (var j = 0; j < 100; j++) {
    var z = x.shift();
    if (j < 50)
      assertEq(z, j);
    else
      assertEq(z, undefined);
  }
}
a();

function b() {
  var x = [];
  for (var i = 0; i < 50; i++)
    x.push(i);
  for (var j = 0; j < 100; j++) {
    var z = x.pop();
    if (j < 50)
      assertEq(z, 49 - j);
    else
      assertEq(z, undefined);
  }
}
b();