bigint comparison tests (#1513)

* relational comparison of bigint and string values

* additional tests for strings converted to NaN
This commit is contained in:
Robin Templeton 2018-04-18 15:33:00 -04:00 committed by Leo Balter
parent 08cc5a8f68
commit 34e7102b78
8 changed files with 312 additions and 0 deletions

View File

@ -0,0 +1,30 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue(1n >= "0n", false, "1n >= '0n'");
assert.sameValue(1n >= "0.", false, "1n >= '0.'");
assert.sameValue(1n >= ".0", false, "1n >= '.0'");
assert.sameValue(1n >= "0/1", false, "1n >= '0/1'");
assert.sameValue(1n >= "z0", false, "1n >= 'z0'");
assert.sameValue(1n >= "0z", false, "1n >= '0z'");
assert.sameValue(1n >= "++0", false, "1n >= '++0'");
assert.sameValue(1n >= "--0", false, "1n >= '--0'");
assert.sameValue(1n >= "0e0", false, "1n >= '0e0'");
assert.sameValue(1n >= "Infinity", false, "1n >= 'Infinity'");
assert.sameValue("1n" >= 0n, false, "'1n' >= 0n");
assert.sameValue("1." >= 0n, false, "'1.' >= 0n");
assert.sameValue(".1" >= 0n, false, "'.1' >= 0n");
assert.sameValue("1/1" >= 0n, false, "'1/1' >= 0n");
assert.sameValue("z1" >= 0n, false, "'z1' >= 0n");
assert.sameValue("1z" >= 0n, false, "'1z' >= 0n");
assert.sameValue("++1" >= 0n, false, "'++1' >= 0n");
assert.sameValue("--1" >= 0n, false, "'--1' >= 0n");
assert.sameValue("1e0" >= 0n, false, "'1e0' >= 0n");
assert.sameValue("Infinity" >= 0n, false, "'Infinity' >= 0n");

View File

@ -0,0 +1,48 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue(0n >= "0", true, "0n >= '0'");
assert.sameValue("0" >= 0n, true, "'0' >= 0n");
assert.sameValue(0n >= "1", false, "0n >= '1'");
assert.sameValue("0" >= 1n, false, "'0' >= 1n");
assert.sameValue(1n >= "0", true, "1n >= '0'");
assert.sameValue("1" >= 0n, true, "'1' >= 0n");
assert.sameValue(0n >= "", true, "0n >= ''");
assert.sameValue("" >= 0n, true, "'' >= 0n");
assert.sameValue(0n >= "1", false, "0n >= '1'");
assert.sameValue("" >= 1n, false, "'' >= 1n");
assert.sameValue(1n >= "", true, "1n >= ''");
assert.sameValue("1" >= 0n, true, "'1' >= 0n");
assert.sameValue(1n >= "1", true, "1n >= '1'");
assert.sameValue("1" >= 1n, true, "'1' >= 1n");
assert.sameValue(1n >= "-1", true, "1n >= '-1'");
assert.sameValue("1" >= -1n, true, "'1' >= -1n");
assert.sameValue(-1n >= "1", false, "-1n >= '1'");
assert.sameValue("-1" >= 1n, false, "'-1' >= 1n");
assert.sameValue(-1n >= "-1", true, "-1n >= '-1'");
assert.sameValue("-1" >= -1n, true, "'-1' >= -1n");
assert.sameValue(9007199254740993n >= "9007199254740992", true,
"9007199254740993n >= '9007199254740992'");
assert.sameValue("9007199254740993" >= 9007199254740992n, true,
"'9007199254740993' >= 9007199254740992n");
assert.sameValue(-9007199254740992n >= "-9007199254740993", true,
"-9007199254740992n >= '-9007199254740993'");
assert.sameValue("-9007199254740992" >= -9007199254740993n, true,
"'-9007199254740992' >= -9007199254740993n");

View File

@ -0,0 +1,30 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue(1n > "0n", false, "1n > '0n'");
assert.sameValue(1n > "0.", false, "1n > '0.'");
assert.sameValue(1n > ".0", false, "1n > '.0'");
assert.sameValue(1n > "0/1", false, "1n > '0/1'");
assert.sameValue(1n > "z0", false, "1n > 'z0'");
assert.sameValue(1n > "0z", false, "1n > '0z'");
assert.sameValue(1n > "++0", false, "1n > '++0'");
assert.sameValue(1n > "--0", false, "1n > '--0'");
assert.sameValue(1n > "0e0", false, "1n > '0e0'");
assert.sameValue(1n > "Infinity", false, "1n > 'Infinity'");
assert.sameValue("1n" > 0n, false, "'1n' > 0n");
assert.sameValue("1." > 0n, false, "'1.' > 0n");
assert.sameValue(".1" > 0n, false, "'.1' > 0n");
assert.sameValue("1/1" > 0n, false, "'1/1' > 0n");
assert.sameValue("z1" > 0n, false, "'z1' > 0n");
assert.sameValue("1z" > 0n, false, "'1z' > 0n");
assert.sameValue("++1" > 0n, false, "'++1' > 0n");
assert.sameValue("--1" > 0n, false, "'--1' > 0n");
assert.sameValue("1e0" > 0n, false, "'1e0' > 0n");
assert.sameValue("Infinity" > 0n, false, "'Infinity' > 0n");

View File

@ -0,0 +1,48 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue(0n > "0", false, "0n > '0'");
assert.sameValue("0" > 0n, false, "'0' > 0n");
assert.sameValue(0n > "1", false, "0n > '1'");
assert.sameValue("0" > 1n, false, "'0' > 1n");
assert.sameValue(1n > "0", true, "1n > '0'");
assert.sameValue("1" > 0n, true, "'1' > 0n");
assert.sameValue(0n > "", false, "0n > ''");
assert.sameValue("" > 0n, false, "'' > 0n");
assert.sameValue(0n > "1", false, "0n > '1'");
assert.sameValue("" > 1n, false, "'' > 1n");
assert.sameValue(1n > "", true, "1n > ''");
assert.sameValue("1" > 0n, true, "'1' > 0n");
assert.sameValue(1n > "1", false, "1n > '1'");
assert.sameValue("1" > 1n, false, "'1' > 1n");
assert.sameValue(1n > "-1", true, "1n > '-1'");
assert.sameValue("1" > -1n, true, "'1' > -1n");
assert.sameValue(-1n > "1", false, "-1n > '1'");
assert.sameValue("-1" > 1n, false, "'-1' > 1n");
assert.sameValue(-1n > "-1", false, "-1n > '-1'");
assert.sameValue("-1" > -1n, false, "'-1' > -1n");
assert.sameValue(9007199254740993n > "9007199254740992", true,
"9007199254740993n > '9007199254740992'");
assert.sameValue("9007199254740993" > 9007199254740992n, true,
"'9007199254740993' > 9007199254740992n");
assert.sameValue(-9007199254740992n > "-9007199254740993", true,
"-9007199254740992n > '-9007199254740993'");
assert.sameValue("-9007199254740992" > -9007199254740993n, true,
"'-9007199254740992' > -9007199254740993n");

View File

@ -0,0 +1,30 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue("0n" <= 1n, false, "'0n' <= 1n");
assert.sameValue("0." <= 1n, false, "'0.' <= 1n");
assert.sameValue(".0" <= 1n, false, "'.0' <= 1n");
assert.sameValue("0/1" <= 1n, false, "'0/1' <= 1n");
assert.sameValue("z0" <= 1n, false, "'z0' <= 1n");
assert.sameValue("0z" <= 1n, false, "'0z' <= 1n");
assert.sameValue("++0" <= 1n, false, "'++0' <= 1n");
assert.sameValue("--0" <= 1n, false, "'--0' <= 1n");
assert.sameValue("0e0" <= 1n, false, "'0e0' <= 1n");
assert.sameValue("Infinity" <= 1n, false, "'Infinity' <= 1n");
assert.sameValue(0n <= "1n", false, "0n <= '1n'");
assert.sameValue(0n <= "1.", false, "0n <= '1.'");
assert.sameValue(0n <= ".1", false, "0n <= '.1'");
assert.sameValue(0n <= "1/1", false, "0n <= '1/1'");
assert.sameValue(0n <= "z1", false, "0n <= 'z1'");
assert.sameValue(0n <= "1z", false, "0n <= '1z'");
assert.sameValue(0n <= "++1", false, "0n <= '++1'");
assert.sameValue(0n <= "--1", false, "0n <= '--1'");
assert.sameValue(0n <= "1e0", false, "0n <= '1e0'");
assert.sameValue(0n <= "Infinity", false, "0n <= 'Infinity'");

View File

@ -0,0 +1,48 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue(0n <= "0", true, "0n <= '0'");
assert.sameValue("0" <= 0n, true, "'0' <= 0n");
assert.sameValue(0n <= "1", true, "0n <= '1'");
assert.sameValue("0" <= 1n, true, "'0' <= 1n");
assert.sameValue(1n <= "0", false, "1n <= '0'");
assert.sameValue("1" <= 0n, false, "'1' <= 0n");
assert.sameValue(0n <= "", true, "0n <= ''");
assert.sameValue("" <= 0n, true, "'' <= 0n");
assert.sameValue(0n <= "1", true, "0n <= '1'");
assert.sameValue("" <= 1n, true, "'' <= 1n");
assert.sameValue(1n <= "", false, "1n <= ''");
assert.sameValue("1" <= 0n, false, "'1' <= 0n");
assert.sameValue(1n <= "1", true, "1n <= '1'");
assert.sameValue("1" <= 1n, true, "'1' <= 1n");
assert.sameValue(1n <= "-1", false, "1n <= '-1'");
assert.sameValue("1" <= -1n, false, "'1' <= -1n");
assert.sameValue(-1n <= "1", true, "-1n <= '1'");
assert.sameValue("-1" <= 1n, true, "'-1' <= 1n");
assert.sameValue(-1n <= "-1", true, "-1n <= '-1'");
assert.sameValue("-1" <= -1n, true, "'-1' <= -1n");
assert.sameValue(9007199254740993n <= "9007199254740992", false,
"9007199254740993n <= '9007199254740992'");
assert.sameValue("9007199254740993" <= 9007199254740992n, false,
"'9007199254740993' <= 9007199254740992n");
assert.sameValue(-9007199254740992n <= "-9007199254740993", false,
"-9007199254740992n <= '-9007199254740993'");
assert.sameValue("-9007199254740992" <= -9007199254740993n, false,
"'-9007199254740992' <= -9007199254740993n");

View File

@ -0,0 +1,30 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue("0n" < 1n, false, "'0n' < 1n");
assert.sameValue("0." < 1n, false, "'0.' < 1n");
assert.sameValue(".0" < 1n, false, "'.0' < 1n");
assert.sameValue("0/1" < 1n, false, "'0/1' < 1n");
assert.sameValue("z0" < 1n, false, "'z0' < 1n");
assert.sameValue("0z" < 1n, false, "'0z' < 1n");
assert.sameValue("++0" < 1n, false, "'++0' < 1n");
assert.sameValue("--0" < 1n, false, "'--0' < 1n");
assert.sameValue("0e0" < 1n, false, "'0e0' < 1n");
assert.sameValue("Infinity" < 1n, false, "'Infinity' < 1n");
assert.sameValue(0n < "1n", false, "0n < '1n'");
assert.sameValue(0n < "1.", false, "0n < '1.'");
assert.sameValue(0n < ".1", false, "0n < '.1'");
assert.sameValue(0n < "1/1", false, "0n < '1/1'");
assert.sameValue(0n < "z1", false, "0n < 'z1'");
assert.sameValue(0n < "1z", false, "0n < '1z'");
assert.sameValue(0n < "++1", false, "0n < '++1'");
assert.sameValue(0n < "--1", false, "0n < '--1'");
assert.sameValue(0n < "1e0", false, "0n < '1e0'");
assert.sameValue(0n < "Infinity", false, "0n < 'Infinity'");

View File

@ -0,0 +1,48 @@
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Relational comparison of BigInt and string values
esid: sec-abstract-relational-comparison
features: [BigInt]
---*/
assert.sameValue(0n < "0", false, "0n < '0'");
assert.sameValue("0" < 0n, false, "'0' < 0n");
assert.sameValue(0n < "1", true, "0n < '1'");
assert.sameValue("0" < 1n, true, "'0' < 1n");
assert.sameValue(1n < "0", false, "1n < '0'");
assert.sameValue("1" < 0n, false, "'1' < 0n");
assert.sameValue(0n < "", false, "0n < ''");
assert.sameValue("" < 0n, false, "'' < 0n");
assert.sameValue(0n < "1", true, "0n < '1'");
assert.sameValue("" < 1n, true, "'' < 1n");
assert.sameValue(1n < "", false, "1n < ''");
assert.sameValue("1" < 0n, false, "'1' < 0n");
assert.sameValue(1n < "1", false, "1n < '1'");
assert.sameValue("1" < 1n, false, "'1' < 1n");
assert.sameValue(1n < "-1", false, "1n < '-1'");
assert.sameValue("1" < -1n, false, "'1' < -1n");
assert.sameValue(-1n < "1", true, "-1n < '1'");
assert.sameValue("-1" < 1n, true, "'-1' < 1n");
assert.sameValue(-1n < "-1", false, "-1n < '-1'");
assert.sameValue("-1" < -1n, false, "'-1' < -1n");
assert.sameValue(9007199254740993n < "9007199254740992", false,
"9007199254740993n < '9007199254740992'");
assert.sameValue("9007199254740993" < 9007199254740992n, false,
"'9007199254740993' < 9007199254740992n");
assert.sameValue(-9007199254740992n < "-9007199254740993", false,
"-9007199254740992n < '-9007199254740993'");
assert.sameValue("-9007199254740992" < -9007199254740993n, false,
"'-9007199254740992' < -9007199254740993n");