tor-browser

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

bigint-neg-32-fold.js (571B)


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