Debian Codegraph @

js/src/jit-test/tests/bigint/asIntN32.js

raw
1 const tests = [
2 [-0x10000000000000001n, -1n],
3 [-0x10000000000000000n, 0n],
4 [-0xffffffffffffffffn, 1n],
5 [-0xfffffffffffffffen, 2n],
6 [-0x8000000000000001n, -1n],
7 [-0x8000000000000000n, 0n],
8 [-0x7fffffffffffffffn, 1n],
9 [-0x7ffffffffffffffen, 2n],
10 [-0x100000001n, -1n],
11 [-0x100000000n, 0n],
12 [-0xffffffffn, 1n],
13 [-0xfffffffen, 2n],
14 [-0x80000001n, 0x7fffffffn],
15 [-0x80000000n, -0x80000000n],
16 [-0x7fffffffn, -0x7fffffffn],
17 [-0x7ffffffen, -0x7ffffffen],
18 [-9n, -9n],
19 [-8n, -8n],
20 [-7n, -7n],
21 [-6n, -6n],
22 [-5n, -5n],
23 [-4n, -4n],
24 [-3n, -3n],
25 [-2n, -2n],
26 [-1n, -1n],
27 [0n, 0n],
28 [1n, 1n],
29 [2n, 2n],
30 [3n, 3n],
31 [4n, 4n],
32 [5n, 5n],
33 [6n, 6n],
34 [7n, 7n],
35 [8n, 8n],
36 [9n, 9n],
37 [0x7ffffffen, 0x7ffffffen],
38 [0x7fffffffn, 0x7fffffffn],
39 [0x80000000n, -0x80000000n],
40 [0x80000001n, -0x7fffffffn],
41 [0xfffffffen, -2n],
42 [0xffffffffn, -1n],
43 [0x100000000n, 0n],
44 [0x100000001n, 1n],
45 [0x7ffffffffffffffen, -2n],
46 [0x7fffffffffffffffn, -1n],
47 [0x8000000000000000n, 0n],
48 [0x8000000000000001n, 1n],
49 [0xfffffffffffffffen, -2n],
50 [0xffffffffffffffffn, -1n],
51 [0x10000000000000000n, 0n],
52 [0x10000000000000001n, 1n],
53 ];
54
55 function f(tests) {
56 for (let test of tests) {
57 let input = test[0], expected = test[1];
58
59 assertEq(BigInt.asIntN(32, input), expected);
60 }
61 }
62
63 for (let i = 0; i < 100; ++i) {
64 f(tests);
65 }