Debian Codegraph @

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

raw
1 function set(k) {
2 // Different typed array types to ensure we emit a SetProp IC.
3 var xs = [
4 new Int32Array(10),
5 new Int16Array(10),
6 ];
7
8 for (var i = 0; i < 100; ++i) {
9 var x = xs[i & 1];
10 x[k] = 0;
11 }
12
13 assertEq(xs[0][k], undefined);
14 assertEq(xs[1][k], undefined);
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(set)(-1);
24 test(set)(-2147483648);
25 test(set)(-2147483649);
26
27 // Int32 indices must be less-or-equal to max-int32.
28 test(set)(2147483648);
29
30 // Int32 indices must not have fractional parts.
31 test(set)(1.5);
32 test(set)(-1.5);
33
34 // Non-finite numbers aren't int32 indices.
35 test(set)(NaN);
36 test(set)(-Infinity);
37 test(set)(Infinity);