Debian Codegraph @

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

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