summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/conditional-test-undefined-2.js
blob: b0dada66840706f01a6a17e66938120c88cb6851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function g(array) {
  // 1. Absent properties return |undefined| from CacheIR.
  // 2. Tests on |undefined| are changed to |false| in CacheIR.
  //
  // When Warp compiling the CacheIR ops, the first test will then happen on
  // a boolean, whereas the phi still sees the original undefined value.
  if (array.does_not_exist || array.does_not_exist_too || array.slice) {
    return 1;
  }
  return 0;
}

function f() {
  var array = [];
  var r = 0;
  for (let i = 0; i < 100; ++i) {
    r += g(array);
  }
  assertEq(r, 100);
}

for (let i = 0; i < 2; ++i) f();