tor-browser

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

bigint-dec-32.js (489B)


      1 const tests = [
      2  [-0x7fffffffn, -0x80000000n],
      3  [-0x7ffffffen, -0x7fffffffn],
      4  [-2n, -3n],
      5  [-1n, -2n],
      6  [0n, -1n],
      7  [1n, 0n],
      8  [2n, 1n],
      9  [0x7ffffffen, 0x7ffffffdn],
     10  [0x7fffffffn, 0x7ffffffen],
     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    assertEq(--input, expected);
     20  }
     21 }
     22 
     23 for (let i = 0; i < 200; ++i) {
     24  f(tests);
     25 }