From aca48e4dfd2ce97eff7c56baed93bba54b553fec Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Mon, 2 Oct 2017 21:40:32 +0200 Subject: [PATCH] Improve coverage for BigInt relational comparison tests (#1251) --- .../bigint-and-bigint.js | 56 +++++++++++++++++++ .../bigint-and-non-finite.js | 31 ++++++++++ .../bigint-and-number-extremes.js | 38 +++++++++++++ .../bigint-and-number.js | 24 +++++--- .../greater-than/bigint-and-bigint.js | 56 +++++++++++++++++++ .../greater-than/bigint-and-non-finite.js | 31 ++++++++++ .../bigint-and-number-extremes.js | 38 +++++++++++++ .../greater-than/bigint-and-number.js | 24 +++++--- .../less-than-or-equal/bigint-and-bigint.js | 56 +++++++++++++++++++ .../bigint-and-non-finite.js | 31 ++++++++++ .../bigint-and-number-extremes.js | 38 +++++++++++++ .../less-than-or-equal/bigint-and-number.js | 24 +++++--- .../less-than/bigint-and-bigint.js | 56 +++++++++++++++++++ .../less-than/bigint-and-non-finite.js | 31 ++++++++++ .../less-than/bigint-and-number-extremes.js | 38 +++++++++++++ .../less-than/bigint-and-number.js | 24 +++++--- 16 files changed, 560 insertions(+), 36 deletions(-) create mode 100644 test/language/expressions/greater-than-or-equal/bigint-and-bigint.js create mode 100644 test/language/expressions/greater-than-or-equal/bigint-and-non-finite.js create mode 100644 test/language/expressions/greater-than-or-equal/bigint-and-number-extremes.js create mode 100644 test/language/expressions/greater-than/bigint-and-bigint.js create mode 100644 test/language/expressions/greater-than/bigint-and-non-finite.js create mode 100644 test/language/expressions/greater-than/bigint-and-number-extremes.js create mode 100644 test/language/expressions/less-than-or-equal/bigint-and-bigint.js create mode 100644 test/language/expressions/less-than-or-equal/bigint-and-non-finite.js create mode 100644 test/language/expressions/less-than-or-equal/bigint-and-number-extremes.js create mode 100644 test/language/expressions/less-than/bigint-and-bigint.js create mode 100644 test/language/expressions/less-than/bigint-and-non-finite.js create mode 100644 test/language/expressions/less-than/bigint-and-number-extremes.js diff --git a/test/language/expressions/greater-than-or-equal/bigint-and-bigint.js b/test/language/expressions/greater-than-or-equal/bigint-and-bigint.js new file mode 100644 index 0000000000..01e8a9cb72 --- /dev/null +++ b/test/language/expressions/greater-than-or-equal/bigint-and-bigint.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and BigInt values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + + sec-numeric-types-bigint-lessThan + BigInt::lessThan (x, y) + + 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. + +features: [BigInt] +---*/ + +assert.sameValue(0n >= 0n, true); +assert.sameValue(1n >= 1n, true); +assert.sameValue(-1n >= -1n, true); +assert.sameValue(0n >= -0n, true); +assert.sameValue(-0n >= 0n, true); +assert.sameValue(0n >= 1n, false); +assert.sameValue(1n >= 0n, true); +assert.sameValue(0n >= -1n, true); +assert.sameValue(-1n >= 0n, false); +assert.sameValue(1n >= -1n, true); +assert.sameValue(-1n >= 1n, false); +assert.sameValue(0x1fffffffffffff01n >= 0x1fffffffffffff02n, false); +assert.sameValue(0x1fffffffffffff02n >= 0x1fffffffffffff01n, true); +assert.sameValue(-0x1fffffffffffff01n >= -0x1fffffffffffff02n, true); +assert.sameValue(-0x1fffffffffffff02n >= -0x1fffffffffffff01n, false); +assert.sameValue(0x10000000000000000n >= 0n, true); +assert.sameValue(0n >= 0x10000000000000000n, false); +assert.sameValue(0x10000000000000000n >= 1n, true); +assert.sameValue(1n >= 0x10000000000000000n, false); +assert.sameValue(0x10000000000000000n >= -1n, true); +assert.sameValue(-1n >= 0x10000000000000000n, false); +assert.sameValue(0x10000000000000001n >= 0n, true); +assert.sameValue(0n >= 0x10000000000000001n, false); +assert.sameValue(-0x10000000000000000n >= 0n, false); +assert.sameValue(0n >= -0x10000000000000000n, true); +assert.sameValue(-0x10000000000000000n >= 1n, false); +assert.sameValue(1n >= -0x10000000000000000n, true); +assert.sameValue(-0x10000000000000000n >= -1n, false); +assert.sameValue(-1n >= -0x10000000000000000n, true); +assert.sameValue(-0x10000000000000001n >= 0n, false); +assert.sameValue(0n >= -0x10000000000000001n, true); +assert.sameValue(0x10000000000000000n >= 0x100000000n, true); +assert.sameValue(0x100000000n >= 0x10000000000000000n, false); diff --git a/test/language/expressions/greater-than-or-equal/bigint-and-non-finite.js b/test/language/expressions/greater-than-or-equal/bigint-and-non-finite.js new file mode 100644 index 0000000000..a3f84924f0 --- /dev/null +++ b/test/language/expressions/greater-than-or-equal/bigint-and-non-finite.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and non-finite Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. +features: [BigInt] +---*/ + +assert.sameValue(1n >= Infinity, false); +assert.sameValue(Infinity >= 1n, true); +assert.sameValue(-1n >= Infinity, false); +assert.sameValue(Infinity >= -1n, true); +assert.sameValue(1n >= -Infinity, true); +assert.sameValue(-Infinity >= 1n, false); +assert.sameValue(-1n >= -Infinity, true); +assert.sameValue(-Infinity >= -1n, false); +assert.sameValue(0n >= NaN, false); +assert.sameValue(NaN >= 0n, false); diff --git a/test/language/expressions/greater-than-or-equal/bigint-and-number-extremes.js b/test/language/expressions/greater-than-or-equal/bigint-and-number-extremes.js new file mode 100644 index 0000000000..ea0a725c78 --- /dev/null +++ b/test/language/expressions/greater-than-or-equal/bigint-and-number-extremes.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of large BigInt and Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. + h. If the mathematical value of nx is less than the mathematical value of ny, return true, otherwise return false. +features: [BigInt] +---*/ + +assert.sameValue(1n >= Number.MAX_VALUE, false); +assert.sameValue(Number.MAX_VALUE >= 1n, true); +assert.sameValue(1n >= -Number.MAX_VALUE, true); +assert.sameValue(-Number.MAX_VALUE >= 1n, false); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn >= Number.MAX_VALUE, + false); +assert.sameValue( + Number.MAX_VALUE >= 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + true); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n >= Number.MAX_VALUE, + true); +assert.sameValue( + Number.MAX_VALUE >= 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + false); diff --git a/test/language/expressions/greater-than-or-equal/bigint-and-number.js b/test/language/expressions/greater-than-or-equal/bigint-and-number.js index e7bb634812..63890b9e3f 100644 --- a/test/language/expressions/greater-than-or-equal/bigint-and-number.js +++ b/test/language/expressions/greater-than-or-equal/bigint-and-number.js @@ -20,17 +20,23 @@ info: | features: [BigInt] ---*/ -assert.sameValue(1n >= 0, true); -assert.sameValue(1n >= 0.999999999999, true); -assert.sameValue(1 >= 0n, true); +assert.sameValue(0n >= 0, true); +assert.sameValue(0 >= 0n, true); +assert.sameValue(0n >= -0, true); +assert.sameValue(-0 >= 0n, true); +assert.sameValue(0n >= 0.000000000001, false); assert.sameValue(0.000000000001 >= 0n, true); +assert.sameValue(0n >= 1, false); +assert.sameValue(1 >= 0n, true); +assert.sameValue(1n >= 0, true); +assert.sameValue(0 >= 1n, false); +assert.sameValue(1n >= 0.999999999999, true); +assert.sameValue(0.999999999999 >= 1n, false); assert.sameValue(1n >= 1, true); assert.sameValue(1 >= 1n, true); -assert.sameValue(0n >= 1, false); -assert.sameValue(0 >= 1n, false); -assert.sameValue(0 >= 0n, true); -assert.sameValue(0n >= 0, true); -assert.sameValue(1n >= Number.MAX_VALUE, false); +assert.sameValue(0n >= Number.MIN_VALUE, false); assert.sameValue(Number.MIN_VALUE >= 0n, true); +assert.sameValue(0n >= -Number.MIN_VALUE, true); +assert.sameValue(-Number.MIN_VALUE >= 0n, false); assert.sameValue(-10n >= Number.MIN_VALUE, false); -assert.sameValue(Number.MAX_VALUE >= 10000000000n, true); +assert.sameValue(Number.MIN_VALUE >= -10n, true); diff --git a/test/language/expressions/greater-than/bigint-and-bigint.js b/test/language/expressions/greater-than/bigint-and-bigint.js new file mode 100644 index 0000000000..fb62743187 --- /dev/null +++ b/test/language/expressions/greater-than/bigint-and-bigint.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and BigInt values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + + sec-numeric-types-bigint-lessThan + BigInt::lessThan (x, y) + + 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. + +features: [BigInt] +---*/ + +assert.sameValue(0n > 0n, false); +assert.sameValue(1n > 1n, false); +assert.sameValue(-1n > -1n, false); +assert.sameValue(0n > -0n, false); +assert.sameValue(-0n > 0n, false); +assert.sameValue(0n > 1n, false); +assert.sameValue(1n > 0n, true); +assert.sameValue(0n > -1n, true); +assert.sameValue(-1n > 0n, false); +assert.sameValue(1n > -1n, true); +assert.sameValue(-1n > 1n, false); +assert.sameValue(0x1fffffffffffff01n > 0x1fffffffffffff02n, false); +assert.sameValue(0x1fffffffffffff02n > 0x1fffffffffffff01n, true); +assert.sameValue(-0x1fffffffffffff01n > -0x1fffffffffffff02n, true); +assert.sameValue(-0x1fffffffffffff02n > -0x1fffffffffffff01n, false); +assert.sameValue(0x10000000000000000n > 0n, true); +assert.sameValue(0n > 0x10000000000000000n, false); +assert.sameValue(0x10000000000000000n > 1n, true); +assert.sameValue(1n > 0x10000000000000000n, false); +assert.sameValue(0x10000000000000000n > -1n, true); +assert.sameValue(-1n > 0x10000000000000000n, false); +assert.sameValue(0x10000000000000001n > 0n, true); +assert.sameValue(0n > 0x10000000000000001n, false); +assert.sameValue(-0x10000000000000000n > 0n, false); +assert.sameValue(0n > -0x10000000000000000n, true); +assert.sameValue(-0x10000000000000000n > 1n, false); +assert.sameValue(1n > -0x10000000000000000n, true); +assert.sameValue(-0x10000000000000000n > -1n, false); +assert.sameValue(-1n > -0x10000000000000000n, true); +assert.sameValue(-0x10000000000000001n > 0n, false); +assert.sameValue(0n > -0x10000000000000001n, true); +assert.sameValue(0x10000000000000000n > 0x100000000n, true); +assert.sameValue(0x100000000n > 0x10000000000000000n, false); diff --git a/test/language/expressions/greater-than/bigint-and-non-finite.js b/test/language/expressions/greater-than/bigint-and-non-finite.js new file mode 100644 index 0000000000..f1efc83dac --- /dev/null +++ b/test/language/expressions/greater-than/bigint-and-non-finite.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and non-finite Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. +features: [BigInt] +---*/ + +assert.sameValue(1n > Infinity, false); +assert.sameValue(Infinity > 1n, true); +assert.sameValue(-1n > Infinity, false); +assert.sameValue(Infinity > -1n, true); +assert.sameValue(1n > -Infinity, true); +assert.sameValue(-Infinity > 1n, false); +assert.sameValue(-1n > -Infinity, true); +assert.sameValue(-Infinity > -1n, false); +assert.sameValue(0n > NaN, false); +assert.sameValue(NaN > 0n, false); diff --git a/test/language/expressions/greater-than/bigint-and-number-extremes.js b/test/language/expressions/greater-than/bigint-and-number-extremes.js new file mode 100644 index 0000000000..de79976069 --- /dev/null +++ b/test/language/expressions/greater-than/bigint-and-number-extremes.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. + h. If the mathematical value of nx is less than the mathematical value of ny, return true, otherwise return false. +features: [BigInt] +---*/ + +assert.sameValue(1n > Number.MAX_VALUE, false); +assert.sameValue(Number.MAX_VALUE > 1n, true); +assert.sameValue(1n > -Number.MAX_VALUE, true); +assert.sameValue(-Number.MAX_VALUE > 1n, false); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn > Number.MAX_VALUE, + false); +assert.sameValue( + Number.MAX_VALUE > 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + true); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n > Number.MAX_VALUE, + true); +assert.sameValue( + Number.MAX_VALUE > 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + false); diff --git a/test/language/expressions/greater-than/bigint-and-number.js b/test/language/expressions/greater-than/bigint-and-number.js index 107d0fe511..10b2ac3f13 100644 --- a/test/language/expressions/greater-than/bigint-and-number.js +++ b/test/language/expressions/greater-than/bigint-and-number.js @@ -20,17 +20,23 @@ info: | features: [BigInt] ---*/ -assert.sameValue(1n > 0, true); -assert.sameValue(1n > 0.999999999999, true); -assert.sameValue(1 > 0n, true); +assert.sameValue(0n > 0, false); +assert.sameValue(0 > 0n, false); +assert.sameValue(0n > -0, false); +assert.sameValue(-0 > 0n, false); +assert.sameValue(0n > 0.000000000001, false); assert.sameValue(0.000000000001 > 0n, true); +assert.sameValue(0n > 1, false); +assert.sameValue(1 > 0n, true); +assert.sameValue(1n > 0, true); +assert.sameValue(0 > 1n, false); +assert.sameValue(1n > 0.999999999999, true); +assert.sameValue(0.999999999999 > 1n, false); assert.sameValue(1n > 1, false); assert.sameValue(1 > 1n, false); -assert.sameValue(0n > 1, false); -assert.sameValue(0 > 1n, false); -assert.sameValue(0 > 0n, false); -assert.sameValue(0n > 0, false); -assert.sameValue(1n > Number.MAX_VALUE, false); +assert.sameValue(0n > Number.MIN_VALUE, false); assert.sameValue(Number.MIN_VALUE > 0n, true); +assert.sameValue(0n > -Number.MIN_VALUE, true); +assert.sameValue(-Number.MIN_VALUE > 0n, false); assert.sameValue(-10n > Number.MIN_VALUE, false); -assert.sameValue(Number.MAX_VALUE > 10000000000n, true); +assert.sameValue(Number.MIN_VALUE > -10n, true); diff --git a/test/language/expressions/less-than-or-equal/bigint-and-bigint.js b/test/language/expressions/less-than-or-equal/bigint-and-bigint.js new file mode 100644 index 0000000000..04f628a61b --- /dev/null +++ b/test/language/expressions/less-than-or-equal/bigint-and-bigint.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and BigInt values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + + sec-numeric-types-bigint-lessThan + BigInt::lessThan (x, y) + + 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. + +features: [BigInt] +---*/ + +assert.sameValue(0n <= 0n, true); +assert.sameValue(1n <= 1n, true); +assert.sameValue(-1n <= -1n, true); +assert.sameValue(0n <= -0n, true); +assert.sameValue(-0n <= 0n, true); +assert.sameValue(0n <= 1n, true); +assert.sameValue(1n <= 0n, false); +assert.sameValue(0n <= -1n, false); +assert.sameValue(-1n <= 0n, true); +assert.sameValue(1n <= -1n, false); +assert.sameValue(-1n <= 1n, true); +assert.sameValue(0x1fffffffffffff01n <= 0x1fffffffffffff02n, true); +assert.sameValue(0x1fffffffffffff02n <= 0x1fffffffffffff01n, false); +assert.sameValue(-0x1fffffffffffff01n <= -0x1fffffffffffff02n, false); +assert.sameValue(-0x1fffffffffffff02n <= -0x1fffffffffffff01n, true); +assert.sameValue(0x10000000000000000n <= 0n, false); +assert.sameValue(0n <= 0x10000000000000000n, true); +assert.sameValue(0x10000000000000000n <= 1n, false); +assert.sameValue(1n <= 0x10000000000000000n, true); +assert.sameValue(0x10000000000000000n <= -1n, false); +assert.sameValue(-1n <= 0x10000000000000000n, true); +assert.sameValue(0x10000000000000001n <= 0n, false); +assert.sameValue(0n <= 0x10000000000000001n, true); +assert.sameValue(-0x10000000000000000n <= 0n, true); +assert.sameValue(0n <= -0x10000000000000000n, false); +assert.sameValue(-0x10000000000000000n <= 1n, true); +assert.sameValue(1n <= -0x10000000000000000n, false); +assert.sameValue(-0x10000000000000000n <= -1n, true); +assert.sameValue(-1n <= -0x10000000000000000n, false); +assert.sameValue(-0x10000000000000001n <= 0n, true); +assert.sameValue(0n <= -0x10000000000000001n, false); +assert.sameValue(0x10000000000000000n <= 0x100000000n, false); +assert.sameValue(0x100000000n <= 0x10000000000000000n, true); diff --git a/test/language/expressions/less-than-or-equal/bigint-and-non-finite.js b/test/language/expressions/less-than-or-equal/bigint-and-non-finite.js new file mode 100644 index 0000000000..7dcaf91784 --- /dev/null +++ b/test/language/expressions/less-than-or-equal/bigint-and-non-finite.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and non-finite Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. +features: [BigInt] +---*/ + +assert.sameValue(1n <= Infinity, true); +assert.sameValue(Infinity <= 1n, false); +assert.sameValue(-1n <= Infinity, true); +assert.sameValue(Infinity <= -1n, false); +assert.sameValue(1n <= -Infinity, false); +assert.sameValue(-Infinity <= 1n, true); +assert.sameValue(-1n <= -Infinity, false); +assert.sameValue(-Infinity <= -1n, true); +assert.sameValue(0n <= NaN, false); +assert.sameValue(NaN <= 0n, false); diff --git a/test/language/expressions/less-than-or-equal/bigint-and-number-extremes.js b/test/language/expressions/less-than-or-equal/bigint-and-number-extremes.js new file mode 100644 index 0000000000..20b563ad9d --- /dev/null +++ b/test/language/expressions/less-than-or-equal/bigint-and-number-extremes.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. + h. If the mathematical value of nx is less than the mathematical value of ny, return true, otherwise return false. +features: [BigInt] +---*/ + +assert.sameValue(1n <= Number.MAX_VALUE, true); +assert.sameValue(Number.MAX_VALUE <= 1n, false); +assert.sameValue(1n <= -Number.MAX_VALUE, false); +assert.sameValue(-Number.MAX_VALUE <= 1n, true); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn <= Number.MAX_VALUE, + true); +assert.sameValue( + Number.MAX_VALUE <= 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + false); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n <= Number.MAX_VALUE, + false); +assert.sameValue( + Number.MAX_VALUE <= 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + true); diff --git a/test/language/expressions/less-than-or-equal/bigint-and-number.js b/test/language/expressions/less-than-or-equal/bigint-and-number.js index 8437b87be6..c57c5a213f 100644 --- a/test/language/expressions/less-than-or-equal/bigint-and-number.js +++ b/test/language/expressions/less-than-or-equal/bigint-and-number.js @@ -20,17 +20,23 @@ info: | features: [BigInt] ---*/ -assert.sameValue(1n <= 0, false); -assert.sameValue(1n <= 0.999999999999, false); -assert.sameValue(1 <= 0n, false); +assert.sameValue(0n <= 0, true); +assert.sameValue(0 <= 0n, true); +assert.sameValue(0n <= -0, true); +assert.sameValue(-0 <= 0n, true); +assert.sameValue(0n <= 0.000000000001, true); assert.sameValue(0.000000000001 <= 0n, false); +assert.sameValue(0n <= 1, true); +assert.sameValue(1 <= 0n, false); +assert.sameValue(1n <= 0, false); +assert.sameValue(0 <= 1n, true); +assert.sameValue(1n <= 0.999999999999, false); +assert.sameValue(0.999999999999 <= 1n, true); assert.sameValue(1n <= 1, true); assert.sameValue(1 <= 1n, true); -assert.sameValue(0n <= 1, true); -assert.sameValue(0 <= 1n, true); -assert.sameValue(0 <= 0n, true); -assert.sameValue(0n <= 0, true); -assert.sameValue(1n <= Number.MAX_VALUE, true); +assert.sameValue(0n <= Number.MIN_VALUE, true); assert.sameValue(Number.MIN_VALUE <= 0n, false); +assert.sameValue(0n <= -Number.MIN_VALUE, false); +assert.sameValue(-Number.MIN_VALUE <= 0n, true); assert.sameValue(-10n <= Number.MIN_VALUE, true); -assert.sameValue(Number.MAX_VALUE <= 10000000000n, false); +assert.sameValue(Number.MIN_VALUE <= -10n, false); diff --git a/test/language/expressions/less-than/bigint-and-bigint.js b/test/language/expressions/less-than/bigint-and-bigint.js new file mode 100644 index 0000000000..55c232d7c9 --- /dev/null +++ b/test/language/expressions/less-than/bigint-and-bigint.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and BigInt values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + + sec-numeric-types-bigint-lessThan + BigInt::lessThan (x, y) + + 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. + +features: [BigInt] +---*/ + +assert.sameValue(0n < 0n, false); +assert.sameValue(1n < 1n, false); +assert.sameValue(-1n < -1n, false); +assert.sameValue(0n < -0n, false); +assert.sameValue(-0n < 0n, false); +assert.sameValue(0n < 1n, true); +assert.sameValue(1n < 0n, false); +assert.sameValue(0n < -1n, false); +assert.sameValue(-1n < 0n, true); +assert.sameValue(1n < -1n, false); +assert.sameValue(-1n < 1n, true); +assert.sameValue(0x1fffffffffffff01n < 0x1fffffffffffff02n, true); +assert.sameValue(0x1fffffffffffff02n < 0x1fffffffffffff01n, false); +assert.sameValue(-0x1fffffffffffff01n < -0x1fffffffffffff02n, false); +assert.sameValue(-0x1fffffffffffff02n < -0x1fffffffffffff01n, true); +assert.sameValue(0x10000000000000000n < 0n, false); +assert.sameValue(0n < 0x10000000000000000n, true); +assert.sameValue(0x10000000000000000n < 1n, false); +assert.sameValue(1n < 0x10000000000000000n, true); +assert.sameValue(0x10000000000000000n < -1n, false); +assert.sameValue(-1n < 0x10000000000000000n, true); +assert.sameValue(0x10000000000000001n < 0n, false); +assert.sameValue(0n < 0x10000000000000001n, true); +assert.sameValue(-0x10000000000000000n < 0n, true); +assert.sameValue(0n < -0x10000000000000000n, false); +assert.sameValue(-0x10000000000000000n < 1n, true); +assert.sameValue(1n < -0x10000000000000000n, false); +assert.sameValue(-0x10000000000000000n < -1n, true); +assert.sameValue(-1n < -0x10000000000000000n, false); +assert.sameValue(-0x10000000000000001n < 0n, true); +assert.sameValue(0n < -0x10000000000000001n, false); +assert.sameValue(0x10000000000000000n < 0x100000000n, false); +assert.sameValue(0x100000000n < 0x10000000000000000n, true); diff --git a/test/language/expressions/less-than/bigint-and-non-finite.js b/test/language/expressions/less-than/bigint-and-non-finite.js new file mode 100644 index 0000000000..07e93fd7eb --- /dev/null +++ b/test/language/expressions/less-than/bigint-and-non-finite.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of BigInt and non-finite Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. +features: [BigInt] +---*/ + +assert.sameValue(1n < Infinity, true); +assert.sameValue(Infinity < 1n, false); +assert.sameValue(-1n < Infinity, true); +assert.sameValue(Infinity < -1n, false); +assert.sameValue(1n < -Infinity, false); +assert.sameValue(-Infinity < 1n, true); +assert.sameValue(-1n < -Infinity, false); +assert.sameValue(-Infinity < -1n, true); +assert.sameValue(0n < NaN, false); +assert.sameValue(NaN < 0n, false); diff --git a/test/language/expressions/less-than/bigint-and-number-extremes.js b/test/language/expressions/less-than/bigint-and-number-extremes.js new file mode 100644 index 0000000000..2819c99a3c --- /dev/null +++ b/test/language/expressions/less-than/bigint-and-number-extremes.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Comparisons of large BigInt and Number values +esid: sec-abstract-relational-comparison +info: | + ... + 3. If both px and py are Strings, then + ... + 4. Else, + a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. + b. Let ny be ? ToNumeric(py). + c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). + d. Assert: Type(nx) is BigInt and Type(ny) is Number, or if Type(nx) is Number and Type(ny) is BigInt. + e. If x or y are any of NaN, return undefined. + f. If x is -∞, or y is +∞, return true. + g. If x is +∞, or y is -∞, return false. + h. If the mathematical value of nx is less than the mathematical value of ny, return true, otherwise return false. +features: [BigInt] +---*/ + +assert.sameValue(1n < Number.MAX_VALUE, true); +assert.sameValue(Number.MAX_VALUE < 1n, false); +assert.sameValue(1n < -Number.MAX_VALUE, false); +assert.sameValue(-Number.MAX_VALUE < 1n, true); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn < Number.MAX_VALUE, + true); +assert.sameValue( + Number.MAX_VALUE < 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + false); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n < Number.MAX_VALUE, + false); +assert.sameValue( + Number.MAX_VALUE < 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + true); diff --git a/test/language/expressions/less-than/bigint-and-number.js b/test/language/expressions/less-than/bigint-and-number.js index be67d29c94..4af7764fd9 100644 --- a/test/language/expressions/less-than/bigint-and-number.js +++ b/test/language/expressions/less-than/bigint-and-number.js @@ -20,17 +20,23 @@ info: | features: [BigInt] ---*/ -assert.sameValue(1n < 0, false); -assert.sameValue(1n < 0.999999999999, false); -assert.sameValue(1 < 0n, false); +assert.sameValue(0n < 0, false); +assert.sameValue(0 < 0n, false); +assert.sameValue(0n < -0, false); +assert.sameValue(-0 < 0n, false); +assert.sameValue(0n < 0.000000000001, true); assert.sameValue(0.000000000001 < 0n, false); +assert.sameValue(0n < 1, true); +assert.sameValue(1 < 0n, false); +assert.sameValue(1n < 0, false); +assert.sameValue(0 < 1n, true); +assert.sameValue(1n < 0.999999999999, false); +assert.sameValue(0.999999999999 < 1n, true); assert.sameValue(1n < 1, false); assert.sameValue(1 < 1n, false); -assert.sameValue(0n < 1, true); -assert.sameValue(0 < 1n, true); -assert.sameValue(0 < 0n, false); -assert.sameValue(0n < 0, false); -assert.sameValue(1n < Number.MAX_VALUE, true); +assert.sameValue(0n < Number.MIN_VALUE, true); assert.sameValue(Number.MIN_VALUE < 0n, false); +assert.sameValue(0n < -Number.MIN_VALUE, false); +assert.sameValue(-Number.MIN_VALUE < 0n, true); assert.sameValue(-10n < Number.MIN_VALUE, true); -assert.sameValue(Number.MAX_VALUE < 10000000000n, false); +assert.sameValue(Number.MIN_VALUE < -10n, false);