diff --git a/test/language/expressions/does-not-equals/bigint-and-bigint.js b/test/language/expressions/does-not-equals/bigint-and-bigint.js new file mode 100644 index 00000000000..fbed259fb70 --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-bigint.js @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict inequality comparison of BigInt values +esid: sec-abstract-equality-comparison +info: | + 1. If Type(x) is the same as Type(y), then + a. Return the result of performing Strict Equality Comparison x === y. + + sec-numeric-types-bigint-equal + BigInt::equal (x, y) + + The abstract operation BigInt::equal with two arguments x and y of BigInt type returns true if x and y have the same mathematical integer value and false otherwise. + +features: [BigInt] +---*/ + +assert.sameValue(0n != 0n, false, "0n != 0n"); +assert.sameValue(1n != 1n, false, "1n != 1n"); +assert.sameValue(-1n != -1n, false, "-1n != -1n"); +assert.sameValue(0n != -0n, false, "0n != -0n"); +assert.sameValue(-0n != 0n, false, "-0n != 0n"); +assert.sameValue(0n != 1n, true, "0n != 1n"); +assert.sameValue(1n != 0n, true, "1n != 0n"); +assert.sameValue(0n != -1n, true, "0n != -1n"); +assert.sameValue(-1n != 0n, true, "-1n != 0n"); +assert.sameValue(1n != -1n, true, "1n != -1n"); +assert.sameValue(-1n != 1n, true, "-1n != 1n"); +assert.sameValue(0x1fffffffffffff01n != 0x1fffffffffffff01n, false, "0x1fffffffffffff01n != 0x1fffffffffffff01n"); +assert.sameValue(0x1fffffffffffff01n != 0x1fffffffffffff02n, true, "0x1fffffffffffff01n != 0x1fffffffffffff02n"); +assert.sameValue(0x1fffffffffffff02n != 0x1fffffffffffff01n, true, "0x1fffffffffffff02n != 0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n != -0x1fffffffffffff01n, false, "-0x1fffffffffffff01n != -0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n != -0x1fffffffffffff02n, true, "-0x1fffffffffffff01n != -0x1fffffffffffff02n"); +assert.sameValue(-0x1fffffffffffff02n != -0x1fffffffffffff01n, true, "-0x1fffffffffffff02n != -0x1fffffffffffff01n"); +assert.sameValue(0x10000000000000000n != 0n, true, "0x10000000000000000n != 0n"); +assert.sameValue(0n != 0x10000000000000000n, true, "0n != 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n != 1n, true, "0x10000000000000000n != 1n"); +assert.sameValue(1n != 0x10000000000000000n, true, "1n != 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n != -1n, true, "0x10000000000000000n != -1n"); +assert.sameValue(-1n != 0x10000000000000000n, true, "-1n != 0x10000000000000000n"); +assert.sameValue(0x10000000000000001n != 0n, true, "0x10000000000000001n != 0n"); +assert.sameValue(0n != 0x10000000000000001n, true, "0n != 0x10000000000000001n"); +assert.sameValue(-0x10000000000000000n != 0n, true, "-0x10000000000000000n != 0n"); +assert.sameValue(0n != -0x10000000000000000n, true, "0n != -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n != 1n, true, "-0x10000000000000000n != 1n"); +assert.sameValue(1n != -0x10000000000000000n, true, "1n != -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n != -1n, true, "-0x10000000000000000n != -1n"); +assert.sameValue(-1n != -0x10000000000000000n, true, "-1n != -0x10000000000000000n"); +assert.sameValue(-0x10000000000000001n != 0n, true, "-0x10000000000000001n != 0n"); +assert.sameValue(0n != -0x10000000000000001n, true, "0n != -0x10000000000000001n"); +assert.sameValue(0x10000000000000000n != 0x100000000n, true, "0x10000000000000000n != 0x100000000n"); +assert.sameValue(0x100000000n != 0x10000000000000000n, true, "0x100000000n != 0x10000000000000000n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-boolean.js b/test/language/expressions/does-not-equals/bigint-and-boolean.js new file mode 100644 index 00000000000..498dd1b77cf --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-boolean.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict inequality comparison of BigInt and Boolean values +esid: sec-abstract-equality-comparison +info: | + 8. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y. + 9. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y). + ... + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + ... + b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. + +features: [BigInt] +---*/ + +assert.sameValue(-1n != false, true, "-1n != false"); +assert.sameValue(false != -1n, true, "false != -1n"); +assert.sameValue(-1n != true, true, "-1n != true"); +assert.sameValue(true != -1n, true, "true != -1n"); +assert.sameValue(0n != false, false, "0n != false"); +assert.sameValue(false != 0n, false, "false != 0n"); +assert.sameValue(0n != true, true, "0n != true"); +assert.sameValue(true != 0n, true, "true != 0n"); +assert.sameValue(1n != false, true, "1n != false"); +assert.sameValue(false != 1n, true, "false != 1n"); +assert.sameValue(1n != true, false, "1n != true"); +assert.sameValue(true != 1n, false, "true != 1n"); +assert.sameValue(2n != false, true, "2n != false"); +assert.sameValue(false != 2n, true, "false != 2n"); +assert.sameValue(2n != true, true, "2n != true"); +assert.sameValue(true != 2n, true, "true != 2n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-incomparable-primitive.js b/test/language/expressions/does-not-equals/bigint-and-incomparable-primitive.js new file mode 100644 index 00000000000..d39e9e38868 --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-incomparable-primitive.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict inequality comparison of BigInt and miscellaneous primitive values +esid: sec-equality-operators-runtime-semantics-evaluation +info: | + EqualityExpression : EqualityExpression != RelationalExpression + ... + 5. Return the result of performing Abstract Equality Comparison rval == lval. + 6. If r is true, return false. Otherwise, return true. + +features: [BigInt, Symbol] +---*/ + +assert.sameValue(0n != undefined, true, "0n != undefined"); +assert.sameValue(undefined != 0n, true, "undefined != 0n"); +assert.sameValue(1n != undefined, true, "1n != undefined"); +assert.sameValue(undefined != 1n, true, "undefined != 1n"); +assert.sameValue(0n != null, true, "0n != null"); +assert.sameValue(null != 0n, true, "null != 0n"); +assert.sameValue(1n != null, true, "1n != null"); +assert.sameValue(null != 1n, true, "null != 1n"); +assert.sameValue(0n != Symbol("1"), true, "0n != Symbol(\"1\")"); +assert.sameValue(Symbol("1") != 0n, true, "Symbol(\"1\") != 0n"); +assert.sameValue(1n != Symbol("1"), true, "1n != Symbol(\"1\")"); +assert.sameValue(Symbol("1") != 1n, true, "Symbol(\"1\") != 1n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-non-finite.js b/test/language/expressions/does-not-equals/bigint-and-non-finite.js new file mode 100644 index 00000000000..2118e014f6b --- /dev/null +++ b/test/language/expressions/does-not-equals/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: Non-strict inequality comparison of BigInt and non-finite Number values +esid: sec-abstract-equality-comparison +info: | + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + a. If x or y are any of NaN, +∞, or -∞, return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n != Infinity, true, "0n != Infinity"); +assert.sameValue(Infinity != 0n, true, "Infinity != 0n"); +assert.sameValue(1n != Infinity, true, "1n != Infinity"); +assert.sameValue(Infinity != 1n, true, "Infinity != 1n"); +assert.sameValue(-1n != Infinity, true, "-1n != Infinity"); +assert.sameValue(Infinity != -1n, true, "Infinity != -1n"); +assert.sameValue(0n != -Infinity, true, "0n != -Infinity"); +assert.sameValue(-Infinity != 0n, true, "-Infinity != 0n"); +assert.sameValue(1n != -Infinity, true, "1n != -Infinity"); +assert.sameValue(-Infinity != 1n, true, "-Infinity != 1n"); +assert.sameValue(-1n != -Infinity, true, "-1n != -Infinity"); +assert.sameValue(-Infinity != -1n, true, "-Infinity != -1n"); +assert.sameValue(0n != NaN, true, "0n != NaN"); +assert.sameValue(NaN != 0n, true, "NaN != 0n"); +assert.sameValue(1n != NaN, true, "1n != NaN"); +assert.sameValue(NaN != 1n, true, "NaN != 1n"); +assert.sameValue(-1n != NaN, true, "-1n != NaN"); +assert.sameValue(NaN != -1n, true, "NaN != -1n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-number-extremes.js b/test/language/expressions/does-not-equals/bigint-and-number-extremes.js new file mode 100644 index 00000000000..dfb2c7ea2cc --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-number-extremes.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict inequality comparison of BigInt and large Number values +esid: sec-abstract-equality-comparison +info: | + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. + +features: [BigInt] +---*/ + +assert.sameValue(1n != Number.MAX_VALUE, true, "1n != Number.MAX_VALUE"); +assert.sameValue(Number.MAX_VALUE != 1n, true, "Number.MAX_VALUE != 1n"); +assert.sameValue(1n != -Number.MAX_VALUE, true, "1n != -Number.MAX_VALUE"); +assert.sameValue(-Number.MAX_VALUE != 1n, true, "-Number.MAX_VALUE != 1n"); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn != Number.MAX_VALUE, + true, + "0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn != Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE != 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + true, + "Number.MAX_VALUE != 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n != Number.MAX_VALUE, + false, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n != Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE != 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, + false, + "Number.MAX_VALUE != 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n != Number.MAX_VALUE, + true, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n != Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE != 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + true, + "Number.MAX_VALUE != 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-number.js b/test/language/expressions/does-not-equals/bigint-and-number.js new file mode 100644 index 00000000000..d0d76c6c2f0 --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-number.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict inequality comparison of BigInt and Number values +esid: sec-abstract-equality-comparison +info: | + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n != 0, false, "0n != 0"); +assert.sameValue(0 != 0n, false, "0 != 0n"); +assert.sameValue(0n != -0, false, "0n != -0"); +assert.sameValue(-0 != 0n, false, "-0 != 0n"); +assert.sameValue(0n != 0.000000000001, true, "0n != 0.000000000001"); +assert.sameValue(0.000000000001 != 0n, true, "0.000000000001 != 0n"); +assert.sameValue(0n != 1, true, "0n != 1"); +assert.sameValue(1 != 0n, true, "1 != 0n"); +assert.sameValue(1n != 0, true, "1n != 0"); +assert.sameValue(0 != 1n, true, "0 != 1n"); +assert.sameValue(1n != 0.999999999999, true, "1n != 0.999999999999"); +assert.sameValue(0.999999999999 != 1n, true, "0.999999999999 != 1n"); +assert.sameValue(1n != 1, false, "1n != 1"); +assert.sameValue(1 != 1n, false, "1 != 1n"); +assert.sameValue(0n != Number.MIN_VALUE, true, "0n != Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE != 0n, true, "Number.MIN_VALUE != 0n"); +assert.sameValue(0n != -Number.MIN_VALUE, true, "0n != -Number.MIN_VALUE"); +assert.sameValue(-Number.MIN_VALUE != 0n, true, "-Number.MIN_VALUE != 0n"); +assert.sameValue(-10n != Number.MIN_VALUE, true, "-10n != Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE != -10n, true, "Number.MIN_VALUE != -10n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-object.js b/test/language/expressions/does-not-equals/bigint-and-object.js new file mode 100644 index 00000000000..f4e57b01215 --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-object.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: Non-strict inequality comparison of BigInt values and non-primitive objects +esid: sec-abstract-equality-comparison +info: | + 10. If Type(x) is either String, Number, BigInt, or Symbol and Type(y) is Object, return the result of the comparison x == ? ToPrimitive(y). + 11. If Type(x) is Object and Type(y) is either String, Number, BigInt, or Symbol, return the result of the comparison ? ToPrimitive(x) == y. + + then after the recursion: + + 1. If Type(x) is the same as Type(y), then + a. Return the result of performing Strict Equality Comparison x === y. + ... + 6. If Type(x) is BigInt and Type(y) is String, + a. Let n be StringToBigInt(y). + b. If n is NaN, return false. + c. Return the result of x == n. + 7. If Type(x) is String and Type(y) is BigInt, return the result of y == x. + +features: [BigInt] +---*/ + +assert.sameValue(0n != Object(0n), false, "0n != Object(0n)"); +assert.sameValue(Object(0n) != 0n, false, "Object(0n) != 0n"); +assert.sameValue(0n != Object(1n), true, "0n != Object(1n)"); +assert.sameValue(Object(1n) != 0n, true, "Object(1n) != 0n"); +assert.sameValue(1n != Object(0n), true, "1n != Object(0n)"); +assert.sameValue(Object(0n) != 1n, true, "Object(0n) != 1n"); +assert.sameValue(1n != Object(1n), false, "1n != Object(1n)"); +assert.sameValue(Object(1n) != 1n, false, "Object(1n) != 1n"); +assert.sameValue(2n != Object(0n), true, "2n != Object(0n)"); +assert.sameValue(Object(0n) != 2n, true, "Object(0n) != 2n"); +assert.sameValue(2n != Object(1n), true, "2n != Object(1n)"); +assert.sameValue(Object(1n) != 2n, true, "Object(1n) != 2n"); +assert.sameValue(2n != Object(2n), false, "2n != Object(2n)"); +assert.sameValue(Object(2n) != 2n, false, "Object(2n) != 2n"); +assert.sameValue(0n != {}, true, "0n != {}"); +assert.sameValue({} != 0n, true, "{} != 0n"); +assert.sameValue(0n != {valueOf: function() { return 0n; }}, false, "0n != {valueOf: function() { return 0n; }}"); +assert.sameValue({valueOf: function() { return 0n; }} != 0n, false, "{valueOf: function() { return 0n; }} != 0n"); +assert.sameValue(0n != {valueOf: function() { return 1n; }}, true, "0n != {valueOf: function() { return 1n; }}"); +assert.sameValue({valueOf: function() { return 1n; }} != 0n, true, "{valueOf: function() { return 1n; }} != 0n"); +assert.sameValue(0n != {toString: function() { return "0"; }}, false, "0n != {toString: function() { return \"0\"; }}"); +assert.sameValue({toString: function() { return "0"; }} != 0n, false, "{toString: function() { return \"0\"; }} != 0n"); +assert.sameValue(0n != {toString: function() { return "1"; }}, true, "0n != {toString: function() { return \"1\"; }}"); +assert.sameValue({toString: function() { return "1"; }} != 0n, true, "{toString: function() { return \"1\"; }} != 0n"); +assert.sameValue(900719925474099101n != {valueOf: function() { return 900719925474099101n; }}, false, "900719925474099101n != {valueOf: function() { return 900719925474099101n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099101n; }} != 900719925474099101n, false, "{valueOf: function() { return 900719925474099101n; }} != 900719925474099101n"); +assert.sameValue(900719925474099101n != {valueOf: function() { return 900719925474099102n; }}, true, "900719925474099101n != {valueOf: function() { return 900719925474099102n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099102n; }} != 900719925474099101n, true, "{valueOf: function() { return 900719925474099102n; }} != 900719925474099101n"); +assert.sameValue(900719925474099101n != {toString: function() { return "900719925474099101"; }}, false, "900719925474099101n != {toString: function() { return \"900719925474099101\"; }}"); +assert.sameValue({toString: function() { return "900719925474099101"; }} != 900719925474099101n, false, "{toString: function() { return \"900719925474099101\"; }} != 900719925474099101n"); +assert.sameValue(900719925474099101n != {toString: function() { return "900719925474099102"; }}, true, "900719925474099101n != {toString: function() { return \"900719925474099102\"; }}"); +assert.sameValue({toString: function() { return "900719925474099102"; }} != 900719925474099101n, true, "{toString: function() { return \"900719925474099102\"; }} != 900719925474099101n"); diff --git a/test/language/expressions/does-not-equals/bigint-and-string.js b/test/language/expressions/does-not-equals/bigint-and-string.js new file mode 100644 index 00000000000..ef6dd05bcd7 --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint-and-string.js @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict inequality comparison of BigInt and String values +esid: sec-abstract-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n != "", false, "0n != \"\""); +assert.sameValue("" != 0n, false, "\"\" != 0n"); +assert.sameValue(0n != "-0", false, "0n != \"-0\""); +assert.sameValue("-0" != 0n, false, "\"-0\" != 0n"); +assert.sameValue(0n != "0", false, "0n != \"0\""); +assert.sameValue("0" != 0n, false, "\"0\" != 0n"); +assert.sameValue(0n != "-1", true, "0n != \"-1\""); +assert.sameValue("-1" != 0n, true, "\"-1\" != 0n"); +assert.sameValue(0n != "1", true, "0n != \"1\""); +assert.sameValue("1" != 0n, true, "\"1\" != 0n"); +assert.sameValue(0n != "foo", true, "0n != \"foo\""); +assert.sameValue("foo" != 0n, true, "\"foo\" != 0n"); +assert.sameValue(1n != "", true, "1n != \"\""); +assert.sameValue("" != 1n, true, "\"\" != 1n"); +assert.sameValue(1n != "-0", true, "1n != \"-0\""); +assert.sameValue("-0" != 1n, true, "\"-0\" != 1n"); +assert.sameValue(1n != "0", true, "1n != \"0\""); +assert.sameValue("0" != 1n, true, "\"0\" != 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 != "foo", true, "1n != \"foo\""); +assert.sameValue("foo" != 1n, true, "\"foo\" != 1n"); +assert.sameValue(-1n != "-", true, "-1n != \"-\""); +assert.sameValue("-" != -1n, true, "\"-\" != -1n"); +assert.sameValue(-1n != "-0", true, "-1n != \"-0\""); +assert.sameValue("-0" != -1n, true, "\"-0\" != -1n"); +assert.sameValue(-1n != "-1", false, "-1n != \"-1\""); +assert.sameValue("-1" != -1n, false, "\"-1\" != -1n"); +assert.sameValue(-1n != "-foo", true, "-1n != \"-foo\""); +assert.sameValue("-foo" != -1n, true, "\"-foo\" != -1n"); +assert.sameValue(900719925474099101n != "900719925474099101", false, "900719925474099101n != \"900719925474099101\""); +assert.sameValue("900719925474099101" != 900719925474099101n, false, "\"900719925474099101\" != 900719925474099101n"); +assert.sameValue(900719925474099102n != "900719925474099101", true, "900719925474099102n != \"900719925474099101\""); +assert.sameValue("900719925474099101" != 900719925474099102n, true, "\"900719925474099101\" != 900719925474099102n"); diff --git a/test/language/expressions/equals/bigint-and-bigint.js b/test/language/expressions/equals/bigint-and-bigint.js new file mode 100644 index 00000000000..7241abd531e --- /dev/null +++ b/test/language/expressions/equals/bigint-and-bigint.js @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict equality comparison of BigInt values +esid: sec-abstract-equality-comparison +info: | + 1. If Type(x) is the same as Type(y), then + a. Return the result of performing Strict Equality Comparison x === y. + + sec-numeric-types-bigint-equal + BigInt::equal (x, y) + + The abstract operation BigInt::equal with two arguments x and y of BigInt type returns true if x and y have the same mathematical integer value and false otherwise. + +features: [BigInt] +---*/ + +assert.sameValue(0n == 0n, true, "0n == 0n"); +assert.sameValue(1n == 1n, true, "1n == 1n"); +assert.sameValue(-1n == -1n, true, "-1n == -1n"); +assert.sameValue(0n == -0n, true, "0n == -0n"); +assert.sameValue(-0n == 0n, true, "-0n == 0n"); +assert.sameValue(0n == 1n, false, "0n == 1n"); +assert.sameValue(1n == 0n, false, "1n == 0n"); +assert.sameValue(0n == -1n, false, "0n == -1n"); +assert.sameValue(-1n == 0n, false, "-1n == 0n"); +assert.sameValue(1n == -1n, false, "1n == -1n"); +assert.sameValue(-1n == 1n, false, "-1n == 1n"); +assert.sameValue(0x1fffffffffffff01n == 0x1fffffffffffff01n, true, "0x1fffffffffffff01n == 0x1fffffffffffff01n"); +assert.sameValue(0x1fffffffffffff01n == 0x1fffffffffffff02n, false, "0x1fffffffffffff01n == 0x1fffffffffffff02n"); +assert.sameValue(0x1fffffffffffff02n == 0x1fffffffffffff01n, false, "0x1fffffffffffff02n == 0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n == -0x1fffffffffffff01n, true, "-0x1fffffffffffff01n == -0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n == -0x1fffffffffffff02n, false, "-0x1fffffffffffff01n == -0x1fffffffffffff02n"); +assert.sameValue(-0x1fffffffffffff02n == -0x1fffffffffffff01n, false, "-0x1fffffffffffff02n == -0x1fffffffffffff01n"); +assert.sameValue(0x10000000000000000n == 0n, false, "0x10000000000000000n == 0n"); +assert.sameValue(0n == 0x10000000000000000n, false, "0n == 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n == 1n, false, "0x10000000000000000n == 1n"); +assert.sameValue(1n == 0x10000000000000000n, false, "1n == 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n == -1n, false, "0x10000000000000000n == -1n"); +assert.sameValue(-1n == 0x10000000000000000n, false, "-1n == 0x10000000000000000n"); +assert.sameValue(0x10000000000000001n == 0n, false, "0x10000000000000001n == 0n"); +assert.sameValue(0n == 0x10000000000000001n, false, "0n == 0x10000000000000001n"); +assert.sameValue(-0x10000000000000000n == 0n, false, "-0x10000000000000000n == 0n"); +assert.sameValue(0n == -0x10000000000000000n, false, "0n == -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n == 1n, false, "-0x10000000000000000n == 1n"); +assert.sameValue(1n == -0x10000000000000000n, false, "1n == -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n == -1n, false, "-0x10000000000000000n == -1n"); +assert.sameValue(-1n == -0x10000000000000000n, false, "-1n == -0x10000000000000000n"); +assert.sameValue(-0x10000000000000001n == 0n, false, "-0x10000000000000001n == 0n"); +assert.sameValue(0n == -0x10000000000000001n, false, "0n == -0x10000000000000001n"); +assert.sameValue(0x10000000000000000n == 0x100000000n, false, "0x10000000000000000n == 0x100000000n"); +assert.sameValue(0x100000000n == 0x10000000000000000n, false, "0x100000000n == 0x10000000000000000n"); diff --git a/test/language/expressions/equals/bigint-and-boolean.js b/test/language/expressions/equals/bigint-and-boolean.js new file mode 100644 index 00000000000..c40ab3adfb0 --- /dev/null +++ b/test/language/expressions/equals/bigint-and-boolean.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict equality comparison of BigInt and Boolean values +esid: sec-abstract-equality-comparison +info: | + 8. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y. + 9. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y). + ... + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + ... + b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. + +features: [BigInt] +---*/ + +assert.sameValue(-1n == false, false, "-1n == false"); +assert.sameValue(false == -1n, false, "false == -1n"); +assert.sameValue(-1n == true, false, "-1n == true"); +assert.sameValue(true == -1n, false, "true == -1n"); +assert.sameValue(0n == false, true, "0n == false"); +assert.sameValue(false == 0n, true, "false == 0n"); +assert.sameValue(0n == true, false, "0n == true"); +assert.sameValue(true == 0n, false, "true == 0n"); +assert.sameValue(1n == false, false, "1n == false"); +assert.sameValue(false == 1n, false, "false == 1n"); +assert.sameValue(1n == true, true, "1n == true"); +assert.sameValue(true == 1n, true, "true == 1n"); +assert.sameValue(2n == false, false, "2n == false"); +assert.sameValue(false == 2n, false, "false == 2n"); +assert.sameValue(2n == true, false, "2n == true"); +assert.sameValue(true == 2n, false, "true == 2n"); diff --git a/test/language/expressions/equals/bigint-and-incomparable-primitive.js b/test/language/expressions/equals/bigint-and-incomparable-primitive.js new file mode 100644 index 00000000000..ff5e28c336b --- /dev/null +++ b/test/language/expressions/equals/bigint-and-incomparable-primitive.js @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict equality comparison of BigInt and miscellaneous primitive values +esid: sec-equality-operators-runtime-semantics-evaluation +info: | + EqualityExpression : EqualityExpression == RelationalExpression + ... + 5. Return the result of performing Abstract Equality Comparison rval == lval. + +features: [BigInt, Symbol] +---*/ + +assert.sameValue(0n == undefined, false, "0n == undefined"); +assert.sameValue(undefined == 0n, false, "undefined == 0n"); +assert.sameValue(1n == undefined, false, "1n == undefined"); +assert.sameValue(undefined == 1n, false, "undefined == 1n"); +assert.sameValue(0n == null, false, "0n == null"); +assert.sameValue(null == 0n, false, "null == 0n"); +assert.sameValue(1n == null, false, "1n == null"); +assert.sameValue(null == 1n, false, "null == 1n"); +assert.sameValue(0n == Symbol("1"), false, "0n == Symbol(\"1\")"); +assert.sameValue(Symbol("1") == 0n, false, "Symbol(\"1\") == 0n"); +assert.sameValue(1n == Symbol("1"), false, "1n == Symbol(\"1\")"); +assert.sameValue(Symbol("1") == 1n, false, "Symbol(\"1\") == 1n"); diff --git a/test/language/expressions/equals/bigint-and-non-finite.js b/test/language/expressions/equals/bigint-and-non-finite.js new file mode 100644 index 00000000000..763233f87f1 --- /dev/null +++ b/test/language/expressions/equals/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: Non-strict equality comparison of BigInt and non-finite Number values +esid: sec-abstract-equality-comparison +info: | + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + a. If x or y are any of NaN, +∞, or -∞, return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n == Infinity, false, "0n == Infinity"); +assert.sameValue(Infinity == 0n, false, "Infinity == 0n"); +assert.sameValue(1n == Infinity, false, "1n == Infinity"); +assert.sameValue(Infinity == 1n, false, "Infinity == 1n"); +assert.sameValue(-1n == Infinity, false, "-1n == Infinity"); +assert.sameValue(Infinity == -1n, false, "Infinity == -1n"); +assert.sameValue(0n == -Infinity, false, "0n == -Infinity"); +assert.sameValue(-Infinity == 0n, false, "-Infinity == 0n"); +assert.sameValue(1n == -Infinity, false, "1n == -Infinity"); +assert.sameValue(-Infinity == 1n, false, "-Infinity == 1n"); +assert.sameValue(-1n == -Infinity, false, "-1n == -Infinity"); +assert.sameValue(-Infinity == -1n, false, "-Infinity == -1n"); +assert.sameValue(0n == NaN, false, "0n == NaN"); +assert.sameValue(NaN == 0n, false, "NaN == 0n"); +assert.sameValue(1n == NaN, false, "1n == NaN"); +assert.sameValue(NaN == 1n, false, "NaN == 1n"); +assert.sameValue(-1n == NaN, false, "-1n == NaN"); +assert.sameValue(NaN == -1n, false, "NaN == -1n"); diff --git a/test/language/expressions/equals/bigint-and-number-extremes.js b/test/language/expressions/equals/bigint-and-number-extremes.js new file mode 100644 index 00000000000..bd49a2b54a7 --- /dev/null +++ b/test/language/expressions/equals/bigint-and-number-extremes.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict equality comparison of BigInt and large Number values +esid: sec-abstract-equality-comparison +info: | + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. + +features: [BigInt] +---*/ + +assert.sameValue(1n == Number.MAX_VALUE, false, "1n == Number.MAX_VALUE"); +assert.sameValue(Number.MAX_VALUE == 1n, false, "Number.MAX_VALUE == 1n"); +assert.sameValue(1n == -Number.MAX_VALUE, false, "1n == -Number.MAX_VALUE"); +assert.sameValue(-Number.MAX_VALUE == 1n, false, "-Number.MAX_VALUE == 1n"); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn == Number.MAX_VALUE, + false, + "0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn == Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE == 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + false, + "Number.MAX_VALUE == 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n == Number.MAX_VALUE, + true, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n == Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE == 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, + true, + "Number.MAX_VALUE == 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n == Number.MAX_VALUE, + false, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n == Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE == 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + false, + "Number.MAX_VALUE == 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n"); diff --git a/test/language/expressions/equals/bigint-and-number.js b/test/language/expressions/equals/bigint-and-number.js new file mode 100644 index 00000000000..1b7bceaa1dc --- /dev/null +++ b/test/language/expressions/equals/bigint-and-number.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict equality comparison of BigInt and Number values +esid: sec-abstract-equality-comparison +info: | + 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, + b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n == 0, true, "0n == 0"); +assert.sameValue(0 == 0n, true, "0 == 0n"); +assert.sameValue(0n == -0, true, "0n == -0"); +assert.sameValue(-0 == 0n, true, "-0 == 0n"); +assert.sameValue(0n == 0.000000000001, false, "0n == 0.000000000001"); +assert.sameValue(0.000000000001 == 0n, false, "0.000000000001 == 0n"); +assert.sameValue(0n == 1, false, "0n == 1"); +assert.sameValue(1 == 0n, false, "1 == 0n"); +assert.sameValue(1n == 0, false, "1n == 0"); +assert.sameValue(0 == 1n, false, "0 == 1n"); +assert.sameValue(1n == 0.999999999999, false, "1n == 0.999999999999"); +assert.sameValue(0.999999999999 == 1n, false, "0.999999999999 == 1n"); +assert.sameValue(1n == 1, true, "1n == 1"); +assert.sameValue(1 == 1n, true, "1 == 1n"); +assert.sameValue(0n == Number.MIN_VALUE, false, "0n == Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE == 0n, false, "Number.MIN_VALUE == 0n"); +assert.sameValue(0n == -Number.MIN_VALUE, false, "0n == -Number.MIN_VALUE"); +assert.sameValue(-Number.MIN_VALUE == 0n, false, "-Number.MIN_VALUE == 0n"); +assert.sameValue(-10n == Number.MIN_VALUE, false, "-10n == Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE == -10n, false, "Number.MIN_VALUE == -10n"); diff --git a/test/language/expressions/equals/bigint-and-object.js b/test/language/expressions/equals/bigint-and-object.js new file mode 100644 index 00000000000..0243b669a19 --- /dev/null +++ b/test/language/expressions/equals/bigint-and-object.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: Non-strict equality comparison of BigInt values and non-primitive objects +esid: sec-abstract-equality-comparison +info: | + 10. If Type(x) is either String, Number, BigInt, or Symbol and Type(y) is Object, return the result of the comparison x == ? ToPrimitive(y). + 11. If Type(x) is Object and Type(y) is either String, Number, BigInt, or Symbol, return the result of the comparison ? ToPrimitive(x) == y. + + then after the recursion: + + 1. If Type(x) is the same as Type(y), then + a. Return the result of performing Strict Equality Comparison x === y. + ... + 6. If Type(x) is BigInt and Type(y) is String, + a. Let n be StringToBigInt(y). + b. If n is NaN, return false. + c. Return the result of x == n. + 7. If Type(x) is String and Type(y) is BigInt, return the result of y == x. + +features: [BigInt] +---*/ + +assert.sameValue(0n == Object(0n), true, "0n == Object(0n)"); +assert.sameValue(Object(0n) == 0n, true, "Object(0n) == 0n"); +assert.sameValue(0n == Object(1n), false, "0n == Object(1n)"); +assert.sameValue(Object(1n) == 0n, false, "Object(1n) == 0n"); +assert.sameValue(1n == Object(0n), false, "1n == Object(0n)"); +assert.sameValue(Object(0n) == 1n, false, "Object(0n) == 1n"); +assert.sameValue(1n == Object(1n), true, "1n == Object(1n)"); +assert.sameValue(Object(1n) == 1n, true, "Object(1n) == 1n"); +assert.sameValue(2n == Object(0n), false, "2n == Object(0n)"); +assert.sameValue(Object(0n) == 2n, false, "Object(0n) == 2n"); +assert.sameValue(2n == Object(1n), false, "2n == Object(1n)"); +assert.sameValue(Object(1n) == 2n, false, "Object(1n) == 2n"); +assert.sameValue(2n == Object(2n), true, "2n == Object(2n)"); +assert.sameValue(Object(2n) == 2n, true, "Object(2n) == 2n"); +assert.sameValue(0n == {}, false, "0n == {}"); +assert.sameValue({} == 0n, false, "{} == 0n"); +assert.sameValue(0n == {valueOf: function() { return 0n; }}, true, "0n == {valueOf: function() { return 0n; }}"); +assert.sameValue({valueOf: function() { return 0n; }} == 0n, true, "{valueOf: function() { return 0n; }} == 0n"); +assert.sameValue(0n == {valueOf: function() { return 1n; }}, false, "0n == {valueOf: function() { return 1n; }}"); +assert.sameValue({valueOf: function() { return 1n; }} == 0n, false, "{valueOf: function() { return 1n; }} == 0n"); +assert.sameValue(0n == {toString: function() { return "0"; }}, true, "0n == {toString: function() { return \"0\"; }}"); +assert.sameValue({toString: function() { return "0"; }} == 0n, true, "{toString: function() { return \"0\"; }} == 0n"); +assert.sameValue(0n == {toString: function() { return "1"; }}, false, "0n == {toString: function() { return \"1\"; }}"); +assert.sameValue({toString: function() { return "1"; }} == 0n, false, "{toString: function() { return \"1\"; }} == 0n"); +assert.sameValue(900719925474099101n == {valueOf: function() { return 900719925474099101n; }}, true, "900719925474099101n == {valueOf: function() { return 900719925474099101n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099101n; }} == 900719925474099101n, true, "{valueOf: function() { return 900719925474099101n; }} == 900719925474099101n"); +assert.sameValue(900719925474099101n == {valueOf: function() { return 900719925474099102n; }}, false, "900719925474099101n == {valueOf: function() { return 900719925474099102n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099102n; }} == 900719925474099101n, false, "{valueOf: function() { return 900719925474099102n; }} == 900719925474099101n"); +assert.sameValue(900719925474099101n == {toString: function() { return "900719925474099101"; }}, true, "900719925474099101n == {toString: function() { return \"900719925474099101\"; }}"); +assert.sameValue({toString: function() { return "900719925474099101"; }} == 900719925474099101n, true, "{toString: function() { return \"900719925474099101\"; }} == 900719925474099101n"); +assert.sameValue(900719925474099101n == {toString: function() { return "900719925474099102"; }}, false, "900719925474099101n == {toString: function() { return \"900719925474099102\"; }}"); +assert.sameValue({toString: function() { return "900719925474099102"; }} == 900719925474099101n, false, "{toString: function() { return \"900719925474099102\"; }} == 900719925474099101n"); diff --git a/test/language/expressions/equals/bigint-and-string.js b/test/language/expressions/equals/bigint-and-string.js new file mode 100644 index 00000000000..569add37090 --- /dev/null +++ b/test/language/expressions/equals/bigint-and-string.js @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Non-strict equality comparison of BigInt and String values +esid: sec-abstract-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n == "", true, "0n == \"\""); +assert.sameValue("" == 0n, true, "\"\" == 0n"); +assert.sameValue(0n == "-0", true, "0n == \"-0\""); +assert.sameValue("-0" == 0n, true, "\"-0\" == 0n"); +assert.sameValue(0n == "0", true, "0n == \"0\""); +assert.sameValue("0" == 0n, true, "\"0\" == 0n"); +assert.sameValue(0n == "-1", false, "0n == \"-1\""); +assert.sameValue("-1" == 0n, false, "\"-1\" == 0n"); +assert.sameValue(0n == "1", false, "0n == \"1\""); +assert.sameValue("1" == 0n, false, "\"1\" == 0n"); +assert.sameValue(0n == "foo", false, "0n == \"foo\""); +assert.sameValue("foo" == 0n, false, "\"foo\" == 0n"); +assert.sameValue(1n == "", false, "1n == \"\""); +assert.sameValue("" == 1n, false, "\"\" == 1n"); +assert.sameValue(1n == "-0", false, "1n == \"-0\""); +assert.sameValue("-0" == 1n, false, "\"-0\" == 1n"); +assert.sameValue(1n == "0", false, "1n == \"0\""); +assert.sameValue("0" == 1n, false, "\"0\" == 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 == "foo", false, "1n == \"foo\""); +assert.sameValue("foo" == 1n, false, "\"foo\" == 1n"); +assert.sameValue(-1n == "-", false, "-1n == \"-\""); +assert.sameValue("-" == -1n, false, "\"-\" == -1n"); +assert.sameValue(-1n == "-0", false, "-1n == \"-0\""); +assert.sameValue("-0" == -1n, false, "\"-0\" == -1n"); +assert.sameValue(-1n == "-1", true, "-1n == \"-1\""); +assert.sameValue("-1" == -1n, true, "\"-1\" == -1n"); +assert.sameValue(-1n == "-foo", false, "-1n == \"-foo\""); +assert.sameValue("-foo" == -1n, false, "\"-foo\" == -1n"); +assert.sameValue(900719925474099101n == "900719925474099101", true, "900719925474099101n == \"900719925474099101\""); +assert.sameValue("900719925474099101" == 900719925474099101n, true, "\"900719925474099101\" == 900719925474099101n"); +assert.sameValue(900719925474099102n == "900719925474099101", false, "900719925474099102n == \"900719925474099101\""); +assert.sameValue("900719925474099101" == 900719925474099102n, false, "\"900719925474099101\" == 900719925474099102n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-bigint.js b/test/language/expressions/strict-does-not-equals/bigint-and-bigint.js new file mode 100644 index 00000000000..3486a4dd528 --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-bigint.js @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + 2. If Type(x) is Number or BigInt, then + a. Return ! Type(x)::equal(x, y). + + sec-numeric-types-bigint-equal + BigInt::equal (x, y) + + The abstract operation BigInt::equal with two arguments x and y of BigInt type returns true if x and y have the same mathematical integer value and false otherwise. + +features: [BigInt] +---*/ + +assert.sameValue(0n !== 0n, false, "0n !== 0n"); +assert.sameValue(1n !== 1n, false, "1n !== 1n"); +assert.sameValue(-1n !== -1n, false, "-1n !== -1n"); +assert.sameValue(0n !== -0n, false, "0n !== -0n"); +assert.sameValue(-0n !== 0n, false, "-0n !== 0n"); +assert.sameValue(0n !== 1n, true, "0n !== 1n"); +assert.sameValue(1n !== 0n, true, "1n !== 0n"); +assert.sameValue(0n !== -1n, true, "0n !== -1n"); +assert.sameValue(-1n !== 0n, true, "-1n !== 0n"); +assert.sameValue(1n !== -1n, true, "1n !== -1n"); +assert.sameValue(-1n !== 1n, true, "-1n !== 1n"); +assert.sameValue(0x1fffffffffffff01n !== 0x1fffffffffffff01n, false, "0x1fffffffffffff01n !== 0x1fffffffffffff01n"); +assert.sameValue(0x1fffffffffffff01n !== 0x1fffffffffffff02n, true, "0x1fffffffffffff01n !== 0x1fffffffffffff02n"); +assert.sameValue(0x1fffffffffffff02n !== 0x1fffffffffffff01n, true, "0x1fffffffffffff02n !== 0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n !== -0x1fffffffffffff01n, false, "-0x1fffffffffffff01n !== -0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n !== -0x1fffffffffffff02n, true, "-0x1fffffffffffff01n !== -0x1fffffffffffff02n"); +assert.sameValue(-0x1fffffffffffff02n !== -0x1fffffffffffff01n, true, "-0x1fffffffffffff02n !== -0x1fffffffffffff01n"); +assert.sameValue(0x10000000000000000n !== 0n, true, "0x10000000000000000n !== 0n"); +assert.sameValue(0n !== 0x10000000000000000n, true, "0n !== 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n !== 1n, true, "0x10000000000000000n !== 1n"); +assert.sameValue(1n !== 0x10000000000000000n, true, "1n !== 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n !== -1n, true, "0x10000000000000000n !== -1n"); +assert.sameValue(-1n !== 0x10000000000000000n, true, "-1n !== 0x10000000000000000n"); +assert.sameValue(0x10000000000000001n !== 0n, true, "0x10000000000000001n !== 0n"); +assert.sameValue(0n !== 0x10000000000000001n, true, "0n !== 0x10000000000000001n"); +assert.sameValue(-0x10000000000000000n !== 0n, true, "-0x10000000000000000n !== 0n"); +assert.sameValue(0n !== -0x10000000000000000n, true, "0n !== -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n !== 1n, true, "-0x10000000000000000n !== 1n"); +assert.sameValue(1n !== -0x10000000000000000n, true, "1n !== -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n !== -1n, true, "-0x10000000000000000n !== -1n"); +assert.sameValue(-1n !== -0x10000000000000000n, true, "-1n !== -0x10000000000000000n"); +assert.sameValue(-0x10000000000000001n !== 0n, true, "-0x10000000000000001n !== 0n"); +assert.sameValue(0n !== -0x10000000000000001n, true, "0n !== -0x10000000000000001n"); +assert.sameValue(0x10000000000000000n !== 0x100000000n, true, "0x10000000000000000n !== 0x100000000n"); +assert.sameValue(0x100000000n !== 0x10000000000000000n, true, "0x100000000n !== 0x10000000000000000n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-boolean.js b/test/language/expressions/strict-does-not-equals/bigint-and-boolean.js new file mode 100644 index 00000000000..fc33b2bf6a6 --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-boolean.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt and Boolean values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(-1n !== false, true, "-1n !== false"); +assert.sameValue(false !== -1n, true, "false !== -1n"); +assert.sameValue(-1n !== true, true, "-1n !== true"); +assert.sameValue(true !== -1n, true, "true !== -1n"); +assert.sameValue(0n !== false, true, "0n !== false"); +assert.sameValue(false !== 0n, true, "false !== 0n"); +assert.sameValue(0n !== true, true, "0n !== true"); +assert.sameValue(true !== 0n, true, "true !== 0n"); +assert.sameValue(1n !== false, true, "1n !== false"); +assert.sameValue(false !== 1n, true, "false !== 1n"); +assert.sameValue(1n !== true, true, "1n !== true"); +assert.sameValue(true !== 1n, true, "true !== 1n"); +assert.sameValue(2n !== false, true, "2n !== false"); +assert.sameValue(false !== 2n, true, "false !== 2n"); +assert.sameValue(2n !== true, true, "2n !== true"); +assert.sameValue(true !== 2n, true, "true !== 2n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-incomparable-primitive.js b/test/language/expressions/strict-does-not-equals/bigint-and-incomparable-primitive.js new file mode 100644 index 00000000000..7e0289458fc --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-incomparable-primitive.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt and miscellaneous primitive values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt, Symbol] +---*/ + +assert.sameValue(0n !== undefined, true, "0n !== undefined"); +assert.sameValue(undefined !== 0n, true, "undefined !== 0n"); +assert.sameValue(1n !== undefined, true, "1n !== undefined"); +assert.sameValue(undefined !== 1n, true, "undefined !== 1n"); +assert.sameValue(0n !== null, true, "0n !== null"); +assert.sameValue(null !== 0n, true, "null !== 0n"); +assert.sameValue(1n !== null, true, "1n !== null"); +assert.sameValue(null !== 1n, true, "null !== 1n"); +assert.sameValue(0n !== Symbol("1"), true, "0n !== Symbol(\"1\")"); +assert.sameValue(Symbol("1") !== 0n, true, "Symbol(\"1\") !== 0n"); +assert.sameValue(1n !== Symbol("1"), true, "1n !== Symbol(\"1\")"); +assert.sameValue(Symbol("1") !== 1n, true, "Symbol(\"1\") !== 1n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-non-finite.js b/test/language/expressions/strict-does-not-equals/bigint-and-non-finite.js new file mode 100644 index 00000000000..52708d8e94e --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-non-finite.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt and non-finite Number values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n !== Infinity, true, "0n !== Infinity"); +assert.sameValue(Infinity !== 0n, true, "Infinity !== 0n"); +assert.sameValue(1n !== Infinity, true, "1n !== Infinity"); +assert.sameValue(Infinity !== 1n, true, "Infinity !== 1n"); +assert.sameValue(-1n !== Infinity, true, "-1n !== Infinity"); +assert.sameValue(Infinity !== -1n, true, "Infinity !== -1n"); +assert.sameValue(0n !== -Infinity, true, "0n !== -Infinity"); +assert.sameValue(-Infinity !== 0n, true, "-Infinity !== 0n"); +assert.sameValue(1n !== -Infinity, true, "1n !== -Infinity"); +assert.sameValue(-Infinity !== 1n, true, "-Infinity !== 1n"); +assert.sameValue(-1n !== -Infinity, true, "-1n !== -Infinity"); +assert.sameValue(-Infinity !== -1n, true, "-Infinity !== -1n"); +assert.sameValue(0n !== NaN, true, "0n !== NaN"); +assert.sameValue(NaN !== 0n, true, "NaN !== 0n"); +assert.sameValue(1n !== NaN, true, "1n !== NaN"); +assert.sameValue(NaN !== 1n, true, "NaN !== 1n"); +assert.sameValue(-1n !== NaN, true, "-1n !== NaN"); +assert.sameValue(NaN !== -1n, true, "NaN !== -1n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-number-extremes.js b/test/language/expressions/strict-does-not-equals/bigint-and-number-extremes.js new file mode 100644 index 00000000000..6449e350cd9 --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-number-extremes.js @@ -0,0 +1,40 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt and large Number values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(1n !== Number.MAX_VALUE, true, "1n !== Number.MAX_VALUE"); +assert.sameValue(Number.MAX_VALUE !== 1n, true, "Number.MAX_VALUE !== 1n"); +assert.sameValue(1n !== -Number.MAX_VALUE, true, "1n !== -Number.MAX_VALUE"); +assert.sameValue(-Number.MAX_VALUE !== 1n, true, "-Number.MAX_VALUE !== 1n"); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn !== Number.MAX_VALUE, + true, + "0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn !== Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE !== 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + true, + "Number.MAX_VALUE !== 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n !== Number.MAX_VALUE, + true, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n !== Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE !== 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, + true, + "Number.MAX_VALUE !== 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n !== Number.MAX_VALUE, + true, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n !== Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE !== 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + true, + "Number.MAX_VALUE !== 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-number.js b/test/language/expressions/strict-does-not-equals/bigint-and-number.js new file mode 100644 index 00000000000..eb3f991ed78 --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-number.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt and Number values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n !== 0, true, "0n !== 0"); +assert.sameValue(0 !== 0n, true, "0 !== 0n"); +assert.sameValue(0n !== -0, true, "0n !== -0"); +assert.sameValue(-0 !== 0n, true, "-0 !== 0n"); +assert.sameValue(0n !== 0.000000000001, true, "0n !== 0.000000000001"); +assert.sameValue(0.000000000001 !== 0n, true, "0.000000000001 !== 0n"); +assert.sameValue(0n !== 1, true, "0n !== 1"); +assert.sameValue(1 !== 0n, true, "1 !== 0n"); +assert.sameValue(1n !== 0, true, "1n !== 0"); +assert.sameValue(0 !== 1n, true, "0 !== 1n"); +assert.sameValue(1n !== 0.999999999999, true, "1n !== 0.999999999999"); +assert.sameValue(0.999999999999 !== 1n, true, "0.999999999999 !== 1n"); +assert.sameValue(1n !== 1, true, "1n !== 1"); +assert.sameValue(1 !== 1n, true, "1 !== 1n"); +assert.sameValue(0n !== Number.MIN_VALUE, true, "0n !== Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE !== 0n, true, "Number.MIN_VALUE !== 0n"); +assert.sameValue(0n !== -Number.MIN_VALUE, true, "0n !== -Number.MIN_VALUE"); +assert.sameValue(-Number.MIN_VALUE !== 0n, true, "-Number.MIN_VALUE !== 0n"); +assert.sameValue(-10n !== Number.MIN_VALUE, true, "-10n !== Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE !== -10n, true, "Number.MIN_VALUE !== -10n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-object.js b/test/language/expressions/strict-does-not-equals/bigint-and-object.js new file mode 100644 index 00000000000..a8018b2ef77 --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-object.js @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt values and non-primitive objects +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n !== Object(0n), true, "0n !== Object(0n)"); +assert.sameValue(Object(0n) !== 0n, true, "Object(0n) !== 0n"); +assert.sameValue(0n !== Object(1n), true, "0n !== Object(1n)"); +assert.sameValue(Object(1n) !== 0n, true, "Object(1n) !== 0n"); +assert.sameValue(1n !== Object(0n), true, "1n !== Object(0n)"); +assert.sameValue(Object(0n) !== 1n, true, "Object(0n) !== 1n"); +assert.sameValue(1n !== Object(1n), true, "1n !== Object(1n)"); +assert.sameValue(Object(1n) !== 1n, true, "Object(1n) !== 1n"); +assert.sameValue(2n !== Object(0n), true, "2n !== Object(0n)"); +assert.sameValue(Object(0n) !== 2n, true, "Object(0n) !== 2n"); +assert.sameValue(2n !== Object(1n), true, "2n !== Object(1n)"); +assert.sameValue(Object(1n) !== 2n, true, "Object(1n) !== 2n"); +assert.sameValue(2n !== Object(2n), true, "2n !== Object(2n)"); +assert.sameValue(Object(2n) !== 2n, true, "Object(2n) !== 2n"); +assert.sameValue(0n !== {}, true, "0n !== {}"); +assert.sameValue({} !== 0n, true, "{} !== 0n"); +assert.sameValue(0n !== {valueOf: function() { return 0n; }}, true, "0n !== {valueOf: function() { return 0n; }}"); +assert.sameValue({valueOf: function() { return 0n; }} !== 0n, true, "{valueOf: function() { return 0n; }} !== 0n"); +assert.sameValue(0n !== {valueOf: function() { return 1n; }}, true, "0n !== {valueOf: function() { return 1n; }}"); +assert.sameValue({valueOf: function() { return 1n; }} !== 0n, true, "{valueOf: function() { return 1n; }} !== 0n"); +assert.sameValue(0n !== {toString: function() { return "0"; }}, true, "0n !== {toString: function() { return \"0\"; }}"); +assert.sameValue({toString: function() { return "0"; }} !== 0n, true, "{toString: function() { return \"0\"; }} !== 0n"); +assert.sameValue(0n !== {toString: function() { return "1"; }}, true, "0n !== {toString: function() { return \"1\"; }}"); +assert.sameValue({toString: function() { return "1"; }} !== 0n, true, "{toString: function() { return \"1\"; }} !== 0n"); +assert.sameValue(900719925474099101n !== {valueOf: function() { return 900719925474099101n; }}, true, "900719925474099101n !== {valueOf: function() { return 900719925474099101n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099101n; }} !== 900719925474099101n, true, "{valueOf: function() { return 900719925474099101n; }} !== 900719925474099101n"); +assert.sameValue(900719925474099101n !== {valueOf: function() { return 900719925474099102n; }}, true, "900719925474099101n !== {valueOf: function() { return 900719925474099102n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099102n; }} !== 900719925474099101n, true, "{valueOf: function() { return 900719925474099102n; }} !== 900719925474099101n"); +assert.sameValue(900719925474099101n !== {toString: function() { return "900719925474099101"; }}, true, "900719925474099101n !== {toString: function() { return \"900719925474099101\"; }}"); +assert.sameValue({toString: function() { return "900719925474099101"; }} !== 900719925474099101n, true, "{toString: function() { return \"900719925474099101\"; }} !== 900719925474099101n"); +assert.sameValue(900719925474099101n !== {toString: function() { return "900719925474099102"; }}, true, "900719925474099101n !== {toString: function() { return \"900719925474099102\"; }}"); +assert.sameValue({toString: function() { return "900719925474099102"; }} !== 900719925474099101n, true, "{toString: function() { return \"900719925474099102\"; }} !== 900719925474099101n"); diff --git a/test/language/expressions/strict-does-not-equals/bigint-and-string.js b/test/language/expressions/strict-does-not-equals/bigint-and-string.js new file mode 100644 index 00000000000..b067b2a8da2 --- /dev/null +++ b/test/language/expressions/strict-does-not-equals/bigint-and-string.js @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict inequality comparison of BigInt and String values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n !== "", true, "0n !== \"\""); +assert.sameValue("" !== 0n, true, "\"\" !== 0n"); +assert.sameValue(0n !== "-0", true, "0n !== \"-0\""); +assert.sameValue("-0" !== 0n, true, "\"-0\" !== 0n"); +assert.sameValue(0n !== "0", true, "0n !== \"0\""); +assert.sameValue("0" !== 0n, true, "\"0\" !== 0n"); +assert.sameValue(0n !== "-1", true, "0n !== \"-1\""); +assert.sameValue("-1" !== 0n, true, "\"-1\" !== 0n"); +assert.sameValue(0n !== "1", true, "0n !== \"1\""); +assert.sameValue("1" !== 0n, true, "\"1\" !== 0n"); +assert.sameValue(0n !== "foo", true, "0n !== \"foo\""); +assert.sameValue("foo" !== 0n, true, "\"foo\" !== 0n"); +assert.sameValue(1n !== "", true, "1n !== \"\""); +assert.sameValue("" !== 1n, true, "\"\" !== 1n"); +assert.sameValue(1n !== "-0", true, "1n !== \"-0\""); +assert.sameValue("-0" !== 1n, true, "\"-0\" !== 1n"); +assert.sameValue(1n !== "0", true, "1n !== \"0\""); +assert.sameValue("0" !== 1n, true, "\"0\" !== 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(1n !== "foo", true, "1n !== \"foo\""); +assert.sameValue("foo" !== 1n, true, "\"foo\" !== 1n"); +assert.sameValue(-1n !== "-", true, "-1n !== \"-\""); +assert.sameValue("-" !== -1n, true, "\"-\" !== -1n"); +assert.sameValue(-1n !== "-0", true, "-1n !== \"-0\""); +assert.sameValue("-0" !== -1n, true, "\"-0\" !== -1n"); +assert.sameValue(-1n !== "-1", true, "-1n !== \"-1\""); +assert.sameValue("-1" !== -1n, true, "\"-1\" !== -1n"); +assert.sameValue(-1n !== "-foo", true, "-1n !== \"-foo\""); +assert.sameValue("-foo" !== -1n, true, "\"-foo\" !== -1n"); +assert.sameValue(900719925474099101n !== "900719925474099101", true, "900719925474099101n !== \"900719925474099101\""); +assert.sameValue("900719925474099101" !== 900719925474099101n, true, "\"900719925474099101\" !== 900719925474099101n"); +assert.sameValue(900719925474099102n !== "900719925474099101", true, "900719925474099102n !== \"900719925474099101\""); +assert.sameValue("900719925474099101" !== 900719925474099102n, true, "\"900719925474099101\" !== 900719925474099102n"); diff --git a/test/language/expressions/strict-equals/bigint-and-bigint.js b/test/language/expressions/strict-equals/bigint-and-bigint.js new file mode 100644 index 00000000000..8d733b37bc8 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-bigint.js @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + 2. If Type(x) is Number or BigInt, then + a. Return ! Type(x)::equal(x, y). + + sec-numeric-types-bigint-equal + BigInt::equal (x, y) + + The abstract operation BigInt::equal with two arguments x and y of BigInt type returns true if x and y have the same mathematical integer value and false otherwise. + +features: [BigInt] +---*/ + +assert.sameValue(0n === 0n, true, "0n === 0n"); +assert.sameValue(1n === 1n, true, "1n === 1n"); +assert.sameValue(-1n === -1n, true, "-1n === -1n"); +assert.sameValue(0n === -0n, true, "0n === -0n"); +assert.sameValue(-0n === 0n, true, "-0n === 0n"); +assert.sameValue(0n === 1n, false, "0n === 1n"); +assert.sameValue(1n === 0n, false, "1n === 0n"); +assert.sameValue(0n === -1n, false, "0n === -1n"); +assert.sameValue(-1n === 0n, false, "-1n === 0n"); +assert.sameValue(1n === -1n, false, "1n === -1n"); +assert.sameValue(-1n === 1n, false, "-1n === 1n"); +assert.sameValue(0x1fffffffffffff01n === 0x1fffffffffffff01n, true, "0x1fffffffffffff01n === 0x1fffffffffffff01n"); +assert.sameValue(0x1fffffffffffff01n === 0x1fffffffffffff02n, false, "0x1fffffffffffff01n === 0x1fffffffffffff02n"); +assert.sameValue(0x1fffffffffffff02n === 0x1fffffffffffff01n, false, "0x1fffffffffffff02n === 0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n === -0x1fffffffffffff01n, true, "-0x1fffffffffffff01n === -0x1fffffffffffff01n"); +assert.sameValue(-0x1fffffffffffff01n === -0x1fffffffffffff02n, false, "-0x1fffffffffffff01n === -0x1fffffffffffff02n"); +assert.sameValue(-0x1fffffffffffff02n === -0x1fffffffffffff01n, false, "-0x1fffffffffffff02n === -0x1fffffffffffff01n"); +assert.sameValue(0x10000000000000000n === 0n, false, "0x10000000000000000n === 0n"); +assert.sameValue(0n === 0x10000000000000000n, false, "0n === 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n === 1n, false, "0x10000000000000000n === 1n"); +assert.sameValue(1n === 0x10000000000000000n, false, "1n === 0x10000000000000000n"); +assert.sameValue(0x10000000000000000n === -1n, false, "0x10000000000000000n === -1n"); +assert.sameValue(-1n === 0x10000000000000000n, false, "-1n === 0x10000000000000000n"); +assert.sameValue(0x10000000000000001n === 0n, false, "0x10000000000000001n === 0n"); +assert.sameValue(0n === 0x10000000000000001n, false, "0n === 0x10000000000000001n"); +assert.sameValue(-0x10000000000000000n === 0n, false, "-0x10000000000000000n === 0n"); +assert.sameValue(0n === -0x10000000000000000n, false, "0n === -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n === 1n, false, "-0x10000000000000000n === 1n"); +assert.sameValue(1n === -0x10000000000000000n, false, "1n === -0x10000000000000000n"); +assert.sameValue(-0x10000000000000000n === -1n, false, "-0x10000000000000000n === -1n"); +assert.sameValue(-1n === -0x10000000000000000n, false, "-1n === -0x10000000000000000n"); +assert.sameValue(-0x10000000000000001n === 0n, false, "-0x10000000000000001n === 0n"); +assert.sameValue(0n === -0x10000000000000001n, false, "0n === -0x10000000000000001n"); +assert.sameValue(0x10000000000000000n === 0x100000000n, false, "0x10000000000000000n === 0x100000000n"); +assert.sameValue(0x100000000n === 0x10000000000000000n, false, "0x100000000n === 0x10000000000000000n"); diff --git a/test/language/expressions/strict-equals/bigint-and-boolean.js b/test/language/expressions/strict-equals/bigint-and-boolean.js new file mode 100644 index 00000000000..718a4afc005 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-boolean.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt and Boolean values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(-1n === false, false, "-1n === false"); +assert.sameValue(false === -1n, false, "false === -1n"); +assert.sameValue(-1n === true, false, "-1n === true"); +assert.sameValue(true === -1n, false, "true === -1n"); +assert.sameValue(0n === false, false, "0n === false"); +assert.sameValue(false === 0n, false, "false === 0n"); +assert.sameValue(0n === true, false, "0n === true"); +assert.sameValue(true === 0n, false, "true === 0n"); +assert.sameValue(1n === false, false, "1n === false"); +assert.sameValue(false === 1n, false, "false === 1n"); +assert.sameValue(1n === true, false, "1n === true"); +assert.sameValue(true === 1n, false, "true === 1n"); +assert.sameValue(2n === false, false, "2n === false"); +assert.sameValue(false === 2n, false, "false === 2n"); +assert.sameValue(2n === true, false, "2n === true"); +assert.sameValue(true === 2n, false, "true === 2n"); diff --git a/test/language/expressions/strict-equals/bigint-and-incomparable-primitive.js b/test/language/expressions/strict-equals/bigint-and-incomparable-primitive.js new file mode 100644 index 00000000000..20197abc5d8 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-incomparable-primitive.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt and miscellaneous primitive values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt, Symbol] +---*/ + +assert.sameValue(0n === undefined, false, "0n === undefined"); +assert.sameValue(undefined === 0n, false, "undefined === 0n"); +assert.sameValue(1n === undefined, false, "1n === undefined"); +assert.sameValue(undefined === 1n, false, "undefined === 1n"); +assert.sameValue(0n === null, false, "0n === null"); +assert.sameValue(null === 0n, false, "null === 0n"); +assert.sameValue(1n === null, false, "1n === null"); +assert.sameValue(null === 1n, false, "null === 1n"); +assert.sameValue(0n === Symbol("1"), false, "0n === Symbol(\"1\")"); +assert.sameValue(Symbol("1") === 0n, false, "Symbol(\"1\") === 0n"); +assert.sameValue(1n === Symbol("1"), false, "1n === Symbol(\"1\")"); +assert.sameValue(Symbol("1") === 1n, false, "Symbol(\"1\") === 1n"); diff --git a/test/language/expressions/strict-equals/bigint-and-non-finite.js b/test/language/expressions/strict-equals/bigint-and-non-finite.js new file mode 100644 index 00000000000..7352fc3dc58 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-non-finite.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt and non-finite Number values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n === Infinity, false, "0n === Infinity"); +assert.sameValue(Infinity === 0n, false, "Infinity === 0n"); +assert.sameValue(1n === Infinity, false, "1n === Infinity"); +assert.sameValue(Infinity === 1n, false, "Infinity === 1n"); +assert.sameValue(-1n === Infinity, false, "-1n === Infinity"); +assert.sameValue(Infinity === -1n, false, "Infinity === -1n"); +assert.sameValue(0n === -Infinity, false, "0n === -Infinity"); +assert.sameValue(-Infinity === 0n, false, "-Infinity === 0n"); +assert.sameValue(1n === -Infinity, false, "1n === -Infinity"); +assert.sameValue(-Infinity === 1n, false, "-Infinity === 1n"); +assert.sameValue(-1n === -Infinity, false, "-1n === -Infinity"); +assert.sameValue(-Infinity === -1n, false, "-Infinity === -1n"); +assert.sameValue(0n === NaN, false, "0n === NaN"); +assert.sameValue(NaN === 0n, false, "NaN === 0n"); +assert.sameValue(1n === NaN, false, "1n === NaN"); +assert.sameValue(NaN === 1n, false, "NaN === 1n"); +assert.sameValue(-1n === NaN, false, "-1n === NaN"); +assert.sameValue(NaN === -1n, false, "NaN === -1n"); diff --git a/test/language/expressions/strict-equals/bigint-and-number-extremes.js b/test/language/expressions/strict-equals/bigint-and-number-extremes.js new file mode 100644 index 00000000000..e1293557376 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-number-extremes.js @@ -0,0 +1,40 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt and large Number values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(1n === Number.MAX_VALUE, false, "1n === Number.MAX_VALUE"); +assert.sameValue(Number.MAX_VALUE === 1n, false, "Number.MAX_VALUE === 1n"); +assert.sameValue(1n === -Number.MAX_VALUE, false, "1n === -Number.MAX_VALUE"); +assert.sameValue(-Number.MAX_VALUE === 1n, false, "-Number.MAX_VALUE === 1n"); +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn === Number.MAX_VALUE, + false, + "0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn === Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE === 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + false, + "Number.MAX_VALUE === 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n === Number.MAX_VALUE, + false, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n === Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, + false, + "Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n"); +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n === Number.MAX_VALUE, + false, + "0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n === Number.MAX_VALUE"); +assert.sameValue( + Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + false, + "Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n"); diff --git a/test/language/expressions/strict-equals/bigint-and-number.js b/test/language/expressions/strict-equals/bigint-and-number.js new file mode 100644 index 00000000000..ed1dde71a24 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-number.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt and Number values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n === 0, false, "0n === 0"); +assert.sameValue(0 === 0n, false, "0 === 0n"); +assert.sameValue(0n === -0, false, "0n === -0"); +assert.sameValue(-0 === 0n, false, "-0 === 0n"); +assert.sameValue(0n === 0.000000000001, false, "0n === 0.000000000001"); +assert.sameValue(0.000000000001 === 0n, false, "0.000000000001 === 0n"); +assert.sameValue(0n === 1, false, "0n === 1"); +assert.sameValue(1 === 0n, false, "1 === 0n"); +assert.sameValue(1n === 0, false, "1n === 0"); +assert.sameValue(0 === 1n, false, "0 === 1n"); +assert.sameValue(1n === 0.999999999999, false, "1n === 0.999999999999"); +assert.sameValue(0.999999999999 === 1n, false, "0.999999999999 === 1n"); +assert.sameValue(1n === 1, false, "1n === 1"); +assert.sameValue(1 === 1n, false, "1 === 1n"); +assert.sameValue(0n === Number.MIN_VALUE, false, "0n === Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE === 0n, false, "Number.MIN_VALUE === 0n"); +assert.sameValue(0n === -Number.MIN_VALUE, false, "0n === -Number.MIN_VALUE"); +assert.sameValue(-Number.MIN_VALUE === 0n, false, "-Number.MIN_VALUE === 0n"); +assert.sameValue(-10n === Number.MIN_VALUE, false, "-10n === Number.MIN_VALUE"); +assert.sameValue(Number.MIN_VALUE === -10n, false, "Number.MIN_VALUE === -10n"); diff --git a/test/language/expressions/strict-equals/bigint-and-object.js b/test/language/expressions/strict-equals/bigint-and-object.js new file mode 100644 index 00000000000..4ca88ff6e7b --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-object.js @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt values and non-primitive objects +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n === Object(0n), false, "0n === Object(0n)"); +assert.sameValue(Object(0n) === 0n, false, "Object(0n) === 0n"); +assert.sameValue(0n === Object(1n), false, "0n === Object(1n)"); +assert.sameValue(Object(1n) === 0n, false, "Object(1n) === 0n"); +assert.sameValue(1n === Object(0n), false, "1n === Object(0n)"); +assert.sameValue(Object(0n) === 1n, false, "Object(0n) === 1n"); +assert.sameValue(1n === Object(1n), false, "1n === Object(1n)"); +assert.sameValue(Object(1n) === 1n, false, "Object(1n) === 1n"); +assert.sameValue(2n === Object(0n), false, "2n === Object(0n)"); +assert.sameValue(Object(0n) === 2n, false, "Object(0n) === 2n"); +assert.sameValue(2n === Object(1n), false, "2n === Object(1n)"); +assert.sameValue(Object(1n) === 2n, false, "Object(1n) === 2n"); +assert.sameValue(2n === Object(2n), false, "2n === Object(2n)"); +assert.sameValue(Object(2n) === 2n, false, "Object(2n) === 2n"); +assert.sameValue(0n === {}, false, "0n === {}"); +assert.sameValue({} === 0n, false, "{} === 0n"); +assert.sameValue(0n === {valueOf: function() { return 0n; }}, false, "0n === {valueOf: function() { return 0n; }}"); +assert.sameValue({valueOf: function() { return 0n; }} === 0n, false, "{valueOf: function() { return 0n; }} === 0n"); +assert.sameValue(0n === {valueOf: function() { return 1n; }}, false, "0n === {valueOf: function() { return 1n; }}"); +assert.sameValue({valueOf: function() { return 1n; }} === 0n, false, "{valueOf: function() { return 1n; }} === 0n"); +assert.sameValue(0n === {toString: function() { return "0"; }}, false, "0n === {toString: function() { return \"0\"; }}"); +assert.sameValue({toString: function() { return "0"; }} === 0n, false, "{toString: function() { return \"0\"; }} === 0n"); +assert.sameValue(0n === {toString: function() { return "1"; }}, false, "0n === {toString: function() { return \"1\"; }}"); +assert.sameValue({toString: function() { return "1"; }} === 0n, false, "{toString: function() { return \"1\"; }} === 0n"); +assert.sameValue(900719925474099101n === {valueOf: function() { return 900719925474099101n; }}, false, "900719925474099101n === {valueOf: function() { return 900719925474099101n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099101n; }} === 900719925474099101n, false, "{valueOf: function() { return 900719925474099101n; }} === 900719925474099101n"); +assert.sameValue(900719925474099101n === {valueOf: function() { return 900719925474099102n; }}, false, "900719925474099101n === {valueOf: function() { return 900719925474099102n; }}"); +assert.sameValue({valueOf: function() { return 900719925474099102n; }} === 900719925474099101n, false, "{valueOf: function() { return 900719925474099102n; }} === 900719925474099101n"); +assert.sameValue(900719925474099101n === {toString: function() { return "900719925474099101"; }}, false, "900719925474099101n === {toString: function() { return \"900719925474099101\"; }}"); +assert.sameValue({toString: function() { return "900719925474099101"; }} === 900719925474099101n, false, "{toString: function() { return \"900719925474099101\"; }} === 900719925474099101n"); +assert.sameValue(900719925474099101n === {toString: function() { return "900719925474099102"; }}, false, "900719925474099101n === {toString: function() { return \"900719925474099102\"; }}"); +assert.sameValue({toString: function() { return "900719925474099102"; }} === 900719925474099101n, false, "{toString: function() { return \"900719925474099102\"; }} === 900719925474099101n"); diff --git a/test/language/expressions/strict-equals/bigint-and-string.js b/test/language/expressions/strict-equals/bigint-and-string.js new file mode 100644 index 00000000000..747dd160343 --- /dev/null +++ b/test/language/expressions/strict-equals/bigint-and-string.js @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Strict equality comparison of BigInt and String values +esid: sec-strict-equality-comparison +info: | + 1. If Type(x) is different from Type(y), return false. + +features: [BigInt] +---*/ + +assert.sameValue(0n === "", false, "0n === \"\""); +assert.sameValue("" === 0n, false, "\"\" === 0n"); +assert.sameValue(0n === "-0", false, "0n === \"-0\""); +assert.sameValue("-0" === 0n, false, "\"-0\" === 0n"); +assert.sameValue(0n === "0", false, "0n === \"0\""); +assert.sameValue("0" === 0n, false, "\"0\" === 0n"); +assert.sameValue(0n === "-1", false, "0n === \"-1\""); +assert.sameValue("-1" === 0n, false, "\"-1\" === 0n"); +assert.sameValue(0n === "1", false, "0n === \"1\""); +assert.sameValue("1" === 0n, false, "\"1\" === 0n"); +assert.sameValue(0n === "foo", false, "0n === \"foo\""); +assert.sameValue("foo" === 0n, false, "\"foo\" === 0n"); +assert.sameValue(1n === "", false, "1n === \"\""); +assert.sameValue("" === 1n, false, "\"\" === 1n"); +assert.sameValue(1n === "-0", false, "1n === \"-0\""); +assert.sameValue("-0" === 1n, false, "\"-0\" === 1n"); +assert.sameValue(1n === "0", false, "1n === \"0\""); +assert.sameValue("0" === 1n, false, "\"0\" === 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(1n === "foo", false, "1n === \"foo\""); +assert.sameValue("foo" === 1n, false, "\"foo\" === 1n"); +assert.sameValue(-1n === "-", false, "-1n === \"-\""); +assert.sameValue("-" === -1n, false, "\"-\" === -1n"); +assert.sameValue(-1n === "-0", false, "-1n === \"-0\""); +assert.sameValue("-0" === -1n, false, "\"-0\" === -1n"); +assert.sameValue(-1n === "-1", false, "-1n === \"-1\""); +assert.sameValue("-1" === -1n, false, "\"-1\" === -1n"); +assert.sameValue(-1n === "-foo", false, "-1n === \"-foo\""); +assert.sameValue("-foo" === -1n, false, "\"-foo\" === -1n"); +assert.sameValue(900719925474099101n === "900719925474099101", false, "900719925474099101n === \"900719925474099101\""); +assert.sameValue("900719925474099101" === 900719925474099101n, false, "\"900719925474099101\" === 900719925474099101n"); +assert.sameValue(900719925474099102n === "900719925474099101", false, "900719925474099102n === \"900719925474099101\""); +assert.sameValue("900719925474099101" === 900719925474099102n, false, "\"900719925474099101\" === 900719925474099102n");