| 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 |
/*--- |
| 5 |
description: Comparisons of large BigInt and Number values |
| 6 |
esid: sec-abstract-relational-comparison |
| 7 |
info: | |
| 8 |
... |
| 9 |
3. If both px and py are Strings, then |
| 10 |
... |
| 11 |
4. Else, |
| 12 |
a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. |
| 13 |
b. Let ny be ? ToNumeric(py). |
| 14 |
c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). |
| 15 |
d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. |
| 16 |
e. If x or y are any of NaN, return undefined. |
| 17 |
f. If x is -∞, or y is +∞, return true. |
| 18 |
g. If x is +∞, or y is -∞, return false. |
| 19 |
h. If the mathematical value of nx is less than the mathematical value of ny, return true, otherwise return false. |
| 20 |
features: [BigInt] |
| 21 |
---*/ |
| 22 |
|
| 23 |
assert.sameValue(1n < Number.MAX_VALUE, true, "1n < Number.MAX_VALUE"); |
| 24 |
assert.sameValue(Number.MAX_VALUE < 1n, false, "Number.MAX_VALUE < 1n"); |
| 25 |
assert.sameValue(1n < -Number.MAX_VALUE, false, "1n < -Number.MAX_VALUE"); |
| 26 |
assert.sameValue(-Number.MAX_VALUE < 1n, true, "-Number.MAX_VALUE < 1n"); |
| 27 |
assert.sameValue( |
| 28 |
0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn < Number.MAX_VALUE, |
| 29 |
true, |
| 30 |
"0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn < Number.MAX_VALUE"); |
| 31 |
assert.sameValue( |
| 32 |
Number.MAX_VALUE < 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, |
| 33 |
false, |
| 34 |
"Number.MAX_VALUE < 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn"); |
| 35 |
assert.sameValue( |
| 36 |
0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n < Number.MAX_VALUE, |
| 37 |
false, |
| 38 |
"0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n < Number.MAX_VALUE"); |
| 39 |
assert.sameValue( |
| 40 |
Number.MAX_VALUE < 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, |
| 41 |
true, |
| 42 |
"Number.MAX_VALUE < 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n"); |