Debian Codegraph @

js/src/tests/test262/language/expressions/less-than/bigint-and-bigint.js

raw
1 // Copyright (C) 2017 Josh Wolfe. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: Comparisons of BigInt and BigInt values
5 esid: sec-abstract-relational-comparison
6 info: |
7 ...
8 3. If both px and py are Strings, then
9 ...
10 4. Else,
11 a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important.
12 b. Let ny be ? ToNumeric(py).
13 c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny).
14
15 sec-numeric-types-bigint-lessThan
16 BigInt::lessThan (x, y)
17
18 The abstract operation BigInt::lessThan with two arguments x and y of BigInt type returns true if x is less than y and false otherwise.
19
20 features: [BigInt]
21 ---*/
22 assert.sameValue(0n < 0n, false, 'The result of (0n < 0n) is false');
23 assert.sameValue(1n < 1n, false, 'The result of (1n < 1n) is false');
24 assert.sameValue(-1n < -1n, false, 'The result of (-1n < -1n) is false');
25 assert.sameValue(0n < -0n, false, 'The result of (0n < -0n) is false');
26 assert.sameValue(-0n < 0n, false, 'The result of (-0n < 0n) is false');
27 assert.sameValue(0n < 1n, true, 'The result of (0n < 1n) is true');
28 assert.sameValue(1n < 0n, false, 'The result of (1n < 0n) is false');
29 assert.sameValue(0n < -1n, false, 'The result of (0n < -1n) is false');
30 assert.sameValue(-1n < 0n, true, 'The result of (-1n < 0n) is true');
31 assert.sameValue(1n < -1n, false, 'The result of (1n < -1n) is false');
32 assert.sameValue(-1n < 1n, true, 'The result of (-1n < 1n) is true');
33
34 assert.sameValue(
35 0x1fffffffffffff01n < 0x1fffffffffffff02n,
36 true,
37 'The result of (0x1fffffffffffff01n < 0x1fffffffffffff02n) is true'
38 );
39
40 assert.sameValue(
41 0x1fffffffffffff02n < 0x1fffffffffffff01n,
42 false,
43 'The result of (0x1fffffffffffff02n < 0x1fffffffffffff01n) is false'
44 );
45
46 assert.sameValue(
47 -0x1fffffffffffff01n < -0x1fffffffffffff02n,
48 false,
49 'The result of (-0x1fffffffffffff01n < -0x1fffffffffffff02n) is false'
50 );
51
52 assert.sameValue(
53 -0x1fffffffffffff02n < -0x1fffffffffffff01n,
54 true,
55 'The result of (-0x1fffffffffffff02n < -0x1fffffffffffff01n) is true'
56 );
57
58 assert.sameValue(
59 0x10000000000000000n < 0n,
60 false,
61 'The result of (0x10000000000000000n < 0n) is false'
62 );
63
64 assert.sameValue(
65 0n < 0x10000000000000000n,
66 true,
67 'The result of (0n < 0x10000000000000000n) is true'
68 );
69
70 assert.sameValue(
71 0x10000000000000000n < 1n,
72 false,
73 'The result of (0x10000000000000000n < 1n) is false'
74 );
75
76 assert.sameValue(
77 1n < 0x10000000000000000n,
78 true,
79 'The result of (1n < 0x10000000000000000n) is true'
80 );
81
82 assert.sameValue(
83 0x10000000000000000n < -1n,
84 false,
85 'The result of (0x10000000000000000n < -1n) is false'
86 );
87
88 assert.sameValue(
89 -1n < 0x10000000000000000n,
90 true,
91 'The result of (-1n < 0x10000000000000000n) is true'
92 );
93
94 assert.sameValue(
95 0x10000000000000001n < 0n,
96 false,
97 'The result of (0x10000000000000001n < 0n) is false'
98 );
99
100 assert.sameValue(
101 0n < 0x10000000000000001n,
102 true,
103 'The result of (0n < 0x10000000000000001n) is true'
104 );
105
106 assert.sameValue(
107 -0x10000000000000000n < 0n,
108 true,
109 'The result of (-0x10000000000000000n < 0n) is true'
110 );
111
112 assert.sameValue(
113 0n < -0x10000000000000000n,
114 false,
115 'The result of (0n < -0x10000000000000000n) is false'
116 );
117
118 assert.sameValue(
119 -0x10000000000000000n < 1n,
120 true,
121 'The result of (-0x10000000000000000n < 1n) is true'
122 );
123
124 assert.sameValue(
125 1n < -0x10000000000000000n,
126 false,
127 'The result of (1n < -0x10000000000000000n) is false'
128 );
129
130 assert.sameValue(
131 -0x10000000000000000n < -1n,
132 true,
133 'The result of (-0x10000000000000000n < -1n) is true'
134 );
135
136 assert.sameValue(
137 -1n < -0x10000000000000000n,
138 false,
139 'The result of (-1n < -0x10000000000000000n) is false'
140 );
141
142 assert.sameValue(
143 -0x10000000000000001n < 0n,
144 true,
145 'The result of (-0x10000000000000001n < 0n) is true'
146 );
147
148 assert.sameValue(
149 0n < -0x10000000000000001n,
150 false,
151 'The result of (0n < -0x10000000000000001n) is false'
152 );
153
154 assert.sameValue(
155 0x10000000000000000n < 0x100000000n,
156 false,
157 'The result of (0x10000000000000000n < 0x100000000n) is false'
158 );
159
160 assert.sameValue(
161 0x100000000n < 0x10000000000000000n,
162 true,
163 'The result of (0x100000000n < 0x10000000000000000n) is true'
164 );
165
166 reportCompare(0, 0);