Debian Codegraph @

js/src/tests/test262/language/expressions/less-than-or-equal/bigint-and-number-extremes.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 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(1n <= Number.MAX_VALUE, true, 'The result of (1n <= Number.MAX_VALUE) is true');
22 assert.sameValue(Number.MAX_VALUE <= 1n, false, 'The result of (Number.MAX_VALUE <= 1n) is false');
23
24 assert.sameValue(
25 1n <= -Number.MAX_VALUE,
26 false,
27 'The result of (1n <= -Number.MAX_VALUE) is false'
28 );
29
30 assert.sameValue(-Number.MAX_VALUE <= 1n, true, 'The result of (-Number.MAX_VALUE <= 1n) is true');
31
32 assert.sameValue(
33 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn <= Number.MAX_VALUE,
34 true,
35 'The result of (0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn <= Number.MAX_VALUE) is true'
36 );
37
38 assert.sameValue(
39 Number.MAX_VALUE <= 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn,
40 false,
41 'The result of (Number.MAX_VALUE <= 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn) is false'
42 );
43
44 assert.sameValue(
45 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n <= Number.MAX_VALUE,
46 false,
47 'The result of (0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n <= Number.MAX_VALUE) is false'
48 );
49
50 assert.sameValue(
51 Number.MAX_VALUE <= 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n,
52 true,
53 'The result of (Number.MAX_VALUE <= 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n) is true'
54 );
55
56 reportCompare(0, 0);