Debian Codegraph @

js/src/jit-test/tests/cacheir/typedarray-non-int32-index-has.js

raw
1 function has(k) {
2 // Different typed array types to ensure we emit a HasProp IC.
3 var xs = [
4 new Int32Array(10),
5 new Int16Array(10),
6 ];
7
8 // Doesn't read values from the prototype chain.
9 Object.prototype[k] = 1;
10
11 for (var i = 0; i < 100; ++i) {
12 var x = xs[i & 1];
13 assertEq(k in x, false);
14 }
15 }
16
17 // Make sure we use a distinct function for each test.
18 function test(fn) {
19 return Function(`return ${fn};`)();
20 }
21
22 // Negative numbers values aren't int32 indices.
23 test(has)(-1);
24 test(has)(-2147483648);
25 test(has)(-2147483649);
26
27 // Int32 indices must be less-or-equal to max-int32.
28 test(has)(2147483648);
29
30 // Int32 indices must not have fractional parts.
31 test(has)(1.5);
32 test(has)(-1.5);
33
34 // Non-finite numbers aren't int32 indices.
35 test(has)(NaN);
36 test(has)(-Infinity);
37 test(has)(Infinity);