Debian Codegraph @

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

raw
1 // Copyright (C) 2017 Robin Templeton. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: Comparisons of BigInt and Number 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 d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt.
15 e. If x or y are any of NaN, return undefined.
16 f. If x is -∞, or y is +∞, return true.
17 g. If x is +∞, or y is -∞, return false.
18 h. If the mathematical value of nx is less than the mathematical value of ny, return true, otherwise return false.
19 features: [BigInt]
20 ---*/
21 assert.sameValue(0n < 0, false, 'The result of (0n < 0) is false');
22 assert.sameValue(0 < 0n, false, 'The result of (0 < 0n) is false');
23 assert.sameValue(0n < -0, false, 'The result of (0n < -0) is false');
24 assert.sameValue(-0 < 0n, false, 'The result of (-0 < 0n) is false');
25 assert.sameValue(0n < 0.000000000001, true, 'The result of (0n < 0.000000000001) is true');
26 assert.sameValue(0.000000000001 < 0n, false, 'The result of (0.000000000001 < 0n) is false');
27 assert.sameValue(0n < 1, true, 'The result of (0n < 1) is true');
28 assert.sameValue(1 < 0n, false, 'The result of (1 < 0n) is false');
29 assert.sameValue(1n < 0, false, 'The result of (1n < 0) is false');
30 assert.sameValue(0 < 1n, true, 'The result of (0 < 1n) is true');
31 assert.sameValue(1n < 0.999999999999, false, 'The result of (1n < 0.999999999999) is false');
32 assert.sameValue(0.999999999999 < 1n, true, 'The result of (0.999999999999 < 1n) is true');
33 assert.sameValue(1n < 1, false, 'The result of (1n < 1) is false');
34 assert.sameValue(1 < 1n, false, 'The result of (1 < 1n) is false');
35 assert.sameValue(0n < Number.MIN_VALUE, true, 'The result of (0n < Number.MIN_VALUE) is true');
36 assert.sameValue(Number.MIN_VALUE < 0n, false, 'The result of (Number.MIN_VALUE < 0n) is false');
37 assert.sameValue(0n < -Number.MIN_VALUE, false, 'The result of (0n < -Number.MIN_VALUE) is false');
38 assert.sameValue(-Number.MIN_VALUE < 0n, true, 'The result of (-Number.MIN_VALUE < 0n) is true');
39 assert.sameValue(-10n < Number.MIN_VALUE, true, 'The result of (-10n < Number.MIN_VALUE) is true');
40
41 assert.sameValue(
42 Number.MIN_VALUE < -10n,
43 false,
44 'The result of (Number.MIN_VALUE < -10n) is false'
45 );
46
47 reportCompare(0, 0);