bigint-inc-64.js (1057B)
1 const tests = [ 2 [-0x8000000000000000n, -0x7fffffffffffffffn], 3 [-0x7fffffffffffffffn, -0x7ffffffffffffffen], 4 [-0x7ffffffffffffffen, -0x7ffffffffffffffdn], 5 [-0x100000001n, -0x100000000n], 6 [-0x100000000n, -0xffffffffn], 7 [-0xffffffffn, -0xfffffffen], 8 [-0xfffffffen, -0xfffffffdn], 9 [-0x80000001n, -0x80000000n], 10 [-0x80000000n, -0x7fffffffn], 11 [-0x7fffffffn, -0x7ffffffen], 12 [-0x7ffffffen, -0x7ffffffdn], 13 [-2n, -1n], 14 [-1n, 0n], 15 [0n, 1n], 16 [1n, 2n], 17 [2n, 3n], 18 [0x7ffffffen, 0x7fffffffn], 19 [0x7fffffffn, 0x80000000n], 20 [0x80000000n, 0x80000001n], 21 [0x80000001n, 0x80000002n], 22 [0xfffffffen, 0xffffffffn], 23 [0xffffffffn, 0x100000000n], 24 [0x100000000n, 0x100000001n], 25 [0x100000001n, 0x100000002n], 26 [0x7ffffffffffffffen, 0x7fffffffffffffffn], 27 ]; 28 29 function f(tests) { 30 for (let test of tests) { 31 let input = test[0], expected = test[1]; 32 assertEq(BigInt.asIntN(64, input), input); 33 assertEq(BigInt.asIntN(64, expected), expected); 34 35 assertEq(++input, expected); 36 } 37 } 38 39 for (let i = 0; i < 200; ++i) { 40 f(tests); 41 }