diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/modulus')
42 files changed, 3240 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A1.js new file mode 100644 index 0000000000..8060162fef --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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 MultiplicativeExpression and "%" + or between "%" and UnaryExpression are allowed +es5id: 11.5.3_A1 +description: Checking by using eval +---*/ + +//CHECK#1 +if (eval("1\u0009%\u00091") !== 0) { + throw new Test262Error('#1: 1\\u0009%\\u00091 === 0'); +} + +//CHECK#2 +if (eval("1\u000B%\u000B1") !== 0) { + throw new Test262Error('#2: 1\\u000B%\\u000B1 === 0'); +} + +//CHECK#3 +if (eval("1\u000C%\u000C1") !== 0) { + throw new Test262Error('#3: 1\\u000C%\\u000C1 === 0'); +} + +//CHECK#4 +if (eval("1\u0020%\u00201") !== 0) { + throw new Test262Error('#4: 1\\u0020%\\u00201 === 0'); +} + +//CHECK#5 +if (eval("1\u00A0%\u00A01") !== 0) { + throw new Test262Error('#5: 1\\u00A0%\\u00A01 === 0'); +} + +//CHECK#6 +if (eval("1\u000A%\u000A1") !== 0) { + throw new Test262Error('#6: 1\\u000A%\\u000A1 === 0'); +} + +//CHECK#7 +if (eval("1\u000D%\u000D1") !== 0) { + throw new Test262Error('#7: 1\\u000D%\\u000D1 === 0'); +} + +//CHECK#8 +if (eval("1\u2028%\u20281") !== 0) { + throw new Test262Error('#8: 1\\u2028%\\u20281 === 0'); +} + +//CHECK#9 +if (eval("1\u2029%\u20291") !== 0) { + throw new Test262Error('#9: 1\\u2029%\\u20291 === 0'); +} + +//CHECK#10 +if (eval("1\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029%\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u20291") !== 0) { + throw new Test262Error('#10: 1\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029%\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u20291 === 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.1_T1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.1_T1.js new file mode 100644 index 0000000000..25f7bd7a43 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_A2.1_T1 +description: Either Type is not Reference or GetBase is not null +---*/ + +//CHECK#1 +if (1 % 2 !== 1) { + throw new Test262Error('#1: 1 % 2 === 1. Actual: ' + (1 % 2)); +} + +//CHECK#2 +var x = 1; +if (x % 2 !== 1) { + throw new Test262Error('#2: var x = 1; x % 2 === 1. Actual: ' + (x % 2)); +} + +//CHECK#3 +var y = 2; +if (1 % y !== 1) { + throw new Test262Error('#3: var y = 2; 1 % y === 1. Actual: ' + (1 % y)); +} + +//CHECK#4 +var x = 1; +var y = 2; +if (x % y !== 1) { + throw new Test262Error('#4: var x = 1; var y = 2; x % y === 1. Actual: ' + (x % y)); +} + +//CHECK#5 +var objectx = new Object(); +var objecty = new Object(); +objectx.prop = 1; +objecty.prop = 2; +if (objectx.prop % objecty.prop !== 1) { + throw new Test262Error('#5: var objectx = new Object(); var objecty = new Object(); objectx.prop = 1; objecty.prop = 2; objectx.prop % objecty.prop === 1. Actual: ' + (objectx.prop % objecty.prop)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.1_T2.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.1_T2.js new file mode 100644 index 0000000000..852ebd2c52 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_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/modulus/S11.5.3_A2.1_T3.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.1_T3.js new file mode 100644 index 0000000000..319bbaecc8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_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/modulus/S11.5.3_A2.2_T1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.2_T1.js new file mode 100644 index 0000000000..1f919aeb0a --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.2_T1.js @@ -0,0 +1,71 @@ +// 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 [[Default Value]] +es5id: 11.5.3_A2.2_T1 +description: If Type(value) is Object, evaluate ToPrimitive(value, Number) +---*/ + +//CHECK#1 +if ({valueOf: function() {return 1}} % 2 !== 1) { + throw new Test262Error('#1: {valueOf: function() {return 1}} % 2 === 1. Actual: ' + ({valueOf: function() {return 1}} % 2)); +} + +//CHECK#2 +if ({valueOf: function() {return 1}, toString: function() {return 0}} % 2 !== 1) { + throw new Test262Error('#2: {valueOf: function() {return 1}, toString: function() {return 0}} % 2 === 1. Actual: ' + ({valueOf: function() {return 1}, toString: function() {return 0}} % 2)); +} + +//CHECK#3 +if ({valueOf: function() {return 1}, toString: function() {return {}}} % 2 !== 1) { + throw new Test262Error('#3: {valueOf: function() {return 1}, toString: function() {return {}}} % 2 === 1. Actual: ' + ({valueOf: function() {return 1}, toString: function() {return {}}} % 2)); +} + +//CHECK#4 +try { + if ({valueOf: function() {return 1}, toString: function() {throw "error"}} % 2 !== 1) { + throw new Test262Error('#4.1: {valueOf: function() {return 1}, toString: function() {throw "error"}} % 2 === 1. Actual: ' + ({valueOf: function() {return 1}, toString: function() {throw "error"}} % 2)); + } +} +catch (e) { + if (e === "error") { + throw new Test262Error('#4.2: {valueOf: function() {return 1}, toString: function() {throw "error"}} % 2 not throw "error"'); + } else { + throw new Test262Error('#4.3: {valueOf: function() {return 1}, toString: function() {throw "error"}} % 2 not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +if (1 % {toString: function() {return 2}} !== 1) { + throw new Test262Error('#5: 1 % {toString: function() {return 2}} === 1. Actual: ' + (1 % {toString: function() {return 2}})); +} + +//CHECK#6 +if (1 % {valueOf: function() {return {}}, toString: function() {return 2}} !== 1) { + throw new Test262Error('#6: 1 % {valueOf: function() {return {}}, toString: function() {return 2}} === 1. Actual: ' + (1 % {valueOf: function() {return {}}, toString: function() {return 2}})); +} + +//CHECK#7 +try { + 1 % {valueOf: function() {throw "error"}, toString: function() {return 2}}; + throw new Test262Error('#7.1: 1 % {valueOf: function() {throw "error"}, toString: function() {return 2}} throw "error". Actual: ' + (1 % {valueOf: function() {throw "error"}, toString: function() {return 2}})); +} +catch (e) { + if (e !== "error") { + throw new Test262Error('#7.2: 1 % {valueOf: function() {throw "error"}, toString: function() {return 2}} throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + 1 % {valueOf: function() {return {}}, toString: function() {return {}}}; + throw new Test262Error('#8.1: 1 % {valueOf: function() {return {}}, toString: function() {return {}}} throw TypeError. Actual: ' + (1 % {valueOf: function() {return {}}, toString: function() {return {}}})); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#8.2: 1 % {valueOf: function() {return {}}, toString: function() {return {}}} throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.3_T1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.3_T1.js new file mode 100644 index 0000000000..ba0d3dbdb7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.3_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + ToNumber(first expression) is called first, and then ToNumber(second + expression) +es5id: 11.5.3_A2.3_T1 +description: Checking with "throw" +---*/ + +//CHECK#1 +var x = { valueOf: function () { throw "x"; } }; +var y = { valueOf: function () { throw "y"; } }; +try { + x % y; + throw new Test262Error('#1.1: var x = { valueOf: function () { throw "x"; } }; var y = { valueOf: function () { throw "y"; } }; x % y throw "x". Actual: ' + (x % y)); +} catch (e) { + if (e === "y") { + throw new Test262Error('#1.2: ToNumber(first expression) is called first, and then ToNumber(second expression)'); + } else { + if (e !== "x") { + throw new Test262Error('#1.3: var x = { valueOf: function () { throw "x"; } }; var y = { valueOf: function () { throw "y"; } }; x % y throw "x". Actual: ' + (e)); + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.4_T1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.4_T1.js new file mode 100644 index 0000000000..2bfa99ff92 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_A2.4_T1 +description: Checking with "=" +---*/ + +//CHECK#1 +var x = 0; +if ((x = 1) % x !== 0) { + throw new Test262Error('#1: var x = 0; (x = 1) % x === 0. Actual: ' + ((x = 1) % x)); +} + +//CHECK#2 +var x = 1; +if (x % (x = 2) !== 1) { + throw new Test262Error('#2: var x = 1; x % (x = 2) === 1. Actual: ' + (x % (x = 2))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.4_T2.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.4_T2.js new file mode 100644 index 0000000000..4449a19fe1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_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/modulus/S11.5.3_A2.4_T3.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.4_T3.js new file mode 100644 index 0000000000..d0894ff321 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_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/modulus/S11.5.3_A2.4_T4.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A2.4_T4.js new file mode 100644 index 0000000000..359f52d905 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_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.5.3_A2.4_T4 +description: Checking with undeclarated variables +flags: [noStrict] +---*/ + +//CHECK#1 +if ((y = 1) % y !== 0) { + throw new Test262Error('#1: (y = 1) % y === 0. Actual: ' + ((y = 1) % y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.1.js new file mode 100644 index 0000000000..954d1c7f2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.1.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T1.1 +description: > + Type(x) and Type(y) vary between primitive boolean and Boolean + object +---*/ + +//CHECK#1 +if (true % true !== 0) { + throw new Test262Error('#1: true % true === 0. Actual: ' + (true % true)); +} + +//CHECK#2 +if (new Boolean(true) % true !== 0) { + throw new Test262Error('#2: new Boolean(true) % true === 0. Actual: ' + (new Boolean(true) % true)); +} + +//CHECK#3 +if (true % new Boolean(true) !== 0) { + throw new Test262Error('#3: true % new Boolean(true) === 0. Actual: ' + (true % new Boolean(true))); +} + +//CHECK#4 +if (new Boolean(true) % new Boolean(true) !== 0) { + throw new Test262Error('#4: new Boolean(true) % new Boolean(true) === 0. Actual: ' + (new Boolean(true) % new Boolean(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.2.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.2.js new file mode 100644 index 0000000000..270c8bf6ca --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.2.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T1.2 +description: Type(x) and Type(y) vary between primitive number and Number object +---*/ + +//CHECK#1 +if (1 % 1 !== 0) { + throw new Test262Error('#1: 1 % 1 === 0. Actual: ' + (1 % 1)); +} + +//CHECK#2 +if (new Number(1) % 1 !== 0) { + throw new Test262Error('#2: new Number(1) % 1 === 0. Actual: ' + (new Number(1) % 1)); +} + +//CHECK#3 +if (1 % new Number(1) !== 0) { + throw new Test262Error('#3: 1 % new Number(1) === 0. Actual: ' + (1 % new Number(1))); +} + +//CHECK#4 +if (new Number(1) % new Number(1) !== 0) { + throw new Test262Error('#4: new Number(1) % new Number(1) === 0. Actual: ' + (new Number(1) % new Number(1))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.3.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.3.js new file mode 100644 index 0000000000..ee643e3510 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.3.js @@ -0,0 +1,40 @@ +// 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 returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T1.3 +description: Type(x) and Type(y) vary between primitive string and String object +---*/ + +//CHECK#1 +if ("1" % "1" !== 0) { + throw new Test262Error('#1: "1" % "1" === 0. Actual: ' + ("1" % "1")); +} + +//CHECK#2 +if (new String("1") % "1" !== 0) { + throw new Test262Error('#2: new String("1") % "1" === 0. Actual: ' + (new String("1") % "1")); +} + +//CHECK#3 +if ("1" % new String("1") !== 0) { + throw new Test262Error('#3: "1" % new String("1") === 0. Actual: ' + ("1" % new String("1"))); +} + +//CHECK#4 +if (new String("1") % new String("1") !== 0) { + throw new Test262Error('#4: new String("1") % new String("1") === 0. Actual: ' + (new String("1") % new String("1"))); +} + +//CHECK#5 +if (isNaN("x" % "1") !== true) { + throw new Test262Error('#5: "x" % "1" === Not-a-Number. Actual: ' + ("x" % "1")); +} + +//CHECK#6 +if (isNaN("1" % "x") !== true) { + throw new Test262Error('#6: "1" % "x" === Not-a-Number. Actual: ' + ("1" % "x")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.4.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.4.js new file mode 100644 index 0000000000..20245ed42c --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.4.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T1.4 +description: Type(x) and Type(y) vary between Null and Undefined +---*/ + +//CHECK#1 +if (isNaN(null % undefined) !== true) { + throw new Test262Error('#1: null % undefined === Not-a-Number. Actual: ' + (null % undefined)); +} + +//CHECK#2 +if (isNaN(undefined % null) !== true) { + throw new Test262Error('#2: undefined % null === Not-a-Number. Actual: ' + (undefined % null)); +} + +//CHECK#3 +if (isNaN(undefined % undefined) !== true) { + throw new Test262Error('#3: undefined % undefined === Not-a-Number. Actual: ' + (undefined % undefined)); +} + +//CHECK#4 +if (isNaN(null % null) !== true) { + throw new Test262Error('#4: null % null === Not-a-Number. Actual: ' + (null % null)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.5.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.5.js new file mode 100644 index 0000000000..069d7d3854 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T1.5.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T1.5 +description: Type(x) and Type(y) vary between Object object and Function object +---*/ + +//CHECK#1 +if (isNaN({} % function(){return 1}) !== true) { + throw new Test262Error('#1: {} % function(){return 1} === Not-a-Number. Actual: ' + ({} % function(){return 1})); +} + +//CHECK#2 +if (isNaN(function(){return 1} % {}) !== true) { + throw new Test262Error('#2: function(){return 1} % {} === Not-a-Number. Actual: ' + (function(){return 1} % {})); +} + +//CHECK#3 +if (isNaN(function(){return 1} % function(){return 1}) !== true) { + throw new Test262Error('#3: function(){return 1} % function(){return 1} === Not-a-Number. Actual: ' + (function(){return 1} % function(){return 1})); +} + +//CHECK#4 +if (isNaN({} % {}) !== true) { + throw new Test262Error('#4: {} % {} === Not-a-Number. Actual: ' + ({} % {})); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.1.js new file mode 100644 index 0000000000..a2edf4faf1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.1.js @@ -0,0 +1,52 @@ +// 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 returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.1 +description: > + Type(x) is different from Type(y) and both types vary between + Number (primitive or object) and Boolean (primitive and object) +---*/ + +//CHECK#1 +if (true % 1 !== 0) { + throw new Test262Error('#1: true % 1 === 0. Actual: ' + (true % 1)); +} + +//CHECK#2 +if (1 % true !== 0) { + throw new Test262Error('#2: 1 % true === 0. Actual: ' + (1 % true)); +} + +//CHECK#3 +if (new Boolean(true) % 1 !== 0) { + throw new Test262Error('#3: new Boolean(true) % 1 === 0. Actual: ' + (new Boolean(true) % 1)); +} + +//CHECK#4 +if (1 % new Boolean(true) !== 0) { + throw new Test262Error('#4: 1 % new Boolean(true) === 0. Actual: ' + (1 % new Boolean(true))); +} + +//CHECK#5 +if (true % new Number(1) !== 0) { + throw new Test262Error('#5: true % new Number(1) === 0. Actual: ' + (true % new Number(1))); +} + +//CHECK#6 +if (new Number(1) % true !== 0) { + throw new Test262Error('#6: new Number(1) % true === 0. Actual: ' + (new Number(1) % true)); +} + +//CHECK#7 +if (new Boolean(true) % new Number(1) !== 0) { + throw new Test262Error('#7: new Boolean(true) % new Number(1) === 0. Actual: ' + (new Boolean(true) % new Number(1))); +} + +//CHECK#8 +if (new Number(1) % new Boolean(true) !== 0) { + throw new Test262Error('#8: new Number(1) % new Boolean(true) === 0. Actual: ' + (new Number(1) % new Boolean(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.2.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.2.js new file mode 100644 index 0000000000..1aea5a8c07 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.2.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.2 +description: > + Type(x) is different from Type(y) and both types vary between + Number (primitive or object) and String (primitive and object) +---*/ + +//CHECK#1 +if ("1" % 1 !== 0) { + throw new Test262Error('#1: "1" % 1 === 0. Actual: ' + ("1" % 1)); +} + +//CHECK#2 +if (1 % "1" !== 0) { + throw new Test262Error('#2: 1 % "1" === 0. Actual: ' + (1 % "1")); +} + +//CHECK#3 +if (new String("1") % 1 !== 0) { + throw new Test262Error('#3: new String("1") % 1 === 0. Actual: ' + (new String("1") % 1)); +} + +//CHECK#4 +if (1 % new String("1") !== 0) { + throw new Test262Error('#4: 1 % new String("1") === 0. Actual: ' + (1 % new String("1"))); +} + +//CHECK#5 +if ("1" % new Number(1) !== 0) { + throw new Test262Error('#5: "1" % new Number(1) === 0. Actual: ' + ("1" % new Number(1))); +} + +//CHECK#6 +if (new Number(1) % "1" !== 0) { + throw new Test262Error('#6: new Number(1) % "1" === 0. Actual: ' + (new Number(1) % "1")); +} + +//CHECK#7 +if (new String("1") % new Number(1) !== 0) { + throw new Test262Error('#7: new String("1") % new Number(1) === 0. Actual: ' + (new String("1") % new Number(1))); +} + +//CHECK#8 +if (new Number(1) % new String("1") !== 0) { + throw new Test262Error('#8: new Number(1) % new String("1") === 0. Actual: ' + (new Number(1) % new String("1"))); +} + +//CHECK#9 +if (isNaN("x" % 1) !== true) { + throw new Test262Error('#9: "x" % 1 === Not-a-Number. Actual: ' + ("x" % 1)); +} + +//CHECK#10 +if (isNaN(1 % "x") !== true) { + throw new Test262Error('#10: 1 % "x" === Not-a-Number. Actual: ' + (1 % "x")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.3.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.3.js new file mode 100644 index 0000000000..a71bff3cc4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.3.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.3 +description: > + Type(x) is different from Type(y) and both types vary between + Number (primitive or object) and Null +---*/ + +//CHECK#1 +if (isNaN(1 % null) !== true) { + throw new Test262Error('#1: 1 % null === Not-a-Number. Actual: ' + (1 % null)); +} + +//CHECK#2 +if (null % 1 !== 0) { + throw new Test262Error('#2: null % 1 === 0. Actual: ' + (null % 1)); +} + +//CHECK#3 +if (isNaN(new Number(1) % null) !== true) { + throw new Test262Error('#3: new Number(1) % null === Not-a-Number. Actual: ' + (new Number(1) % null)); +} + +//CHECK#4 +if (null % new Number(1) !== 0) { + throw new Test262Error('#4: null % new Number(1) === 0. Actual: ' + (null % new Number(1))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.4.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.4.js new file mode 100644 index 0000000000..16d0192bc2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.4.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.4 +description: > + Type(x) is different from Type(y) and both types vary between + Number (primitive or object) and Undefined +---*/ + +//CHECK#1 +if (isNaN(1 % undefined) !== true) { + throw new Test262Error('#1: 1 % undefined === Not-a-Number. Actual: ' + (1 % undefined)); +} + +//CHECK#2 +if (isNaN(undefined % 1) !== true) { + throw new Test262Error('#2: undefined % 1 === Not-a-Number. Actual: ' + (undefined % 1)); +} + +//CHECK#3 +if (isNaN(new Number(1) % undefined) !== true) { + throw new Test262Error('#3: new Number(1) % undefined === Not-a-Number. Actual: ' + (new Number(1) % undefined)); +} + +//CHECK#4 +if (isNaN(undefined % new Number(1)) !== true) { + throw new Test262Error('#4: undefined % new Number(1) === Not-a-Number. Actual: ' + (undefined % new Number(1))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.5.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.5.js new file mode 100644 index 0000000000..36580dd8b8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.5.js @@ -0,0 +1,52 @@ +// 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 returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.5 +description: > + Type(x) is different from Type(y) and both types vary between + String (primitive or object) and Boolean (primitive and object) +---*/ + +//CHECK#1 +if (true % "1" !== 0) { + throw new Test262Error('#1: true % "1" === 0. Actual: ' + (true % "1")); +} + +//CHECK#2 +if ("1" % true !== 0) { + throw new Test262Error('#2: "1" % true === 0. Actual: ' + ("1" % true)); +} + +//CHECK#3 +if (new Boolean(true) % "1" !== 0) { + throw new Test262Error('#3: new Boolean(true) % "1" === 0. Actual: ' + (new Boolean(true) % "1")); +} + +//CHECK#4 +if ("1" % new Boolean(true) !== 0) { + throw new Test262Error('#4: "1" % new Boolean(true) === 0. Actual: ' + ("1" % new Boolean(true))); +} + +//CHECK#5 +if (true % new String("1") !== 0) { + throw new Test262Error('#5: true % new String("1") === 0. Actual: ' + (true % new String("1"))); +} + +//CHECK#6 +if (new String("1") % true !== 0) { + throw new Test262Error('#6: new String("1") % true === 0. Actual: ' + (new String("1") % true)); +} + +//CHECK#7 +if (new Boolean(true) % new String("1") !== 0) { + throw new Test262Error('#7: new Boolean(true) % new String("1") === 0. Actual: ' + (new Boolean(true) % new String("1"))); +} + +//CHECK#8 +if (new String("1") % new Boolean(true) !== 0) { + throw new Test262Error('#8: new String("1") % new Boolean(true) === 0. Actual: ' + (new String("1") % new Boolean(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.6.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.6.js new file mode 100644 index 0000000000..d9914c0537 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.6.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.6 +description: > + Type(x) is different from Type(y) and both types vary between + String (primitive or object) and Undefined +---*/ + +//CHECK#1 +if (isNaN("1" % undefined) !== true) { + throw new Test262Error('#1: "1" % undefined === Not-a-Number. Actual: ' + ("1" % undefined)); +} + +//CHECK#2 +if (isNaN(undefined % "1") !== true) { + throw new Test262Error('#2: undefined % "1" === Not-a-Number. Actual: ' + (undefined % "1")); +} + +//CHECK#3 +if (isNaN(new String("1") % undefined) !== true) { + throw new Test262Error('#3: new String("1") % undefined === Not-a-Number. Actual: ' + (new String("1") % undefined)); +} + +//CHECK#4 +if (isNaN(undefined % new String("1")) !== true) { + throw new Test262Error('#4: undefined % new String("1") === Not-a-Number. Actual: ' + (undefined % new String("1"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.7.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.7.js new file mode 100644 index 0000000000..5797bcb9e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.7.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.7 +description: > + Type(x) is different from Type(y) and both types vary between + String (primitive or object) and Null +---*/ + +//CHECK#1 +if (isNaN("1" % null) !== true) { + throw new Test262Error('#1: "1" % null === Not-a-Number. Actual: ' + ("1" % null)); +} + +//CHECK#2 +if (null % "1" !== 0) { + throw new Test262Error('#2: null % "1" === 0. Actual: ' + (null % "1")); +} + +//CHECK#3 +if (isNaN(new String("1") % null) !== true) { + throw new Test262Error('#3: new String("1") % null === Not-a-Number. Actual: ' + (new String("1") % null)); +} + +//CHECK#4 +if (null % new String("1") !== 0) { + throw new Test262Error('#4: null % new String("1") === 0. Actual: ' + (null % new String("1"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.8.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.8.js new file mode 100644 index 0000000000..465a2d3bcc --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.8.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.8 +description: > + Type(x) is different from Type(y) and both types vary between + Boolean (primitive or object) and Undefined +---*/ + +//CHECK#1 +if (isNaN(true % undefined) !== true) { + throw new Test262Error('#1: true % undefined === Not-a-Number. Actual: ' + (true % undefined)); +} + +//CHECK#2 +if (isNaN(undefined % true) !== true) { + throw new Test262Error('#2: undefined % true === Not-a-Number. Actual: ' + (undefined % true)); +} + +//CHECK#3 +if (isNaN(new Boolean(true) % undefined) !== true) { + throw new Test262Error('#3: new Boolean(true) % undefined === Not-a-Number. Actual: ' + (new Boolean(true) % undefined)); +} + +//CHECK#4 +if (isNaN(undefined % new Boolean(true)) !== true) { + throw new Test262Error('#4: undefined % new Boolean(true) === Not-a-Number. Actual: ' + (undefined % new Boolean(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.9.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.9.js new file mode 100644 index 0000000000..083b555f4e --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A3_T2.9.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: Operator x % y returns ToNumber(x) % ToNumber(y) +es5id: 11.5.3_A3_T2.9 +description: > + Type(x) is different from Type(y) and both types vary between + Boolean (primitive or object) and Null +---*/ + +//CHECK#1 +if (isNaN(true % null) !== true) { + throw new Test262Error('#1: true % null === Not-a-Number. Actual: ' + (true % null)); +} + +//CHECK#2 +if (null % true !== 0) { + throw new Test262Error('#2: null % true === 0. Actual: ' + (null % true)); +} + +//CHECK#3 +if (isNaN(new Boolean(true) % null) !== true) { + throw new Test262Error('#3: new Boolean(true) % null === Not-a-Number. Actual: ' + (new Boolean(true) % null)); +} + +//CHECK#4 +if (null % new Boolean(true) !== 0) { + throw new Test262Error('#4: null % new Boolean(true) === 0. Actual: ' + (null % new Boolean(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T1.1.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T1.1.js new file mode 100644 index 0000000000..19877b9f39 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T1.1.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T1.1 +description: If either operand is NaN, the result is NaN +---*/ + +//CHECK#1 +if (isNaN(Number.NaN % Number.NaN) !== true) { + throw new Test262Error('#1: NaN % NaN === Not-a-Number. Actual: ' + (NaN % NaN)); +} + +//CHECK#2 +if (isNaN(Number.NaN % +0) !== true) { + throw new Test262Error('#2: NaN % +0 === Not-a-Number. Actual: ' + (NaN % +0)); +} + +//CHECK#3 +if (isNaN(Number.NaN % -0) !== true) { + throw new Test262Error('#3: NaN % -0 === Not-a-Number. Actual: ' + (NaN % -0)); +} + +//CHECK#4 +if (isNaN(Number.NaN % Number.POSITIVE_INFINITY) !== true) { + throw new Test262Error('#4: NaN % Infinity === Not-a-Number. Actual: ' + (NaN % Infinity)); +} + +//CHECK#5 +if (isNaN(Number.NaN % Number.NEGATIVE_INFINITY) !== true) { + throw new Test262Error('#5: NaN % -Infinity === Not-a-Number. Actual: ' + (NaN % -Infinity)); +} + +//CHECK#6 +if (isNaN(Number.NaN % Number.MAX_VALUE) !== true) { + throw new Test262Error('#6: NaN % Number.MAX_VALUE === Not-a-Number. Actual: ' + (NaN % Number.MAX_VALUE)); +} + +//CHECK#7 +if (isNaN(Number.NaN % Number.MIN_VALUE) !== true) { + throw new Test262Error('#7: NaN % Number.MIN_VALUE === Not-a-Number. Actual: ' + (NaN % Number.MIN_VALUE)); +} + +//CHECK#8 +if (isNaN(Number.NaN % 1) !== true) { + throw new Test262Error('#8: NaN % 1 === Not-a-Number. Actual: ' + (NaN % 1)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T1.2.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T1.2.js new file mode 100644 index 0000000000..13c04f933a --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T1.2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T1.2 +description: If either operand is NaN, the result is NaN +---*/ + +//CHECK#1 +if (isNaN(Number.NaN % Number.NaN) !== true) { + throw new Test262Error('#1: NaN % NaN === Not-a-Number. Actual: ' + (NaN % NaN)); +} + +//CHECK#2 +if (isNaN(+0 % Number.NaN) !== true) { + throw new Test262Error('#2: +0 % NaN === Not-a-Number. Actual: ' + (+0 % NaN)); +} + +//CHECK#3 +if (isNaN(-0 % Number.NaN) !== true) { + throw new Test262Error('#3: -0 % NaN === Not-a-Number. Actual: ' + (-0 % NaN)); +} + +//CHECK#4 +if (isNaN(Number.POSITIVE_INFINITY % Number.NaN) !== true) { + throw new Test262Error('#4: Infinity % NaN === Not-a-Number. Actual: ' + (Infinity % NaN)); +} + +//CHECK#5 +if (isNaN(Number.NEGATIVE_INFINITY % Number.NaN) !== true) { + throw new Test262Error('#5: -Infinity % NaN === Not-a-Number. Actual: ' + ( -Infinity % NaN)); +} + +//CHECK#6 +if (isNaN(Number.MAX_VALUE % Number.NaN) !== true) { + throw new Test262Error('#6: Number.MAX_VALUE % NaN === Not-a-Number. Actual: ' + (Number.MAX_VALUE % NaN)); +} + +//CHECK#7 +if (isNaN(Number.MIN_VALUE % Number.NaN) !== true) { + throw new Test262Error('#7: Number.MIN_VALUE % NaN === Not-a-Number. Actual: ' + (Number.MIN_VALUE % NaN)); +} + +//CHECK#8 +if (isNaN(1 % Number.NaN) !== true) { + throw new Test262Error('#8: 1 % NaN === Not-a-Number. Actual: ' + (1 % NaN)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T2.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T2.js new file mode 100644 index 0000000000..628073b433 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T2.js @@ -0,0 +1,70 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T2 +description: > + The sign of the finite non-zero value result equals the sign of + the divided +---*/ + +//CHECK#1 +if (1 % 1 !== 0) { + throw new Test262Error('#1.1: 1 % 1 === 0. Actual: ' + (1 % 1)); +} else { + if (1 / (1 % 1) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#1.2: 1 % 1 === + 0. Actual: -0'); + } +} + +//CHECK#2 +if (-1 % -1 !== -0) { + throw new Test262Error('#2.1: -1 % -1 === 0. Actual: ' + (-1 % -1)); +} else { + if (1 / (-1 % -1) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#2.2: -1 % -1 === - 0. Actual: +0'); + } +} + +//CHECK#3 +if (-1 % 1 !== -0) { + throw new Test262Error('#3.1: -1 % 1 === 0. Actual: ' + (-1 % 1)); +} else { + if (1 / (-1 % 1) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#3.2: -1 % 1 === - 0. Actual: +0'); + } +} + +//CHECK#4 +if (1 % -1 !== 0) { + throw new Test262Error('#4.1: 1 % -1 === 0. Actual: ' + (1 % -1)); +} else { + if (1 / (1 % -1) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#4.2: 1 % -1 === + 0. Actual: -0'); + } +} + +//CHECK#5 +if (101 % 51 !== 50) { + throw new Test262Error('#5: 101 % 51 === 50. Actual: ' + (101 % 51)); +} + +//CHECK#6 +if (101 % -51 !== 50) { + throw new Test262Error('#6: 101 % -51 === 50. Actual: ' + (101 % -51)); +} + +//CHECK#7 +if (-101 % 51 !== -50) { + throw new Test262Error('#7: -101 % 51 === -50. Actual: ' + (-101 % 51)); +} + +//CHECK#8 +if (-101 % -51 !== -50) { + throw new Test262Error('#8: -101 % -51 === -50. Actual: ' + (-101 % -51)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T3.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T3.js new file mode 100644 index 0000000000..1b57aa2cf7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T3.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T3 +description: If the dividend is an infinity results is NaN +---*/ + +//CHECK#1 +if (isNaN(Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY) !== true) { + throw new Test262Error('#1: -Infinity % Infinity === Not-a-Number. Actual: ' + (-Infinity % Infinity)); +} + +//CHECK#2 +if (isNaN(Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY) !== true) { + throw new Test262Error('#2: -Infinity % -Infinity === Not-a-Number. Actual: ' + (-Infinity % -Infinity)); +} + +//CHECK#3 +if (isNaN(Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY) !== true) { + throw new Test262Error('#3: Infinity % Infinity === Not-a-Number. Actual: ' + (Infinity % Infinity)); +} + +//CHECK#4 +if (isNaN(Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY) !== true) { + throw new Test262Error('#4: Infinity % -Infinity === Not-a-Number. Actual: ' + (Infinity % -Infinity)); +} + +//CHECK#5 +if (isNaN(Number.NEGATIVE_INFINITY % 1) !== true) { + throw new Test262Error('#5: Infinity % 1 === Not-a-Number. Actual: ' + (Infinity % 1)); +} + +//CHECK#6 +if (isNaN(Number.NEGATIVE_INFINITY % -1) !== true) { + throw new Test262Error('#6: -Infinity % -1 === Not-a-Number. Actual: ' + (-Infinity % -1)); +} + +//CHECK#7 +if (isNaN(Number.POSITIVE_INFINITY % 1) !== true) { + throw new Test262Error('#7: Infinity % 1 === Not-a-Number. Actual: ' + (Infinity % 1)); +} + +//CHECK#8 +if (isNaN(Number.POSITIVE_INFINITY % -1) !== true) { + throw new Test262Error('#8: Infinity % -1 === Not-a-Number. Actual: ' + (Infinity % -1)); +} + +//CHECK#9 +if (isNaN(Number.NEGATIVE_INFINITY % Number.MAX_VALUE) !== true) { + throw new Test262Error('#9: Infinity % Number.MAX_VALUE === Not-a-Number. Actual: ' + (Infinity % Number.MAX_VALUE)); +} + +//CHECK#10 +if (isNaN(Number.NEGATIVE_INFINITY % -Number.MAX_VALUE) !== true) { + throw new Test262Error('#10: -Infinity % -Number.MAX_VALUE === Not-a-Number. Actual: ' + (-Infinity % -Number.MAX_VALUE)); +} + +//CHECK#11 +if (isNaN(Number.POSITIVE_INFINITY % Number.MAX_VALUE) !== true) { + throw new Test262Error('#11: Infinity % Number.MAX_VALUE === Not-a-Number. Actual: ' + (Infinity % Number.MAX_VALUE)); +} + +//CHECK#12 +if (isNaN(Number.POSITIVE_INFINITY % -Number.MAX_VALUE) !== true) { + throw new Test262Error('#12: Infinity % -Number.MAX_VALUE === Not-a-Number. Actual: ' + (Infinity % -Number.MAX_VALUE)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T4.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T4.js new file mode 100644 index 0000000000..b1d627c7e4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T4.js @@ -0,0 +1,92 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T4 +description: If the divisor is zero results is NaN +---*/ + +//CHECK#1 +if (isNaN(-0 % 0) !== true) { + throw new Test262Error('#1: -0 % 0 === Not-a-Number. Actual: ' + (-0 % 0)); +} + +//CHECK#2 +if (isNaN(-0 % -0) !== true) { + throw new Test262Error('#2: -0 % -0 === Not-a-Number. Actual: ' + (-0 % -0)); +} + +//CHECK#3 +if (isNaN(0 % 0) !== true) { + throw new Test262Error('#3: 0 % 0 === Not-a-Number. Actual: ' + (0 % 0)); +} + +//CHECK#4 +if (isNaN(0 % -0) !== true) { + throw new Test262Error('#4: 0 % -0 === Not-a-Number. Actual: ' + (0 % -0)); +} + +//CHECK#5 +if (isNaN(-1 % 0) !== true) { + throw new Test262Error('#5: 1 % 0 === Not-a-Number. Actual: ' + (1 % 0)); +} + +//CHECK#6 +if (isNaN(-1 % -0) !== true) { + throw new Test262Error('#6: -1 % -0 === Not-a-Number. Actual: ' + (-1 % -0)); +} + +//CHECK#7 +if (isNaN(1 % 0) !== true) { + throw new Test262Error('#7: 1 % 0 === Not-a-Number. Actual: ' + (1 % 0)); +} + +//CHECK#8 +if (isNaN(1 % -0) !== true) { + throw new Test262Error('#8: 1 % -0 === Not-a-Number. Actual: ' + (1 % -0)); +} + +//CHECK#9 +if (isNaN(Number.NEGATIVE_INFINITY % 0) !== true) { + throw new Test262Error('#9: Infinity % 0 === Not-a-Number. Actual: ' + (Infinity % 0)); +} + +//CHECK#10 +if (isNaN(Number.NEGATIVE_INFINITY % -0) !== true) { + throw new Test262Error('#10: -Infinity % -0 === Not-a-Number. Actual: ' + (-Infinity % -0)); +} + +//CHECK#11 +if (isNaN(Number.POSITIVE_INFINITY % 0) !== true) { + throw new Test262Error('#11: Infinity % 0 === Not-a-Number. Actual: ' + (Infinity % 0)); +} + +//CHECK#12 +if (isNaN(Number.POSITIVE_INFINITY % -0) !== true) { + throw new Test262Error('#12: Infinity % -0 === Not-a-Number. Actual: ' + (Infinity % -0)); +} + +//CHECK#13 +if (isNaN(Number.MIN_VALUE % 0) !== true) { + throw new Test262Error('#13: Number.MIN_VALUE % 0 === Not-a-Number. Actual: ' + (Number.MIN_VALUE % 0)); +} + +//CHECK#14 +if (isNaN(Number.MIN_VALUE % -0) !== true) { + throw new Test262Error('#14: -Number.MIN_VALUE % -0 === Not-a-Number. Actual: ' + (-Number.MIN_VALUE % -0)); +} + +//CHECK#15 +if (isNaN(Number.MAX_VALUE % 0) !== true) { + throw new Test262Error('#15: Number.MAX_VALUE % 0 === Not-a-Number. Actual: ' + (Number.MAX_VALUE % 0)); +} + +//CHECK#16 +if (isNaN(Number.MAX_VALUE % -0) !== true) { + throw new Test262Error('#16: Number.MAX_VALUE % -0 === Not-a-Number. Actual: ' + (Number.MAX_VALUE % -0)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T5.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T5.js new file mode 100644 index 0000000000..0f5d8a3c77 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T5.js @@ -0,0 +1,108 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T5 +description: > + If dividend is finite and the divisor is an infinity, the result + equals the dividend +---*/ + +//CHECK#1 +if (1 % Number.NEGATIVE_INFINITY !== 1) { + throw new Test262Error('#1: 1 % -Infinity === 1. Actual: ' + (1 % -Infinity)); +} +//CHECK#2 +if (1 % Number.POSITIVE_INFINITY !==1) { + throw new Test262Error('#2: 1 % Infinity === 1. Actual: ' + (1 % Infinity)); +} + +//CHECK#3 +if (-1 % Number.POSITIVE_INFINITY !== -1) { + throw new Test262Error('#3: -1 % Infinity === -1. Actual: ' + (-1 % Infinity)); +} + +//CHECK#4 +if (-1 % Number.NEGATIVE_INFINITY !== -1) { + throw new Test262Error('#4: -1 % -Infinity === -1. Actual: ' + (-1 % -Infinity)); +} + +//CHECK#5 +if (0 % Number.POSITIVE_INFINITY !== 0) { + throw new Test262Error('#5.1: 0 % Infinity === 0. Actual: ' + (0 % Infinity)); +} else { + if (1 / (0 % Number.POSITIVE_INFINITY) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5.2: 0 % Infinity === + 0. Actual: -0'); + } +} + +//CHECK#6 +if (0 % Number.NEGATIVE_INFINITY !== 0) { + throw new Test262Error('#6.1: 0 % -Infinity === 0. Actual: ' + (0 % -Infinity)); +} else { + if (1 / (0 % Number.NEGATIVE_INFINITY) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#6.2: 0 % -Infinity === + 0. Actual: -0'); + } +} + +//CHECK#7 +if (-0 % Number.POSITIVE_INFINITY !== -0) { + throw new Test262Error('#7.1: -0 % Infinity === 0. Actual: ' + (-0 % Infinity)); +} else { + if (1 / (-0 % Number.POSITIVE_INFINITY) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#7.2: -0 % Infinity === - 0. Actual: +0'); + } +} + +//CHECK#8 +if (-0 % Number.NEGATIVE_INFINITY !== -0) { + throw new Test262Error('#8.1: -0 % -Infinity === 0. Actual: ' + (-0 % -Infinity)); +} else { + if (1 / (-0 % Number.NEGATIVE_INFINITY) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#8.2: -0 % -Infinity === - 0. Actual: +0'); + } +} + +//CHECK#9 +if (Number.MAX_VALUE % Number.NEGATIVE_INFINITY !== Number.MAX_VALUE) { + throw new Test262Error('#9: Number.MAX_VALUE % -Infinity === Number.MAX_VALUE. Actual: ' + (Number.MAX_VALUE % -Infinity)); +} + +//CHECK#10 +if (Number.MAX_VALUE % Number.POSITIVE_INFINITY !== Number.MAX_VALUE) { + throw new Test262Error('#10: Number.MAX_VALUE % Infinity === Number.MAX_VALUE. Actual: ' + (Number.MAX_VALUE % Infinity)); +} + +//CHECK#11 +if (-Number.MAX_VALUE % Number.POSITIVE_INFINITY !== -Number.MAX_VALUE) { + throw new Test262Error('#11: -Number.MAX_VALUE % Infinity === -Number.MAX_VALUE. Actual: ' + (-Number.MAX_VALUE % Infinity)); +} + +//CHECK#12 +if (-Number.MAX_VALUE % Number.NEGATIVE_INFINITY !== -Number.MAX_VALUE) { + throw new Test262Error('#12: -Number.MAX_VALUE % -Infinity === -Number.MAX_VALUE. Actual: ' + (-Number.MAX_VALUE % -Infinity)); +} + +//CHECK#13 +if (Number.MIN_VALUE % Number.NEGATIVE_INFINITY !== Number.MIN_VALUE) { + throw new Test262Error('#13: Number.MIN_VALUE % -Infinity === Number.MIN_VALUE. Actual: ' + (Number.MIN_VALUE % -Infinity)); +} +//CHECK#14 +if (Number.MIN_VALUE % Number.POSITIVE_INFINITY !== Number.MIN_VALUE) { + throw new Test262Error('#14: Number.MIN_VALUE % Infinity === Number.MIN_VALUE. Actual: ' + (Number.MIN_VALUE % Infinity)); +} + +//CHECK#15 +if (-Number.MIN_VALUE % Number.POSITIVE_INFINITY !== -Number.MIN_VALUE) { + throw new Test262Error('#15: -Number.MIN_VALUE % Infinity === -Number.MIN_VALUE. Actual: ' + (-Number.MIN_VALUE % Infinity)); +} + +//CHECK#16 +if (-Number.MIN_VALUE % Number.NEGATIVE_INFINITY !== -Number.MIN_VALUE) { + throw new Test262Error('#16: -Number.MIN_VALUE % -Infinity === -Number.MIN_VALUE. Actual: ' + (-Number.MIN_VALUE % -Infinity)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T6.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T6.js new file mode 100644 index 0000000000..0664f1266d --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T6.js @@ -0,0 +1,86 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T6 +description: > + If dividend is a zero and the divisor is nonzero finite, the + result equals the dividend +---*/ + +//CHECK#1 +if (0 % 1 !== 0) { + throw new Test262Error('#1.1: 0 % 1 === 0. Actual: ' + (0 % 1)); +} else { + if (1 / (0 % 1) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#1.2: 0 % 1 === + 0. Actual: -0'); + } +} + +//CHECK#2 +if (0 % -1 !== 0) { + throw new Test262Error('#2.1: 0 % -1 === 0. Actual: ' + (0 % -1)); +} else { + if (1 / (0 % -1) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#2.2: 0 % -1 === + 0. Actual: -0'); + } +} + +//CHECK#3 +if (-0 % 1 !== -0) { + throw new Test262Error('#3.1: -0 % 1 === 0. Actual: ' + (-0 % 1)); +} else { + if (1 / (-0 % 1) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#3.2: -0 % 1 === - 0. Actual: +0'); + } +} + +//CHECK#4 +if (-0 % -1 !== -0) { + throw new Test262Error('#4.1: -0 % -1 === 0. Actual: ' + (-0 % -1)); +} else { + if (1 / (-0 % -1) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#4.2: 0 % -1 === - 0. Actual: +0'); + } +} + +//CHECK#5 +if (0 % Number.MAX_VALUE !== 0) { + throw new Test262Error('#5.1: 0 % Number.MAX_VALUE === 0. Actual: ' + (0 % Number.MAX_VALUE)); +} else { + if (1 / (0 % Number.MAX_VALUE) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5.2: 0 % Number.MAX_VALUE === + 0. Actual: -0'); + } +} + +//CHECK#6 +if (0 % Number.MIN_VALUE !== 0) { + throw new Test262Error('#6.1: 0 % Number.MIN_VALUE === 0. Actual: ' + (0 % Number.MIN_VALUE)); +} else { + if (1 / (0 % Number.MIN_VALUE) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#6.2: 0 % Number.MIN_VALUE === + 0. Actual: -0'); + } +} + +//CHECK#7 +if (-0 % Number.MAX_VALUE !== -0) { + throw new Test262Error('#7.1: -0 % Number.MAX_VALUE === 0. Actual: ' + (-0 % Number.MAX_VALUE)); +} else { + if (1 / (-0 % Number.MAX_VALUE) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#7.2: -0 % Number.MAX_VALUE === - 0. Actual: +0'); + } +} + +//CHECK#8 +if (-0 % Number.MIN_VALUE !== -0) { + throw new Test262Error('#8.1: -0 % Number.MIN_VALUE === 0. Actual: ' + (-0 % Number.MIN_VALUE)); +} else { + if (1 / (-0 % Number.MIN_VALUE) !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#8.2: 0 % Number.MIN_VALUE === - 0. Actual: +0'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T7.js b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T7.js new file mode 100644 index 0000000000..6d9baaf151 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/S11.5.3_A4_T7.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: | + The result of a ECMAScript floating-point remainder operation is + determined by the rules of IEEE arithmetics +es5id: 11.5.3_A4_T7 +description: > + If operands neither an infinity, nor a zero, nor NaN, return x - + truncate(x / y) * y +---*/ + +function truncate(x) { + if (x > 0) { + return Math.floor(x); + } else { + return Math.ceil(x); + } +} + +var x, y; + +//CHECK#1 +x = 1.3; +y = 1.1; +if (x % y !== 0.19999999999999996) { + throw new Test262Error('#1: x = 1.3; y = 1.1; x % y === 0.19999999999999996. Actual: ' + (x % y)); +} + +//CHECK#2 +x = -1.3; +y = 1.1; +if (x % y !== -0.19999999999999996) { + throw new Test262Error('#2: x = -1.3; y = 1.1; x % y === -0.19999999999999996. Actual: ' + (x % y)); +} + +//CHECK#3 +x = 1.3; +y = -1.1; +if (x % y !== 0.19999999999999996) { + throw new Test262Error('#3: x = 1.3; y = -1.1; x % y === 0.19999999999999996. Actual: ' + (x % y)); +} + +//CHECK#4 +x = -1.3; +y = -1.1; +if (x % y !== -0.19999999999999996) { + throw new Test262Error('#4: x = -1.3; y = -1.1; x % y === -0.19999999999999996. Actual: ' + (x % y)); +} + +//CHECK#5 +x = 1.3; +y = 1.1; +if (x % y !== x - truncate(x / y) * y) { + throw new Test262Error('#5: x = 1.3; y = 1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y)); +} + +//CHECK#6 +x = -1.3; +y = 1.1; +if (x % y !== x - truncate(x / y) * y) { + throw new Test262Error('#6: x = -1.3; y = 1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y)); +} + +//CHECK#7 +x = 1.3; +y = -1.1; +if (x % y !== x - truncate(x / y) * y) { + throw new Test262Error('#7: x = 1.3; y = -1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y)); +} + +//CHECK#8 +x = -1.3; +y = -1.1; +if (x % y !== x - truncate(x / y) * y) { + throw new Test262Error('#8: x = -1.3; y = -1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/bigint-and-number.js b/js/src/tests/test262/language/expressions/modulus/bigint-and-number.js new file mode 100644 index 0000000000..6f4b3acb64 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/bigint-and-number.js @@ -0,0 +1,92 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: Mixing BigInt and Number produces a TypeError for modulus operator +features: [BigInt] +info: | + Let lnum be ? ToNumeric(leftValue). + Let rnum be ? ToNumeric(rightValue). + If Type(lnum) does not equal Type(rnum), throw a TypeError exception. +---*/ +assert.throws(TypeError, function() { + 1n % 1; +}, '1n % 1 throws TypeError'); + +assert.throws(TypeError, function() { + 1 % 1n; +}, '1 % 1n throws TypeError'); + +assert.throws(TypeError, function() { + Object(1n) % 1; +}, 'Object(1n) % 1 throws TypeError'); + +assert.throws(TypeError, function() { + 1 % Object(1n); +}, '1 % Object(1n) throws TypeError'); + +assert.throws(TypeError, function() { + 1n % Object(1); +}, '1n % Object(1) throws TypeError'); + +assert.throws(TypeError, function() { + Object(1) % 1n; +}, 'Object(1) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + Object(1n) % Object(1); +}, 'Object(1n) % Object(1) throws TypeError'); + +assert.throws(TypeError, function() { + Object(1) % Object(1n); +}, 'Object(1) % Object(1n) throws TypeError'); + +assert.throws(TypeError, function() { + 1n % NaN; +}, '1n % NaN throws TypeError'); + +assert.throws(TypeError, function() { + NaN % 1n; +}, 'NaN % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 1n % Infinity; +}, '1n % Infinity throws TypeError'); + +assert.throws(TypeError, function() { + Infinity % 1n; +}, 'Infinity % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 1n % true; +}, '1n % true throws TypeError'); + +assert.throws(TypeError, function() { + true % 1n; +}, 'true % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 1n % '1'; +}, '1n % "1" throws TypeError'); + +assert.throws(TypeError, function() { + '1' % 1n; +}, '"1" % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 1n % null; +}, '1n % null throws TypeError'); + +assert.throws(TypeError, function() { + null % 1n; +}, 'null % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 1n % undefined; +}, '1n % undefined throws TypeError'); + +assert.throws(TypeError, function() { + undefined % 1n; +}, 'undefined % 1n throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/bigint-arithmetic.js b/js/src/tests/test262/language/expressions/modulus/bigint-arithmetic.js new file mode 100644 index 0000000000..1960b2036d --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/bigint-arithmetic.js @@ -0,0 +1,986 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: BigInt remainder arithmetic +features: [BigInt] +---*/ +assert.sameValue( + 0xFEDCBA9876543210n % 0xFEDCBA9876543210n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % 0xFEDCBA9876543210n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0xFEDCBA987654320Fn, + 0x1n, + 'The result of (0xFEDCBA9876543210n % 0xFEDCBA987654320Fn) is 0x1n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0xFEDCBA98n, + 0x76543210n, + 'The result of (0xFEDCBA9876543210n % 0xFEDCBA98n) is 0x76543210n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0xFEDCBA97n, + 0x77777779n, + 'The result of (0xFEDCBA9876543210n % 0xFEDCBA97n) is 0x77777779n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0x1234n, + 0x960n, + 'The result of (0xFEDCBA9876543210n % 0x1234n) is 0x960n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0x3n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % 0x3n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0x2n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % 0x2n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % 0x1n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % 0x1n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0x1n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % -0x1n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0x2n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % -0x2n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0x3n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % -0x3n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0x1234n, + 0x960n, + 'The result of (0xFEDCBA9876543210n % -0x1234n) is 0x960n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0xFEDCBA97n, + 0x77777779n, + 'The result of (0xFEDCBA9876543210n % -0xFEDCBA97n) is 0x77777779n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0xFEDCBA98n, + 0x76543210n, + 'The result of (0xFEDCBA9876543210n % -0xFEDCBA98n) is 0x76543210n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0xFEDCBA987654320Fn, + 0x1n, + 'The result of (0xFEDCBA9876543210n % -0xFEDCBA987654320Fn) is 0x1n' +); + +assert.sameValue( + 0xFEDCBA9876543210n % -0xFEDCBA9876543210n, + 0x0n, + 'The result of (0xFEDCBA9876543210n % -0xFEDCBA9876543210n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0xFEDCBA9876543210n, + 0xFEDCBA987654320Fn, + 'The result of (0xFEDCBA987654320Fn % 0xFEDCBA9876543210n) is 0xFEDCBA987654320Fn' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0xFEDCBA987654320Fn, + 0x0n, + 'The result of (0xFEDCBA987654320Fn % 0xFEDCBA987654320Fn) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0xFEDCBA98n, + 0x7654320Fn, + 'The result of (0xFEDCBA987654320Fn % 0xFEDCBA98n) is 0x7654320Fn' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0xFEDCBA97n, + 0x77777778n, + 'The result of (0xFEDCBA987654320Fn % 0xFEDCBA97n) is 0x77777778n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0x1234n, + 0x95Fn, + 'The result of (0xFEDCBA987654320Fn % 0x1234n) is 0x95Fn' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0x3n, + 0x2n, + 'The result of (0xFEDCBA987654320Fn % 0x3n) is 0x2n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0x2n, + 0x1n, + 'The result of (0xFEDCBA987654320Fn % 0x2n) is 0x1n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % 0x1n, + 0x0n, + 'The result of (0xFEDCBA987654320Fn % 0x1n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0x1n, + 0x0n, + 'The result of (0xFEDCBA987654320Fn % -0x1n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0x2n, + 0x1n, + 'The result of (0xFEDCBA987654320Fn % -0x2n) is 0x1n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0x3n, + 0x2n, + 'The result of (0xFEDCBA987654320Fn % -0x3n) is 0x2n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0x1234n, + 0x95Fn, + 'The result of (0xFEDCBA987654320Fn % -0x1234n) is 0x95Fn' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0xFEDCBA97n, + 0x77777778n, + 'The result of (0xFEDCBA987654320Fn % -0xFEDCBA97n) is 0x77777778n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0xFEDCBA98n, + 0x7654320Fn, + 'The result of (0xFEDCBA987654320Fn % -0xFEDCBA98n) is 0x7654320Fn' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0xFEDCBA987654320Fn, + 0x0n, + 'The result of (0xFEDCBA987654320Fn % -0xFEDCBA987654320Fn) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA987654320Fn % -0xFEDCBA9876543210n, + 0xFEDCBA987654320Fn, + 'The result of (0xFEDCBA987654320Fn % -0xFEDCBA9876543210n) is 0xFEDCBA987654320Fn' +); + +assert.sameValue( + 0xFEDCBA98n % 0xFEDCBA9876543210n, + 0xFEDCBA98n, + 'The result of (0xFEDCBA98n % 0xFEDCBA9876543210n) is 0xFEDCBA98n' +); + +assert.sameValue( + 0xFEDCBA98n % 0xFEDCBA987654320Fn, + 0xFEDCBA98n, + 'The result of (0xFEDCBA98n % 0xFEDCBA987654320Fn) is 0xFEDCBA98n' +); + +assert.sameValue( + 0xFEDCBA98n % 0xFEDCBA98n, + 0x0n, + 'The result of (0xFEDCBA98n % 0xFEDCBA98n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA98n % 0xFEDCBA97n, + 0x1n, + 'The result of (0xFEDCBA98n % 0xFEDCBA97n) is 0x1n' +); + +assert.sameValue(0xFEDCBA98n % 0x1234n, 0x930n, 'The result of (0xFEDCBA98n % 0x1234n) is 0x930n'); +assert.sameValue(0xFEDCBA98n % 0x3n, 0x2n, 'The result of (0xFEDCBA98n % 0x3n) is 0x2n'); +assert.sameValue(0xFEDCBA98n % 0x2n, 0x0n, 'The result of (0xFEDCBA98n % 0x2n) is 0x0n'); +assert.sameValue(0xFEDCBA98n % 0x1n, 0x0n, 'The result of (0xFEDCBA98n % 0x1n) is 0x0n'); +assert.sameValue(0xFEDCBA98n % -0x1n, 0x0n, 'The result of (0xFEDCBA98n % -0x1n) is 0x0n'); +assert.sameValue(0xFEDCBA98n % -0x2n, 0x0n, 'The result of (0xFEDCBA98n % -0x2n) is 0x0n'); +assert.sameValue(0xFEDCBA98n % -0x3n, 0x2n, 'The result of (0xFEDCBA98n % -0x3n) is 0x2n'); + +assert.sameValue( + 0xFEDCBA98n % -0x1234n, + 0x930n, + 'The result of (0xFEDCBA98n % -0x1234n) is 0x930n' +); + +assert.sameValue( + 0xFEDCBA98n % -0xFEDCBA97n, + 0x1n, + 'The result of (0xFEDCBA98n % -0xFEDCBA97n) is 0x1n' +); + +assert.sameValue( + 0xFEDCBA98n % -0xFEDCBA98n, + 0x0n, + 'The result of (0xFEDCBA98n % -0xFEDCBA98n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA98n % -0xFEDCBA987654320Fn, + 0xFEDCBA98n, + 'The result of (0xFEDCBA98n % -0xFEDCBA987654320Fn) is 0xFEDCBA98n' +); + +assert.sameValue( + 0xFEDCBA98n % -0xFEDCBA9876543210n, + 0xFEDCBA98n, + 'The result of (0xFEDCBA98n % -0xFEDCBA9876543210n) is 0xFEDCBA98n' +); + +assert.sameValue( + 0xFEDCBA97n % 0xFEDCBA9876543210n, + 0xFEDCBA97n, + 'The result of (0xFEDCBA97n % 0xFEDCBA9876543210n) is 0xFEDCBA97n' +); + +assert.sameValue( + 0xFEDCBA97n % 0xFEDCBA987654320Fn, + 0xFEDCBA97n, + 'The result of (0xFEDCBA97n % 0xFEDCBA987654320Fn) is 0xFEDCBA97n' +); + +assert.sameValue( + 0xFEDCBA97n % 0xFEDCBA98n, + 0xFEDCBA97n, + 'The result of (0xFEDCBA97n % 0xFEDCBA98n) is 0xFEDCBA97n' +); + +assert.sameValue( + 0xFEDCBA97n % 0xFEDCBA97n, + 0x0n, + 'The result of (0xFEDCBA97n % 0xFEDCBA97n) is 0x0n' +); + +assert.sameValue(0xFEDCBA97n % 0x1234n, 0x92Fn, 'The result of (0xFEDCBA97n % 0x1234n) is 0x92Fn'); +assert.sameValue(0xFEDCBA97n % 0x3n, 0x1n, 'The result of (0xFEDCBA97n % 0x3n) is 0x1n'); +assert.sameValue(0xFEDCBA97n % 0x2n, 0x1n, 'The result of (0xFEDCBA97n % 0x2n) is 0x1n'); +assert.sameValue(0xFEDCBA97n % 0x1n, 0x0n, 'The result of (0xFEDCBA97n % 0x1n) is 0x0n'); +assert.sameValue(0xFEDCBA97n % -0x1n, 0x0n, 'The result of (0xFEDCBA97n % -0x1n) is 0x0n'); +assert.sameValue(0xFEDCBA97n % -0x2n, 0x1n, 'The result of (0xFEDCBA97n % -0x2n) is 0x1n'); +assert.sameValue(0xFEDCBA97n % -0x3n, 0x1n, 'The result of (0xFEDCBA97n % -0x3n) is 0x1n'); + +assert.sameValue( + 0xFEDCBA97n % -0x1234n, + 0x92Fn, + 'The result of (0xFEDCBA97n % -0x1234n) is 0x92Fn' +); + +assert.sameValue( + 0xFEDCBA97n % -0xFEDCBA97n, + 0x0n, + 'The result of (0xFEDCBA97n % -0xFEDCBA97n) is 0x0n' +); + +assert.sameValue( + 0xFEDCBA97n % -0xFEDCBA98n, + 0xFEDCBA97n, + 'The result of (0xFEDCBA97n % -0xFEDCBA98n) is 0xFEDCBA97n' +); + +assert.sameValue( + 0xFEDCBA97n % -0xFEDCBA987654320Fn, + 0xFEDCBA97n, + 'The result of (0xFEDCBA97n % -0xFEDCBA987654320Fn) is 0xFEDCBA97n' +); + +assert.sameValue( + 0xFEDCBA97n % -0xFEDCBA9876543210n, + 0xFEDCBA97n, + 'The result of (0xFEDCBA97n % -0xFEDCBA9876543210n) is 0xFEDCBA97n' +); + +assert.sameValue( + 0x1234n % 0xFEDCBA9876543210n, + 0x1234n, + 'The result of (0x1234n % 0xFEDCBA9876543210n) is 0x1234n' +); + +assert.sameValue( + 0x1234n % 0xFEDCBA987654320Fn, + 0x1234n, + 'The result of (0x1234n % 0xFEDCBA987654320Fn) is 0x1234n' +); + +assert.sameValue( + 0x1234n % 0xFEDCBA98n, + 0x1234n, + 'The result of (0x1234n % 0xFEDCBA98n) is 0x1234n' +); + +assert.sameValue( + 0x1234n % 0xFEDCBA97n, + 0x1234n, + 'The result of (0x1234n % 0xFEDCBA97n) is 0x1234n' +); + +assert.sameValue(0x1234n % 0x1234n, 0x0n, 'The result of (0x1234n % 0x1234n) is 0x0n'); +assert.sameValue(0x1234n % 0x3n, 0x1n, 'The result of (0x1234n % 0x3n) is 0x1n'); +assert.sameValue(0x1234n % 0x2n, 0x0n, 'The result of (0x1234n % 0x2n) is 0x0n'); +assert.sameValue(0x1234n % 0x1n, 0x0n, 'The result of (0x1234n % 0x1n) is 0x0n'); +assert.sameValue(0x1234n % -0x1n, 0x0n, 'The result of (0x1234n % -0x1n) is 0x0n'); +assert.sameValue(0x1234n % -0x2n, 0x0n, 'The result of (0x1234n % -0x2n) is 0x0n'); +assert.sameValue(0x1234n % -0x3n, 0x1n, 'The result of (0x1234n % -0x3n) is 0x1n'); +assert.sameValue(0x1234n % -0x1234n, 0x0n, 'The result of (0x1234n % -0x1234n) is 0x0n'); + +assert.sameValue( + 0x1234n % -0xFEDCBA97n, + 0x1234n, + 'The result of (0x1234n % -0xFEDCBA97n) is 0x1234n' +); + +assert.sameValue( + 0x1234n % -0xFEDCBA98n, + 0x1234n, + 'The result of (0x1234n % -0xFEDCBA98n) is 0x1234n' +); + +assert.sameValue( + 0x1234n % -0xFEDCBA987654320Fn, + 0x1234n, + 'The result of (0x1234n % -0xFEDCBA987654320Fn) is 0x1234n' +); + +assert.sameValue( + 0x1234n % -0xFEDCBA9876543210n, + 0x1234n, + 'The result of (0x1234n % -0xFEDCBA9876543210n) is 0x1234n' +); + +assert.sameValue( + 0x3n % 0xFEDCBA9876543210n, + 0x3n, + 'The result of (0x3n % 0xFEDCBA9876543210n) is 0x3n' +); + +assert.sameValue( + 0x3n % 0xFEDCBA987654320Fn, + 0x3n, + 'The result of (0x3n % 0xFEDCBA987654320Fn) is 0x3n' +); + +assert.sameValue(0x3n % 0xFEDCBA98n, 0x3n, 'The result of (0x3n % 0xFEDCBA98n) is 0x3n'); +assert.sameValue(0x3n % 0xFEDCBA97n, 0x3n, 'The result of (0x3n % 0xFEDCBA97n) is 0x3n'); +assert.sameValue(0x3n % 0x1234n, 0x3n, 'The result of (0x3n % 0x1234n) is 0x3n'); +assert.sameValue(0x3n % 0x3n, 0x0n, 'The result of (0x3n % 0x3n) is 0x0n'); +assert.sameValue(0x3n % 0x2n, 0x1n, 'The result of (0x3n % 0x2n) is 0x1n'); +assert.sameValue(0x3n % 0x1n, 0x0n, 'The result of (0x3n % 0x1n) is 0x0n'); +assert.sameValue(0x3n % -0x1n, 0x0n, 'The result of (0x3n % -0x1n) is 0x0n'); +assert.sameValue(0x3n % -0x2n, 0x1n, 'The result of (0x3n % -0x2n) is 0x1n'); +assert.sameValue(0x3n % -0x3n, 0x0n, 'The result of (0x3n % -0x3n) is 0x0n'); +assert.sameValue(0x3n % -0x1234n, 0x3n, 'The result of (0x3n % -0x1234n) is 0x3n'); +assert.sameValue(0x3n % -0xFEDCBA97n, 0x3n, 'The result of (0x3n % -0xFEDCBA97n) is 0x3n'); +assert.sameValue(0x3n % -0xFEDCBA98n, 0x3n, 'The result of (0x3n % -0xFEDCBA98n) is 0x3n'); + +assert.sameValue( + 0x3n % -0xFEDCBA987654320Fn, + 0x3n, + 'The result of (0x3n % -0xFEDCBA987654320Fn) is 0x3n' +); + +assert.sameValue( + 0x3n % -0xFEDCBA9876543210n, + 0x3n, + 'The result of (0x3n % -0xFEDCBA9876543210n) is 0x3n' +); + +assert.sameValue( + 0x2n % 0xFEDCBA9876543210n, + 0x2n, + 'The result of (0x2n % 0xFEDCBA9876543210n) is 0x2n' +); + +assert.sameValue( + 0x2n % 0xFEDCBA987654320Fn, + 0x2n, + 'The result of (0x2n % 0xFEDCBA987654320Fn) is 0x2n' +); + +assert.sameValue(0x2n % 0xFEDCBA98n, 0x2n, 'The result of (0x2n % 0xFEDCBA98n) is 0x2n'); +assert.sameValue(0x2n % 0xFEDCBA97n, 0x2n, 'The result of (0x2n % 0xFEDCBA97n) is 0x2n'); +assert.sameValue(0x2n % 0x1234n, 0x2n, 'The result of (0x2n % 0x1234n) is 0x2n'); +assert.sameValue(0x2n % 0x3n, 0x2n, 'The result of (0x2n % 0x3n) is 0x2n'); +assert.sameValue(0x2n % 0x2n, 0x0n, 'The result of (0x2n % 0x2n) is 0x0n'); +assert.sameValue(0x2n % 0x1n, 0x0n, 'The result of (0x2n % 0x1n) is 0x0n'); +assert.sameValue(0x2n % -0x1n, 0x0n, 'The result of (0x2n % -0x1n) is 0x0n'); +assert.sameValue(0x2n % -0x2n, 0x0n, 'The result of (0x2n % -0x2n) is 0x0n'); +assert.sameValue(0x2n % -0x3n, 0x2n, 'The result of (0x2n % -0x3n) is 0x2n'); +assert.sameValue(0x2n % -0x1234n, 0x2n, 'The result of (0x2n % -0x1234n) is 0x2n'); +assert.sameValue(0x2n % -0xFEDCBA97n, 0x2n, 'The result of (0x2n % -0xFEDCBA97n) is 0x2n'); +assert.sameValue(0x2n % -0xFEDCBA98n, 0x2n, 'The result of (0x2n % -0xFEDCBA98n) is 0x2n'); + +assert.sameValue( + 0x2n % -0xFEDCBA987654320Fn, + 0x2n, + 'The result of (0x2n % -0xFEDCBA987654320Fn) is 0x2n' +); + +assert.sameValue( + 0x2n % -0xFEDCBA9876543210n, + 0x2n, + 'The result of (0x2n % -0xFEDCBA9876543210n) is 0x2n' +); + +assert.sameValue( + 0x1n % 0xFEDCBA9876543210n, + 0x1n, + 'The result of (0x1n % 0xFEDCBA9876543210n) is 0x1n' +); + +assert.sameValue( + 0x1n % 0xFEDCBA987654320Fn, + 0x1n, + 'The result of (0x1n % 0xFEDCBA987654320Fn) is 0x1n' +); + +assert.sameValue(0x1n % 0xFEDCBA98n, 0x1n, 'The result of (0x1n % 0xFEDCBA98n) is 0x1n'); +assert.sameValue(0x1n % 0xFEDCBA97n, 0x1n, 'The result of (0x1n % 0xFEDCBA97n) is 0x1n'); +assert.sameValue(0x1n % 0x1234n, 0x1n, 'The result of (0x1n % 0x1234n) is 0x1n'); +assert.sameValue(0x1n % 0x3n, 0x1n, 'The result of (0x1n % 0x3n) is 0x1n'); +assert.sameValue(0x1n % 0x2n, 0x1n, 'The result of (0x1n % 0x2n) is 0x1n'); +assert.sameValue(0x1n % 0x1n, 0x0n, 'The result of (0x1n % 0x1n) is 0x0n'); +assert.sameValue(0x1n % -0x1n, 0x0n, 'The result of (0x1n % -0x1n) is 0x0n'); +assert.sameValue(0x1n % -0x2n, 0x1n, 'The result of (0x1n % -0x2n) is 0x1n'); +assert.sameValue(0x1n % -0x3n, 0x1n, 'The result of (0x1n % -0x3n) is 0x1n'); +assert.sameValue(0x1n % -0x1234n, 0x1n, 'The result of (0x1n % -0x1234n) is 0x1n'); +assert.sameValue(0x1n % -0xFEDCBA97n, 0x1n, 'The result of (0x1n % -0xFEDCBA97n) is 0x1n'); +assert.sameValue(0x1n % -0xFEDCBA98n, 0x1n, 'The result of (0x1n % -0xFEDCBA98n) is 0x1n'); + +assert.sameValue( + 0x1n % -0xFEDCBA987654320Fn, + 0x1n, + 'The result of (0x1n % -0xFEDCBA987654320Fn) is 0x1n' +); + +assert.sameValue( + 0x1n % -0xFEDCBA9876543210n, + 0x1n, + 'The result of (0x1n % -0xFEDCBA9876543210n) is 0x1n' +); + +assert.sameValue( + -0x1n % 0xFEDCBA9876543210n, + -0x1n, + 'The result of (-0x1n % 0xFEDCBA9876543210n) is -0x1n' +); + +assert.sameValue( + -0x1n % 0xFEDCBA987654320Fn, + -0x1n, + 'The result of (-0x1n % 0xFEDCBA987654320Fn) is -0x1n' +); + +assert.sameValue(-0x1n % 0xFEDCBA98n, -0x1n, 'The result of (-0x1n % 0xFEDCBA98n) is -0x1n'); +assert.sameValue(-0x1n % 0xFEDCBA97n, -0x1n, 'The result of (-0x1n % 0xFEDCBA97n) is -0x1n'); +assert.sameValue(-0x1n % 0x1234n, -0x1n, 'The result of (-0x1n % 0x1234n) is -0x1n'); +assert.sameValue(-0x1n % 0x3n, -0x1n, 'The result of (-0x1n % 0x3n) is -0x1n'); +assert.sameValue(-0x1n % 0x2n, -0x1n, 'The result of (-0x1n % 0x2n) is -0x1n'); +assert.sameValue(-0x1n % 0x1n, 0x0n, 'The result of (-0x1n % 0x1n) is 0x0n'); +assert.sameValue(-0x1n % -0x1n, 0x0n, 'The result of (-0x1n % -0x1n) is 0x0n'); +assert.sameValue(-0x1n % -0x2n, -0x1n, 'The result of (-0x1n % -0x2n) is -0x1n'); +assert.sameValue(-0x1n % -0x3n, -0x1n, 'The result of (-0x1n % -0x3n) is -0x1n'); +assert.sameValue(-0x1n % -0x1234n, -0x1n, 'The result of (-0x1n % -0x1234n) is -0x1n'); +assert.sameValue(-0x1n % -0xFEDCBA97n, -0x1n, 'The result of (-0x1n % -0xFEDCBA97n) is -0x1n'); +assert.sameValue(-0x1n % -0xFEDCBA98n, -0x1n, 'The result of (-0x1n % -0xFEDCBA98n) is -0x1n'); + +assert.sameValue( + -0x1n % -0xFEDCBA987654320Fn, + -0x1n, + 'The result of (-0x1n % -0xFEDCBA987654320Fn) is -0x1n' +); + +assert.sameValue( + -0x1n % -0xFEDCBA9876543210n, + -0x1n, + 'The result of (-0x1n % -0xFEDCBA9876543210n) is -0x1n' +); + +assert.sameValue( + -0x2n % 0xFEDCBA9876543210n, + -0x2n, + 'The result of (-0x2n % 0xFEDCBA9876543210n) is -0x2n' +); + +assert.sameValue( + -0x2n % 0xFEDCBA987654320Fn, + -0x2n, + 'The result of (-0x2n % 0xFEDCBA987654320Fn) is -0x2n' +); + +assert.sameValue(-0x2n % 0xFEDCBA98n, -0x2n, 'The result of (-0x2n % 0xFEDCBA98n) is -0x2n'); +assert.sameValue(-0x2n % 0xFEDCBA97n, -0x2n, 'The result of (-0x2n % 0xFEDCBA97n) is -0x2n'); +assert.sameValue(-0x2n % 0x1234n, -0x2n, 'The result of (-0x2n % 0x1234n) is -0x2n'); +assert.sameValue(-0x2n % 0x3n, -0x2n, 'The result of (-0x2n % 0x3n) is -0x2n'); +assert.sameValue(-0x2n % 0x2n, 0x0n, 'The result of (-0x2n % 0x2n) is 0x0n'); +assert.sameValue(-0x2n % 0x1n, 0x0n, 'The result of (-0x2n % 0x1n) is 0x0n'); +assert.sameValue(-0x2n % -0x1n, 0x0n, 'The result of (-0x2n % -0x1n) is 0x0n'); +assert.sameValue(-0x2n % -0x2n, 0x0n, 'The result of (-0x2n % -0x2n) is 0x0n'); +assert.sameValue(-0x2n % -0x3n, -0x2n, 'The result of (-0x2n % -0x3n) is -0x2n'); +assert.sameValue(-0x2n % -0x1234n, -0x2n, 'The result of (-0x2n % -0x1234n) is -0x2n'); +assert.sameValue(-0x2n % -0xFEDCBA97n, -0x2n, 'The result of (-0x2n % -0xFEDCBA97n) is -0x2n'); +assert.sameValue(-0x2n % -0xFEDCBA98n, -0x2n, 'The result of (-0x2n % -0xFEDCBA98n) is -0x2n'); + +assert.sameValue( + -0x2n % -0xFEDCBA987654320Fn, + -0x2n, + 'The result of (-0x2n % -0xFEDCBA987654320Fn) is -0x2n' +); + +assert.sameValue( + -0x2n % -0xFEDCBA9876543210n, + -0x2n, + 'The result of (-0x2n % -0xFEDCBA9876543210n) is -0x2n' +); + +assert.sameValue( + -0x3n % 0xFEDCBA9876543210n, + -0x3n, + 'The result of (-0x3n % 0xFEDCBA9876543210n) is -0x3n' +); + +assert.sameValue( + -0x3n % 0xFEDCBA987654320Fn, + -0x3n, + 'The result of (-0x3n % 0xFEDCBA987654320Fn) is -0x3n' +); + +assert.sameValue(-0x3n % 0xFEDCBA98n, -0x3n, 'The result of (-0x3n % 0xFEDCBA98n) is -0x3n'); +assert.sameValue(-0x3n % 0xFEDCBA97n, -0x3n, 'The result of (-0x3n % 0xFEDCBA97n) is -0x3n'); +assert.sameValue(-0x3n % 0x1234n, -0x3n, 'The result of (-0x3n % 0x1234n) is -0x3n'); +assert.sameValue(-0x3n % 0x3n, 0x0n, 'The result of (-0x3n % 0x3n) is 0x0n'); +assert.sameValue(-0x3n % 0x2n, -0x1n, 'The result of (-0x3n % 0x2n) is -0x1n'); +assert.sameValue(-0x3n % 0x1n, 0x0n, 'The result of (-0x3n % 0x1n) is 0x0n'); +assert.sameValue(-0x3n % -0x1n, 0x0n, 'The result of (-0x3n % -0x1n) is 0x0n'); +assert.sameValue(-0x3n % -0x2n, -0x1n, 'The result of (-0x3n % -0x2n) is -0x1n'); +assert.sameValue(-0x3n % -0x3n, 0x0n, 'The result of (-0x3n % -0x3n) is 0x0n'); +assert.sameValue(-0x3n % -0x1234n, -0x3n, 'The result of (-0x3n % -0x1234n) is -0x3n'); +assert.sameValue(-0x3n % -0xFEDCBA97n, -0x3n, 'The result of (-0x3n % -0xFEDCBA97n) is -0x3n'); +assert.sameValue(-0x3n % -0xFEDCBA98n, -0x3n, 'The result of (-0x3n % -0xFEDCBA98n) is -0x3n'); + +assert.sameValue( + -0x3n % -0xFEDCBA987654320Fn, + -0x3n, + 'The result of (-0x3n % -0xFEDCBA987654320Fn) is -0x3n' +); + +assert.sameValue( + -0x3n % -0xFEDCBA9876543210n, + -0x3n, + 'The result of (-0x3n % -0xFEDCBA9876543210n) is -0x3n' +); + +assert.sameValue( + -0x1234n % 0xFEDCBA9876543210n, + -0x1234n, + 'The result of (-0x1234n % 0xFEDCBA9876543210n) is -0x1234n' +); + +assert.sameValue( + -0x1234n % 0xFEDCBA987654320Fn, + -0x1234n, + 'The result of (-0x1234n % 0xFEDCBA987654320Fn) is -0x1234n' +); + +assert.sameValue( + -0x1234n % 0xFEDCBA98n, + -0x1234n, + 'The result of (-0x1234n % 0xFEDCBA98n) is -0x1234n' +); + +assert.sameValue( + -0x1234n % 0xFEDCBA97n, + -0x1234n, + 'The result of (-0x1234n % 0xFEDCBA97n) is -0x1234n' +); + +assert.sameValue(-0x1234n % 0x1234n, 0x0n, 'The result of (-0x1234n % 0x1234n) is 0x0n'); +assert.sameValue(-0x1234n % 0x3n, -0x1n, 'The result of (-0x1234n % 0x3n) is -0x1n'); +assert.sameValue(-0x1234n % 0x2n, 0x0n, 'The result of (-0x1234n % 0x2n) is 0x0n'); +assert.sameValue(-0x1234n % 0x1n, 0x0n, 'The result of (-0x1234n % 0x1n) is 0x0n'); +assert.sameValue(-0x1234n % -0x1n, 0x0n, 'The result of (-0x1234n % -0x1n) is 0x0n'); +assert.sameValue(-0x1234n % -0x2n, 0x0n, 'The result of (-0x1234n % -0x2n) is 0x0n'); +assert.sameValue(-0x1234n % -0x3n, -0x1n, 'The result of (-0x1234n % -0x3n) is -0x1n'); +assert.sameValue(-0x1234n % -0x1234n, 0x0n, 'The result of (-0x1234n % -0x1234n) is 0x0n'); + +assert.sameValue( + -0x1234n % -0xFEDCBA97n, + -0x1234n, + 'The result of (-0x1234n % -0xFEDCBA97n) is -0x1234n' +); + +assert.sameValue( + -0x1234n % -0xFEDCBA98n, + -0x1234n, + 'The result of (-0x1234n % -0xFEDCBA98n) is -0x1234n' +); + +assert.sameValue( + -0x1234n % -0xFEDCBA987654320Fn, + -0x1234n, + 'The result of (-0x1234n % -0xFEDCBA987654320Fn) is -0x1234n' +); + +assert.sameValue( + -0x1234n % -0xFEDCBA9876543210n, + -0x1234n, + 'The result of (-0x1234n % -0xFEDCBA9876543210n) is -0x1234n' +); + +assert.sameValue( + -0xFEDCBA97n % 0xFEDCBA9876543210n, + -0xFEDCBA97n, + 'The result of (-0xFEDCBA97n % 0xFEDCBA9876543210n) is -0xFEDCBA97n' +); + +assert.sameValue( + -0xFEDCBA97n % 0xFEDCBA987654320Fn, + -0xFEDCBA97n, + 'The result of (-0xFEDCBA97n % 0xFEDCBA987654320Fn) is -0xFEDCBA97n' +); + +assert.sameValue( + -0xFEDCBA97n % 0xFEDCBA98n, + -0xFEDCBA97n, + 'The result of (-0xFEDCBA97n % 0xFEDCBA98n) is -0xFEDCBA97n' +); + +assert.sameValue( + -0xFEDCBA97n % 0xFEDCBA97n, + 0x0n, + 'The result of (-0xFEDCBA97n % 0xFEDCBA97n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA97n % 0x1234n, + -0x92Fn, + 'The result of (-0xFEDCBA97n % 0x1234n) is -0x92Fn' +); + +assert.sameValue(-0xFEDCBA97n % 0x3n, -0x1n, 'The result of (-0xFEDCBA97n % 0x3n) is -0x1n'); +assert.sameValue(-0xFEDCBA97n % 0x2n, -0x1n, 'The result of (-0xFEDCBA97n % 0x2n) is -0x1n'); +assert.sameValue(-0xFEDCBA97n % 0x1n, 0x0n, 'The result of (-0xFEDCBA97n % 0x1n) is 0x0n'); +assert.sameValue(-0xFEDCBA97n % -0x1n, 0x0n, 'The result of (-0xFEDCBA97n % -0x1n) is 0x0n'); +assert.sameValue(-0xFEDCBA97n % -0x2n, -0x1n, 'The result of (-0xFEDCBA97n % -0x2n) is -0x1n'); +assert.sameValue(-0xFEDCBA97n % -0x3n, -0x1n, 'The result of (-0xFEDCBA97n % -0x3n) is -0x1n'); + +assert.sameValue( + -0xFEDCBA97n % -0x1234n, + -0x92Fn, + 'The result of (-0xFEDCBA97n % -0x1234n) is -0x92Fn' +); + +assert.sameValue( + -0xFEDCBA97n % -0xFEDCBA97n, + 0x0n, + 'The result of (-0xFEDCBA97n % -0xFEDCBA97n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA97n % -0xFEDCBA98n, + -0xFEDCBA97n, + 'The result of (-0xFEDCBA97n % -0xFEDCBA98n) is -0xFEDCBA97n' +); + +assert.sameValue( + -0xFEDCBA97n % -0xFEDCBA987654320Fn, + -0xFEDCBA97n, + 'The result of (-0xFEDCBA97n % -0xFEDCBA987654320Fn) is -0xFEDCBA97n' +); + +assert.sameValue( + -0xFEDCBA97n % -0xFEDCBA9876543210n, + -0xFEDCBA97n, + 'The result of (-0xFEDCBA97n % -0xFEDCBA9876543210n) is -0xFEDCBA97n' +); + +assert.sameValue( + -0xFEDCBA98n % 0xFEDCBA9876543210n, + -0xFEDCBA98n, + 'The result of (-0xFEDCBA98n % 0xFEDCBA9876543210n) is -0xFEDCBA98n' +); + +assert.sameValue( + -0xFEDCBA98n % 0xFEDCBA987654320Fn, + -0xFEDCBA98n, + 'The result of (-0xFEDCBA98n % 0xFEDCBA987654320Fn) is -0xFEDCBA98n' +); + +assert.sameValue( + -0xFEDCBA98n % 0xFEDCBA98n, + 0x0n, + 'The result of (-0xFEDCBA98n % 0xFEDCBA98n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA98n % 0xFEDCBA97n, + -0x1n, + 'The result of (-0xFEDCBA98n % 0xFEDCBA97n) is -0x1n' +); + +assert.sameValue( + -0xFEDCBA98n % 0x1234n, + -0x930n, + 'The result of (-0xFEDCBA98n % 0x1234n) is -0x930n' +); + +assert.sameValue(-0xFEDCBA98n % 0x3n, -0x2n, 'The result of (-0xFEDCBA98n % 0x3n) is -0x2n'); +assert.sameValue(-0xFEDCBA98n % 0x2n, 0x0n, 'The result of (-0xFEDCBA98n % 0x2n) is 0x0n'); +assert.sameValue(-0xFEDCBA98n % 0x1n, 0x0n, 'The result of (-0xFEDCBA98n % 0x1n) is 0x0n'); +assert.sameValue(-0xFEDCBA98n % -0x1n, 0x0n, 'The result of (-0xFEDCBA98n % -0x1n) is 0x0n'); +assert.sameValue(-0xFEDCBA98n % -0x2n, 0x0n, 'The result of (-0xFEDCBA98n % -0x2n) is 0x0n'); +assert.sameValue(-0xFEDCBA98n % -0x3n, -0x2n, 'The result of (-0xFEDCBA98n % -0x3n) is -0x2n'); + +assert.sameValue( + -0xFEDCBA98n % -0x1234n, + -0x930n, + 'The result of (-0xFEDCBA98n % -0x1234n) is -0x930n' +); + +assert.sameValue( + -0xFEDCBA98n % -0xFEDCBA97n, + -0x1n, + 'The result of (-0xFEDCBA98n % -0xFEDCBA97n) is -0x1n' +); + +assert.sameValue( + -0xFEDCBA98n % -0xFEDCBA98n, + 0x0n, + 'The result of (-0xFEDCBA98n % -0xFEDCBA98n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA98n % -0xFEDCBA987654320Fn, + -0xFEDCBA98n, + 'The result of (-0xFEDCBA98n % -0xFEDCBA987654320Fn) is -0xFEDCBA98n' +); + +assert.sameValue( + -0xFEDCBA98n % -0xFEDCBA9876543210n, + -0xFEDCBA98n, + 'The result of (-0xFEDCBA98n % -0xFEDCBA9876543210n) is -0xFEDCBA98n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0xFEDCBA9876543210n, + -0xFEDCBA987654320Fn, + 'The result of (-0xFEDCBA987654320Fn % 0xFEDCBA9876543210n) is -0xFEDCBA987654320Fn' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0xFEDCBA987654320Fn, + 0x0n, + 'The result of (-0xFEDCBA987654320Fn % 0xFEDCBA987654320Fn) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0xFEDCBA98n, + -0x7654320Fn, + 'The result of (-0xFEDCBA987654320Fn % 0xFEDCBA98n) is -0x7654320Fn' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0xFEDCBA97n, + -0x77777778n, + 'The result of (-0xFEDCBA987654320Fn % 0xFEDCBA97n) is -0x77777778n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0x1234n, + -0x95Fn, + 'The result of (-0xFEDCBA987654320Fn % 0x1234n) is -0x95Fn' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0x3n, + -0x2n, + 'The result of (-0xFEDCBA987654320Fn % 0x3n) is -0x2n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0x2n, + -0x1n, + 'The result of (-0xFEDCBA987654320Fn % 0x2n) is -0x1n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % 0x1n, + 0x0n, + 'The result of (-0xFEDCBA987654320Fn % 0x1n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0x1n, + 0x0n, + 'The result of (-0xFEDCBA987654320Fn % -0x1n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0x2n, + -0x1n, + 'The result of (-0xFEDCBA987654320Fn % -0x2n) is -0x1n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0x3n, + -0x2n, + 'The result of (-0xFEDCBA987654320Fn % -0x3n) is -0x2n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0x1234n, + -0x95Fn, + 'The result of (-0xFEDCBA987654320Fn % -0x1234n) is -0x95Fn' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0xFEDCBA97n, + -0x77777778n, + 'The result of (-0xFEDCBA987654320Fn % -0xFEDCBA97n) is -0x77777778n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0xFEDCBA98n, + -0x7654320Fn, + 'The result of (-0xFEDCBA987654320Fn % -0xFEDCBA98n) is -0x7654320Fn' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0xFEDCBA987654320Fn, + 0x0n, + 'The result of (-0xFEDCBA987654320Fn % -0xFEDCBA987654320Fn) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA987654320Fn % -0xFEDCBA9876543210n, + -0xFEDCBA987654320Fn, + 'The result of (-0xFEDCBA987654320Fn % -0xFEDCBA9876543210n) is -0xFEDCBA987654320Fn' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0xFEDCBA9876543210n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % 0xFEDCBA9876543210n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0xFEDCBA987654320Fn, + -0x1n, + 'The result of (-0xFEDCBA9876543210n % 0xFEDCBA987654320Fn) is -0x1n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0xFEDCBA98n, + -0x76543210n, + 'The result of (-0xFEDCBA9876543210n % 0xFEDCBA98n) is -0x76543210n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0xFEDCBA97n, + -0x77777779n, + 'The result of (-0xFEDCBA9876543210n % 0xFEDCBA97n) is -0x77777779n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0x1234n, + -0x960n, + 'The result of (-0xFEDCBA9876543210n % 0x1234n) is -0x960n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0x3n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % 0x3n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0x2n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % 0x2n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % 0x1n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % 0x1n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0x1n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % -0x1n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0x2n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % -0x2n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0x3n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % -0x3n) is 0x0n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0x1234n, + -0x960n, + 'The result of (-0xFEDCBA9876543210n % -0x1234n) is -0x960n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0xFEDCBA97n, + -0x77777779n, + 'The result of (-0xFEDCBA9876543210n % -0xFEDCBA97n) is -0x77777779n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0xFEDCBA98n, + -0x76543210n, + 'The result of (-0xFEDCBA9876543210n % -0xFEDCBA98n) is -0x76543210n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0xFEDCBA987654320Fn, + -0x1n, + 'The result of (-0xFEDCBA9876543210n % -0xFEDCBA987654320Fn) is -0x1n' +); + +assert.sameValue( + -0xFEDCBA9876543210n % -0xFEDCBA9876543210n, + 0x0n, + 'The result of (-0xFEDCBA9876543210n % -0xFEDCBA9876543210n) is 0x0n' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/bigint-errors.js b/js/src/tests/test262/language/expressions/modulus/bigint-errors.js new file mode 100644 index 0000000000..87936c2436 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/bigint-errors.js @@ -0,0 +1,72 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: modulus operator ToNumeric with BigInt operands +esid: sec-multiplicative-operators-runtime-semantics-evaluation +features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names] +---*/ +assert.throws(TypeError, function() { + Symbol('1') % 1n; +}, 'Symbol("1") % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % Symbol('1'); +}, '0n % Symbol("1") throws TypeError'); + +assert.throws(TypeError, function() { + Object(Symbol('1')) % 1n; +}, 'Object(Symbol("1")) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % Object(Symbol('1')); +}, '0n % Object(Symbol("1")) throws TypeError'); + +assert.throws(TypeError, function() { + ({ + [Symbol.toPrimitive]: function() { + return Symbol('1'); + } + }) % 1n; +}, '({[Symbol.toPrimitive]: function() {return Symbol("1");}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + [Symbol.toPrimitive]: function() { + return Symbol('1'); + } + }; +}, '0n % {[Symbol.toPrimitive]: function() {return Symbol("1");}} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + valueOf: function() { + return Symbol('1'); + } + }) % 1n; +}, '({valueOf: function() {return Symbol("1");}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + valueOf: function() { + return Symbol('1'); + } + }; +}, '0n % {valueOf: function() {return Symbol("1");}} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + toString: function() { + return Symbol('1'); + } + }) % 1n; +}, '({toString: function() {return Symbol("1");}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + toString: function() { + return Symbol('1'); + } + }; +}, '0n % {toString: function() {return Symbol("1");}} throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/bigint-modulo-zero.js b/js/src/tests/test262/language/expressions/modulus/bigint-modulo-zero.js new file mode 100644 index 0000000000..bb72bd692e --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/bigint-modulo-zero.js @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: BigInt modulo 0 throws a range error +esid: sec-multiplicative-operators-runtime-semantics-evaluation +info: | + Runtime Semantics: Evaluation + + MultiplicativeExpression: MultiplicativeExpression MultiplicativeOperator ExponentiationExpression + + ... + 12. Otherwise, MultiplicativeOperator is %; return T::remainder(lnum, rnum). + ... + + BigInt::remainder (x, y) + + 1. If y is 0n, throw a RangeError exception. + 2. Return the BigInt representing x modulo y. +features: [BigInt] +---*/ +assert.throws(RangeError, function() { + 1n % 0n; +}, '1n % 0n throws RangeError'); + +assert.throws(RangeError, function() { + 10n % 0n; +}, '10n % 0n throws RangeError'); + +assert.throws(RangeError, function() { + 0n % 0n; +}, '0n % 0n throws RangeError'); + +assert.throws(RangeError, function() { + 1000000000000000000n % 0n; +}, '1000000000000000000n % 0n throws RangeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/bigint-toprimitive.js b/js/src/tests/test262/language/expressions/modulus/bigint-toprimitive.js new file mode 100644 index 0000000000..0ad86f9959 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/bigint-toprimitive.js @@ -0,0 +1,374 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: modulus operator ToNumeric with BigInt operands +esid: sec-multiplicative-operators-runtime-semantics-evaluation +features: [BigInt, Symbol.toPrimitive, computed-property-names] +---*/ +function err() { + throw new Test262Error(); +} + +function MyError() {} + +assert.sameValue({ + [Symbol.toPrimitive]: function() { + return 2n; + }, + + valueOf: err, + toString: err +} % 2n, 0n, 'The result of (({[Symbol.toPrimitive]: function() {return 2n;}, valueOf: err, toString: err}) % 2n) is 0n'); + +assert.sameValue(2n % { + [Symbol.toPrimitive]: function() { + return 2n; + }, + + valueOf: err, + toString: err +}, 0n, 'The result of (2n % {[Symbol.toPrimitive]: function() {return 2n;}, valueOf: err, toString: err}) is 0n'); + +assert.sameValue({ + valueOf: function() { + return 2n; + }, + + toString: err +} % 2n, 0n, 'The result of (({valueOf: function() {return 2n;}, toString: err}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: function() { + return 2n; + }, + + toString: err +}, 0n, 'The result of (2n % {valueOf: function() {return 2n;}, toString: err}) is 0n'); + +assert.sameValue({ + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {toString: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + [Symbol.toPrimitive]: undefined, + + valueOf: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({[Symbol.toPrimitive]: undefined, valueOf: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + [Symbol.toPrimitive]: undefined, + + valueOf: function() { + return 2n; + } +}, 0n, 'The result of (2n % {[Symbol.toPrimitive]: undefined, valueOf: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + [Symbol.toPrimitive]: null, + + valueOf: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({[Symbol.toPrimitive]: null, valueOf: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + [Symbol.toPrimitive]: null, + + valueOf: function() { + return 2n; + } +}, 0n, 'The result of (2n % {[Symbol.toPrimitive]: null, valueOf: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + valueOf: null, + + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({valueOf: null, toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: null, + + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {valueOf: null, toString: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + valueOf: 1, + + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({valueOf: 1, toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: 1, + + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {valueOf: 1, toString: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + valueOf: {}, + + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({valueOf: {}, toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: {}, + + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {valueOf: {}, toString: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + valueOf: function() { + return {}; + }, + + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({valueOf: function() {return {};}, toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: function() { + return {}; + }, + + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {valueOf: function() {return {};}, toString: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + valueOf: function() { + return Object(12345); + }, + + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({valueOf: function() {return Object(12345);}, toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: function() { + return Object(12345); + }, + + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {valueOf: function() {return Object(12345);}, toString: function() {return 2n;}}) is 0n'); + +assert.throws(TypeError, function() { + ({ + [Symbol.toPrimitive]: 1 + }) % 1n; +}, '({[Symbol.toPrimitive]: 1}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + [Symbol.toPrimitive]: 1 + }; +}, '0n % {[Symbol.toPrimitive]: 1} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + [Symbol.toPrimitive]: {} + }) % 1n; +}, '({[Symbol.toPrimitive]: {}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + [Symbol.toPrimitive]: {} + }; +}, '0n % {[Symbol.toPrimitive]: {}} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + [Symbol.toPrimitive]: function() { + return Object(1); + } + }) % 1n; +}, '({[Symbol.toPrimitive]: function() {return Object(1);}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + [Symbol.toPrimitive]: function() { + return Object(1); + } + }; +}, '0n % {[Symbol.toPrimitive]: function() {return Object(1);}} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + [Symbol.toPrimitive]: function() { + return {}; + } + }) % 1n; +}, '({[Symbol.toPrimitive]: function() {return {};}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + [Symbol.toPrimitive]: function() { + return {}; + } + }; +}, '0n % {[Symbol.toPrimitive]: function() {return {};}} throws TypeError'); + +assert.throws(MyError, function() { + ({ + [Symbol.toPrimitive]: function() { + throw new MyError(); + } + }) % 1n; +}, '({[Symbol.toPrimitive]: function() {throw new MyError();}}) % 1n throws MyError'); + +assert.throws(MyError, function() { + 0n % { + [Symbol.toPrimitive]: function() { + throw new MyError(); + } + }; +}, '0n % {[Symbol.toPrimitive]: function() {throw new MyError();}} throws MyError'); + +assert.throws(MyError, function() { + ({ + valueOf: function() { + throw new MyError(); + } + }) % 1n; +}, '({valueOf: function() {throw new MyError();}}) % 1n throws MyError'); + +assert.throws(MyError, function() { + 0n % { + valueOf: function() { + throw new MyError(); + } + }; +}, '0n % {valueOf: function() {throw new MyError();}} throws MyError'); + +assert.throws(MyError, function() { + ({ + toString: function() { + throw new MyError(); + } + }) % 1n; +}, '({toString: function() {throw new MyError();}}) % 1n throws MyError'); + +assert.throws(MyError, function() { + 0n % { + toString: function() { + throw new MyError(); + } + }; +}, '0n % {toString: function() {throw new MyError();}} throws MyError'); + +assert.throws(TypeError, function() { + ({ + valueOf: null, + toString: null + }) % 1n; +}, '({valueOf: null, toString: null}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + valueOf: null, + toString: null + }; +}, '0n % {valueOf: null, toString: null} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + valueOf: 1, + toString: 1 + }) % 1n; +}, '({valueOf: 1, toString: 1}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + valueOf: 1, + toString: 1 + }; +}, '0n % {valueOf: 1, toString: 1} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + valueOf: {}, + toString: {} + }) % 1n; +}, '({valueOf: {}, toString: {}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + valueOf: {}, + toString: {} + }; +}, '0n % {valueOf: {}, toString: {}} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + valueOf: function() { + return Object(1); + }, + + toString: function() { + return Object(1); + } + }) % 1n; +}, '({valueOf: function() {return Object(1);}, toString: function() {return Object(1);}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + valueOf: function() { + return Object(1); + }, + + toString: function() { + return Object(1); + } + }; +}, '0n % {valueOf: function() {return Object(1);}, toString: function() {return Object(1);}} throws TypeError'); + +assert.throws(TypeError, function() { + ({ + valueOf: function() { + return {}; + }, + + toString: function() { + return {}; + } + }) % 1n; +}, '({valueOf: function() {return {};}, toString: function() {return {};}}) % 1n throws TypeError'); + +assert.throws(TypeError, function() { + 0n % { + valueOf: function() { + return {}; + }, + + toString: function() { + return {}; + } + }; +}, '0n % {valueOf: function() {return {};}, toString: function() {return {};}} throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/bigint-wrapped-values.js b/js/src/tests/test262/language/expressions/modulus/bigint-wrapped-values.js new file mode 100644 index 0000000000..a80b14d9f7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/bigint-wrapped-values.js @@ -0,0 +1,47 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: modulus operator ToNumeric with BigInt operands +esid: sec-multiplicative-operators-runtime-semantics-evaluation +features: [BigInt, Symbol.toPrimitive, computed-property-names] +---*/ +assert.sameValue(Object(2n) % 2n, 0n, 'The result of (Object(2n) % 2n) is 0n'); +assert.sameValue(2n % Object(2n), 0n, 'The result of (2n % Object(2n)) is 0n'); + +assert.sameValue({ + [Symbol.toPrimitive]: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({[Symbol.toPrimitive]: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + [Symbol.toPrimitive]: function() { + return 2n; + } +}, 0n, 'The result of (2n % {[Symbol.toPrimitive]: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + valueOf: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({valueOf: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + valueOf: function() { + return 2n; + } +}, 0n, 'The result of (2n % {valueOf: function() {return 2n;}}) is 0n'); + +assert.sameValue({ + toString: function() { + return 2n; + } +} % 2n, 0n, 'The result of (({toString: function() {return 2n;}}) % 2n) is 0n'); + +assert.sameValue(2n % { + toString: function() { + return 2n; + } +}, 0n, 'The result of (2n % {toString: function() {return 2n;}}) is 0n'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/browser.js b/js/src/tests/test262/language/expressions/modulus/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/browser.js diff --git a/js/src/tests/test262/language/expressions/modulus/line-terminator.js b/js/src/tests/test262/language/expressions/modulus/line-terminator.js new file mode 100644 index 0000000000..8976067330 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/line-terminator.js @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: Line terminator between the operands of a modulus operator +info: | + MultiplicativeExpression[Yield, Await]: + ExponentiationExpression + MultiplicativeExpression MultiplicativeOperator ExponentiationExpression + + MultiplicativeOperator : one of + * / % +---*/ + +var x = 18 + +% + +7 + +% + +3 +; + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/order-of-evaluation.js b/js/src/tests/test262/language/expressions/modulus/order-of-evaluation.js new file mode 100644 index 0000000000..6de970d731 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/order-of-evaluation.js @@ -0,0 +1,140 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: Type coercion order of operations for modulus operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() % (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf: function() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() % (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf: function() { + trace += "3"; + throw new MyError(); + } + }; + })() % (function() { + trace += "2"; + return { + valueOf: function() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf: function() { + trace += "3"; + return 1; + } + }; + })() % (function() { + trace += "2"; + return { + valueOf: function() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf: function() { + trace += "3"; + return Symbol("1"); + } + }; + })() % (function() { + trace += "2"; + return { + valueOf: function() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf: function() { + trace += "3"; + return 1; + } + }; + })() % (function() { + trace += "2"; + return { + valueOf: function() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/modulus/shell.js b/js/src/tests/test262/language/expressions/modulus/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/modulus/shell.js |