tor-browser

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

bigint-not-32-fold.js (603B)


      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    let f = Function(`
     21      let input = ${input}n;
     22      assertEq(~input, ${expected}n);
     23    `);
     24 
     25    for (let j = 0; j < 100; ++j) {
     26      f();
     27    }
     28  }
     29 }
     30 
     31 f(tests);