summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/smallObjectVariableKeyHasProp-2.js
blob: d170afd5d9018fb6a4c5adf0b5676c28339df326 (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
31
32
33
34
let obj = {
  a: 1,
  b: 1,
  c: 1,
};

function test(id) {
  return Object.hasOwn(obj, id);
}

let testKeys = [
  ["a", true],
  ["b", true],
  ["c", true],
  ["d", false],
  ["e", false],
  ["f", false],
  ["g", false],
  ["h", false],
];

with({});
for (var i = 0; i < 1000; i++) {
  let [key, has] = testKeys[i % testKeys.length];
  test(key);
}

obj["0"] = 1;
testKeys.push(["0", true]);

for (var i = 0; i < 1000; i++) {
  let [key, has] = testKeys[i % testKeys.length];
  assertEq(test(key), has);
}