tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

same-value-fold-null-or-undefined.js (731B)


      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();