diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/strict-equals')
32 files changed, 1471 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A1.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A1.js new file mode 100644 index 0000000000..081b35c1ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A1.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + White Space and Line Terminator between EqualityExpression and "===" or + between "===" and RelationalExpression are allowed +es5id: 11.9.4_A1 +description: Checking by using eval +---*/ + +//CHECK#1 +if (!(eval("1\u0009===\u00091"))) { + throw new Test262Error('#1: 1\\u0009===\\u00091'); +} + +//CHECK#2 +if (!(eval("1\u000B===\u000B1"))) { + throw new Test262Error('#2: 1\\u000B===\\u000B1'); +} + +//CHECK#3 +if (!(eval("1\u000C===\u000C1"))) { + throw new Test262Error('#3: 1\\u000C===\\u000C1'); +} + +//CHECK#4 +if (!(eval("1\u0020===\u00201"))) { + throw new Test262Error('#4: 1\\u0020===\\u00201'); +} + +//CHECK#5 +if (!(eval("1\u00A0===\u00A01"))) { + throw new Test262Error('#5: 1\\u00A0===\\u00A01'); +} + +//CHECK#6 +if (!(eval("1\u000A===\u000A1"))) { + throw new Test262Error('#6: 1\\u000A===\\u000A1'); +} + +//CHECK#7 +if (!(eval("1\u000D===\u000D1"))) { + throw new Test262Error('#7: 1\\u000D===\\u000D1'); +} + +//CHECK#8 +if (!(eval("1\u2028===\u20281"))) { + throw new Test262Error('#8: 1\\u2028===\\u20281'); +} + +//CHECK#9 +if (!(eval("1\u2029===\u20291"))) { + throw new Test262Error('#9: 1\\u2029===\\u20291'); +} + +//CHECK#10 +if (!(eval("1\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029===\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u20291"))) { + throw new Test262Error('#10: 1\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029===\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u20291'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T1.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T1.js new file mode 100644 index 0000000000..10919e7acf --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T1.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x === y uses GetValue +es5id: 11.9.4_A2.1_T1 +description: Either Type is not Reference or GetBase is not null +---*/ + +//CHECK#1 +if (!(1 === 1)) { + throw new Test262Error('#1: 1 === 1'); +} + +//CHECK#2 +var x = 1; +if (!(x === 1)) { + throw new Test262Error('#2: var x = 1; x === 1'); +} + +//CHECK#3 +var y = 1; +if (!(1 === y)) { + throw new Test262Error('#3: var y = 1; 1 === y'); +} + +//CHECK#4 +var x = 1; +var y = 1; +if (!(x === y)) { + throw new Test262Error('#4: var x = 1; var y = 1; x === y'); +} + +//CHECK#5 +var objectx = new Object(); +var objecty = new Object(); +objectx.prop = 1; +objecty.prop = 1; +if (!(objectx.prop === objecty.prop)) { + throw new Test262Error('#5: var objectx = new Object(); var objecty = new Object(); objectx.prop = 1; objecty.prop = 1; objectx.prop === objecty.prop'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T2.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T2.js new file mode 100644 index 0000000000..ee6341dfca --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x === y uses GetValue +es5id: 11.9.4_A2.1_T2 +description: If GetBase(x) is null, throw ReferenceError +---*/ + +//CHECK#1 +try { + x === 1; + throw new Test262Error('#1.1: x === 1 throw ReferenceError. Actual: ' + (x === 1)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: x === 1 throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T3.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T3.js new file mode 100644 index 0000000000..c9df9bd6b3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator x === y uses GetValue +es5id: 11.9.4_A2.1_T3 +description: If GetBase(y) is null, throw ReferenceError +---*/ + +//CHECK#1 +try { + 1 === y; + throw new Test262Error('#1.1: 1 === y throw ReferenceError. Actual: ' + (1 === y)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: 1 === y throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T1.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T1.js new file mode 100644 index 0000000000..f3f3eeea5f --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: First expression is evaluated first, and then second expression +es5id: 11.9.4_A2.4_T1 +description: Checking with "=" +---*/ + +//CHECK#1 +var x = 0; +if (!((x = 1) === x)) { + throw new Test262Error('#1: var x = 0; (x = 1) === x'); +} + +//CHECK#2 +var x = 0; +if (x === (x = 1)) { + throw new Test262Error('#2: var x = 0; x !== (x = 1)'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T2.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T2.js new file mode 100644 index 0000000000..71e1d8553f --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: First expression is evaluated first, and then second expression +es5id: 11.9.4_A2.4_T2 +description: Checking with "throw" +---*/ + +//CHECK#1 +var x = function () { throw "x"; }; +var y = function () { throw "y"; }; +try { + x() === y(); + throw new Test262Error('#1.1: var x = function () { throw "x"; }; var y = function () { throw "y"; }; x() === y() throw "x". Actual: ' + (x() === y())); +} catch (e) { + if (e === "y") { + throw new Test262Error('#1.2: First expression is evaluated first, and then second expression'); + } else { + if (!(e === "x")) { + throw new Test262Error('#1.3: var x = function () { throw "x"; }; var y = function () { throw "y"; }; x() === y() throw "x". Actual: ' + (e)); + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T3.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T3.js new file mode 100644 index 0000000000..13c7a074be --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: First expression is evaluated first, and then second expression +es5id: 11.9.4_A2.4_T3 +description: Checking with undeclarated variables +---*/ + +//CHECK#1 +try { + x === (x = 1); + throw new Test262Error('#1.1: x === (x = 1) throw ReferenceError. Actual: ' + (x === (x = 1))); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: x === (x = 1) throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T4.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T4.js new file mode 100644 index 0000000000..7482c27750 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A2.4_T4.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: First expression is evaluated first, and then second expression +es5id: 11.9.4_A2.4_T4 +description: Checking with undeclarated variables +flags: [noStrict] +---*/ + +//CHECK#1 +if (!((y = 1) === y)) { + throw new Test262Error('#1: (y = 1) === y'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A3.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A3.js new file mode 100644 index 0000000000..f21a96c5e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A3.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Type(x) and Type(y) are Boolean-s. + Return true, if x and y are both true and both false; otherwise, return false +es5id: 11.9.4_A3 +description: x and y are primitive booleans +---*/ + +//CHECK#1 +if (!(true === true)) { + throw new Test262Error('#1: true === true'); +} + +//CHECK#2 +if (!(false === false)) { + throw new Test262Error('#2: false === false'); +} + +//CHECK#3 +if (true === false) { + throw new Test262Error('#3: true !== false'); +} + +//CHECK#4 +if (false === true) { + throw new Test262Error('#4: false !== true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.1_T1.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.1_T1.js new file mode 100644 index 0000000000..f106c9c5da --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.1_T1.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If x or y is NaN, return false +es5id: 11.9.4_A4.1_T1 +description: x is NaN +---*/ + +//CHECK#1 +if (Number.NaN === true) { + throw new Test262Error('#1: NaN !== true'); +} + +//CHECK#2 +if (Number.NaN === 1) { + throw new Test262Error('#2: NaN !== 1'); +} + +//CHECK#3 +if (Number.NaN === Number.NaN) { + throw new Test262Error('#3: NaN !== NaN'); +} + +//CHECK#4 +if (Number.NaN === Number.POSITIVE_INFINITY) { + throw new Test262Error('#4: NaN !== +Infinity'); +} + +//CHECK#5 +if (Number.NaN === Number.NEGATIVE_INFINITY) { + throw new Test262Error('#5: NaN !== -Infinity'); +} + +//CHECK#6 +if (Number.NaN === Number.MAX_VALUE) { + throw new Test262Error('#6: NaN !== Number.MAX_VALUE'); +} + +//CHECK#7 +if (Number.NaN === Number.MIN_VALUE) { + throw new Test262Error('#7: NaN !== Number.MIN_VALUE'); +} + +//CHECK#8 +if (Number.NaN === "string") { + throw new Test262Error('#8: NaN !== "string"'); +} + +//CHECK#9 +if (Number.NaN === new Object()) { + throw new Test262Error('#9: NaN !== new Object()'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.1_T2.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.1_T2.js new file mode 100644 index 0000000000..ed54c3e466 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.1_T2.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If x or y is NaN, return false +es5id: 11.9.4_A4.1_T2 +description: y is NaN +---*/ + +//CHECK#1 +if (true === Number.NaN) { + throw new Test262Error('#1: true !== NaN'); +} + +//CHECK#2 +if (-1 === Number.NaN) { + throw new Test262Error('#2: -1 !== NaN'); +} + +//CHECK#3 +if (Number.NaN === Number.NaN) { + throw new Test262Error('#3: NaN !== NaN'); +} + +//CHECK#4 +if (Number.POSITIVE_INFINITY === Number.NaN) { + throw new Test262Error('#4: +Infinity !== NaN'); +} + +//CHECK#5 +if (Number.NEGATIVE_INFINITY === Number.NaN) { + throw new Test262Error('#5: -Infinity !== NaN'); +} + +//CHECK#6 +if (Number.MAX_VALUE === Number.NaN) { + throw new Test262Error('#6: Number.MAX_VALUE !== NaN'); +} + +//CHECK#7 +if (Number.MIN_VALUE === Number.NaN) { + throw new Test262Error('#7: Number.MIN_VALUE !== NaN'); +} + +//CHECK#8 +if ("string" === Number.NaN) { + throw new Test262Error('#8: "string" !== NaN'); +} + +//CHECK#9 +if (new Object() === Number.NaN) { + throw new Test262Error('#9: new Object() !== NaN'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.2.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.2.js new file mode 100644 index 0000000000..545f25c6eb --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If x is +0(-0) and y is -0(+0), return true +es5id: 11.9.4_A4.2 +description: Checking all combinations +---*/ + +//CHECK#1 +if (!(+0 === -0)) { + throw new Test262Error('#1: +0 === -0'); +} + +//CHECK#2 +if (!(-0 === +0)) { + throw new Test262Error('#2: -0 === +0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.3.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.3.js new file mode 100644 index 0000000000..d13ef1e47b --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A4.3.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Type(x) and Type(y) are Number-s minus NaN, +0, -0. + Return true, if x is the same number value as y; otherwise, return false +es5id: 11.9.4_A4.3 +description: x and y are primitive numbers +---*/ + +//CHECK#1 +if (!(Number.POSITIVE_INFINITY === Number.POSITIVE_INFINITY)) { + throw new Test262Error('#1: +Infinity === +Infinity'); +} + +//CHECK#2 +if (!(Number.NEGATIVE_INFINITY === Number.NEGATIVE_INFINITY)) { + throw new Test262Error('#2: -Infinity === -Infinity'); +} + +//CHECK#3 +if (!(13 === 13)) { + throw new Test262Error('#3: 13 === 13'); +} + +//CHECK#4 +if (!(-13 === -13)) { + throw new Test262Error('#4: -13 === -13'); +} + +//CHECK#5 +if (!(1.3 === 1.3)) { + throw new Test262Error('#5: 1.3 === 1.3'); +} + +//CHECK#6 +if (!(-1.3 === -1.3)) { + throw new Test262Error('#6: -1.3 === -1.3'); +} + +//CHECK#7 +if (!(Number.POSITIVE_INFINITY === -Number.NEGATIVE_INFINITY)) { + throw new Test262Error('#7: +Infinity === -(-Infinity)'); +} + +//CHECK#8 +if (1 === 0.999999999999) { + throw new Test262Error('#8: 1 !== 0.999999999999'); +} + +//CHECK#9 +if (!(1.0 === 1)) { + throw new Test262Error('#9: 1.0 === 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A5.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A5.js new file mode 100644 index 0000000000..f2149a646e --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A5.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Type(x) and Type(y) are String-s. + Return true, if x and y are exactly the same sequence of characters; otherwise, return false +es5id: 11.9.4_A5 +description: x and y are primitive strings +---*/ + +//CHECK#1 +if (!("" === "")) { + throw new Test262Error('#1: "" === ""'); +} + +//CHECK#2 +if (!(" " === " ")) { + throw new Test262Error('#2: " " === " "'); +} + +//CHECK#3 +if (!("string" === "string")) { + throw new Test262Error('#3: "string" === "string"'); +} + +//CHECK#4 +if (" string" === "string ") { + throw new Test262Error('#4: " string" !== "string "'); +} + +//CHECK#5 +if ("1.0" === "1") { + throw new Test262Error('#5: "1.0" !== "1"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A6.1.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A6.1.js new file mode 100644 index 0000000000..bab1dcaa5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A6.1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) and Type(y) are Undefined-s, return true +es5id: 11.9.4_A6.1 +description: void 0, eval("var x") is undefined +---*/ + +//CHECK#1 +if (!(undefined === undefined)) { + throw new Test262Error('#1: undefined === undefined'); +} + +//CHECK#2 +if (!(void 0 === undefined)) { + throw new Test262Error('#2: void 0 === undefined'); +} + +//CHECK#3 +if (!(undefined === eval("var x"))) { + throw new Test262Error('#3: undefined === eval("var x")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A6.2.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A6.2.js new file mode 100644 index 0000000000..755d8bfa9d --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A6.2.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) and Type(y) are Null-s, return true +es5id: 11.9.4_A6.2 +description: null === null +---*/ + +//CHECK#1 +if (!(null === null)) { + throw new Test262Error('#1: null === null'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A7.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A7.js new file mode 100644 index 0000000000..bf62eda236 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A7.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Type(x) and Type(y) are Object-s. + Return true, if x and y are references to the same Object; otherwise, return false +es5id: 11.9.4_A7 +description: > + Checking Boolean object, Number object, String object, Object + object +---*/ + +//CHECK#1 +if (new Object() === new Object()) { + throw new Test262Error('#1: new Object() !== new Object()'); +} + +//CHECK#2 +if (new Object(true) === new Object(true)) { + throw new Test262Error('#2: new Object() !== new Object()'); +} + +//CHECK#3 +if (new Object(false) === new Object(false)) { + throw new Test262Error('#3: new Object() !== new Object()'); +} + +//CHECK#4 +if (new Object(+0) === new Object(-0)) { + throw new Test262Error('#4: new Object(+0) !== new Object(-0)'); +} + +//CHECK#5 +var x, y; +x = {}; +y = x; +if (!(x === y)) { + throw new Test262Error('#5: x = {}; y = x; x === y'); +} + +//CHECK#6 +if (new Boolean(true) === new Number(1)) { + throw new Test262Error('#6 new Boolean(true) === new Number(1)'); +} + +//CHECK#7 +if (new Number(1) === new String("1")) { + throw new Test262Error('#7: new Number(1) === new String("1")'); +} + +//CHECK#8 +if (new String("1") === new Boolean(true)) { + throw new Test262Error('#8: new String("x") === new Boolean(true)'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T1.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T1.js new file mode 100644 index 0000000000..37b5824145 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T1.js @@ -0,0 +1,65 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) is different from Type(y), return false +es5id: 11.9.4_A8_T1 +description: x or y is primitive boolean +---*/ + +//CHECK#1 +if (true === new Boolean(true)) { + throw new Test262Error('#1: true !== new Number(true)'); +} + +//CHECK#2 +if (true === 1) { + throw new Test262Error('#2: true !== 1'); +} + +//CHECK#3 +if (true === new Number(true)) { + throw new Test262Error('#3: true !== new Number(true)'); +} + +//CHECK#4 +if (true === "1") { + throw new Test262Error('#4: true !== "1"'); +} + +//CHECK#5 +if (true === new String(true)) { + throw new Test262Error('#5: true !== new String(true)'); +} + +//CHECK#6 +if (new Boolean(false) === false) { + throw new Test262Error('#6: new Number(false) !== false'); +} + +//CHECK#7 +if (0 === false) { + throw new Test262Error('#7: 0 !== false'); +} + +//CHECK#8 +if (new Number(false) === false) { + throw new Test262Error('#8: new Number(false) !== false'); +} + +//CHECK#9 +if ("0" === false) { + throw new Test262Error('#9: "0" !== false'); +} + +//CHECK#10 +if (false === new String(false)) { + throw new Test262Error('#10: false !== new String(false)'); +} + +//CHECK#11 +if (true === {valueOf: function () {return true}}) { + throw new Test262Error('#11: true === {valueOf: function () {return true}}'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T2.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T2.js new file mode 100644 index 0000000000..4f9f7f515c --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T2.js @@ -0,0 +1,65 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) is different from Type(y), return false +es5id: 11.9.4_A8_T2 +description: x or y is primitive number +---*/ + +//CHECK#1 +if (1 === new Number(1)) { + throw new Test262Error('#1: 1 !== new Number(1)'); +} + +//CHECK#2 +if (1 === true) { + throw new Test262Error('#2: 1 !== true'); +} + +//CHECK#3 +if (1 === new Boolean(1)) { + throw new Test262Error('#3: 1 !== new Boolean(1)'); +} + +//CHECK#4 +if (1 === "1") { + throw new Test262Error('#4: 1 !== "1"'); +} + +//CHECK#5 +if (1 === new String(1)) { + throw new Test262Error('#5: 1 !== new String(1)'); +} + +//CHECK#6 +if (new Number(0) === 0) { + throw new Test262Error('#6: new Number(0) !== 0'); +} + +//CHECK#7 +if (false === 0) { + throw new Test262Error('#7: false !== 0'); +} + +//CHECK#8 +if (new Boolean(0) === 0) { + throw new Test262Error('#8: new Boolean(0) !== 0'); +} + +//CHECK#9 +if ("0" === 0) { + throw new Test262Error('#9: "0" !== 0'); +} + +//CHECK#10 +if (new String(0) === 0) { + throw new Test262Error('#10: new String(0) !== 0'); +} + +//CHECK#11 +if (1 === {valueOf: function () {return 1}}) { + throw new Test262Error('#11: 1 === {valueOf: function () {return 1}}'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T3.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T3.js new file mode 100644 index 0000000000..2440120987 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T3.js @@ -0,0 +1,65 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) is different from Type(y), return false +es5id: 11.9.4_A8_T3 +description: x or y is primitive string +---*/ + +//CHECK#1 +if ("1" === new String("1")) { + throw new Test262Error('#1: "1" !== new String("1")'); +} + +//CHECK#2 +if ("1" === true) { + throw new Test262Error('#2: "1" !== true'); +} + +//CHECK#3 +if ("1" === new Boolean("1")) { + throw new Test262Error('#3: "1" !== new Boolean("1")'); +} + +//CHECK#4 +if ("1" === 1) { + throw new Test262Error('#4: "1" === 1'); +} + +//CHECK#5 +if ("1" === new Number("1")) { + throw new Test262Error('#5: "1" === new Number("1")'); +} + +//CHECK#6 +if (new String(false) === false) { + throw new Test262Error('#6: new Number(false) !== false'); +} + +//CHECK#7 +if (false === "0") { + throw new Test262Error('#7: false !== "0"'); +} + +//CHECK#8 +if ("0" === new Boolean("0")) { + throw new Test262Error('#8: "0" !== new Boolean("0")'); +} + +//CHECK#9 +if (false === 0) { + throw new Test262Error('#9: false !== 0'); +} + +//CHECK#10 +if (false === new Number(false)) { + throw new Test262Error('#10: false !== new Number(false)'); +} + +//CHECK#11 +if ("1" === {valueOf: function () {return "1"}}) { + throw new Test262Error('#11: "1" === {valueOf: function () {return "1"}}'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T4.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T4.js new file mode 100644 index 0000000000..e135ce2a20 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T4.js @@ -0,0 +1,80 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) is different from Type(y), return false +es5id: 11.9.4_A8_T4 +description: x or y is null or undefined +---*/ + +//CHECK#1 +if (undefined === null) { + throw new Test262Error('#1: undefined !== null'); +} + +//CHECK#2 +if (null === undefined) { + throw new Test262Error('#2: null !== undefined'); +} + +//CHECK#3 +if (null === 0) { + throw new Test262Error('#3: null !== 0'); +} + +//CHECK#4 +if (0 === null) { + throw new Test262Error('#4: 0 !== null'); +} + +//CHECK#5 +if (null === false) { + throw new Test262Error('#5: null !== false'); +} + +//CHECK#6 +if (false === null) { + throw new Test262Error('#6: false !== null'); +} + +//CHECK#7 +if (undefined === false) { + throw new Test262Error('#7: undefined !== false'); +} + +//CHECK#8 +if (false === undefined) { + throw new Test262Error('#8: false !== undefined'); +} + +//CHECK#9 +if (null === new Object()) { + throw new Test262Error('#9: null !== new Object()'); +} + +//CHECK#10 +if (new Object() === null) { + throw new Test262Error('#10: new Object() !== null'); +} + +//CHECK#11 +if (null === "null") { + throw new Test262Error('#11: null !== "null"'); +} + +//CHECK#12 +if ("null" === null) { + throw new Test262Error('#12: "null" !== null'); +} + +//CHECK#13 +if (undefined === "undefined") { + throw new Test262Error('#13: undefined !== "undefined"'); +} + +//CHECK#14 +if ("undefined" === undefined) { + throw new Test262Error('#14: "undefined" !== undefined'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T5.js b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T5.js new file mode 100644 index 0000000000..7c21b6a10c --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/S11.9.4_A8_T5.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) is different from Type(y), return false +es5id: 11.9.4_A8_T5 +description: > + Checking with such x and y that either x or y is primitive string + and the other is primitive number +---*/ + +//CHECK#1 +try { + throw 1; +} catch(e) { + if (e === "1") { + throw new Test262Error('#1: throw 1 !== "1"'); + } +} + +//CHECK#2 +try { + throw "1"; +} catch(e) { + if (1 === e) { + throw new Test262Error('#2: 1 !== throw "1"'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-bigint.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-bigint.js new file mode 100644 index 0000000000..86f028ca79 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-bigint.js @@ -0,0 +1,174 @@ +// 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, 'The result of (0n === 0n) is true'); +assert.sameValue(1n === 1n, true, 'The result of (1n === 1n) is true'); +assert.sameValue(-1n === -1n, true, 'The result of (-1n === -1n) is true'); +assert.sameValue(0n === -0n, true, 'The result of (0n === -0n) is true'); +assert.sameValue(-0n === 0n, true, 'The result of (-0n === 0n) is true'); +assert.sameValue(0n === 1n, false, 'The result of (0n === 1n) is false'); +assert.sameValue(1n === 0n, false, 'The result of (1n === 0n) is false'); +assert.sameValue(0n === -1n, false, 'The result of (0n === -1n) is false'); +assert.sameValue(-1n === 0n, false, 'The result of (-1n === 0n) is false'); +assert.sameValue(1n === -1n, false, 'The result of (1n === -1n) is false'); +assert.sameValue(-1n === 1n, false, 'The result of (-1n === 1n) is false'); + +assert.sameValue( + 0x1fffffffffffff01n === 0x1fffffffffffff01n, + true, + 'The result of (0x1fffffffffffff01n === 0x1fffffffffffff01n) is true' +); + +assert.sameValue( + 0x1fffffffffffff01n === 0x1fffffffffffff02n, + false, + 'The result of (0x1fffffffffffff01n === 0x1fffffffffffff02n) is false' +); + +assert.sameValue( + 0x1fffffffffffff02n === 0x1fffffffffffff01n, + false, + 'The result of (0x1fffffffffffff02n === 0x1fffffffffffff01n) is false' +); + +assert.sameValue( + -0x1fffffffffffff01n === -0x1fffffffffffff01n, + true, + 'The result of (-0x1fffffffffffff01n === -0x1fffffffffffff01n) is true' +); + +assert.sameValue( + -0x1fffffffffffff01n === -0x1fffffffffffff02n, + false, + 'The result of (-0x1fffffffffffff01n === -0x1fffffffffffff02n) is false' +); + +assert.sameValue( + -0x1fffffffffffff02n === -0x1fffffffffffff01n, + false, + 'The result of (-0x1fffffffffffff02n === -0x1fffffffffffff01n) is false' +); + +assert.sameValue( + 0x10000000000000000n === 0n, + false, + 'The result of (0x10000000000000000n === 0n) is false' +); + +assert.sameValue( + 0n === 0x10000000000000000n, + false, + 'The result of (0n === 0x10000000000000000n) is false' +); + +assert.sameValue( + 0x10000000000000000n === 1n, + false, + 'The result of (0x10000000000000000n === 1n) is false' +); + +assert.sameValue( + 1n === 0x10000000000000000n, + false, + 'The result of (1n === 0x10000000000000000n) is false' +); + +assert.sameValue( + 0x10000000000000000n === -1n, + false, + 'The result of (0x10000000000000000n === -1n) is false' +); + +assert.sameValue( + -1n === 0x10000000000000000n, + false, + 'The result of (-1n === 0x10000000000000000n) is false' +); + +assert.sameValue( + 0x10000000000000001n === 0n, + false, + 'The result of (0x10000000000000001n === 0n) is false' +); + +assert.sameValue( + 0n === 0x10000000000000001n, + false, + 'The result of (0n === 0x10000000000000001n) is false' +); + +assert.sameValue( + -0x10000000000000000n === 0n, + false, + 'The result of (-0x10000000000000000n === 0n) is false' +); + +assert.sameValue( + 0n === -0x10000000000000000n, + false, + 'The result of (0n === -0x10000000000000000n) is false' +); + +assert.sameValue( + -0x10000000000000000n === 1n, + false, + 'The result of (-0x10000000000000000n === 1n) is false' +); + +assert.sameValue( + 1n === -0x10000000000000000n, + false, + 'The result of (1n === -0x10000000000000000n) is false' +); + +assert.sameValue( + -0x10000000000000000n === -1n, + false, + 'The result of (-0x10000000000000000n === -1n) is false' +); + +assert.sameValue( + -1n === -0x10000000000000000n, + false, + 'The result of (-1n === -0x10000000000000000n) is false' +); + +assert.sameValue( + -0x10000000000000001n === 0n, + false, + 'The result of (-0x10000000000000001n === 0n) is false' +); + +assert.sameValue( + 0n === -0x10000000000000001n, + false, + 'The result of (0n === -0x10000000000000001n) is false' +); + +assert.sameValue( + 0x10000000000000000n === 0x100000000n, + false, + 'The result of (0x10000000000000000n === 0x100000000n) is false' +); + +assert.sameValue( + 0x100000000n === 0x10000000000000000n, + false, + 'The result of (0x100000000n === 0x10000000000000000n) is false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-boolean.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-boolean.js new file mode 100644 index 0000000000..dd0104bd69 --- /dev/null +++ b/js/src/tests/test262/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, 'The result of (-1n === false) is false'); +assert.sameValue(false === -1n, false, 'The result of (false === -1n) is false'); +assert.sameValue(-1n === true, false, 'The result of (-1n === true) is false'); +assert.sameValue(true === -1n, false, 'The result of (true === -1n) is false'); +assert.sameValue(0n === false, false, 'The result of (0n === false) is false'); +assert.sameValue(false === 0n, false, 'The result of (false === 0n) is false'); +assert.sameValue(0n === true, false, 'The result of (0n === true) is false'); +assert.sameValue(true === 0n, false, 'The result of (true === 0n) is false'); +assert.sameValue(1n === false, false, 'The result of (1n === false) is false'); +assert.sameValue(false === 1n, false, 'The result of (false === 1n) is false'); +assert.sameValue(1n === true, false, 'The result of (1n === true) is false'); +assert.sameValue(true === 1n, false, 'The result of (true === 1n) is false'); +assert.sameValue(2n === false, false, 'The result of (2n === false) is false'); +assert.sameValue(false === 2n, false, 'The result of (false === 2n) is false'); +assert.sameValue(2n === true, false, 'The result of (2n === true) is false'); +assert.sameValue(true === 2n, false, 'The result of (true === 2n) is false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-incomparable-primitive.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-incomparable-primitive.js new file mode 100644 index 0000000000..cd87be7685 --- /dev/null +++ b/js/src/tests/test262/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, 'The result of (0n === undefined) is false'); +assert.sameValue(undefined === 0n, false, 'The result of (undefined === 0n) is false'); +assert.sameValue(1n === undefined, false, 'The result of (1n === undefined) is false'); +assert.sameValue(undefined === 1n, false, 'The result of (undefined === 1n) is false'); +assert.sameValue(0n === null, false, 'The result of (0n === null) is false'); +assert.sameValue(null === 0n, false, 'The result of (null === 0n) is false'); +assert.sameValue(1n === null, false, 'The result of (1n === null) is false'); +assert.sameValue(null === 1n, false, 'The result of (null === 1n) is false'); +assert.sameValue(0n === Symbol('1'), false, 'The result of (0n === Symbol("1")) is false'); +assert.sameValue(Symbol('1') === 0n, false, 'The result of (Symbol("1") === 0n) is false'); +assert.sameValue(1n === Symbol('1'), false, 'The result of (1n === Symbol("1")) is false'); +assert.sameValue(Symbol('1') === 1n, false, 'The result of (Symbol("1") === 1n) is false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-non-finite.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-non-finite.js new file mode 100644 index 0000000000..e7ddbb51af --- /dev/null +++ b/js/src/tests/test262/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, 'The result of (0n === Infinity) is false'); +assert.sameValue(Infinity === 0n, false, 'The result of (Infinity === 0n) is false'); +assert.sameValue(1n === Infinity, false, 'The result of (1n === Infinity) is false'); +assert.sameValue(Infinity === 1n, false, 'The result of (Infinity === 1n) is false'); +assert.sameValue(-1n === Infinity, false, 'The result of (-1n === Infinity) is false'); +assert.sameValue(Infinity === -1n, false, 'The result of (Infinity === -1n) is false'); +assert.sameValue(0n === -Infinity, false, 'The result of (0n === -Infinity) is false'); +assert.sameValue(-Infinity === 0n, false, 'The result of (-Infinity === 0n) is false'); +assert.sameValue(1n === -Infinity, false, 'The result of (1n === -Infinity) is false'); +assert.sameValue(-Infinity === 1n, false, 'The result of (-Infinity === 1n) is false'); +assert.sameValue(-1n === -Infinity, false, 'The result of (-1n === -Infinity) is false'); +assert.sameValue(-Infinity === -1n, false, 'The result of (-Infinity === -1n) is false'); +assert.sameValue(0n === NaN, false, 'The result of (0n === NaN) is false'); +assert.sameValue(NaN === 0n, false, 'The result of (NaN === 0n) is false'); +assert.sameValue(1n === NaN, false, 'The result of (1n === NaN) is false'); +assert.sameValue(NaN === 1n, false, 'The result of (NaN === 1n) is false'); +assert.sameValue(-1n === NaN, false, 'The result of (-1n === NaN) is false'); +assert.sameValue(NaN === -1n, false, 'The result of (NaN === -1n) is false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-number-extremes.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-number-extremes.js new file mode 100644 index 0000000000..9d3441811e --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-number-extremes.js @@ -0,0 +1,71 @@ +// 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, + 'The result of (1n === Number.MAX_VALUE) is false' +); + +assert.sameValue( + Number.MAX_VALUE === 1n, + false, + 'The result of (Number.MAX_VALUE === 1n) is false' +); + +assert.sameValue( + 1n === -Number.MAX_VALUE, + false, + 'The result of (1n === -Number.MAX_VALUE) is false' +); + +assert.sameValue( + -Number.MAX_VALUE === 1n, + false, + 'The result of (-Number.MAX_VALUE === 1n) is false' +); + +assert.sameValue( + 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn === Number.MAX_VALUE, + false, + 'The result of (0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn === Number.MAX_VALUE) is false' +); + +assert.sameValue( + Number.MAX_VALUE === 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn, + false, + 'The result of (Number.MAX_VALUE === 0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn) is false' +); + +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n === Number.MAX_VALUE, + false, + 'The result of (0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n === Number.MAX_VALUE) is false' +); + +assert.sameValue( + Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, + false, + 'The result of (Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n) is false' +); + +assert.sameValue( + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n === Number.MAX_VALUE, + false, + 'The result of (0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n === Number.MAX_VALUE) is false' +); + +assert.sameValue( + Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n, + false, + 'The result of (Number.MAX_VALUE === 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001n) is false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-number.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-number.js new file mode 100644 index 0000000000..5a726137cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-number.js @@ -0,0 +1,62 @@ +// 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, 'The result of (0n === 0) is false'); +assert.sameValue(0 === 0n, false, 'The result of (0 === 0n) is false'); +assert.sameValue(0n === -0, false, 'The result of (0n === -0) is false'); +assert.sameValue(-0 === 0n, false, 'The result of (-0 === 0n) is false'); +assert.sameValue(0n === 0.000000000001, false, 'The result of (0n === 0.000000000001) is false'); +assert.sameValue(0.000000000001 === 0n, false, 'The result of (0.000000000001 === 0n) is false'); +assert.sameValue(0n === 1, false, 'The result of (0n === 1) is false'); +assert.sameValue(1 === 0n, false, 'The result of (1 === 0n) is false'); +assert.sameValue(1n === 0, false, 'The result of (1n === 0) is false'); +assert.sameValue(0 === 1n, false, 'The result of (0 === 1n) is false'); +assert.sameValue(1n === 0.999999999999, false, 'The result of (1n === 0.999999999999) is false'); +assert.sameValue(0.999999999999 === 1n, false, 'The result of (0.999999999999 === 1n) is false'); +assert.sameValue(1n === 1, false, 'The result of (1n === 1) is false'); +assert.sameValue(1 === 1n, false, 'The result of (1 === 1n) is false'); + +assert.sameValue( + 0n === Number.MIN_VALUE, + false, + 'The result of (0n === Number.MIN_VALUE) is false' +); + +assert.sameValue( + Number.MIN_VALUE === 0n, + false, + 'The result of (Number.MIN_VALUE === 0n) is false' +); + +assert.sameValue( + 0n === -Number.MIN_VALUE, + false, + 'The result of (0n === -Number.MIN_VALUE) is false' +); + +assert.sameValue( + -Number.MIN_VALUE === 0n, + false, + 'The result of (-Number.MIN_VALUE === 0n) is false' +); + +assert.sameValue( + -10n === Number.MIN_VALUE, + false, + 'The result of (-10n === Number.MIN_VALUE) is false' +); + +assert.sameValue( + Number.MIN_VALUE === -10n, + false, + 'The result of (Number.MIN_VALUE === -10n) is false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-object.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-object.js new file mode 100644 index 0000000000..fe3fdca7d9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-object.js @@ -0,0 +1,124 @@ +// 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, 'The result of (0n === Object(0n)) is false'); +assert.sameValue(Object(0n) === 0n, false, 'The result of (Object(0n) === 0n) is false'); +assert.sameValue(0n === Object(1n), false, 'The result of (0n === Object(1n)) is false'); +assert.sameValue(Object(1n) === 0n, false, 'The result of (Object(1n) === 0n) is false'); +assert.sameValue(1n === Object(0n), false, 'The result of (1n === Object(0n)) is false'); +assert.sameValue(Object(0n) === 1n, false, 'The result of (Object(0n) === 1n) is false'); +assert.sameValue(1n === Object(1n), false, 'The result of (1n === Object(1n)) is false'); +assert.sameValue(Object(1n) === 1n, false, 'The result of (Object(1n) === 1n) is false'); +assert.sameValue(2n === Object(0n), false, 'The result of (2n === Object(0n)) is false'); +assert.sameValue(Object(0n) === 2n, false, 'The result of (Object(0n) === 2n) is false'); +assert.sameValue(2n === Object(1n), false, 'The result of (2n === Object(1n)) is false'); +assert.sameValue(Object(1n) === 2n, false, 'The result of (Object(1n) === 2n) is false'); +assert.sameValue(2n === Object(2n), false, 'The result of (2n === Object(2n)) is false'); +assert.sameValue(Object(2n) === 2n, false, 'The result of (Object(2n) === 2n) is false'); +assert.sameValue(0n === {}, false, 'The result of (0n === {}) is false'); +assert.sameValue({} === 0n, false, 'The result of (({}) === 0n) is false'); + +assert.sameValue(0n === { + valueOf: function() { + return 0n; + } +}, false, 'The result of (0n === {valueOf: function() {return 0n;}}) is false'); + +assert.sameValue({ + valueOf: function() { + return 0n; + } +} === 0n, false, 'The result of (({valueOf: function() {return 0n;}}) === 0n) is false'); + +assert.sameValue(0n === { + valueOf: function() { + return 1n; + } +}, false, 'The result of (0n === {valueOf: function() {return 1n;}}) is false'); + +assert.sameValue({ + valueOf: function() { + return 1n; + } +} === 0n, false, 'The result of (({valueOf: function() {return 1n;}}) === 0n) is false'); + +assert.sameValue(0n === { + toString: function() { + return '0'; + } +}, false, 'The result of (0n === {toString: function() {return "0";}}) is false'); + +assert.sameValue({ + toString: function() { + return '0'; + } +} === 0n, false, 'The result of (({toString: function() {return "0";}}) === 0n) is false'); + +assert.sameValue(0n === { + toString: function() { + return '1'; + } +}, false, 'The result of (0n === {toString: function() {return "1";}}) is false'); + +assert.sameValue({ + toString: function() { + return '1'; + } +} === 0n, false, 'The result of (({toString: function() {return "1";}}) === 0n) is false'); + +assert.sameValue(900719925474099101n === { + valueOf: function() { + return 900719925474099101n; + } +}, false, 'The result of (900719925474099101n === {valueOf: function() {return 900719925474099101n;}}) is false'); + +assert.sameValue({ + valueOf: function() { + return 900719925474099101n; + } +} === 900719925474099101n, false, 'The result of (({valueOf: function() {return 900719925474099101n;}}) === 900719925474099101n) is false'); + +assert.sameValue(900719925474099101n === { + valueOf: function() { + return 900719925474099102n; + } +}, false, 'The result of (900719925474099101n === {valueOf: function() {return 900719925474099102n;}}) is false'); + +assert.sameValue({ + valueOf: function() { + return 900719925474099102n; + } +} === 900719925474099101n, false, 'The result of (({valueOf: function() {return 900719925474099102n;}}) === 900719925474099101n) is false'); + +assert.sameValue(900719925474099101n === { + toString: function() { + return '900719925474099101'; + } +}, false, 'The result of (900719925474099101n === {toString: function() {return "900719925474099101";}}) is false'); + +assert.sameValue({ + toString: function() { + return '900719925474099101'; + } +} === 900719925474099101n, false, 'The result of (({toString: function() {return "900719925474099101";}}) === 900719925474099101n) is false'); + +assert.sameValue(900719925474099101n === { + toString: function() { + return '900719925474099102'; + } +}, false, 'The result of (900719925474099101n === {toString: function() {return "900719925474099102";}}) is false'); + +assert.sameValue({ + toString: function() { + return '900719925474099102'; + } +} === 900719925474099101n, false, 'The result of (({toString: function() {return "900719925474099102";}}) === 900719925474099101n) is false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/bigint-and-string.js b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-string.js new file mode 100644 index 0000000000..826da77466 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/bigint-and-string.js @@ -0,0 +1,68 @@ +// 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, 'The result of (0n === "") is false'); +assert.sameValue('' === 0n, false, 'The result of ("" === 0n) is false'); +assert.sameValue(0n === '-0', false, 'The result of (0n === "-0") is false'); +assert.sameValue('-0' === 0n, false, 'The result of ("-0" === 0n) is false'); +assert.sameValue(0n === '0', false, 'The result of (0n === "0") is false'); +assert.sameValue('0' === 0n, false, 'The result of ("0" === 0n) is false'); +assert.sameValue(0n === '-1', false, 'The result of (0n === "-1") is false'); +assert.sameValue('-1' === 0n, false, 'The result of ("-1" === 0n) is false'); +assert.sameValue(0n === '1', false, 'The result of (0n === "1") is false'); +assert.sameValue('1' === 0n, false, 'The result of ("1" === 0n) is false'); +assert.sameValue(0n === 'foo', false, 'The result of (0n === "foo") is false'); +assert.sameValue('foo' === 0n, false, 'The result of ("foo" === 0n) is false'); +assert.sameValue(1n === '', false, 'The result of (1n === "") is false'); +assert.sameValue('' === 1n, false, 'The result of ("" === 1n) is false'); +assert.sameValue(1n === '-0', false, 'The result of (1n === "-0") is false'); +assert.sameValue('-0' === 1n, false, 'The result of ("-0" === 1n) is false'); +assert.sameValue(1n === '0', false, 'The result of (1n === "0") is false'); +assert.sameValue('0' === 1n, false, 'The result of ("0" === 1n) is false'); +assert.sameValue(1n === '-1', false, 'The result of (1n === "-1") is false'); +assert.sameValue('-1' === 1n, false, 'The result of ("-1" === 1n) is false'); +assert.sameValue(1n === '1', false, 'The result of (1n === "1") is false'); +assert.sameValue('1' === 1n, false, 'The result of ("1" === 1n) is false'); +assert.sameValue(1n === 'foo', false, 'The result of (1n === "foo") is false'); +assert.sameValue('foo' === 1n, false, 'The result of ("foo" === 1n) is false'); +assert.sameValue(-1n === '-', false, 'The result of (-1n === "-") is false'); +assert.sameValue('-' === -1n, false, 'The result of ("-" === -1n) is false'); +assert.sameValue(-1n === '-0', false, 'The result of (-1n === "-0") is false'); +assert.sameValue('-0' === -1n, false, 'The result of ("-0" === -1n) is false'); +assert.sameValue(-1n === '-1', false, 'The result of (-1n === "-1") is false'); +assert.sameValue('-1' === -1n, false, 'The result of ("-1" === -1n) is false'); +assert.sameValue(-1n === '-foo', false, 'The result of (-1n === "-foo") is false'); +assert.sameValue('-foo' === -1n, false, 'The result of ("-foo" === -1n) is false'); + +assert.sameValue( + 900719925474099101n === '900719925474099101', + false, + 'The result of (900719925474099101n === "900719925474099101") is false' +); + +assert.sameValue( + '900719925474099101' === 900719925474099101n, + false, + 'The result of ("900719925474099101" === 900719925474099101n) is false' +); + +assert.sameValue( + 900719925474099102n === '900719925474099101', + false, + 'The result of (900719925474099102n === "900719925474099101") is false' +); + +assert.sameValue( + '900719925474099101' === 900719925474099102n, + false, + 'The result of ("900719925474099101" === 900719925474099102n) is false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/strict-equals/browser.js b/js/src/tests/test262/language/expressions/strict-equals/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/browser.js diff --git a/js/src/tests/test262/language/expressions/strict-equals/shell.js b/js/src/tests/test262/language/expressions/strict-equals/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/strict-equals/shell.js |