tor-browser

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

bigint-not-32.js (519B)


      1 const tests = [
      2  [-0x80000000n, 0x7fffffffn],
      3  [-0x7fffffffn, 0x7ffffffen],
      4  [-0x7ffffffen, 0x7ffffffdn],
      5  [-2n, 1n],
      6  [-1n, 0n],
      7  [0n, -1n],
      8  [1n, -2n],
      9  [2n, -3n],
     10  [0x7ffffffen, -0x7fffffffn],
     11  [0x7fffffffn, -0x80000000n],
     12 ];
     13 
     14 function f(tests) {
     15  for (let test of tests) {
     16    let input = test[0], expected = test[1];
     17    assertEq(BigInt.asIntN(32, input), input);
     18    assertEq(BigInt.asIntN(32, expected), expected);
     19 
     20    assertEq(~input, expected);
     21  }
     22 }
     23 
     24 for (let i = 0; i < 200; ++i) {
     25  f(tests);
     26 }