Debian Codegraph @

js/src/jit-test/tests/warp/same-value-fold-null-or-undefined.js

raw
1 // Use different types to ensure we compile to MSameValue.
2 var xs = [
3 null,
4 undefined,
5 {},
6 123,
7 NaN,
8 false,
9 Symbol(),
10 "",
11 ];
12
13 // Object.is(input, null) is folded to |input === null|.
14 function testNull() {
15 for (var i = 0; i < 500; ++i) {
16 var x = xs[i & 7];
17 assertEq(Object.is(null, x), x === null);
18 assertEq(Object.is(x, null), x === null);
19 }
20 }
21 for (let i = 0; i < 2; ++i) testNull();
22
23 // Object.is(input, undefined) is folded to |input === undefined|.
24 function testUndefined() {
25 for (var i = 0; i < 500; ++i) {
26 var x = xs[i & 7];
27 assertEq(Object.is(undefined, x), x === undefined);
28 assertEq(Object.is(x, undefined), x === undefined);
29 }
30 }
31 for (let i = 0; i < 2; ++i) testUndefined();