diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Number')
371 files changed, 11027 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Number/15.7.3-1.js b/js/src/tests/test262/built-ins/Number/15.7.3-1.js new file mode 100644 index 0000000000..de15384865 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/15.7.3-1.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.7.3-1 +description: Number constructor - [[Prototype]] is the Function prototype object +---*/ + +assert.sameValue(Function.prototype.isPrototypeOf(Number), true, 'Function.prototype.isPrototypeOf(Number)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/15.7.3-2.js b/js/src/tests/test262/built-ins/Number/15.7.3-2.js new file mode 100644 index 0000000000..bad66daf47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/15.7.3-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.7.3-2 +description: > + Number constructor - [[Prototype]] is the Function prototype + object (using getPrototypeOf) +---*/ + +var p = Object.getPrototypeOf(Number); + +assert.sameValue(p, Function.prototype, 'p'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/15.7.4-1.js b/js/src/tests/test262/built-ins/Number/15.7.4-1.js new file mode 100644 index 0000000000..405e0491f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/15.7.4-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.7.4-1 +description: "Number prototype object: its [[Class]] must be 'Number'" +---*/ + +var numProto = Object.getPrototypeOf(new Number(42)); +var s = Object.prototype.toString.call(numProto); + +assert.sameValue(s, '[object Number]', 's'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/EPSILON.js b/js/src/tests/test262/built-ins/Number/EPSILON.js new file mode 100644 index 0000000000..76382b959b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/EPSILON.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.epsilon +description: > + "EPSILON" property of Number +info: | + 20.1.2.1 Number.EPSILON + + The value of Number.EPSILON is the difference between 1 and the smallest value + greater than 1 that is representable as a Number value, which is approximately + 2.2204460492503130808472633361816 x 10-16. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert( + Number.EPSILON > 0, + "value is greater than 0" +); +assert( + Number.EPSILON < 0.000001, + "value is smaller than 0.000001" +); + +verifyNotEnumerable(Number, "EPSILON"); +verifyNotWritable(Number, "EPSILON"); +verifyNotConfigurable(Number, "EPSILON"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MAX_SAFE_INTEGER.js b/js/src/tests/test262/built-ins/Number/MAX_SAFE_INTEGER.js new file mode 100644 index 0000000000..9191a6e81f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_SAFE_INTEGER.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Property descriptor for `Number.MAX_SAFE_INTEGER` +esid: sec-number.max_safe_integer +info: | + The value of Number.MAX_SAFE_INTEGER is 9007199254740991 + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Number, 'MAX_SAFE_INTEGER'); + +assert.sameValue(desc.set, undefined, 'Does not define a `get` accessor'); +assert.sameValue(desc.get, undefined, 'Does not define a `set` accessor'); +assert.sameValue(desc.value, 9007199254740991); + +verifyNotEnumerable(Number, 'MAX_SAFE_INTEGER'); +verifyNotWritable(Number, 'MAX_SAFE_INTEGER'); +verifyNotConfigurable(Number, 'MAX_SAFE_INTEGER'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A2.js b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A2.js new file mode 100644 index 0000000000..192f1b27f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.MAX_VALUE is ReadOnly +es5id: 15.7.3.2_A2 +description: Checking if varying Number.MAX_VALUE fails +includes: [propertyHelper.js] +---*/ + +// CHECK#1 +var x = Number.MAX_VALUE; +verifyNotWritable(Number, "MAX_VALUE", null, 1); +if (Number.MAX_VALUE !== x) { + $ERROR('#1: x = Number.MAX_VALUE; Number.MAX_VALUE = 1; Number.MAX_VALUE === x'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A3.js b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A3.js new file mode 100644 index 0000000000..5529b7a4b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.MAX_VALUE is DontDelete +es5id: 15.7.3.2_A3 +description: Checking if deleting Number.MAX_VALUE fails +includes: [propertyHelper.js] +---*/ + +verifyNotConfigurable(Number, "MAX_VALUE"); + +// CHECK#1 +try { + if (delete Number.MAX_VALUE !== false) { + $ERROR('#1: delete Number.MAX_VALUE === false'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A4.js b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A4.js new file mode 100644 index 0000000000..39f499b4e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A4.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: Number.MAX_VALUE has the attribute DontEnum +es5id: 15.7.3.2_A4 +description: Checking if enumerating Number.MAX_VALUE fails +---*/ + +//CHECK#1 +for (var x in Number) { + if (x === "MAX_VALUE") { + $ERROR('#1: Number.MAX_VALUE has the attribute DontEnum'); + } +} + +if (Number.propertyIsEnumerable('MAX_VALUE')) { + $ERROR('#2: Number.MAX_VALUE has the attribute DontEnum'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MAX_VALUE/browser.js b/js/src/tests/test262/built-ins/Number/MAX_VALUE/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_VALUE/browser.js diff --git a/js/src/tests/test262/built-ins/Number/MAX_VALUE/shell.js b/js/src/tests/test262/built-ins/Number/MAX_VALUE/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_VALUE/shell.js diff --git a/js/src/tests/test262/built-ins/Number/MIN_SAFE_INTEGER.js b/js/src/tests/test262/built-ins/Number/MIN_SAFE_INTEGER.js new file mode 100644 index 0000000000..34041f5506 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_SAFE_INTEGER.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Property descriptor for `Number.MIN_SAFE_INTEGER` +esid: sec-number.min_safe_integer +info: | + The value of Number.MIN_SAFE_INTEGER is −9007199254740991 + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Number, 'MIN_SAFE_INTEGER'); + +assert.sameValue(desc.set, undefined, 'Does not define a `get` accessor'); +assert.sameValue(desc.get, undefined, 'Does not define a `set` accessor'); +assert.sameValue(desc.value, -9007199254740991); + +verifyNotEnumerable(Number, 'MIN_SAFE_INTEGER'); +verifyNotWritable(Number, 'MIN_SAFE_INTEGER'); +verifyNotConfigurable(Number, 'MIN_SAFE_INTEGER'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A2.js b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A2.js new file mode 100644 index 0000000000..20bf62940c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.MIN_VALUE is ReadOnly +es5id: 15.7.3.3_A2 +description: Checking if varying Number.MIN_VALUE fails +includes: [propertyHelper.js] +---*/ + +// CHECK#1 +var x = Number.MIN_VALUE; +verifyNotWritable(Number, "MIN_VALUE", null, 1); +if (Number.MIN_VALUE !== x) { + $ERROR('#1: x = Number.MIN_VALUE; Number.MIN_VALUE = 1; Number.MIN_VALUE === x'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A3.js b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A3.js new file mode 100644 index 0000000000..725531d28e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.MIN_VALUE is DontDelete +es5id: 15.7.3.3_A3 +description: Checking if deleting Number.MIN_VALUE fails +includes: [propertyHelper.js] +---*/ + +verifyNotConfigurable(Number, "MIN_VALUE"); + +//CHECK#1 +try { + if (delete Number.MIN_VALUE !== false) { + $ERROR('#1: delete Number.MIN_VALUE === false'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A4.js b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A4.js new file mode 100644 index 0000000000..3ca98e3900 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A4.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: Number.MIN_VALUE has the attribute DontEnum +es5id: 15.7.3.3_A4 +description: Checking if enumerating Number.MIN_VALUE fails +---*/ + +//CHECK#1 +for (var x in Number) { + if (x === "MIN_VALUE") { + $ERROR('#1: Number.MIN_VALUE has the attribute DontEnum'); + } +} + +if (Number.propertyIsEnumerable('MIN_VALUE')) { + $ERROR('#2: Number.MIN_VALUE has the attribute DontEnum'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/MIN_VALUE/browser.js b/js/src/tests/test262/built-ins/Number/MIN_VALUE/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_VALUE/browser.js diff --git a/js/src/tests/test262/built-ins/Number/MIN_VALUE/shell.js b/js/src/tests/test262/built-ins/Number/MIN_VALUE/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_VALUE/shell.js diff --git a/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A1.js b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A1.js new file mode 100644 index 0000000000..61b17745cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.NEGATIVE_INFINITY is -Infinity +es5id: 15.7.3.5_A1 +description: Checking sign and finiteness of Number.NEGATIVE_INFINITY +---*/ + +// CHECK#1 +if (isFinite(Number.NEGATIVE_INFINITY) !== false) { + $ERROR('#1: Number.NEGATIVE_INFINITY === Not-a-Finite'); +} else { + if ((Number.NEGATIVE_INFINITY < 0) !== true) { + $ERROR('#1: Number.NEGATIVE_INFINITY === -Infinity'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A2.js b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A2.js new file mode 100644 index 0000000000..4aaa931183 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A2.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: Number.NEGATIVE_INFINITY is ReadOnly +es5id: 15.7.3.5_A2 +description: Checking if varying Number.NEGATIVE_INFINITY fails +includes: [propertyHelper.js] +---*/ + +// CHECK#1 +verifyNotWritable(Number, "NEGATIVE_INFINITY", null, 1); +if (isFinite(Number.NEGATIVE_INFINITY)) { + $ERROR('#1: Number.NEGATIVE_INFINITY = 1; Number.NEGATIVE_INFINITY === -Infinity'); +} else { + if (Number.NEGATIVE_INFINITY >= 0) { + $ERROR('#1: Number.NEGATIVE_INFINITY = 1; Number.NEGATIVE_INFINITY === -Infinity'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/browser.js b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/browser.js diff --git a/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/prop-desc.js b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/prop-desc.js new file mode 100644 index 0000000000..43487219d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/prop-desc.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.negative_infinity +description: > + "NEGATIVE_INFINITY" property of Number +info: | + Number.NEGATIVE_INFINITY + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "NEGATIVE_INFINITY"); +verifyNotWritable(Number, "NEGATIVE_INFINITY"); +verifyNotConfigurable(Number, "NEGATIVE_INFINITY"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/shell.js b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/shell.js diff --git a/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/value.js b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/value.js new file mode 100644 index 0000000000..6a874bdce0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/value.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.negative_infinity +description: > + The value of Number.NEGATIVE_INFINITY is -Infinity +info: | + Number.NEGATIVE_INFINITY + + The value of Number.NEGATIVE_INFINITY is -∞. +---*/ + +assert.sameValue(Number.NEGATIVE_INFINITY, -Infinity); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/NaN.js b/js/src/tests/test262/built-ins/Number/NaN.js new file mode 100644 index 0000000000..b2cb77c9e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NaN.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.nan +description: > + "NaN" property descriptor and value of Number +info: | + 20.1.2.10 Number.NaN + + The value of Number.NaN is NaN. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.NaN, NaN); + +verifyNotEnumerable(Number, "NaN"); +verifyNotWritable(Number, "NaN"); +verifyNotConfigurable(Number, "NaN"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A1.js b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A1.js new file mode 100644 index 0000000000..7861346ab3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.POSITIVE_INFINITY is +Infinity +es5id: 15.7.3.6_A1 +description: Checking sign and finiteness of Number.POSITIVE_INFINITY +---*/ + +// CHECK#1 +if (isFinite(Number.POSITIVE_INFINITY) !== false) { + $ERROR('#1: Number.POSITIVE_INFINITY === Not-a-Finite'); +} else { + if ((Number.POSITIVE_INFINITY > 0) !== true) { + $ERROR('#1: Number.POSITIVE_INFINITY === +Infinity'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A2.js b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A2.js new file mode 100644 index 0000000000..c8cb33d695 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A2.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: Number.POSITIVE_INFINITY is ReadOnly +es5id: 15.7.3.6_A2 +description: Checking if varying Number.POSITIVE_INFINITY fails +includes: [propertyHelper.js] +---*/ + +// CHECK#1 +verifyNotWritable(Number, "POSITIVE_INFINITY", null, 1); +if (isFinite(Number.POSITIVE_INFINITY)) { + $ERROR('#1: Number.POSITIVE_INFINITY = 1; Number.POSITIVE_INFINITY === +Infinity'); +} else { + if (Number.POSITIVE_INFINITY <= 0) { + $ERROR('#1: Number.POSITIVE_INFINITY = 1; Number.POSITIVE_INFINITY === +Infinity'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/browser.js b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/browser.js diff --git a/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/prop-desc.js b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/prop-desc.js new file mode 100644 index 0000000000..1f3ceb0ce6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/prop-desc.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.positive_infinity +description: > + "POSITIVE_INFINITY" property of Number +info: | + Number.POSITIVE_INFINITY + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "POSITIVE_INFINITY"); +verifyNotWritable(Number, "POSITIVE_INFINITY"); +verifyNotConfigurable(Number, "POSITIVE_INFINITY"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/shell.js b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/shell.js diff --git a/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/value.js b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/value.js new file mode 100644 index 0000000000..4bb44cf491 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/value.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.positive_infinity +description: > + The value of Number.POSITIVE_INFINITY is +Infinity +info: | + Number.POSITIVE_INFINITY + + The value of Number.POSITIVE_INFINITY is +∞. +---*/ + +assert.sameValue(Number.POSITIVE_INFINITY, Infinity); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.1.1_A1.js b/js/src/tests/test262/built-ins/Number/S15.7.1.1_A1.js new file mode 100644 index 0000000000..7ffcd4af56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.1.1_A1.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Number([value]) returns a number value (not a Number object) computed by + ToNumber(value) if value was supplied +es5id: 15.7.1.1_A1 +description: Used values "10", 10, new String("10"), new Object(10) and "abc" +---*/ + +//CHECK#1 +if (typeof Number("10") !== "number") { + $ERROR('#1: typeof Number("10") should be "number", actual is "' + typeof Number("10") + '"'); +} + +//CHECK#2 +if (typeof Number(10) !== "number") { + $ERROR('#2: typeof Number(10) should be "number", actual is "' + typeof Number(10) + '"'); +} + +//CHECK#3 +if (typeof Number(new String("10")) !== "number") { + $ERROR('#3: typeof Number(new String("10")) should be "number", actual is "' + typeof Number(new String("10")) + '"'); +} + +//CHECK#4 +if (typeof Number(new Object(10)) !== "number") { + $ERROR('#4: typeof Number(new Object(10)) should be "number", actual is "' + typeof Number(new Object(10)) + '"'); +} + +//CHECK #5 +assert.sameValue(Number("abc"), NaN, "Number('abc')"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.1.1_A2.js b/js/src/tests/test262/built-ins/Number/S15.7.1.1_A2.js new file mode 100644 index 0000000000..f349ec370a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.1.1_A2.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: Number() returns +0 +es5id: 15.7.1.1_A2 +description: Call Number() and check result +---*/ + +//CHECK#1 +if (typeof Number() !== "number") { + $ERROR('#1: typeof Number() should be "number", actual is "' + typeof Number() + '"'); +} + +//CHECK#2 +if (Number() !== 0) { + $ERROR('#2: Number() === 0, actual is ' + Number()); +} else if (1 / Number() !== Number.POSITIVE_INFINITY) { + $ERROR('#2: Number() === +0, actual is ' + Number()); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.2.1_A1.js b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A1.js new file mode 100644 index 0000000000..be83079545 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A1.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Number is called as part of a new expression it is + a constructor: it initialises the newly created object +es5id: 15.7.2.1_A1 +description: Checking type of the newly created object and it value +---*/ + +//CHECK#1 +if (typeof new Number() !== "object") { + $ERROR("#1: typeof new Number() === 'object'"); +} + +//CHECK#2 +if (new Number() === undefined) { + $ERROR("#2: new Number() should not be undefined"); +} + +//CHECK#3 +var x3 = new Number(); +if (typeof x3 !== "object") { + $ERROR("#3: typeof new Number() === 'object'"); +} + +//CHECK#4 +var x4 = new Number(); +if (x4 === undefined) { + $ERROR("#4: new Number() should not be undefined"); +} + +//CHECK#5 +if (typeof new Number(10) !== "object") { + $ERROR("#5: typeof new Number(10) === 'object'"); +} + +//CHECK#6 +if (new Number(10) === undefined) { + $ERROR("#6: new Number(10) should not be undefined"); +} + +//CHECK#7 +var x7 = new Number(10); +if (typeof x7 !== "object") { + $ERROR("#7: typeof new Number(10) === 'object'"); +} + +//CHECK#8 +var x8 = new Number(10); +if (x8 === undefined) { + $ERROR("#8: new Number(10) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.2.1_A2.js b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A2.js new file mode 100644 index 0000000000..85e062128c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A2.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Number prototype object, the one that is the + initial value of Number.prototype +es5id: 15.7.2.1_A2 +description: Checking prototype property of the newly created objects +---*/ + +// CHECK#1 +var x1 = new Number(1); +if (typeof x1.constructor.prototype !== "object") { + $ERROR('#1: typeof x1.constructor.prototype === "object"'); +} + +//CHECK#2 +var x2 = new Number(2); +if (!Number.prototype.isPrototypeOf(x2)) { + $ERROR('#2: Number.prototype.isPrototypeOf(x2)'); +} + +//CHECK#3 +var x3 = new Number(3); +if (Number.prototype !== x3.constructor.prototype) { + $ERROR('#3: Number.prototype === x3.constructor.prototype'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.2.1_A3.js b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A3.js new file mode 100644 index 0000000000..de4b64c3c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A3.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: | + The [[Value]] property of the newly constructed object + is set to ToNumber(value) if value was supplied, else to +0 +es5id: 15.7.2.1_A3 +description: Checking value of the newly created object +---*/ + +//CHECK#1 +var x1 = new Number(1); +if (x1.valueOf() !== 1) { + $ERROR('#1: var x1 = new Number(1); x1.valueOf() === 1'); +} + +//CHECK#2 +var x2 = new Number(); +if (x2.valueOf() !== 0) { + $ERROR('#2.1: var x2 = new Number(); x2.valueOf() === 0'); +} else if (1 / x2.valueOf() !== Number.POSITIVE_INFINITY) { + $ERROR('#2.2: var x2 = new Number(); x2.valueOf() === +0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.2.1_A4.js b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A4.js new file mode 100644 index 0000000000..ab7b3efcc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A4.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: | + The [[Class]] property of the newly constructed object + is set to "Number" +es5id: 15.7.2.1_A4 +description: For testing toString function is used +---*/ + +delete Number.prototype.toString; + +var obj = new Number(); + +//CHECK#1 +if (obj.toString() !== "[object Number]") { + $ERROR('#1: The [[Class]] property of the newly constructed object is set to "Number"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A1.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A1.js new file mode 100644 index 0000000000..c04d6a384d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number constructor has the property "prototype" +es5id: 15.7.3_A1 +description: Checking existence of the property "prototype" +---*/ + +if (!Number.hasOwnProperty("prototype")) { + $ERROR('#1: The Number constructor has the property "prototype"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A2.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A2.js new file mode 100644 index 0000000000..b894877028 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A2.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number constructor has the property "MAX_VALUE" +es5id: 15.7.3_A2 +description: Checking existence of the property "MAX_VALUE" +---*/ + +if (!Number.hasOwnProperty("MAX_VALUE")) { + $ERROR('#1: The Number constructor has the property "MAX_VALUE"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A3.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A3.js new file mode 100644 index 0000000000..aedeb6cdaf --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A3.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number constructor has the property "MIN_VALUE" +es5id: 15.7.3_A3 +description: Checking existence of the property "MIN_VALUE" +---*/ + +if (!Number.hasOwnProperty("MIN_VALUE")) { + $ERROR('#1: The Number constructor has the property "MIN_VALUE"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A4.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A4.js new file mode 100644 index 0000000000..241a0c6040 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A4.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number constructor has the property "NaN" +es5id: 15.7.3_A4 +description: Checking existence of the property "NaN" +---*/ + +if (!Number.hasOwnProperty("NaN")) { + $ERROR('#1: The Number constructor has the property "NaN"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A5.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A5.js new file mode 100644 index 0000000000..48b328308f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A5.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number constructor has the property "NEGATIVE_INFINITY" +es5id: 15.7.3_A5 +description: Checking existence of the property "NEGATIVE_INFINITY" +---*/ + +if (!Number.hasOwnProperty("NEGATIVE_INFINITY")) { + $ERROR('#1: The Number constructor has the property "NEGATIVE_INFINITY"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A6.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A6.js new file mode 100644 index 0000000000..3c7b3e1b52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A6.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number constructor has the property "POSITIVE_INFINITY" +es5id: 15.7.3_A6 +description: Checking existence of the property "POSITIVE_INFINITY" +---*/ + +if (!Number.hasOwnProperty("POSITIVE_INFINITY")) { + $ERROR('#1: The Number constructor has the property "POSITIVE_INFINITY"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A7.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A7.js new file mode 100644 index 0000000000..e7fb024b6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A7.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the Number + constructor is the Function prototype object +es5id: 15.7.3_A7 +description: Checking Function.prototype.isPrototypeOf(Number) +---*/ + +//CHECK#1 +if (!(Function.prototype.isPrototypeOf(Number))) { + $ERROR('#1: the value of the internal [[Prototype]] property of the Number constructor is the Function prototype object.'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.3_A8.js b/js/src/tests/test262/built-ins/Number/S15.7.3_A8.js new file mode 100644 index 0000000000..c93f72832a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A8.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number constructor has length property whose value is 1 +es5id: 15.7.3_A8 +description: Checking Number.length property +---*/ + +//CHECK#1 +if (!Number.hasOwnProperty("length")) { + $ERROR('#1: Number constructor has length property'); +} + +//CHECK#2 +if (Number.length !== 1) { + $ERROR('#2: Number constructor length property value is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T01.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T01.js new file mode 100644 index 0000000000..fad5b8d349 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T01.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T01 +description: Checking property constructor +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("constructor") !== false) { + $ERROR('#1: Number instance must have no special property "constructor"'); +} + +//CHECK#2 +if ((new Number()).constructor !== Number.prototype.constructor) { + $ERROR('#2: Number instance property "constructor" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T02.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T02.js new file mode 100644 index 0000000000..edec4a3a19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T02.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T02 +description: Checking property toString +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("toString") !== false) { + $ERROR('#1: Number instance must have no special property "toString"'); +} + +//CHECK#2 +if ((new Number()).toString !== Number.prototype.toString) { + $ERROR('#2: Number instance property "toString" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T03.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T03.js new file mode 100644 index 0000000000..4488f57836 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T03.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T03 +description: Checking property toLocaleString +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("toLocaleString") !== false) { + $ERROR('#1: Number instance must have no special property "toLocaleString"'); +} + +//CHECK#2 +if ((new Number()).toLocaleString !== Number.prototype.toLocaleString) { + $ERROR('#2: Number instance property "toLocaleString" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T04.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T04.js new file mode 100644 index 0000000000..093931bc2b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T04.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T04 +description: Checking property valueOf +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("valueOf") !== false) { + $ERROR('#1: Number instance must have no special property "valueOf"'); +} + +//CHECK#2 +if ((new Number()).valueOf !== Number.prototype.valueOf) { + $ERROR('#2: Number instance property "valueOf" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T05.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T05.js new file mode 100644 index 0000000000..4b722d1277 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T05.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T05 +description: Checking property toFixed +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("toFixed") !== false) { + $ERROR('#1: Number instance must have no special property "toFixed"'); +} + +//CHECK#2 +if ((new Number()).toFixed !== Number.prototype.toFixed) { + $ERROR('#2: Number instance property "toFixed" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T06.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T06.js new file mode 100644 index 0000000000..400ec2d44f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T06.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T06 +description: Checking property toExponential +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("toExponential") !== false) { + $ERROR('#1: Number instance must have no special property "toExponential"'); +} + +//CHECK#2 +if ((new Number()).toExponential !== Number.prototype.toExponential) { + $ERROR('#2: Number instance property "toExponential" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T07.js b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T07.js new file mode 100644 index 0000000000..ceb7601374 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T07.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: | + Number instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T07 +description: Checking property toPrecision +---*/ + +//CHECK#1 +if ((new Number()).hasOwnProperty("toPrecision") !== false) { + $ERROR('#1: Number instance must have no special property "toPrecision"'); +} + +//CHECK#2 +if ((new Number()).toPrecision !== Number.prototype.toPrecision) { + $ERROR('#2: Number instance property "toPrecision" must be inherited from Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S8.12.8_A3.js b/js/src/tests/test262/built-ins/Number/S8.12.8_A3.js new file mode 100644 index 0000000000..70343e4e87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S8.12.8_A3.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + We overload valueOf method so it return non Primitive value + Thus [[DefaultValue]] must return Object.toString() value +es5id: 8.12.8_A3 +description: > + Try to overload toString method, that returned Primitive, and + valueOf method, that returned new Object +---*/ + +try +{ + var __obj = { + toString: function() { + return "1" + }, + valueOf: function() { + return new Object(); + } + } + if (Number(__obj) !== 1) { + $ERROR('#1.1: var __obj = {toNumber: function() {return "1"}, valueOf: function() {return new Object();}}; Number(__obj) === 1. Actual: ' + (Number(__obj))); + } +} +catch (e) +{ + $ERROR('#1.2: var __obj = {toNumber: function() {return "1"}, valueOf: function() {return new Object();}}; Number(__obj) === 1. Actual: ' + (e)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S8.12.8_A4.js b/js/src/tests/test262/built-ins/Number/S8.12.8_A4.js new file mode 100644 index 0000000000..e4f674adfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S8.12.8_A4.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + We overload valueOf method so it return non Primitive value and toString method so it return non Primitive value too + Thus [[DefaultValue]] must generate TypeError error +es5id: 8.12.8_A4 +description: > + Try to overload toString and valueOf methods, they returned new + Objects +---*/ + +try +{ + var __obj = { + valueOf: function() { + return new Object; + }, + toString: function() { + return new Object(); + } + } + Number(__obj); + $ERROR('#1.1: var __obj = {valueOf:function(){return new Object;},toNumber: function() {return new Object();}}; Number(__obj) throw TypeError. Actual: ' + (Number(__obj))); +} +catch (e) +{ + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: var __obj = {valueOf:function(){return new Object;},toNumber: function() {return new Object();}}; Number(__obj) throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.1_A1_T1.js b/js/src/tests/test262/built-ins/Number/S9.1_A1_T1.js new file mode 100644 index 0000000000..7712223311 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.1_A1_T1.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: | + Result of primitive conversion from object is a default value for the + Object +es5id: 9.1_A1_T1 +description: > + Using operator Number. The operator calls ToPrimitive with hint + Number +---*/ + +// CHECK#1 +var object = { + valueOf: function() { + return "1" + }, + toString: function() { + return 0 + } +}; +if (Number(object) !== 1) { + $ERROR('#1: var object = {valueOf: function() {return "1"}, toString: function() {return 0}}; Number(object) === 1. Actual: ' + (Number(object))); +} + +// CHECK#2 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "0" + } +}; +if (Number(object) !== 0) { + $ERROR('#2: var object = {valueOf: function() {return {}}, toString: function() {return "0"}}; Number(object) === 0. Actual: ' + (Number(object))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A1.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A1.js new file mode 100644 index 0000000000..9778f5e2be --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of StringNumericLiteral ::: [empty] is 0" +es5id: 9.3.1_A1 +description: Number('') convert to Number by explicit transformation +---*/ + +// CHECK#1 +if (Number("") !== 0) { + $ERROR('#1.1: Number("") === 0. Actual: ' + (Number(""))); +} else { + if (1 / Number("") !== Number.POSITIVE_INFINITY) { + $ERROR('#1.2: Number("") == +0. Actual: -0'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A10.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A10.js new file mode 100644 index 0000000000..956bcd3abd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A10.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral:::. DecimalDigits is the + MV of DecimalDigits times 10<sup><small>-n</small></sup>, where n is the + number of characters in DecimalDigits +es5id: 9.3.1_A10 +description: Compare Number('.12345') with +('12345')*1e-5 +---*/ + +// CHECK#1 +if (Number(".12345") !== +("12345") * 1e-5) { + $ERROR('#1: Number(".12345") === +("12345")*1e-5'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A11.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A11.js new file mode 100644 index 0000000000..889dda8bab --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A11.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral:::. DecimalDigits ExponentPart + is the MV of DecimalDigits times 10<sup><small>e-n</small></sup>, where n is + the number of characters in DecimalDigits and e is the MV of ExponentPart +es5id: 9.3.1_A11 +description: > + Compare Number('.12345e6') with +('12345')*1e1, and + Number('.12345e-3') !== Number('12345')*1e-8 +---*/ + +// CHECK#1 +if (Number(".12345e6") !== +("12345") * 1e1) { + $ERROR('#1: Number(".12345e6") === +("12345")*1e1'); +} + +// CHECK#2 +if (Number(".12345e-3") !== Number("12345") * 1e-8) { + $ERROR('#2: Number(".12345e-3") === Number("12345")*1e-8'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A12.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A12.js new file mode 100644 index 0000000000..4cc8621ed5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A12.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral::: DecimalDigits ExponentPart + is the MV of DecimalDigits times 10<sup><small>e</small></sup>, where e is the MV of ExponentPart +es5id: 9.3.1_A12 +description: > + Compare Number('12345e6') with +('12345')*1e1, and + Number('12345e-6') !== Number('12345')*1e-6 +---*/ + +// CHECK#1 +if (Number("12345e6") !== +("12345") * 1e6) { + $ERROR('#1: Number("12345e6") === +("12345")*1e6'); +} + +// CHECK#2 +if (Number("12345e-6") !== Number("12345") * 1e-6) { + $ERROR('#2: Number("12345e-6") === Number("12345")*1e-6'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A13.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A13.js new file mode 100644 index 0000000000..9a553ba56f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A13.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of DecimalDigits ::: DecimalDigits DecimalDigit is + (the MV of DecimalDigits times 10) plus the MV of DecimalDigit +es5id: 9.3.1_A13 +description: Compare '12' with Number("1")*10+Number("2") and analogous +---*/ + +// CHECK#1 +if (+("12") !== Number("1") * 10 + Number("2")) { + $ERROR('#1: +("12") === Number("1")*10+Number("2")'); +} + +// CHECK#2 +if (Number("123") !== Number("12") * 10 + Number("3")) { + $ERROR('#2: Number("123") === Number("12")*10+Number("3")'); +} + +// CHECK#2 +if (Number("1234") !== Number("123") * 10 + Number("4")) { + $ERROR('#2: Number("1234") === Number("123")*10+Number("4")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A14.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A14.js new file mode 100644 index 0000000000..82c89d1a34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A14.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of SignedInteger ::: + DecimalDigits is the MV of DecimalDigits" +es5id: 9.3.1_A14 +description: Compare Number('+1234567890') with +('1234567890') +---*/ + +// CHECK#1 +if (Number("+1234567890") !== +("1234567890")) { + $ERROR('#1: Number("+1234567890") === +("1234567890")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A15.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A15.js new file mode 100644 index 0000000000..79093103a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A15.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of SignedInteger ::: - DecimalDigits is the negative of the MV of + DecimalDigits +es5id: 9.3.1_A15 +description: Compare -Number('1234567890') with ('-1234567890') +---*/ + +// CHECK#1 +if (+("-1234567890") !== -Number("1234567890")) { + $ERROR('#1: +("-1234567890") === -Number("1234567890")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A16.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A16.js new file mode 100644 index 0000000000..a43f671300 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A16.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 0 or of HexDigit ::: 0 is 0" +es5id: 9.3.1_A16 +description: Compare Number('0x0') and Number('0X0') with 0 +---*/ + +// CHECK#1 +if (Number("0") !== 0) { + $ERROR('#1: Number("0") === 0. Actual: ' + (Number("0"))); +} + +// CHECK#2 +if (+("0x0") !== 0) { + $ERROR('#2: +("0x0") === 0. Actual: ' + (+("0x0"))); +} + +// CHECK#3 +if (Number("0X0") !== 0) { + $ERROR('#3: Number("0X0") === 0. Actual: ' + (Number("0X0"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A17.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A17.js new file mode 100644 index 0000000000..8875b400a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A17.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 1 or of HexDigit ::: 1 is 1" +es5id: 9.3.1_A17 +description: Compare Number('0x1') and Number('0X1') with 1 +---*/ + +// CHECK#1 +if (Number("1") !== 1) { + $ERROR('#1: Number("1") === 1. Actual: ' + (Number("1"))); +} + +// CHECK#2 +if (Number("0x1") !== 1) { + $ERROR('#2: Number("0x1") === 1. Actual: ' + (Number("0x1"))); +} + +// CHECK#3 +if (+("0X1") !== 1) { + $ERROR('#3: +("0X1") === 1. Actual: ' + (+("0X1"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A18.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A18.js new file mode 100644 index 0000000000..2b9b4410b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A18.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 2 or of HexDigit ::: 2 is 2" +es5id: 9.3.1_A18 +description: Compare Number('0x2') and Number('0X2') with 2 +---*/ + +// CHECK#1 +if (+("2") !== 2) { + $ERROR('#1: +("2") === 2. Actual: ' + (+("2"))); +} + +// CHECK#2 +if (Number("0x2") !== 2) { + $ERROR('#2: Number("0x2") === 2. Actual: ' + (Number("0x2"))); +} + +// CHECK#3 +if (Number("0X2") !== 2) { + $ERROR('#3: Number("0X2") === 2. Actual: ' + (Number("0X2"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A19.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A19.js new file mode 100644 index 0000000000..3081ef68e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A19.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 3 or of HexDigit ::: 3 is 3" +es5id: 9.3.1_A19 +description: Compare Number('0x3') and Number('0X3') with 3 +---*/ + +// CHECK#1 +if (Number("3") !== 3) { + $ERROR('#1: Number("3") === 3. Actual: ' + (Number("3"))); +} + +// CHECK#2 +if (+("0x3") !== 3) { + $ERROR('#2: +("0x3") === 3. Actual: ' + (+("0x3"))); +} + +// CHECK#3 +if (Number("0X3") !== 3) { + $ERROR('#3: Number("0X3") === 3. Actual: ' + (Number("0X3"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A2.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A2.js new file mode 100644 index 0000000000..b568489a8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A2.js @@ -0,0 +1,282 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of StringNumericLiteral ::: StrWhiteSpace is 0" +es5id: 9.3.1_A2 +description: > + Strings with various WhiteSpaces convert to Number by explicit + transformation +---*/ + +// CHECK#1 +if (Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") !== 0) { + $ERROR('#1.1: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === 0. Actual: ' + (Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000"))); +} else { + if (1 / Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") !== Number.POSITIVE_INFINITY) { + $ERROR('#1.2: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === +0. Actual: -0'); + } +} + +// CHECK#2 +if (Number(" ") !== 0) { + $ERROR('#2.1: Number(" ") === 0. Actual: ' + (Number(" "))); +} else { + if (1 / Number(" ") !== Number.POSITIVE_INFINITY) { + $ERROR('#2.2: Number(" ") === +0. Actual: -0'); + } +} + +// CHECK#3 +if (Number("\t") !== 0) { + $ERROR('#3.1: Number("\\t") === 0. Actual: ' + (Number("\t"))); +} else { + if (1 / Number("\t") !== Number.POSITIVE_INFINITY) { + $ERROR('#3.2: Number("\\t") === +0. Actual: -0'); + } +} + +// CHECK#4 +if (Number("\r") !== 0) { + $ERROR('#4.1: Number("\\r") === 0. Actual: ' + (Number("\r"))); +} else { + if (1 / Number("\r") !== Number.POSITIVE_INFINITY) { + $ERROR('#4.2: Number("\\r") === +0. Actual: -0'); + } +} + +// CHECK#5 +if (Number("\n") !== 0) { + $ERROR('#5.1: Number("\\n") === 0. Actual: ' + (Number("\n"))); +} else { + if (1 / Number("\n") !== Number.POSITIVE_INFINITY) { + $ERROR('#5.2: Number("\\n") === +0. Actual: -0'); + } +} + +// CHECK#6 +if (Number("\f") !== 0) { + $ERROR('#6.1: Number("\\f") === 0. Actual: ' + (Number("\f"))); +} else { + if (1 / Number("\f") !== Number.POSITIVE_INFINITY) { + $ERROR('#6.2: Number("\\f") === +0. Actual: -0'); + } +} + +// CHECK#7 +if (Number("\u0009") !== 0) { + $ERROR('#7.1: Number("\\u0009") === 0. Actual: ' + (Number("\u0009"))); +} else { + if (1 / Number("\u0009") !== Number.POSITIVE_INFINITY) { + $ERROR('#7.2: Number("\\u0009") === +0. Actual: -0'); + } +} + +// CHECK#8 +if (Number("\u000A") !== 0) { + $ERROR('#8.1: Number("\\u000A") === 0. Actual: ' + (Number("\u000A"))); +} else { + if (1 / Number("\u000A") !== Number.POSITIVE_INFINITY) { + $ERROR('#8.2: Number("\\u000A") === +0. Actual: -0'); + } +} + +// CHECK#9 +if (Number("\u000B") !== 0) { + $ERROR('#9.1: Number("\\u000B") === 0. Actual: ' + (Number("\u000B"))); +} else { + if (1 / Number("\u000B") !== Number.POSITIVE_INFINITY) { + $ERROR('#9.1.2: Number("\\u000B") === +0. Actual: -0'); + } +} + +// CHECK#10 +if (Number("\u000C") !== 0) { + $ERROR('#10.1: Number("\\u000C") === 0. Actual: ' + (Number("\u000C"))); +} else { + if (1 / Number("\u000C") !== Number.POSITIVE_INFINITY) { + $ERROR('#10.2: Number("\\u000C") === +0. Actual: -0'); + } +} + +// CHECK#11 +if (Number("\u000D") !== 0) { + $ERROR('#11.1: Number("\\u000D") === 0. Actual: ' + (Number("\u000D"))); +} else { + if (1 / Number("\u000D") !== Number.POSITIVE_INFINITY) { + $ERROR('#11.2: Number("\\u000D") === +0. Actual: -0'); + } +} + +// CHECK#12 +if (Number("\u00A0") !== 0) { + $ERROR('#12.1: Number("\\u00A0") === 0. Actual: ' + (Number("\u00A0"))); +} else { + if (1 / Number("\u00A0") !== Number.POSITIVE_INFINITY) { + $ERROR('#12.2: Number("\\u00A0") === +0. Actual: -0'); + } +} + +// CHECK#13 +if (Number("\u0020") !== 0) { + $ERROR('#13.1: Number("\\u0020") === 0. Actual: ' + (Number("\u0020"))); +} else { + if (1 / Number("\u0020") !== Number.POSITIVE_INFINITY) { + $ERROR('#13.2: Number("\\u0020") === +0. Actual: -0'); + } +} + +// CHECK#14 +if (Number("\u2028") !== 0) { + $ERROR('#14.1: Number("\\u2028") === 0. Actual: ' + (Number("\u2028"))); +} else { + if (1 / Number("\u2028") !== Number.POSITIVE_INFINITY) { + $ERROR('#14.2: Number("\\u2028") === +0. Actual: -0'); + } +} + +// CHECK#15 +if (Number("\u2029") !== 0) { + $ERROR('#15.1: Number("\\u2029") === 0. Actual: ' + (Number("\u2029"))); +} else { + if (1 / Number("\u2029") !== Number.POSITIVE_INFINITY) { + $ERROR('#15.2: Number("\\u2029") === +0. Actual: -0'); + } +} + +// CHECK#16 +if (Number("\u1680") !== 0) { + $ERROR('#16.1: Number("\\u1680") === 0. Actual: ' + (Number("\u1680"))); +} else { + if (1 / Number("\u1680") !== Number.POSITIVE_INFINITY) { + $ERROR('#16.2: Number("\\u1680") === +0. Actual: -0'); + } +} + +// CHECK#17 +if (Number("\u2000") !== 0) { + $ERROR('#17.1: Number("\\u2000") === 0. Actual: ' + (Number("\u2000"))); +} else { + if (1 / Number("\u2000") !== Number.POSITIVE_INFINITY) { + $ERROR('#17.2: Number("\\u2000") === +0. Actual: -0'); + } +} + +// CHECK#18 +if (Number("\u2001") !== 0) { + $ERROR('#18.1: Number("\\u2001") === 0. Actual: ' + (Number("\u2001"))); +} else { + if (1 / Number("\u2001") !== Number.POSITIVE_INFINITY) { + $ERROR('#18.2: Number("\\u2001") === +0. Actual: -0'); + } +} + +// CHECK#19 +if (Number("\u2002") !== 0) { + $ERROR('#19.1: Number("\\u2002") === 0. Actual: ' + (Number("\u2002"))); +} else { + if (1 / Number("\u2002") !== Number.POSITIVE_INFINITY) { + $ERROR('#19.2: Number("\\u2002") === +0. Actual: -0'); + } +} + +// CHECK#20 +if (Number("\u2003") !== 0) { + $ERROR('#20.1: Number("\\u2003") === 0. Actual: ' + (Number("\u2003"))); +} else { + if (1 / Number("\u2003") !== Number.POSITIVE_INFINITY) { + $ERROR('#20.2: Number("\\u2003") === +0. Actual: -0'); + } +} + +// CHECK#21 +if (Number("\u2004") !== 0) { + $ERROR('#21.1: Number("\\u2004") === 0. Actual: ' + (Number("\u2004"))); +} else { + if (1 / Number("\u2004") !== Number.POSITIVE_INFINITY) { + $ERROR('#21.2: Number("\\u2004") === +0. Actual: -0'); + } +} + +// CHECK#22 +if (Number("\u2005") !== 0) { + $ERROR('#22.1: Number("\\u2005") === 0. Actual: ' + (Number("\u2005"))); +} else { + if (1 / Number("\u2005") !== Number.POSITIVE_INFINITY) { + $ERROR('#22.2: Number("\\u2005") === +0. Actual: -0'); + } +} + +// CHECK#23 +if (Number("\u2006") !== 0) { + $ERROR('#23.1: Number("\\u2006") === 0. Actual: ' + (Number("\u2006"))); +} else { + if (1 / Number("\u2006") !== Number.POSITIVE_INFINITY) { + $ERROR('#23.2: Number("\\u2006") === +0. Actual: -0'); + } +} + +// CHECK#24 +if (Number("\u2007") !== 0) { + $ERROR('#24.1: Number("\\u2007") === 0. Actual: ' + (Number("\u2007"))); +} else { + if (1 / Number("\u2007") !== Number.POSITIVE_INFINITY) { + $ERROR('#24.2: Number("\\u2007") === +0. Actual: -0'); + } +} + +// CHECK#25 +if (Number("\u2008") !== 0) { + $ERROR('#25.1: Number("\\u2008") === 0. Actual: ' + (Number("\u2008"))); +} else { + if (1 / Number("\u2008") !== Number.POSITIVE_INFINITY) { + $ERROR('#25.2: Number("\\u2008") === +0. Actual: -0'); + } +} + +// CHECK#26 +if (Number("\u2009") !== 0) { + $ERROR('#26.1: Number("\\u2009") === 0. Actual: ' + (Number("\u2009"))); +} else { + if (1 / Number("\u2009") !== Number.POSITIVE_INFINITY) { + $ERROR('#26.2: Number("\\u2009") === +0. Actual: -0'); + } +} + +// CHECK#27 +if (Number("\u200A") !== 0) { + $ERROR('#27.1: Number("\\u200A") === 0. Actual: ' + (Number("\u200A"))); +} else { + if (1 / Number("\u200A") !== Number.POSITIVE_INFINITY) { + $ERROR('#27.2: Number("\\u200A") === +0. Actual: -0'); + } +} + +// CHECK#28 +if (Number("\u202F") !== 0) { + $ERROR('#28.1: Number("\\u202F") === 0. Actual: ' + (Number("\u202F"))); +} else { + if (1 / Number("\u202F") !== Number.POSITIVE_INFINITY) { + $ERROR('#28.2: Number("\\u202F") === +0. Actual: -0'); + } +} + +// CHECK#29 +if (Number("\u205F") !== 0) { + $ERROR('#29.1: Number("\\u205F") === 0. Actual: ' + (Number("\u205F"))); +} else { + if (1 / Number("\u205F") !== Number.POSITIVE_INFINITY) { + $ERROR('#29.2: Number("\\u205F") === +0. Actual: -0'); + } +} + +// CHECK#30 +if (Number("\u3000") !== 0) { + $ERROR('#30.1: Number("\\u3000") === 0. Actual: ' + (Number("\u3000"))); +} else { + if (1 / Number("\u3000") !== Number.POSITIVE_INFINITY) { + $ERROR('#30.2: Number("\\u3000") === +0. Actual: -0'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A20.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A20.js new file mode 100644 index 0000000000..7ea2cad9c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A20.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 4 or of HexDigit ::: 4 is 4" +es5id: 9.3.1_A20 +description: Compare Number('0x4') and Number('0X4') with 4 +---*/ + +// CHECK#1 +if (Number("4") !== 4) { + $ERROR('#1: Number("4") === 4. Actual: ' + (Number("4"))); +} + +// CHECK#2 +if (Number("0x4") !== 4) { + $ERROR('#2: Number("0x4") === 4. Actual: ' + (Number("0x4"))); +} + +// CHECK#3 +if (+("0X4") !== 4) { + $ERROR('#3: +("0X4") === 4. Actual: ' + (+("0X4"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A21.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A21.js new file mode 100644 index 0000000000..3318dbc3d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A21.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 5 or of HexDigit ::: 5 is 5" +es5id: 9.3.1_A21 +description: Compare Number('0x5') and Number('0X5') with 5 +---*/ + +// CHECK#1 +if (+("5") !== 5) { + $ERROR('#1: +("5") === 5. Actual: ' + (+("5"))); +} + +// CHECK#2 +if (Number("0x5") !== 5) { + $ERROR('#2: Number("0x5") === 5. Actual: ' + (Number("0x5"))); +} + +// CHECK#3 +if (Number("0X5") !== 5) { + $ERROR('#3: Number("0X5") === 5. Actual: ' + (Number("0X5"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A22.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A22.js new file mode 100644 index 0000000000..6c1befb5fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A22.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 6 or of HexDigit ::: 6 is 6" +es5id: 9.3.1_A22 +description: Compare Number('0x6') and Number('0X6') with 6 +---*/ + +// CHECK#1 +if (Number("6") !== 6) { + $ERROR('#1: Number("6") === 6. Actual: ' + (Number("6"))); +} + +// CHECK#2 +if (+("0x6") !== 6) { + $ERROR('#2: +("0x6") === 6. Actual: ' + (+("0x6"))); +} + +// CHECK#3 +if (Number("0X6") !== 6) { + $ERROR('#3: Number("0X6") === 6. Actual: ' + (Number("0X6"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A23.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A23.js new file mode 100644 index 0000000000..ff5f1844ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A23.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 7 or of HexDigit ::: 7 is 7" +es5id: 9.3.1_A23 +description: Compare Number('0x7') and Number('0X7') with 7 +---*/ + +// CHECK#1 +if (Number("7") !== 7) { + $ERROR('#1: Number("7") === 7. Actual: ' + (Number("7"))); +} + +// CHECK#2 +if (Number("0x7") !== 7) { + $ERROR('#2: Number("0x7") === 7. Actual: ' + (Number("0x7"))); +} + +// CHECK#3 +if (+("0X7") !== 7) { + $ERROR('#3: +("0X7") === 7. Actual: ' + (+("0X7"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A24.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A24.js new file mode 100644 index 0000000000..830cf5960c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A24.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 8 or of HexDigit ::: 8 is 8" +es5id: 9.3.1_A24 +description: Compare Number('0x8') and Number('0X8') with 8 +---*/ + +// CHECK#1 +if (+("8") !== 8) { + $ERROR('#1: +("8") === 8. Actual: ' + (+("8"))); +} + +// CHECK#2 +if (Number("0x8") !== 8) { + $ERROR('#2: Number("0x8") === 8. Actual: ' + (Number("0x8"))); +} + +// CHECK#3 +if (Number("0X8") !== 8) { + $ERROR('#3: Number("0X8") === 8. Actual: ' + (Number("0X8"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A25.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A25.js new file mode 100644 index 0000000000..1ba1bc54b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A25.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "The MV of DecimalDigit ::: 9 or of HexDigit ::: 9 is 9" +es5id: 9.3.1_A25 +description: Compare Number('0x9') and Number('0X9') with 9 +---*/ + +// CHECK#1 +if (Number("9") !== 9) { + $ERROR('#1: Number("9") === 9. Actual: ' + (Number("9"))); +} + +// CHECK#2 +if (+("0x9") !== 9) { + $ERROR('#2: +("0x9") === 9. Actual: ' + (+("0x9"))); +} + +// CHECK#3 +if (Number("0X9") !== 9) { + $ERROR('#3: Number("0X9") === 9. Actual: ' + (Number("0X9"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A26.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A26.js new file mode 100644 index 0000000000..f3e468e88e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A26.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: "The MV of HexDigit ::: a or of HexDigit ::: A is 10" +es5id: 9.3.1_A26 +description: > + Compare Number('0xA'), Number('0XA'), Number('0xa') and + Number('0Xa') with 10 +---*/ + +// CHECK#1 +if (Number("0xa") !== 10) { + $ERROR('#1: Number("0xa") === 10. Actual: ' + (Number("0xa"))); +} + +// CHECK#2 +if (Number("0xA") !== 10) { + $ERROR('#2: Number("0xA") === 10. Actual: ' + (Number("0xA"))); +} + +// CHECK#3 +if (Number("0Xa") !== 10) { + $ERROR('#3: Number("0Xa") === 10. Actual: ' + (Number("0Xa"))); +} + +// CHECK#4 +if (+("0XA") !== 10) { + $ERROR('#4: +("0XA") === 10. Actual: ' + (+("0XA"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A27.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A27.js new file mode 100644 index 0000000000..c996692cc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A27.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: "The MV of HexDigit ::: b or of HexDigit ::: B is 11" +es5id: 9.3.1_A27 +description: > + Compare Number('0xB'), Number('0XB'), Number('0xb') and + Number('0Xb') with 11 +---*/ + +// CHECK#1 +if (Number("0xb") !== 11) { + $ERROR('#1: Number("0xb") === 11. Actual: ' + (Number("0xb"))); +} + +// CHECK#2 +if (Number("0xB") !== 11) { + $ERROR('#2: Number("0xB") === 11. Actual: ' + (Number("0xB"))); +} + +// CHECK#3 +if (+("0Xb") !== 11) { + $ERROR('#3: +("0Xb") === 11. Actual: ' + (+("0Xb"))); +} + +// CHECK#4 +if (Number("0XB") !== 11) { + $ERROR('#4: Number("0XB") === 11. Actual: ' + (Number("0XB"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A28.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A28.js new file mode 100644 index 0000000000..43845d0748 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A28.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: "The MV of HexDigit ::: c or of HexDigit ::: C is 12" +es5id: 9.3.1_A28 +description: > + Compare Number('0xC'), Number('0XC'), Number('0xc') and + Number('0Xc') with 12 +---*/ + +// CHECK#1 +if (Number("0xc") !== 12) { + $ERROR('#1: Number("0xc") === 12. Actual: ' + (Number("0xc"))); +} + +// CHECK#2 +if (+("0xC") !== 12) { + $ERROR('#2: +("0xC") === 12. Actual: ' + (+("0xC"))); +} + +// CHECK#3 +if (Number("0Xc") !== 12) { + $ERROR('#3: Number("0Xc") === 12. Actual: ' + (Number("0Xc"))); +} + +// CHECK#4 +if (Number("0XC") !== 12) { + $ERROR('#4: Number("0XC") === 12. Actual: ' + (Number("0XC"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A29.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A29.js new file mode 100644 index 0000000000..c5932365e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A29.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: "The MV of HexDigit ::: d or of HexDigit ::: D is 13" +es5id: 9.3.1_A29 +description: > + Compare Number('0xD'), Number('0XD'), Number('0xd') and + Number('0Xd') with 13 +---*/ + +// CHECK#1 +if (+("0xd") !== 13) { + $ERROR('#1: +("0xd") === 13. Actual: ' + (+("0xd"))); +} + +// CHECK#2 +if (Number("0xD") !== 13) { + $ERROR('#2: Number("0xD") === 13. Actual: ' + (Number("0xD"))); +} + +// CHECK#3 +if (Number("0Xd") !== 13) { + $ERROR('#3: Number("0Xd") === 13. Actual: ' + (Number("0Xd"))); +} + +// CHECK#4 +if (Number("0XD") !== 13) { + $ERROR('#4: Number("0XD") === 13. Actual: ' + (Number("0XD"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A2_U180E.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A2_U180E.js new file mode 100644 index 0000000000..6edad70964 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A2_U180E.js @@ -0,0 +1,36 @@ +// Copyright 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-tonumber-applied-to-the-string-type +description: > + Ensure U+180E is not recognized as whitespace, convert to Number by explicit transformation +info: | + 7.1.3.1 ToNumber Applied to the String Type + + If the grammar cannot interpret the String as an expansion of + StringNumericLiteral, then the result of ToNumber is NaN. + + StringNumericLiteral ::: + StrWhiteSpace_opt StrNumericLiteral StrWhiteSpace_opt + StrWhiteSpace ::: + StrWhiteSpaceChar StrWhiteSpace_opt + StrWhiteSpaceChar ::: + WhiteSpace + LineTerminator + WhiteSpace :: + <TAB> + <VT> + <FF> + <SP> + <NBSP> + <ZWNBSP> + <USP> + <USP> :: + Other category “Zs” code points +features: [u180e] +---*/ + +assert.sameValue(Number('\u180E'), NaN, 'Number("\\u180E") === NaN. Actual: ' + (Number("\u180E"))); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A30.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A30.js new file mode 100644 index 0000000000..3cb4726ba8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A30.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: "The MV of HexDigit ::: e or of HexDigit ::: E is 14" +es5id: 9.3.1_A30 +description: > + Compare Number('0xE'), Number('0XE'), Number('0xe') and + Number('0Xe') with 14 +---*/ + +// CHECK#1 +if (Number("0xe") !== 14) { + $ERROR('#1: Number("0xe") === 14. Actual: ' + (Number("0xe"))); +} + +// CHECK#2 +if (Number("0xE") !== 14) { + $ERROR('#2: Number("0xE") === 14. Actual: ' + (Number("0xE"))); +} + +// CHECK#3 +if (Number("0Xe") !== 14) { + $ERROR('#3: Number("0Xe") === 14. Actual: ' + (Number("0Xe"))); +} + +// CHECK#4 +if (+("0XE") !== 14) { + $ERROR('#4: +("0XE") === 14. Actual: ' + (+("0XE"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A31.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A31.js new file mode 100644 index 0000000000..227a67f648 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A31.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: "The MV of HexDigit ::: f or of HexDigit ::: F is 15" +es5id: 9.3.1_A31 +description: > + Compare Number('0xF'), Number('0XF'), Number('0xf') and + Number('0Xf') with 15 +---*/ + +// CHECK#1 +if (Number("0xf") !== 15) { + $ERROR('#1: Number("0xf") === 15. Actual: ' + (Number("0xf"))); +} + +// CHECK#2 +if (Number("0xF") !== 15) { + $ERROR('#2: Number("0xF") === 15. Actual: ' + (Number("0xF"))); +} + +// CHECK#3 +if (+("0Xf") !== 15) { + $ERROR('#3: +("0Xf") === 15. Actual: ' + (+("0Xf"))); +} + +// CHECK#4 +if (Number("0XF") !== 15) { + $ERROR('#4: Number("0XF") === 15. Actual: ' + (Number("0XF"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A32.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A32.js new file mode 100644 index 0000000000..312125be6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A32.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Once the exact MV for a string numeric literal has been + determined, it is then rounded to a value of the Number type with 20 + significant digits by replacing each significant digit after the 20th + with a 0 digit or the number value +es5id: 9.3.1_A32 +description: Use various long numbers, for example, 1234567890.1234567890 +---*/ + +// CHECK#1 +if (Number("1234567890.1234567890") !== 1234567890.1234567890) { + $ERROR('#1: Number("1234567890.1234567890") === 1234567890.1234567890. Actual: ' + (Number("1234567890.1234567890"))); +} + +// CHECK#2 +if (Number("1234567890.1234567890") !== 1234567890.1234567000) { + $ERROR('#2: Number("1234567890.1234567890") === 1234567890.1234567000. Actual: ' + (Number("1234567890.1234567890"))); +} + +// CHECK#3 +if (+("1234567890.1234567890") === 1234567890.123456) { + $ERROR('#3: +("1234567890.1234567890") !== 1234567890.123456'); +} + +// CHECK#4 +if (Number("0.12345678901234567890") !== 0.123456789012345678) { + $ERROR('#4: Number("0.12345678901234567890") === 0.123456789012345678. Actual: ' + (Number("0.12345678901234567890"))); +} + +// CHECK#4 +if (Number("00.12345678901234567890") !== 0.123456789012345678) { + $ERROR('#4: Number("00.12345678901234567890") === 0.123456789012345678. Actual: ' + (Number("00.12345678901234567890"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1.js new file mode 100644 index 0000000000..48ac0da993 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral + StrWhiteSpaceopt is the MV of StrNumericLiteral, no matter whether white + space is present or not +es5id: 9.3.1_A3_T1 +description: static string +---*/ + +// CHECK#1 +if (Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") !== Number("")) { + $ERROR('#1: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === Number("")'); +} + +// CHECK#2 +if (Number("\u0009\u000C\u0020\u00A0\u000A\u000D\u2028\u2029\u000B\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u30001234567890\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") !== Number("1234567890")) { + $ERROR('#2: Number("\\u0009\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029\\u000B\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u30001234567890\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === Number("1234567890")'); +} + +// CHECK#3 +if (!(+("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000Infinity\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") == Number("Infinity"))) { + $ERROR('#3: +("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000Infinity\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") == Number("Infinity")'); +} + +// CHECK#4 +if (!(Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000-Infinity\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") == Number(-"Infinity"))) { + $ERROR('#4: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000-Infinity\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") == Number("-Infinity")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1_U180E.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1_U180E.js new file mode 100644 index 0000000000..3f617d5eeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1_U180E.js @@ -0,0 +1,46 @@ +// Copyright 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-tonumber-applied-to-the-string-type +description: > + Ensure U+180E is not recognized as whitespace, test ToNumber with static string +info: | + 7.1.3.1 ToNumber Applied to the String Type + + If the grammar cannot interpret the String as an expansion of + StringNumericLiteral, then the result of ToNumber is NaN. + + StringNumericLiteral ::: + StrWhiteSpace_opt StrNumericLiteral StrWhiteSpace_opt + StrWhiteSpace ::: + StrWhiteSpaceChar StrWhiteSpace_opt + StrWhiteSpaceChar ::: + WhiteSpace + LineTerminator + WhiteSpace :: + <TAB> + <VT> + <FF> + <SP> + <NBSP> + <ZWNBSP> + <USP> + <USP> :: + Other category “Zs” code points +features: [u180e] +---*/ + +// CHECK#1 +assert.sameValue(Number('\u180E'), NaN, 'Number("\\u180E") === NaN'); + +// CHECK#2 +assert.sameValue(Number('\u180E1234567890\u180E'), NaN, 'Number("\u180E1234567890\u180E") === NaN'); + +// CHECK#3 +assert.sameValue(Number('\u180EInfinity\u180E'), NaN, 'Number("\u180EInfinity\u180E") === NaN'); + +// CHECK#4 +assert.sameValue(Number('\u180E-Infinity\u180E'), NaN, 'Number("\u180E-Infinity\u180E") === NaN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T2.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T2.js new file mode 100644 index 0000000000..1989723371 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T2.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral + StrWhiteSpaceopt is the MV of StrNumericLiteral, no matter whether white + space is present or not +es5id: 9.3.1_A3_T2 +description: dynamic string +---*/ + +function dynaString(s1, s2) { + return String(s1) + String(s2); +} + +// CHECK#1 +if (Number(dynaString("\u0009\u000C\u0020\u00A0\u000B", "\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000")) !== Number("")) { + $ERROR('#1: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B"+"\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === Number("")'); +} + +// CHECK#2 +if (+(dynaString("\u0009\u000C\u0020\u00A0\u000A\u000D\u2028\u2029\u000B12345", "67890\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000")) !== Number("1234567890")) { + $ERROR('#2: +("\\u0009\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029\\u000B12345"+"67890\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === Number("1234567890")'); +} + +// CHECK#3 +if (!(Number(dynaString("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029Infi", "nity\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000")) == Number("Infinity"))) { + $ERROR('#3: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029Infi"+"nity\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") == Number("Infinity")'); +} + +// CHECK#4 +if (!(Number(dynaString("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029-Infi", "nity\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000")) == Number(-"Infinity"))) { + $ERROR('#4: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029-Infi"+"nity\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") == Number("-Infinity")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T2_U180E.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T2_U180E.js new file mode 100644 index 0000000000..f56561e959 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T2_U180E.js @@ -0,0 +1,50 @@ +// Copyright 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-tonumber-applied-to-the-string-type +description: > + Ensure U+180E is not recognized as whitespace, test ToNumber with dynamic string +info: | + 7.1.3.1 ToNumber Applied to the String Type + + If the grammar cannot interpret the String as an expansion of + StringNumericLiteral, then the result of ToNumber is NaN. + + StringNumericLiteral ::: + StrWhiteSpace_opt StrNumericLiteral StrWhiteSpace_opt + StrWhiteSpace ::: + StrWhiteSpaceChar StrWhiteSpace_opt + StrWhiteSpaceChar ::: + WhiteSpace + LineTerminator + WhiteSpace :: + <TAB> + <VT> + <FF> + <SP> + <NBSP> + <ZWNBSP> + <USP> + <USP> :: + Other category “Zs” code points +features: [u180e] +---*/ + +function dynaString(s1, s2) { + return String(s1) + String(s2); +} + +// CHECK#1 +assert.sameValue(Number(dynaString("", "\u180E")), NaN, 'Number(dynaString("", "\u180E")) === NaN'); + +// CHECK#2 +assert.sameValue(+(dynaString("12345", "67890\u180E")), NaN, '+(dynaString("12345", "67890\u180E")) === NaN'); + +// CHECK#3 +assert.sameValue(Number(dynaString("Infi", "nity\u180E")), NaN, 'Number(dynaString("Infi", "nity\u180E")) === NaN'); + +// CHECK#4 +assert.sameValue(Number(dynaString("-Infi", "nity\u180E")), NaN, 'Number(dynaString("-Infi", "nity\u180E")) === NaN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T1.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T1.js new file mode 100644 index 0000000000..86e7e37adb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T1.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 MV of StrDecimalLiteral::: + StrUnsignedDecimalLiteral is the MV of + StrUnsignedDecimalLiteral +es5id: 9.3.1_A4_T1 +description: Compare Number('+any_number') with Number('any_number') +---*/ + +// CHECK#1 +if (Number("+0") !== Number("0")) { + $ERROR('#1.1: Number("+0") === Number("0")'); +} else { + // CHECK#2 + if (1 / Number("+0") !== 1 / Number("0")) { + $ERROR('#2.2: 1/Number("+0") === 1/Number("0")'); + } +} + +// CHECK#3 +if (Number("+Infinity") !== Number("Infinity")) { + $ERROR('#3: Number("+Infinity") === Number("Infinity")'); +} + +// CHECK#4 +if (Number("+1234.5678") !== Number("1234.5678")) { + $ERROR('#4: Number("+1234.5678") === Number("1234.5678")'); +} + +// CHECK#5 +if (Number("+1234.5678e90") !== Number("1234.5678e90")) { + $ERROR('#5: Number("+1234.5678e90") === Number("1234.5678e90")'); +} + +// CHECK#6 +if (Number("+1234.5678E90") !== Number("1234.5678E90")) { + $ERROR('#6: Number("+1234.5678E90") === Number("1234.5678E90")'); +} + +// CHECK#7 +if (Number("+1234.5678e-90") !== Number("1234.5678e-90")) { + $ERROR('#7: Number("+1234.5678e-90") === Number("1234.5678e-90")'); +} + +// CHECK#8 +if (Number("+1234.5678E-90") !== Number("1234.5678E-90")) { + $ERROR('#8: Number("+1234.5678E-90") === Number("1234.5678E-90")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T2.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T2.js new file mode 100644 index 0000000000..8a629399a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T2.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrDecimalLiteral::: + StrUnsignedDecimalLiteral is the MV of + StrUnsignedDecimalLiteral +es5id: 9.3.1_A4_T2 +description: Compare Number('+' + 'any_number') with Number('any_number') +---*/ + +function dynaString(s1, s2) { + return String(s1) + String(s2); +} + +// CHECK#1 +if (Number(dynaString("+", "0")) !== Number("0")) { + $ERROR('#1: Number("+"+"0") === Number("0")'); +} else { + // CHECK#2 + if (1 / Number(dynaString("+", "0")) !== 1 / Number("0")) { + $ERROR('#2: 1/Number("+"+"0") === 1/Number("0")'); + } +} + +// CHECK#3 +if (Number(dynaString("+Infi", "nity")) !== Number("Infinity")) { + $ERROR('#3: Number("+Infin"+"ity") === Number("Infinity")'); +} + +// CHECK#4 +if (Number(dynaString("+1234.", "5678")) !== Number("1234.5678")) { + $ERROR('#4: Number("+1234."+"5678") === Number("1234.5678")'); +} + +// CHECK#5 +if (Number(dynaString("+1234.", "5678e90")) !== Number("1234.5678e90")) { + $ERROR('#5: Number("+1234."+"5678e90") === Number("1234.5678e90")'); +} + +// CHECK#6 +if (Number(dynaString("+1234.", "5678E90")) !== Number("1234.5678E90")) { + $ERROR('#6: Number("+1234."+"5678E90") === Number("1234.5678E90")'); +} + +// CHECK#7 +if (Number(dynaString("+1234.", "5678e-90")) !== Number("1234.5678e-90")) { + $ERROR('#7: Number("+1234."+"5678e-90") === Number("1234.5678e-90")'); +} + +// CHECK#8 +if (Number(dynaString("+1234.", "5678E-90")) !== Number("1234.5678E-90")) { + $ERROR('#8: Number("+1234."+"5678E-90") === Number("1234.5678E-90")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T1.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T1.js new file mode 100644 index 0000000000..b363c302a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T1.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: | + The MV of StrDecimalLiteral::: - StrUnsignedDecimalLiteral is the negative + of the MV of StrUnsignedDecimalLiteral. (the negative of this 0 is also 0) +es5id: 9.3.1_A5_T1 +description: Compare Number('-any_number') with -Number('any_number') +---*/ + +// CHECK#1 +if (Number("-0") !== -Number("0")) { + $ERROR('#1: Number("-0") === -Number("0")'); +} else { + // CHECK#2 + if (1 / Number("-0") !== -1 / Number("0")) { + $ERROR('#2: 1/Number("-0") === -1/Number("0")'); + } +} + +// CHECK#3 +if (Number("-Infinity") !== -Number("Infinity")) { + $ERROR('#3: Number("-Infinity") === -Number("Infinity")'); +} + +// CHECK#4 +if (Number("-1234567890") !== -Number("1234567890")) { + $ERROR('#4: Number("-1234567890") === -Number("1234567890")'); +} + +// CHECK#5 +if (Number("-1234.5678") !== -Number("1234.5678")) { + $ERROR('#5: Number("-1234.5678") === -Number("1234.5678")'); +} + +// CHECK#6 +if (Number("-1234.5678e90") !== -Number("1234.5678e90")) { + $ERROR('#6: Number("-1234.5678e90") === -Number("1234.5678e90")'); +} + +// CHECK#7 +if (Number("-1234.5678E90") !== -Number("1234.5678E90")) { + $ERROR('#6: Number("-1234.5678E90") === -Number("1234.5678E90")'); +} + +// CHECK#8 +if (Number("-1234.5678e-90") !== -Number("1234.5678e-90")) { + $ERROR('#6: Number("-1234.5678e-90") === -Number("1234.5678e-90")'); +} + +// CHECK#9 +if (Number("-1234.5678E-90") !== -Number("1234.5678E-90")) { + $ERROR('#6: Number("-1234.5678E-90") === -Number("1234.5678E-90")'); +} + +// CHECK#10 +if (Number("-Infinity") !== Number.NEGATIVE_INFINITY) { + $ERROR('#3: Number("-Infinity") === Number.NEGATIVE_INFINITY'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T2.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T2.js new file mode 100644 index 0000000000..1cf73a93c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T2.js @@ -0,0 +1,147 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrDecimalLiteral::: - StrUnsignedDecimalLiteral is the negative + of the MV of StrUnsignedDecimalLiteral. (the negative of this 0 is also 0) +es5id: 9.3.1_A5_T2 +description: Compare Number('-[or +]any_number') with -[or without -]any_number) +---*/ + +// CHECK#1 +if (Number("1") !== 1) { + $ERROR('#1: Number("1") === 1'); +} + +// CHECK#2 +if (Number("+1") !== 1) { + $ERROR('#3: Number("+1") === 1'); +} + +// CHECK#3 +if (Number("-1") !== -1) { + $ERROR('#3: Number("-1") === -1'); +} + +// CHECK#4 +if (Number("2") !== 2) { + $ERROR('#4: Number("2") === 2'); +} + +// CHECK#5 +if (Number("+2") !== 2) { + $ERROR('#5: Number("+2") === 2'); +} + +// CHECK#6 +if (Number("-2") !== -2) { + $ERROR('#6: Number("-2") === -2'); +} + +// CHECK#7 +if (Number("3") !== 3) { + $ERROR('#7: Number("3") === 3'); +} + +// CHECK#8 +if (Number("+3") !== 3) { + $ERROR('#8: Number("+3") === 3'); +} + +// CHECK#9 +if (Number("-3") !== -3) { + $ERROR('#9: Number("-3") === -3'); +} + +// CHECK#10 +if (Number("4") !== 4) { + $ERROR('#10: Number("4") === 4'); +} + +// CHECK#11 +if (Number("+4") !== 4) { + $ERROR('#11: Number("+4") === 4'); +} + +// CHECK#12 +if (Number("-4") !== -4) { + $ERROR('#12: Number("-4") === -4'); +} + +// CHECK#13 +if (Number("5") !== 5) { + $ERROR('#13: Number("5") === 5'); +} + +// CHECK#14 +if (Number("+5") !== 5) { + $ERROR('#14: Number("+5") === 5'); +} + +// CHECK#15 +if (Number("-5") !== -5) { + $ERROR('#15: Number("-5") === -5'); +} + +// CHECK#16 +if (Number("6") !== 6) { + $ERROR('#16: Number("6") === 6'); +} + +// CHECK#17 +if (Number("+6") !== 6) { + $ERROR('#17: Number("+6") === 6'); +} + +// CHECK#18 +if (Number("-6") !== -6) { + $ERROR('#18: Number("-6") === -6'); +} + +// CHECK#19 +if (Number("7") !== 7) { + $ERROR('#19: Number("7") === 7'); +} + +// CHECK#20 +if (Number("+7") !== 7) { + $ERROR('#20: Number("+7") === 7'); +} + +// CHECK#21 +if (Number("-7") !== -7) { + $ERROR('#21: Number("-7") === -7'); +} + +// CHECK#22 +if (Number("8") !== 8) { + $ERROR('#22: Number("8") === 8'); +} + +// CHECK#23 +if (Number("+8") !== 8) { + $ERROR('#23: Number("+8") === 8'); +} + +// CHECK#24 +if (Number("-8") !== -8) { + $ERROR('#24: Number("-8") === -8'); +} + +// CHECK#25 +if (Number("9") !== 9) { + $ERROR('#25: Number("9") === 9'); +} + +// CHECK#26 +if (Number("+9") !== 9) { + $ERROR('#26: Number("+9") === 9'); +} + +// CHECK#27 +if (Number("-9") !== -9) { + $ERROR('#27: Number("-9") === -9'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T3.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T3.js new file mode 100644 index 0000000000..3c2572411e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T3.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrDecimalLiteral::: - StrUnsignedDecimalLiteral is the negative + of the MV of StrUnsignedDecimalLiteral. (the negative of this 0 is also 0) +es5id: 9.3.1_A5_T3 +description: Compare Number('-' + 'any_number') with -Number('any_number') +---*/ + +function dynaString(s1, s2) { + return String(s1) + String(s2); +} + +// CHECK#1 +if (Number(dynaString("-", "0")) !== -Number("0")) { + $ERROR('#1: Number("-"+"0") === -Number("0")'); +} else { + // CHECK#2 + if (1 / Number(dynaString("-", "0")) !== -1 / Number("0")) { + $ERROR('#2: 1/Number("-"+"0") === -1/Number("0")'); + } +} + +// CHECK#3 +if (Number(dynaString("-Infi", "nity")) !== -Number("Infinity")) { + $ERROR('#3: Number("-Infi"+"nity") === -Number("Infinity")'); +} + +// CHECK#4 +if (Number(dynaString("-12345", "67890")) !== -Number("1234567890")) { + $ERROR('#4: Number("-12345"+"67890") === -Number("1234567890")'); +} + +// CHECK#5 +if (Number(dynaString("-1234.", "5678")) !== -Number("1234.5678")) { + $ERROR('#5: Number("-1234."+"5678") === -Number("1234.5678")'); +} + +// CHECK#6 +if (Number(dynaString("-1234.", "5678e90")) !== -Number("1234.5678e90")) { + $ERROR('#6: Number("-1234."+"5678e90") === -Number("1234.5678e90")'); +} + +// CHECK#7 +if (Number(dynaString("-1234.", "5678E90")) !== -Number("1234.5678E90")) { + $ERROR('#6: Number("-1234."+"5678E90") === -Number("1234.5678E90")'); +} + +// CHECK#8 +if (Number(dynaString("-1234.", "5678e-90")) !== -Number("1234.5678e-90")) { + $ERROR('#6: Number("-1234."+"5678e-90") === -Number("1234.5678e-90")'); +} + +// CHECK#9 +if (Number(dynaString("-1234.", "5678E-90")) !== -Number("1234.5678E-90")) { + $ERROR('#6: Number("-1234."+"5678E-90") === -Number("1234.5678E-90")'); +} + +// CHECK#10 +if (Number(dynaString("-Infi", "nity")) !== Number.NEGATIVE_INFINITY) { + $ERROR('#3: Number("-Infi"+"nity") === Number.NEGATIVE_INFINITY'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T1.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T1.js new file mode 100644 index 0000000000..5363dce421 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral::: Infinity is 10<sup><small>10000</small></sup> + (a value so large that it will round to <b><tt>+∞</tt></b>) +es5id: 9.3.1_A6_T1 +description: > + Compare Number('Infinity') with Number.POSITIVE_INFINITY, + 10e10000, 10E10000 and Number("10e10000") +---*/ + +// CHECK#1 +if (Number("Infinity") !== Number.POSITIVE_INFINITY) { + $ERROR('#1: Number("Infinity") === Number.POSITIVE_INFINITY'); +} + +// CHECK#2 +if (Number("Infinity") !== 10e10000) { + $ERROR('#2: Number("Infinity") === 10e10000'); +} + +// CHECK#3 +if (Number("Infinity") !== 10E10000) { + $ERROR('#3: Number("Infinity") === 10E10000'); +} + +// CHECK#4 +if (Number("Infinity") !== Number("10e10000")) { + $ERROR('#4: Number("Infinity") === Number("10e10000")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T2.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T2.js new file mode 100644 index 0000000000..56fbc182c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T2.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral::: Infinity is 10<sup><small>10000</small></sup> + (a value so large that it will round to <b><tt>+∞</tt></b>) +es5id: 9.3.1_A6_T2 +description: > + Compare Number('Infi'+'nity') with Number.POSITIVE_INFINITY, + 10e10000, 10E10000 and Number("10e10000") +---*/ + +function dynaString(s1, s2) { + return String(s1) + String(s2); +} + + +// CHECK#1 +if (Number(dynaString("Infi", "nity")) !== Number.POSITIVE_INFINITY) { + $ERROR('#1: Number("Infi"+"nity") === Number.POSITIVE_INFINITY'); +} + +// CHECK#2 +if (Number(dynaString("Infi", "nity")) !== 10e10000) { + $ERROR('#2: Number("Infi"+"nity") === 10e10000'); +} + +// CHECK#3 +if (Number(dynaString("Infi", "nity")) !== 10E10000) { + $ERROR('#3: Number("Infi"+"nity") === 10E10000'); +} + +// CHECK#4 +if (Number(dynaString("Infi", "nity")) !== Number("10e10000")) { + $ERROR('#4: Number("Infi"+"nity") === Number("10e10000")'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A7.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A7.js new file mode 100644 index 0000000000..59ba102c70 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A7.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral::: DecimalDigits. DecimalDigits + is the MV of the first DecimalDigits plus the MV of the second DecimalDigits times + 10<sup><small>-n</small></sup>, where n is the number of characters in the second DecimalDigits +es5id: 9.3.1_A7 +description: Compare Number('1234.5678') with Number('1234')+(+('5678')*1e-4) +---*/ + +// CHECK#1 +if (Number("1234.5678") !== Number("1234") + (+("5678") * 1e-4)) { + $ERROR('#1: Number("1234.5678") === Number("1234")+(+("5678")*1e-4)'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A8.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A8.js new file mode 100644 index 0000000000..483d138612 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A8.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral::: DecimalDigits. ExponentPart + is the MV of DecimalDigits times 10<sup><small>e</small></sup> , where e is the MV of ExponentPart +es5id: 9.3.1_A8 +description: > + Compare Number('1234e5') and Number('1234.e5') with + Number('1234')*1e5 +---*/ + +// CHECK#1 +if (Number("1234e5") !== Number("1234") * 1e5) { + $ERROR('#1: Number("1234e5") === Number("1234")*1e5'); +} + +// CHECK#2 +if (Number("1234.e5") !== +("1234") * 1e5) { + $ERROR('#2: Number("1234.e5") === +("1234")*1e5'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3.1_A9.js b/js/src/tests/test262/built-ins/Number/S9.3.1_A9.js new file mode 100644 index 0000000000..8d473f56f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A9.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The MV of StrUnsignedDecimalLiteral::: DecimalDigits. DecimalDigits ExponentPart + is (the MV of the first DecimalDigits plus (the MV of the second DecimalDigits times + 10<sup><small>-n</small></sup>)) times 10<sup><small>e</small></sup>, where n is the number + of characters in the second DecimalDigits and e is the MV of ExponentPart +es5id: 9.3.1_A9 +description: > + Compare Number('1234.5678e9') with + (Number('1234')+(Number('5678')*1e-4))*1e9, and +('1234.5678e-9') + with (Number('1234')+(Number('5678')*1e-4))*1e-9 +---*/ + +// CHECK#1 +if (Number("1234.5678e9") !== (Number("1234") + (Number("5678") * 1e-4)) * 1e9) { + $ERROR('#1: Number("1234.5678e9") === (Number("1234")+(Number("5678")*1e-4))*1e9'); +} + +// CHECK#2 +if (+("1234.5678e-9") !== (Number("1234") + (Number("5678") * 1e-4)) * 1e-9) { + $ERROR('#2: +("1234.5678e-9") === (Number("1234")+(Number("5678")*1e-4))*1e-9'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3_A1_T1.js b/js/src/tests/test262/built-ins/Number/S9.3_A1_T1.js new file mode 100644 index 0000000000..ad9f4c76ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A1_T1.js @@ -0,0 +1,12 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Result of number conversion from undefined value is NaN +es5id: 9.3_A1_T1 +description: Undefined convert to Number by explicit transformation +---*/ + +assert.sameValue(Number(undefined), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3_A2_T1.js b/js/src/tests/test262/built-ins/Number/S9.3_A2_T1.js new file mode 100644 index 0000000000..60834e05cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Result of number conversion from null value is +0 +es5id: 9.3_A2_T1 +description: null convert to Number by explicit transformation +---*/ + +// CHECK #1 +if (Number(null) !== 0) { + $ERROR('#1.1: Number(null) === 0. Actual: ' + (Number(null))); +} else { + if (1 / Number(null) !== Number.POSITIVE_INFINITY) { + $ERROR('#1.2: Number(null) === +0. Actual: -0'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3_A3_T1.js b/js/src/tests/test262/built-ins/Number/S9.3_A3_T1.js new file mode 100644 index 0000000000..72c0bdfc26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A3_T1.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: | + Result of number conversion from boolean value is 1 if the argument is + true, else is +0 +es5id: 9.3_A3_T1 +description: False and true convert to Number by explicit transformation +---*/ + +// CHECK#1 +if (Number(false) !== +0) { + $ERROR('#1.1: Number(false) === 0. Actual: ' + (Number(false))); +} else { + if (1 / Number(false) !== Number.POSITIVE_INFINITY) { + $ERROR('#1.2: Number(false) === +0. Actual: -0'); + } +} + +// CHECK#2 +if (Number(true) !== 1) { + $ERROR('#2: Number(true) === 1. Actual: ' + (Number(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3_A4.1_T1.js b/js/src/tests/test262/built-ins/Number/S9.3_A4.1_T1.js new file mode 100644 index 0000000000..d84380cd96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A4.1_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of number conversion from number value equals to the input + argument (no conversion) +es5id: 9.3_A4.1_T1 +description: > + Some numbers including Number.MAX_VALUE and Number.MIN_VALUE are + converted to Number with explicit transformation +---*/ + +// CHECK#1 +if (Number(13) !== 13) { + $ERROR('#1: Number(13) === 13. Actual: ' + (Number(13))); +} + +// CHECK#2 +if (Number(-13) !== -13) { + $ERROR('#2: Number(-13) === -13. Actual: ' + (Number(-13))); +} + +// CHECK#3 +if (Number(1.3) !== 1.3) { + $ERROR('#3: Number(1.3) === 1.3. Actual: ' + (Number(1.3))); +} + +// CHECK#4 +if (Number(-1.3) !== -1.3) { + $ERROR('#4: Number(-1.3) === -1.3. Actual: ' + (Number(-1.3))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3_A4.2_T1.js b/js/src/tests/test262/built-ins/Number/S9.3_A4.2_T1.js new file mode 100644 index 0000000000..7bb1c6ad0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A4.2_T1.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of number conversion from number value equals to the input + argument (no conversion) +es5id: 9.3_A4.2_T1 +description: > + Number.NaN, +0, -0, Number.POSITIVE_INFINITY, + Number.NEGATIVE_INFINITY, Number.MAX_VALUE and Number.MIN_VALUE + convert to Number by explicit transformation +---*/ + +// CHECK#1 +assert.sameValue(Number(NaN), NaN, "NaN"); + +// CHECK#2 +if (Number(+0) !== +0) { + $ERROR('#2.1: Number(+0) === 0. Actual: ' + (Number(+0))); +} else { + if (1 / Number(+0) !== Number.POSITIVE_INFINITY) { + $ERROR('#2.2: Number(+0) === +0. Actual: -0'); + } +} + +// CHECK#3 +if (Number(-0) !== -0) { + $ERROR('#3.1: Number(-0) === 0. Actual: ' + (Number(-0))); +} else { + if (1 / Number(-0) !== Number.NEGATIVE_INFINITY) { + $ERROR('#3.2: Number(-0) === -0. Actual: +0'); + } +} + +// CHECK#4 +if (Number(Number.POSITIVE_INFINITY) !== Number.POSITIVE_INFINITY) { + $ERROR('#4: Number(+Infinity) === +Infinity. Actual: ' + (Number(+Infinity))); +} + +// CHECK#5 +if (Number(Number.NEGATIVE_INFINITY) !== Number.NEGATIVE_INFINITY) { + $ERROR('#5: Number(-Infinity) === -Infinity. Actual: ' + (Number(-Infinity))); +} + +// CHECK#6 +if (Number(Number.MAX_VALUE) !== Number.MAX_VALUE) { + $ERROR('#6: Number(Number.MAX_VALUE) === Number.MAX_VALUE. Actual: ' + (Number(Number.MAX_VALUE))); +} + +// CHECK#7 +if (Number(Number.MIN_VALUE) !== Number.MIN_VALUE) { + $ERROR('#7: Number(Number.MIN_VALUE) === Number.MIN_VALUE. Actual: ' + (Number(Number.MIN_VALUE))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/S9.3_A5_T1.js b/js/src/tests/test262/built-ins/Number/S9.3_A5_T1.js new file mode 100644 index 0000000000..0e7be83134 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A5_T1.js @@ -0,0 +1,139 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of number conversion from object value is the result + of conversion from primitive value +es5id: 9.3_A5_T1 +description: > + new Number(), new Number(0), new Number(Number.NaN), new + Number(null), new Number(void 0) and others convert to Number by + explicit transformation +---*/ + +// CHECK#1 +if (Number(new Number()) !== 0) { + $ERROR('#1: Number(new Number()) === 0. Actual: ' + (Number(new Number()))); +} + +// CHECK#2 +if (Number(new Number(0)) !== 0) { + $ERROR('#2: Number(new Number(0)) === 0. Actual: ' + (Number(new Number(0)))); +} + +// CHECK#3 +assert.sameValue(Number(new Number(NaN)), NaN, "Number(new Number(NaN)"); + +// CHECK#4 +if (Number(new Number(null)) !== 0) { + $ERROR('#4.1: Number(new Number(null)) === 0. Actual: ' + (Number(new Number(null)))); +} else { + if (1 / Number(new Number(null)) !== Number.POSITIVE_INFINITY) { + $ERROR('#4.2: Number(new Number(null)) === +0. Actual: -0'); + } +} + +// CHECK#5 +assert.sameValue(Number(new Number(void 0)), NaN, "Number(new Number(void 0)"); + +// CHECK#6 +if (Number(new Number(true)) !== 1) { + $ERROR('#6: Number(new Number(true)) === 1. Actual: ' + (Number(new Number(true)))); +} + +// CHECK#7 +if (Number(new Number(false)) !== +0) { + $ERROR('#7.1: Number(new Number(false)) === 0. Actual: ' + (Number(new Number(false)))); +} else { + if (1 / Number(new Number(false)) !== Number.POSITIVE_INFINITY) { + $ERROR('#7.2: Number(new Number(false)) === +0. Actual: -0'); + } +} + +// CHECK#8 +if (Number(new Boolean(true)) !== 1) { + $ERROR('#8: Number(new Boolean(true)) === 1. Actual: ' + (Number(new Boolean(true)))); +} + +// CHECK#9 +if (Number(new Boolean(false)) !== +0) { + $ERROR('#9.1: Number(new Boolean(false)) === 0. Actual: ' + (Number(new Boolean(false)))); +} else { + if (1 / Number(new Boolean(false)) !== Number.POSITIVE_INFINITY) { + $ERROR('#9.2: Number(new Boolean(false)) === +0. Actual: -0'); + } +} + +// CHECK#10 +assert.sameValue(Number(new Array(2, 4, 8, 16, 32)), NaN, "Number(new Array(2,4,8,16,32))"); + +// CHECK#11 +var myobj1 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "67890"; + }, + valueOf: function() { + return "[object MyObj]"; + } +}; + +assert.sameValue(Number(myobj1), NaN, "Number(myobj1)"); + +// CHECK#12 +var myobj2 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "67890"; + }, + valueOf: function() { + return "9876543210"; + } +}; + +if (Number(myobj2) !== 9876543210) { + $ERROR("#12: Number(myobj2) calls ToPrimitive with hint Number. Exptected: 9876543210. Actual: " + (Number(myobj2))); +} + + +// CHECK#13 +var myobj3 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "[object MyObj]"; + } +}; + +assert.sameValue(Number(myobj3), NaN, "Number(myobj3)"); + +// CHECK#14 +var myobj4 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "67890"; + } +}; + +if (Number(myobj4) !== 67890) { + $ERROR("#14: Number(myobj4) calls ToPrimitive with hint Number. Exptected: 67890. Actual: " + (Number(myobj4))); +} + +// CHECK#15 +var myobj5 = { + ToNumber: function() { + return 12345; + } +}; + +assert.sameValue(Number(myobj5), NaN, "Number(myobj5)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/bigint-conversion.js b/js/src/tests/test262/built-ins/Number/bigint-conversion.js new file mode 100644 index 0000000000..51468bd84f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/bigint-conversion.js @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt to Number conversion +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(Number(0n), 0); +assert.sameValue(+(new Number(0n)), +(new Number(0))); + +assert.sameValue(Number(2n**53n), 9007199254740992); +assert.sameValue(Number(2n**53n + 1n), 9007199254740992); +assert.sameValue(Number(2n**53n + 2n), 9007199254740994); +assert.sameValue(Number(2n**53n + 3n), 9007199254740996); +assert.sameValue(Number(2n**53n + 4n), 9007199254740996); + +assert.sameValue(Number(-(2n**53n)), -9007199254740992); +assert.sameValue(Number(-(2n**53n + 1n)), -9007199254740992); +assert.sameValue(Number(-(2n**53n + 2n)), -9007199254740994); +assert.sameValue(Number(-(2n**53n + 3n)), -9007199254740996); +assert.sameValue(Number(-(2n**53n + 4n)), -9007199254740996); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/browser.js b/js/src/tests/test262/built-ins/Number/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/browser.js diff --git a/js/src/tests/test262/built-ins/Number/is-a-constructor.js b/js/src/tests/test262/built-ins/Number/is-a-constructor.js new file mode 100644 index 0000000000..91a9632c5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/is-a-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The Number constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(Number), true, 'isConstructor(Number) must return true'); +new Number(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/arg-is-not-number.js b/js/src/tests/test262/built-ins/Number/isFinite/arg-is-not-number.js new file mode 100644 index 0000000000..b7030cff6c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/arg-is-not-number.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isfinite +description: > + Return false if argument is not Number +info: | + Number.isFinite ( number ) + + 1. If Type(number) is not Number, return false. + [...] +features: [Symbol] +---*/ + +assert.sameValue(Number.isFinite("1"), false, "string"); +assert.sameValue(Number.isFinite([1]), false, "[1]"); +assert.sameValue(Number.isFinite(new Number(42)), false, "Number object"); +assert.sameValue(Number.isFinite(false), false, "false"); +assert.sameValue(Number.isFinite(true), false, "true"); +assert.sameValue(Number.isFinite(undefined), false, "undefined"); +assert.sameValue(Number.isFinite(null), false, "null"); +assert.sameValue(Number.isFinite(Symbol("1")), false, "symbol"); +assert.sameValue(Number.isFinite(), false, "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/browser.js b/js/src/tests/test262/built-ins/Number/isFinite/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/browser.js diff --git a/js/src/tests/test262/built-ins/Number/isFinite/finite-numbers.js b/js/src/tests/test262/built-ins/Number/isFinite/finite-numbers.js new file mode 100644 index 0000000000..72a9bdebd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/finite-numbers.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isfinite +description: > + Return true for valid finite numbers +info: | + Number.isFinite ( number ) + + 1. If Type(number) is not Number, return false. + 2. If number is NaN, +∞, or -∞, return false. + 3. Otherwise, return true. +---*/ + +assert.sameValue(Number.isFinite(-10), true, "-10"); +assert.sameValue(Number.isFinite(-0), true, "-0"); +assert.sameValue(Number.isFinite(0), true, "0"); +assert.sameValue(Number.isFinite(10), true, "10"); +assert.sameValue(Number.isFinite(1e10), true, "1e10"); +assert.sameValue(Number.isFinite(10.10), true, "10.10"); +assert.sameValue(Number.isFinite(9007199254740991), true, "9007199254740991"); +assert.sameValue(Number.isFinite(-9007199254740991), true, "-9007199254740991"); +assert.sameValue(Number.isFinite(Number.MAX_VALUE), true, "Number.MAX_VALUE"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/infinity.js b/js/src/tests/test262/built-ins/Number/isFinite/infinity.js new file mode 100644 index 0000000000..9f11c1ef41 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/infinity.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isfinite +description: > + Return false if argument is Infinity or -Infinity +info: | + Number.isFinite ( number ) + + [...] + 2. If number is NaN, +∞, or -∞, return false. + [...] +---*/ + +assert.sameValue(Number.isFinite(Infinity), false, "+Infinity"); +assert.sameValue(Number.isFinite(-Infinity), false, "-Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/length.js b/js/src/tests/test262/built-ins/Number/isFinite/length.js new file mode 100644 index 0000000000..474fcb877f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.2 +description: > + Number.isFinite.length is 1. +info: | + Number.isFinite ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isFinite.length, 1); + +verifyNotEnumerable(Number.isFinite, "length"); +verifyNotWritable(Number.isFinite, "length"); +verifyConfigurable(Number.isFinite, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/name.js b/js/src/tests/test262/built-ins/Number/isFinite/name.js new file mode 100644 index 0000000000..61abe6571a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.2 +description: > + Number.isFinite.name is "isFinite". +info: | + Number.isFinite ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isFinite.name, "isFinite"); + +verifyNotEnumerable(Number.isFinite, "name"); +verifyNotWritable(Number.isFinite, "name"); +verifyConfigurable(Number.isFinite, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/nan.js b/js/src/tests/test262/built-ins/Number/isFinite/nan.js new file mode 100644 index 0000000000..10b9ceaae2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/nan.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isfinite +description: > + Return false if argument is NaN +info: | + Number.isFinite ( number ) + + [...] + 2. If number is NaN, +∞, or -∞, return false. + [...] +---*/ + +assert.sameValue(Number.isFinite(NaN), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js new file mode 100644 index 0000000000..4e42a62e9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.isFinite does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Number.isFinite), false, 'isConstructor(Number.isFinite) must return false'); + +assert.throws(TypeError, () => { + new Number.isFinite(); +}, '`new Number.isFinite()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/prop-desc.js b/js/src/tests/test262/built-ins/Number/isFinite/prop-desc.js new file mode 100644 index 0000000000..3f42350cca --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isfinite +description: > + "isFinite" property of Number +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "isFinite"); +verifyWritable(Number, "isFinite"); +verifyConfigurable(Number, "isFinite"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/shell.js b/js/src/tests/test262/built-ins/Number/isFinite/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isFinite/shell.js diff --git a/js/src/tests/test262/built-ins/Number/isInteger/arg-is-not-number.js b/js/src/tests/test262/built-ins/Number/isInteger/arg-is-not-number.js new file mode 100644 index 0000000000..59aa03c750 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/arg-is-not-number.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isinteger +description: > + Return false if argument is not Number +info: | + Number.isInteger ( number ) + + 1. If Type(number) is not Number, return false. + [...] +features: [Symbol] +---*/ + +assert.sameValue(Number.isInteger("1"), false, "string"); +assert.sameValue(Number.isInteger([1]), false, "[1]"); +assert.sameValue(Number.isInteger(new Number(42)), false, "Number object"); +assert.sameValue(Number.isInteger(false), false, "false"); +assert.sameValue(Number.isInteger(true), false, "true"); +assert.sameValue(Number.isInteger(undefined), false, "undefined"); +assert.sameValue(Number.isInteger(null), false, "null"); +assert.sameValue(Number.isInteger(Symbol("1")), false, "symbol"); +assert.sameValue(Number.isInteger(), false, "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/browser.js b/js/src/tests/test262/built-ins/Number/isInteger/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/browser.js diff --git a/js/src/tests/test262/built-ins/Number/isInteger/infinity.js b/js/src/tests/test262/built-ins/Number/isInteger/infinity.js new file mode 100644 index 0000000000..5988e69f33 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/infinity.js @@ -0,0 +1,13 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.3 +author: Ryan Lewis +description: Number.isInteger should return false if called with Infinity. +---*/ + +assert.sameValue(Number.isInteger(Infinity), false, 'Infinity'); +assert.sameValue(Number.isInteger(-Infinity), false, '-Infinity'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/integers.js b/js/src/tests/test262/built-ins/Number/isInteger/integers.js new file mode 100644 index 0000000000..b3110dd8f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/integers.js @@ -0,0 +1,19 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.3 +author: Ryan Lewis +description: Number.isInteger should return true if called with an integer. +---*/ + +assert.sameValue(Number.isInteger(478), true, 'Number.isInteger(478)'); +assert.sameValue(Number.isInteger(-0), true, '-0'); +assert.sameValue(Number.isInteger(0), true, '0'); +assert.sameValue(Number.isInteger(-1), true, '-1'); +assert.sameValue(Number.isInteger(9007199254740991), true, '9007199254740991'); +assert.sameValue(Number.isInteger(-9007199254740991), true, '-9007199254740991'); +assert.sameValue(Number.isInteger(9007199254740992), true, '9007199254740992'); +assert.sameValue(Number.isInteger(-9007199254740992), true, '-9007199254740992'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/length.js b/js/src/tests/test262/built-ins/Number/isInteger/length.js new file mode 100644 index 0000000000..99bd2d168f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.3 +description: > + Number.isInteger.length is 1. +info: | + Number.isInteger ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isInteger.length, 1); + +verifyNotEnumerable(Number.isInteger, "length"); +verifyNotWritable(Number.isInteger, "length"); +verifyConfigurable(Number.isInteger, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/name.js b/js/src/tests/test262/built-ins/Number/isInteger/name.js new file mode 100644 index 0000000000..224c94dba9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.3 +description: > + Number.isInteger.name is "isInteger". +info: | + Number.isInteger ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isInteger.name, "isInteger"); + +verifyNotEnumerable(Number.isInteger, "name"); +verifyNotWritable(Number.isInteger, "name"); +verifyConfigurable(Number.isInteger, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/nan.js b/js/src/tests/test262/built-ins/Number/isInteger/nan.js new file mode 100644 index 0000000000..b367702f3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/nan.js @@ -0,0 +1,12 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.3 +author: Ryan Lewis +description: Number.isInteger should return false if called with NaN. +---*/ + +assert.sameValue(Number.isInteger(NaN), false, 'Number.isInteger(NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/non-integers.js b/js/src/tests/test262/built-ins/Number/isInteger/non-integers.js new file mode 100644 index 0000000000..78a3857ec7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/non-integers.js @@ -0,0 +1,15 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.3 +author: Ryan Lewis +description: Number.isInteger should return false if called with a double. +---*/ + +assert.sameValue(Number.isInteger(6.75), false, '6.75'); +assert.sameValue(Number.isInteger(0.000001), false, '0.000001'); +assert.sameValue(Number.isInteger(-0.000001), false, '-0.000001'); +assert.sameValue(Number.isInteger(11e-1), false, '11e-1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js new file mode 100644 index 0000000000..2dad2e9df7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.isInteger does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Number.isInteger), false, 'isConstructor(Number.isInteger) must return false'); + +assert.throws(TypeError, () => { + new Number.isInteger(); +}, '`new Number.isInteger()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/prop-desc.js b/js/src/tests/test262/built-ins/Number/isInteger/prop-desc.js new file mode 100644 index 0000000000..ed31b7bc65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isinteger +description: > + "isInteger" property of Number +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "isInteger"); +verifyWritable(Number, "isInteger"); +verifyConfigurable(Number, "isInteger"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/shell.js b/js/src/tests/test262/built-ins/Number/isInteger/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isInteger/shell.js diff --git a/js/src/tests/test262/built-ins/Number/isNaN/arg-is-not-number.js b/js/src/tests/test262/built-ins/Number/isNaN/arg-is-not-number.js new file mode 100644 index 0000000000..ba9cf69765 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/arg-is-not-number.js @@ -0,0 +1,26 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isnan +description: > + Return false if argument is not Number +info: | + Number.isNaN ( number ) + + 1. If Type(number) is not Number, return false. + [...] +features: [Symbol] +---*/ + +assert.sameValue(Number.isNaN("NaN"), false, "string"); +assert.sameValue(Number.isNaN([NaN]), false, "[NaN]"); +assert.sameValue(Number.isNaN(new Number(NaN)), false, "Number object"); +assert.sameValue(Number.isNaN(false), false, "false"); +assert.sameValue(Number.isNaN(true), false, "true"); +assert.sameValue(Number.isNaN(undefined), false, "undefined"); +assert.sameValue(Number.isNaN(null), false, "null"); +assert.sameValue(Number.isNaN(Symbol("1")), false, "symbol"); +assert.sameValue(Number.isNaN(), false, "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/browser.js b/js/src/tests/test262/built-ins/Number/isNaN/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/browser.js diff --git a/js/src/tests/test262/built-ins/Number/isNaN/length.js b/js/src/tests/test262/built-ins/Number/isNaN/length.js new file mode 100644 index 0000000000..302e20edf9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.4 +description: > + Number.isNaN.length is 1. +info: | + Number.isNaN ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isNaN.length, 1); + +verifyNotEnumerable(Number.isNaN, "length"); +verifyNotWritable(Number.isNaN, "length"); +verifyConfigurable(Number.isNaN, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/name.js b/js/src/tests/test262/built-ins/Number/isNaN/name.js new file mode 100644 index 0000000000..4d97acdf97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.4 +description: > + Number.isNaN.name is "isNaN". +info: | + Number.isNaN ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isNaN.name, "isNaN"); + +verifyNotEnumerable(Number.isNaN, "name"); +verifyNotWritable(Number.isNaN, "name"); +verifyConfigurable(Number.isNaN, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/nan.js b/js/src/tests/test262/built-ins/Number/isNaN/nan.js new file mode 100644 index 0000000000..3dad3549ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/nan.js @@ -0,0 +1,12 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.4 +author: Ryan Lewis +description: Number.IsNaN should return true if called with NaN. +---*/ + +assert.sameValue(Number.isNaN(NaN), true, 'Number.isNaN(NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js new file mode 100644 index 0000000000..482812547c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.isNaN does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Number.isNaN), false, 'isConstructor(Number.isNaN) must return false'); + +assert.throws(TypeError, () => { + new Number.isNaN(); +}, '`new Number.isNaN()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/not-nan.js b/js/src/tests/test262/built-ins/Number/isNaN/not-nan.js new file mode 100644 index 0000000000..60910c00a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/not-nan.js @@ -0,0 +1,25 @@ +// Copyright (c) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isnan +description: > + Return false if argument is not NaN +info: | + Number.isNaN ( number ) + + 1. If Type(number) is not Number, return false. + 2. If number is NaN, return true. + 3. Otherwise, return false. +---*/ + +assert.sameValue(Number.isNaN(0), false, "0"); +assert.sameValue(Number.isNaN(-0), false, "-0"); +assert.sameValue(Number.isNaN(1), false, "1"); +assert.sameValue(Number.isNaN(-1), false, "-1"); +assert.sameValue(Number.isNaN(1.1), false, "1.1"); +assert.sameValue(Number.isNaN(1e10), false, "1e10"); +assert.sameValue(Number.isNaN(Infinity), false, "Infinity"); +assert.sameValue(Number.isNaN(-Infinity), false, "-Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/prop-desc.js b/js/src/tests/test262/built-ins/Number/isNaN/prop-desc.js new file mode 100644 index 0000000000..f9b86fafc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.isnan +description: > + "isNaN" property of Number +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "isNaN"); +verifyWritable(Number, "isNaN"); +verifyConfigurable(Number, "isNaN"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/shell.js b/js/src/tests/test262/built-ins/Number/isNaN/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isNaN/shell.js diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js new file mode 100644 index 0000000000..d6b7e3f640 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + Return false if argument is not Number +info: | + Number.isSafeInteger ( number ) + + 1. If Type(number) is not Number, return false. + [...] +features: [Symbol] +---*/ + +assert.sameValue(Number.isSafeInteger("1"), false, "string"); +assert.sameValue(Number.isSafeInteger([1]), false, "[1]"); +assert.sameValue(Number.isSafeInteger(new Number(42)), false, "Number object"); +assert.sameValue(Number.isSafeInteger(false), false, "false"); +assert.sameValue(Number.isSafeInteger(true), false, "true"); +assert.sameValue(Number.isSafeInteger(undefined), false, "undefined"); +assert.sameValue(Number.isSafeInteger(null), false, "null"); +assert.sameValue(Number.isSafeInteger(Symbol("1")), false, "symbol"); +assert.sameValue(Number.isSafeInteger(), false, "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js new file mode 100644 index 0000000000..53642c9289 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js @@ -0,0 +1,19 @@ +// Copyright (c) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + Return false if argument is an Infinity value +info: | + Number.isSafeInteger ( number ) + + [...] + 2. If number is NaN, +∞, or -∞, return false. + [...] +---*/ + +assert.sameValue(Number.isSafeInteger(Infinity), false, "Infinity"); +assert.sameValue(Number.isSafeInteger(-Infinity), false, "-Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js new file mode 100644 index 0000000000..bcc7e6a770 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.5 +description: > + Number.isSafeInteger.length is 1. +info: | + Number.isSafeInteger ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isSafeInteger.length, 1); + +verifyNotEnumerable(Number.isSafeInteger, "length"); +verifyNotWritable(Number.isSafeInteger, "length"); +verifyConfigurable(Number.isSafeInteger, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js new file mode 100644 index 0000000000..3844d43e13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.2.5 +description: > + Number.isSafeInteger.name is "isSafeInteger". +info: | + Number.isSafeInteger ( number ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.isSafeInteger.name, "isSafeInteger"); + +verifyNotEnumerable(Number.isSafeInteger, "name"); +verifyNotWritable(Number.isSafeInteger, "name"); +verifyConfigurable(Number.isSafeInteger, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js new file mode 100644 index 0000000000..7320e44f77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js @@ -0,0 +1,18 @@ +// Copyright (c) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + Return false if argument is NaN +info: | + Number.isSafeInteger ( number ) + + [...] + 2. If number is NaN, +∞, or -∞, return false. + [...] +---*/ + +assert.sameValue(Number.isSafeInteger(NaN), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js new file mode 100644 index 0000000000..dca11c9cd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.isSafeInteger does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Number.isSafeInteger), false, 'isConstructor(Number.isSafeInteger) must return false'); + +assert.throws(TypeError, () => { + new Number.isSafeInteger(); +}, '`new Number.isSafeInteger()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js new file mode 100644 index 0000000000..794a6d623c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js @@ -0,0 +1,22 @@ +// Copyright (c) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + Return false if argument is not an integer +info: | + Number.isSafeInteger ( number ) + + [...] + 3. Let integer be ToInteger(number). + 4. If integer is not equal to number, return false. + [...] +---*/ + +assert.sameValue(Number.isSafeInteger(1.1), false, "1.1"); +assert.sameValue(Number.isSafeInteger(0.000001), false, "0.000001"); +assert.sameValue(Number.isSafeInteger(-0.000001), false, "-0.000001"); +assert.sameValue(Number.isSafeInteger(11e-1), false, "11e-1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js new file mode 100644 index 0000000000..d3552d0511 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js @@ -0,0 +1,21 @@ +// Copyright (c) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + Return false if argument is not a safe integer +info: | + Number.isSafeInteger ( number ) + + [...] + 3. Let integer be ToInteger(number). + 4. If integer is not equal to number, return false. + 5. If abs(integer) ≤ 2**53-1, return true. + 6. Otherwise, return false. +---*/ + +assert.sameValue(Number.isSafeInteger(9007199254740992), false, "2**53"); +assert.sameValue(Number.isSafeInteger(-9007199254740992), false, "-(2**53)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js new file mode 100644 index 0000000000..5fdb2ba049 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + "isSafeInteger" property of Number +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "isSafeInteger"); +verifyWritable(Number, "isSafeInteger"); +verifyConfigurable(Number, "isSafeInteger"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js new file mode 100644 index 0000000000..721a045434 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js @@ -0,0 +1,25 @@ +// Copyright (c) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.issafeinteger +description: > + Return true if argument is a safe integer +info: | + Number.isSafeInteger ( number ) + + [...] + 3. Let integer be ToInteger(number). + 4. If integer is not equal to number, return false. + 5. If abs(integer) ≤ 2**53-1, return true. + [...] +---*/ + +assert.sameValue(Number.isSafeInteger(1), true, "1"); +assert.sameValue(Number.isSafeInteger(-0), true, "-0"); +assert.sameValue(Number.isSafeInteger(0), true, "0"); +assert.sameValue(Number.isSafeInteger(-1), true, "-1"); +assert.sameValue(Number.isSafeInteger(9007199254740991), true, "9007199254740991"); +assert.sameValue(Number.isSafeInteger(-9007199254740991), true, "-9007199254740991"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js diff --git a/js/src/tests/test262/built-ins/Number/parseFloat.js b/js/src/tests/test262/built-ins/Number/parseFloat.js new file mode 100644 index 0000000000..27a5759b02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseFloat.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.parsefloat +description: > + "parseFloat" property descriptor and value of Number +info: | + Number.parseFloat + + The value of the Number.parseFloat data property is the same built-in function + object that is the value of the parseFloat property of the global object + defined in 18.2.4. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.parseFloat, parseFloat); + +verifyNotEnumerable(Number, "parseFloat"); +verifyWritable(Number, "parseFloat"); +verifyConfigurable(Number, "parseFloat"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/parseFloat/browser.js b/js/src/tests/test262/built-ins/Number/parseFloat/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseFloat/browser.js diff --git a/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js new file mode 100644 index 0000000000..b660870fa8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.parseFloat does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Number.parseFloat), false, 'isConstructor(Number.parseFloat) must return false'); + +assert.throws(TypeError, () => { + new Number.parseFloat(); +}, '`new Number.parseFloat()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/parseFloat/shell.js b/js/src/tests/test262/built-ins/Number/parseFloat/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseFloat/shell.js diff --git a/js/src/tests/test262/built-ins/Number/parseInt.js b/js/src/tests/test262/built-ins/Number/parseInt.js new file mode 100644 index 0000000000..04c1318424 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseInt.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.parseint +description: > + "parseInt" property descriptor and value of Number +info: | + Number.parseInt + + The value of the Number.parseInt data property is the same built-in function + object that is the value of the parseInt property of the global object + defined in 18.2.4. + + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.parseInt, parseInt); + +verifyNotEnumerable(Number, "parseInt"); +verifyWritable(Number, "parseInt"); +verifyConfigurable(Number, "parseInt"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/parseInt/browser.js b/js/src/tests/test262/built-ins/Number/parseInt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseInt/browser.js diff --git a/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js new file mode 100644 index 0000000000..871e87adea --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.parseInt does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Number.parseInt), false, 'isConstructor(Number.parseInt) must return false'); + +assert.throws(TypeError, () => { + new Number.parseInt(); +}, '`new Number.parseInt()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/parseInt/shell.js b/js/src/tests/test262/built-ins/Number/parseInt/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/parseInt/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prop-desc.js b/js/src/tests/test262/built-ins/Number/prop-desc.js new file mode 100644 index 0000000000..d08151f474 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number-constructor-number-value +description: > + Property descriptor of Number +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Number"); +verifyWritable(this, "Number"); +verifyConfigurable(this, "Number"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Number/proto-from-ctor-realm.js new file mode 100644 index 0000000000..32e0512cbb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/proto-from-ctor-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-number-constructor-number-value +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%NumberPrototype%", + « [[NumberData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Number, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Number.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/15.7.3.1-2.js b/js/src/tests/test262/built-ins/Number/prototype/15.7.3.1-2.js new file mode 100644 index 0000000000..d153512e78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/15.7.3.1-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.7.3.1-2 +description: Number.prototype, initial value is the Number prototype object +---*/ + +// assume that Number.prototype has not been modified. + +assert.sameValue(Object.getPrototypeOf(new Number(42)), Number.prototype, 'Object.getPrototypeOf(new Number(42))'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T1.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T1.js new file mode 100644 index 0000000000..e41a59219b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.prototype is itself Number object +es5id: 15.7.3.1_A2_T1 +description: > + Checking type of Number.prototype property - test based on + deleting Number.prototype.toString +---*/ + +//CHECK#1 +if (typeof Number.prototype !== "object") { + $ERROR('#1: typeof Number.prototype === "object"'); +} + +delete Number.prototype.toString; + +if (Number.prototype.toString() !== "[object Number]") { + $ERROR('#3: The [[Class]] property of the Number prototype object is set to "Number"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T2.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T2.js new file mode 100644 index 0000000000..6976f519ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T2.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.prototype is itself Number object +es5id: 15.7.3.1_A2_T2 +description: > + Checking type of Number.prototype property - test based on + overwriting of Number.prototype.toString +---*/ + +//CHECK#1 +if (typeof Number.prototype !== "object") { + $ERROR('#1: typeof Number.prototype === "object"'); +} + +Number.prototype.toString = Object.prototype.toString; + +if (Number.prototype.toString() !== "[object Number]") { + $ERROR('#3: The [[Class]] property of the Number prototype object is set to "Number"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A3.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A3.js new file mode 100644 index 0000000000..2f3b51ed48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A3.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Number.prototype value is +0 +es5id: 15.7.3.1_A3 +description: Checking value of Number.prototype property +---*/ + +//CHECK#1 +if (Number.prototype != 0) { + $ERROR('#2: Number.prototype == +0'); +} else if (1 / Number.prototype != Number.POSITIVE_INFINITY) { + $ERROR('#2: Number.prototype == +0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A1.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A1.js new file mode 100644 index 0000000000..8a49a14e2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A1.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: | + The Number prototype object is itself a Number object + (its [[Class]] is "Number") whose value is +0 +es5id: 15.7.4_A1 +description: Checking type and value of Number.prototype property +---*/ + +//CHECK#1 +if (typeof Number.prototype !== "object") { + $ERROR('#1: typeof Number.prototype === "object"'); +} + +//CHECK#2 +if (Number.prototype != 0) { + $ERROR('#2: Number.prototype == +0'); +} else if (1 / Number.prototype != Number.POSITIVE_INFINITY) { + $ERROR('#2: Number.prototype == +0'); +} + +delete Number.prototype.toString; + +if (Number.prototype.toString() !== "[object Number]") { + $ERROR('#3: The [[Class]] property of the Number prototype object is set to "Number"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A2.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A2.js new file mode 100644 index 0000000000..6008d85159 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A2.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the Number + prototype object is the Object prototype object +es5id: 15.7.4_A2 +description: Checking Object.prototype.isPrototypeOf(Number.prototype) +---*/ + +//CHECK#1 +if (!Object.prototype.isPrototypeOf(Number.prototype)) { + $ERROR('#1: Object prototype object is the prototype of Number prototype object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.1.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.1.js new file mode 100644 index 0000000000..c7b839ed09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.1.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property constructor +es5id: 15.7.4_A3.1 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("constructor") !== true) { + $ERROR('#1: The Number prototype object has the property constructor'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.2.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.2.js new file mode 100644 index 0000000000..d31b353e3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.2.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property toString +es5id: 15.7.4_A3.2 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("toString") !== true) { + $ERROR('#1: The Number prototype object has the property toString'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.3.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.3.js new file mode 100644 index 0000000000..8f356fd4dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.3.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property toLocaleString +es5id: 15.7.4_A3.3 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("toLocaleString") !== true) { + $ERROR('#1: The Number prototype object has the property toLocaleString'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.4.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.4.js new file mode 100644 index 0000000000..c83789c4bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.4.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property valueOf +es5id: 15.7.4_A3.4 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("valueOf") !== true) { + $ERROR('#1: The Number prototype object has the property valueOf'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.5.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.5.js new file mode 100644 index 0000000000..c7ab631f28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.5.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property toFixed +es5id: 15.7.4_A3.5 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("toFixed") !== true) { + $ERROR('#1: The Number prototype object has the property toFixed'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.6.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.6.js new file mode 100644 index 0000000000..d07bebc4e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.6.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property toExponential +es5id: 15.7.4_A3.6 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("toExponential") !== true) { + $ERROR('#1: The Number prototype object has the property toExponential'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.7.js b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.7.js new file mode 100644 index 0000000000..5dd5c40abb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A3.7.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Number prototype object has the property toPrecision +es5id: 15.7.4_A3.7 +description: The test uses hasOwnProperty() method +---*/ + +//CHECK#1 +if (Number.prototype.hasOwnProperty("toPrecision") !== true) { + $ERROR('#1: The Number prototype object has the property toPrecision'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/browser.js b/js/src/tests/test262/built-ins/Number/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/constructor.js b/js/src/tests/test262/built-ins/Number/prototype/constructor.js new file mode 100644 index 0000000000..1197ebae67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/constructor.js @@ -0,0 +1,22 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.constructor +description: > + Property descriptor and value for Number.prototype.constructor +info: | + Number.prototype.constructor + + The initial value of Number.prototype.constructor is the intrinsic object + %Number%. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.constructor, Number); + +verifyNotEnumerable(Number.prototype, "constructor"); +verifyWritable(Number.prototype, "constructor"); +verifyConfigurable(Number.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/prop-desc.js new file mode 100644 index 0000000000..a94eefbae0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/prop-desc.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype +description: > + "prototype" property of Number +info: | + Number.prototype + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number, "prototype"); +verifyNotWritable(Number, "prototype"); +verifyNotConfigurable(Number, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/shell.js b/js/src/tests/test262/built-ins/Number/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/browser.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/infinity.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/infinity.js new file mode 100644 index 0000000000..b9870e5902 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/infinity.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return signed Infinity string if this is Infinity +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 5. Let s be the empty String. + 6. If x < 0, then + a. Let s be "-". + b. Let x be -x. + 7. If x = +∞, then + a. Return the concatenation of the Strings s and "Infinity". + [...] +---*/ + +assert.sameValue((+Infinity).toExponential(1000), "Infinity", "Infinity value"); +var n = new Number(+Infinity); +assert.sameValue(n.toExponential(1000), "Infinity", "Number Infinity"); + +assert.sameValue((-Infinity).toExponential(1000), "-Infinity", "-Infinity value"); +var n = new Number(-Infinity); +assert.sameValue(n.toExponential(1000), "-Infinity", "Number -Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js new file mode 100644 index 0000000000..0c146d1500 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.2 +description: > + Number.prototype.toExponential.length is 1. +info: | + Number.prototype.toExponential ( fractionDigits ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toExponential.length, 1); + +verifyNotEnumerable(Number.prototype.toExponential, "length"); +verifyNotWritable(Number.prototype.toExponential, "length"); +verifyConfigurable(Number.prototype.toExponential, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js new file mode 100644 index 0000000000..a92b59ba75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.2 +description: > + Number.prototype.toExponential.name is "toExponential". +info: | + Number.prototype.toExponential ( fractionDigits ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toExponential.name, "toExponential"); + +verifyNotEnumerable(Number.prototype.toExponential, "name"); +verifyNotWritable(Number.prototype.toExponential, "name"); +verifyConfigurable(Number.prototype.toExponential, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/nan.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/nan.js new file mode 100644 index 0000000000..0a5e46535c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/nan.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return "NaN" if this is NaN +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + 2. Let f be ? ToInteger(fractionDigits). + 3. Assert: f is 0, when fractionDigits is undefined. + 4. If x is NaN, return the String "NaN". + [...] +---*/ + +assert.sameValue(NaN.toExponential(Infinity), "NaN", "NaN value"); + +var n = new Number(NaN); +assert.sameValue(n.toExponential(NaN), "NaN", "NaN obj"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js new file mode 100644 index 0000000000..bbf60fe972 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.prototype.toExponential does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Number.prototype.toExponential), + false, + 'isConstructor(Number.prototype.toExponential) must return false' +); + +assert.throws(TypeError, () => { + new Number.prototype.toExponential(); +}, '`new Number.prototype.toExponential()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/prop-desc.js new file mode 100644 index 0000000000..9e66b6c426 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/prop-desc.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + "toExponential" property of Number.prototype +info: | + ES6 section 17: Every other data property described in clauses 18 through 26 + and in Annex B.2 has the attributes { [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number.prototype, "toExponential"); +verifyWritable(Number.prototype, "toExponential"); +verifyConfigurable(Number.prototype, "toExponential"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/range.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/range.js new file mode 100644 index 0000000000..32f36b1ea5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/range.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: Number.prototype.toExponential permits fractionDigits from 0 to 100 +info: | + Number.prototype.toExponential ( fractionDigits ) + + ... + 8. If _p_ < 0 or _p_ > 100, throw a *RangeError* exception. + ... +---*/ + +assert.sameValue((3).toExponential(0), "3e+0"); +assert.throws(RangeError, () => (3).toExponential(-1)); + +assert.sameValue((3).toExponential(100), "3.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+0"); +assert.throws(RangeError, () => (3).toExponential(101)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits-symbol.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits-symbol.js new file mode 100644 index 0000000000..a281c9282d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return abrupt completion from ToInteger(symbol fractionDigits) +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + 2. Let f be ? ToInteger(fractionDigits). + [...] +features: [Symbol] +---*/ + +var fd = Symbol("1"); + +assert.throws(TypeError, function() { + NaN.toExponential(fd); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits.js new file mode 100644 index 0000000000..481033a58e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return abrupt completion from ToInteger(fractionDigits) +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + 2. Let f be ? ToInteger(fractionDigits). + [...] +---*/ + +var fd1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var fd2 = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + NaN.toExponential(fd1); +}, "valueOf"); + +assert.throws(Test262Error, function() { + NaN.toExponential(fd2); +}, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-values.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-values.js new file mode 100644 index 0000000000..a9e15c87a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/return-values.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return regular string values +---*/ + +assert.sameValue((123.456).toExponential(0), "1e+2"); +assert.sameValue((123.456).toExponential(1), "1.2e+2"); +assert.sameValue((123.456).toExponential(2), "1.23e+2"); +assert.sameValue((123.456).toExponential(3), "1.235e+2"); +assert.sameValue((123.456).toExponential(4), "1.2346e+2"); +assert.sameValue((123.456).toExponential(5), "1.23456e+2"); +assert.sameValue((123.456).toExponential(6), "1.234560e+2"); +assert.sameValue((123.456).toExponential(7), "1.2345600e+2"); +assert.sameValue((123.456).toExponential(17), "1.23456000000000003e+2"); +assert.sameValue((123.456).toExponential(20), "1.23456000000000003070e+2"); + +assert.sameValue((-123.456).toExponential(0), "-1e+2"); +assert.sameValue((-123.456).toExponential(1), "-1.2e+2"); +assert.sameValue((-123.456).toExponential(2), "-1.23e+2"); +assert.sameValue((-123.456).toExponential(3), "-1.235e+2"); +assert.sameValue((-123.456).toExponential(4), "-1.2346e+2"); +assert.sameValue((-123.456).toExponential(5), "-1.23456e+2"); +assert.sameValue((-123.456).toExponential(6), "-1.234560e+2"); +assert.sameValue((-123.456).toExponential(7), "-1.2345600e+2"); +assert.sameValue((-123.456).toExponential(17), "-1.23456000000000003e+2"); +assert.sameValue((-123.456).toExponential(20), "-1.23456000000000003070e+2"); + +assert.sameValue((0.0001).toExponential(0), "1e-4"); +assert.sameValue((0.0001).toExponential(1), "1.0e-4"); +assert.sameValue((0.0001).toExponential(2), "1.00e-4"); +assert.sameValue((0.0001).toExponential(3), "1.000e-4"); +assert.sameValue((0.0001).toExponential(4), "1.0000e-4"); +assert.sameValue((0.0001).toExponential(16), "1.0000000000000000e-4"); +assert.sameValue((0.0001).toExponential(17), "1.00000000000000005e-4"); +assert.sameValue((0.0001).toExponential(18), "1.000000000000000048e-4"); +assert.sameValue((0.0001).toExponential(19), "1.0000000000000000479e-4"); +assert.sameValue((0.0001).toExponential(20), "1.00000000000000004792e-4"); + +assert.sameValue((0.9999).toExponential(0), "1e+0"); +assert.sameValue((0.9999).toExponential(1), "1.0e+0"); +assert.sameValue((0.9999).toExponential(2), "1.00e+0"); +assert.sameValue((0.9999).toExponential(3), "9.999e-1"); +assert.sameValue((0.9999).toExponential(4), "9.9990e-1"); +assert.sameValue((0.9999).toExponential(16), "9.9990000000000001e-1"); +assert.sameValue((0.9999).toExponential(17), "9.99900000000000011e-1"); +assert.sameValue((0.9999).toExponential(18), "9.999000000000000110e-1"); +assert.sameValue((0.9999).toExponential(19), "9.9990000000000001101e-1"); +assert.sameValue((0.9999).toExponential(20), "9.99900000000000011013e-1"); + +assert.sameValue((25).toExponential(0), "3e+1"); +assert.sameValue((12345).toExponential(3), "1.235e+4"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/shell.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-0.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-0.js new file mode 100644 index 0000000000..da4fafacd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-0.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return "0" if this value is 0 and ToInteger(fractionDigits) is 0 +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 9. If x = 0, then + a. Let m be the String consisting of f+1 occurrences of the code unit 0x0030 + (DIGIT ZERO). + b. Let e be 0. + [...] + 11. If f ≠ 0, then + [...] + 12. If e = 0, then + a. Let c be "+". + b. Let d be "0". + [...] + 14. Let m be the concatenation of the four Strings m, "e", c, and d. + 15. Return the concatenation of the Strings s and m. +---*/ + +assert.sameValue(Number.prototype.toExponential(0), "0e+0", "Number.prototype"); + +assert.sameValue((0).toExponential(0), "0e+0", "(0).toExponential(0)"); +assert.sameValue((-0).toExponential(0), "0e+0", "(-0).toExponential(0)"); + +assert.sameValue((0).toExponential(-0), "0e+0", "(0).toExponential(-0)"); +assert.sameValue((-0).toExponential(-0), "0e+0", "(-0).toExponential(-0)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-not-0.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-not-0.js new file mode 100644 index 0000000000..0fbdf1bc42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-not-0.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Return string value for this value = 0 and fractionDigits != 0 +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 9. If x = 0, then + a. Let m be the String consisting of f+1 occurrences of the code unit 0x0030 + (DIGIT ZERO). + b. Let e be 0. + [...] + 11. If f ≠ 0, then + a. Let a be the first element of m, and let b be the remaining f elements of m. + b. Let m be the concatenation of the three Strings a, ".", and b. + 12. If e = 0, then + a. Let c be "+". + b. Let d be "0". + [...] + 14. Let m be the concatenation of the four Strings m, "e", c, and d. + 15. Return the concatenation of the Strings s and m. +---*/ + +assert.sameValue((0).toExponential(1), "0.0e+0", "0 and 1"); +assert.sameValue((0).toExponential(2), "0.00e+0", "0 and 2"); +assert.sameValue((0).toExponential(7), "0.0000000e+0", "0 and 7"); +assert.sameValue((0).toExponential(20), "0.00000000000000000000e+0", "0 and 20"); + +assert.sameValue((-0).toExponential(1), "0.0e+0", "-0 and 1"); +assert.sameValue((-0).toExponential(2), "0.00e+0", "-0 and 2"); +assert.sameValue((-0).toExponential(7), "0.0000000e+0", "-0 and 7"); +assert.sameValue((-0).toExponential(20), "0.00000000000000000000e+0", "-0 and 20"); + +assert.sameValue((0.0).toExponential(4), "0.0000e+0", "0.0 and 4"); +assert.sameValue((-0.0).toExponential(4), "0.0000e+0", "-0.0 and 4"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-type-not-number-or-number-object.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-type-not-number-or-number-object.js new file mode 100644 index 0000000000..30987186be --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/this-type-not-number-or-number-object.js @@ -0,0 +1,69 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Throws a TypeError if this value is not a number object or value +info: | + 20.1.3 Properties of the Number Prototype Object + + The Number prototype object is the intrinsic object %NumberPrototype%. The + Number prototype object is an ordinary object. The Number prototype is itself + a Number object; it has a [[NumberData]] internal slot with the value +0. + + [...] + The abstract operation thisNumberValue(value) performs the following steps: + + 1. If Type(value) is Number, return value. + 2. If Type(value) is Object and value has a [[NumberData]] internal slot, then + a. Assert: value's [[NumberData]] internal slot is a Number value. + b. Return the value of value's [[NumberData]] internal slot. + 3. Throw a TypeError exception. + + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + [...] +features: [Symbol] +---*/ + +var toExponential = Number.prototype.toExponential; + +assert.throws(TypeError, function() { + toExponential.call({}, 1); +}, "{}"); + +assert.throws(TypeError, function() { + toExponential.call("1", 1); +}, "string"); + +assert.throws(TypeError, function() { + toExponential.call(Number, 1); +}, "Number"); + +assert.throws(TypeError, function() { + toExponential.call(true, 1); +}, "true"); + +assert.throws(TypeError, function() { + toExponential.call(false, 1); +}, "false"); + +assert.throws(TypeError, function() { + toExponential.call(null, 1); +}, "null"); + +assert.throws(TypeError, function() { + toExponential.call(undefined, 1); +}, "undefined"); + +assert.throws(TypeError, function() { + toExponential.call(Symbol("1"), 1); +}, "symbol"); + +assert.throws(TypeError, function() { + toExponential.call([], 1); +}, "[]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/tointeger-fractiondigits.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/tointeger-fractiondigits.js new file mode 100644 index 0000000000..be496bde7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/tointeger-fractiondigits.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + ToInteger(fractionDigits operations) +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + 2. Let f be ? ToInteger(fractionDigits). + [...] +---*/ + +assert.sameValue((123.456).toExponential(0.1), "1e+2", "0.1"); +assert.sameValue((123.456).toExponential(-0.1), "1e+2", "-0.1"); +assert.sameValue((123.456).toExponential(0.9), "1e+2", "0.9"); +assert.sameValue((123.456).toExponential(-0.9), "1e+2", "-0.9"); + +assert.sameValue((123.456).toExponential(false), "1e+2", "false"); +assert.sameValue((123.456).toExponential(true), "1.2e+2", "true"); + +assert.sameValue((123.456).toExponential(NaN), "1e+2", "NaN"); +assert.sameValue((123.456).toExponential(null), "1e+2", "null"); + +assert.sameValue((123.456).toExponential("2"), "1.23e+2", "string"); +assert.sameValue((123.456).toExponential(""), "1e+2", "the empty string"); + +assert.sameValue((123.456).toExponential([]), "1e+2", "[]"); +assert.sameValue((123.456).toExponential([2]), "1.23e+2", "[2]"); + +assert.sameValue((0).toExponential(undefined), "0e+0", "undefined"); +assert.sameValue((0).toExponential(), "0e+0", "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/undefined-fractiondigits.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/undefined-fractiondigits.js new file mode 100644 index 0000000000..9194721ad6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/undefined-fractiondigits.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toexponential +description: > + Handle undefined fractionDigits, not only casting it to 0 +info: | + Number.prototype.toExponential ( fractionDigits ) + + 1. Let x be ? thisNumberValue(this value). + 2. Let f be ? ToInteger(fractionDigits). + [...] + 10. Else x ≠ 0, + a. If fractionDigits is not undefined, then + i. Let e and n be integers such that 10f ≤ n < 10f+1 and for which the + exact mathematical value of n × 10e-f - x is as close to zero as + possible. If there are two such sets of e and n, pick the e and n for + which n × 10e-f is larger. + b. Else fractionDigits is undefined, + i. Let e, n, and f be integers such that f ≥ 0, 10f ≤ n < 10f+1, the + Number value for n × 10e-f is x, and f is as small as possible. Note + that the decimal representation of n has f+1 digits, n is not divisible + by 10, and the least significant digit of n is not necessarily uniquely + determined by these criteria. +---*/ + +assert.sameValue((123.456).toExponential(undefined), "1.23456e+2", "undefined"); +assert.sameValue((123.456).toExponential(), "1.23456e+2", "no arg"); +assert.sameValue((123.456).toExponential(0), "1e+2", "0"); + +assert.sameValue((1.1e-32).toExponential(undefined), "1.1e-32", "undefined"); +assert.sameValue((1.1e-32).toExponential(), "1.1e-32", "no arg"); +assert.sameValue((1.1e-32).toExponential(0), "1e-32", "0"); + +assert.sameValue((100).toExponential(undefined), "1e+2", "undefined"); +assert.sameValue((100).toExponential(), "1e+2", "no arg"); +assert.sameValue((100).toExponential(0), "1e+2", "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T01.js new file mode 100644 index 0000000000..8f4e1a0f04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T01.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 1: Let f be ToInteger(fractionDigits). (If fractionDigits + is undefined, this step produces the value 0) +es5id: 15.7.4.5_A1.1_T01 +description: calling on Number prototype object +---*/ + +//CHECK#1 +if (Number.prototype.toFixed() !== "0") { + $ERROR('#1: Number.prototype.toFixed() === "0"'); +} + +//CHECK#2 +if (Number.prototype.toFixed(0) !== "0") { + $ERROR('#2: Number.prototype.toFixed(0) === "0"'); +} + +//CHECK#3 +if (Number.prototype.toFixed(1) !== "0.0") { + $ERROR('#3: Number.prototype.toFixed(1) === "0.0"'); +} + +//CHECK#4 +if (Number.prototype.toFixed(1.1) !== "0.0") { + $ERROR('#4: Number.prototype.toFixed(1.1) === "0.0"'); +} + +//CHECK#5 +if (Number.prototype.toFixed(0.9) !== "0") { + $ERROR('#5: Number.prototype.toFixed(0.9) === "0"'); +} + + +//CHECK#6 +if (Number.prototype.toFixed("1") !== "0.0") { + $ERROR('#6: Number.prototype.toFixed("1") === "0.0"'); +} + +//CHECK#7 +if (Number.prototype.toFixed("1.1") !== "0.0") { + $ERROR('#7: Number.prototype.toFixed("1.1") === "0.0"'); +} + +//CHECK#8 +if (Number.prototype.toFixed("0.9") !== "0") { + $ERROR('#8: Number.prototype.toFixed("0.9") === "0"'); +} + +//CHECK#9 +if (Number.prototype.toFixed(Number.NaN) !== "0") { + $ERROR('#9: Number.prototype.toFixed(Number.NaN) === "0"'); +} + +//CHECK#10 +if (Number.prototype.toFixed("some string") !== "0") { + $ERROR('#9: Number.prototype.toFixed("some string") === "0"'); +} + +//CHECK#11 +try { + if (Number.prototype.toFixed(-0.1) !== "0") { + $ERROR('#10: Number.prototype.toFixed(-0.1) === "0"'); + } +} +catch (e) { + $ERROR('#10: Number.prototype.toFixed(-0.1) should not throw ' + e); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T02.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T02.js new file mode 100644 index 0000000000..5c6e84bd27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T02.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: | + Step 1: Let f be ToInteger(fractionDigits). (If fractionDigits + is undefined, this step produces the value 0) +es5id: 15.7.4.5_A1.1_T02 +description: calling on Number object +---*/ + +//CHECK#1 +if ((new Number(1)).toFixed() !== "1") { + $ERROR('#1: (new Number(1)).prototype.toFixed() === "1"'); +} + +//CHECK#2 +if ((new Number(1)).toFixed(0) !== "1") { + $ERROR('#2: (new Number(1)).prototype.toFixed(0) === "1"'); +} + +//CHECK#3 +if ((new Number(1)).toFixed(1) !== "1.0") { + $ERROR('#3: (new Number(1)).prototype.toFixed(1) === "1.0"'); +} + +//CHECK#4 +if ((new Number(1)).toFixed(1.1) !== "1.0") { + $ERROR('#4: (new Number(1)).toFixed(1.1) === "1.0"'); +} + +//CHECK#5 +if ((new Number(1)).toFixed(0.9) !== "1") { + $ERROR('#5: (new Number(1)).toFixed(0.9) === "1"'); +} + +//CHECK#6 +if ((new Number(1)).toFixed("1") !== "1.0") { + $ERROR('#6: (new Number(1)).toFixed("1") === "1.0"'); +} + +//CHECK#7 +if ((new Number(1)).toFixed("1.1") !== "1.0") { + $ERROR('#7: (new Number(1)).toFixed("1.1") === "1.0"'); +} + +//CHECK#8 +if ((new Number(1)).toFixed("0.9") !== "1") { + $ERROR('#8: (new Number(1)).toFixed("0.9") === "1"'); +} + +//CHECK#9 +if ((new Number(1)).toFixed(Number.NaN) !== "1") { + $ERROR('#9: (new Number(1)).toFixed(Number.NaN) === "1"'); +} + +//CHECK#10 +if ((new Number(1)).toFixed("some string") !== "1") { + $ERROR('#9: (new Number(1)).toFixed("some string") === "1"'); +} + +//CHECK#10 +try { + if ((new Number(1)).toFixed(-0.1) !== "1") { + $ERROR('#10: (new Number(1)).toFixed(-0.1) === "1"'); + } +} +catch (e) { + $ERROR('#10: (new Number(1)).toFixed(-0.1) should not throw ' + e); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T01.js new file mode 100644 index 0000000000..f7863925d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T01.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: "Step 4: If this number value is NaN, return the string \"NaN\"" +es5id: 15.7.4.5_A1.3_T01 +description: NaN is computed by new Number("string") +---*/ + +//CHECK#1 +if ((new Number("a")).toFixed() !== "NaN") { + $ERROR('#1: (new Number("a")).prototype.toFixed() === "NaN"'); +} + +//CHECK#2 +if ((new Number("a")).toFixed(0) !== "NaN") { + $ERROR('#2: (new Number("a")).prototype.toFixed(0) === "NaN"'); +} + +//CHECK#3 +if ((new Number("a")).toFixed(1) !== "NaN") { + $ERROR('#3: (new Number("a")).prototype.toFixed(1) === "NaN"'); +} + +//CHECK#4 +if ((new Number("a")).toFixed(1.1) !== "NaN") { + $ERROR('#4: (new Number("a")).toFixed(1.1) === "NaN"'); +} + +//CHECK#5 +if ((new Number("a")).toFixed(0.9) !== "NaN") { + $ERROR('#5: (new Number("a")).toFixed(0.9) === "NaN"'); +} + +//CHECK#6 +if ((new Number("a")).toFixed("1") !== "NaN") { + $ERROR('#6: (new Number("a")).toFixed("1") === "NaN"'); +} + +//CHECK#7 +if ((new Number("a")).toFixed("1.1") !== "NaN") { + $ERROR('#7: (new Number("a")).toFixed("1.1") === "NaN"'); +} + +//CHECK#8 +if ((new Number("a")).toFixed("0.9") !== "NaN") { + $ERROR('#8: (new Number("a")).toFixed("0.9") === "NaN"'); +} + +//CHECK#9 +if ((new Number("a")).toFixed(Number.NaN) !== "NaN") { + $ERROR('#9: (new Number("a")).toFixed(Number.NaN) === "NaN"'); +} + +//CHECK#10 +if ((new Number("a")).toFixed("some string") !== "NaN") { + $ERROR('#9: (new Number("a")).toFixed("some string") === "NaN"'); +} + +//CHECK#10 +try { + s = (new Number("a")).toFixed(Number.POSITIVE_INFINITY); + $ERROR('#10: (new Number("a")).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not return NaN'); +} +catch (e) { + if (!(e instanceof RangeError)) { + $ERROR('#10: (new Number("a")).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T02.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T02.js new file mode 100644 index 0000000000..40ee54996e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T02.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: "Step 4: If this number value is NaN, return the string \"NaN\"" +es5id: 15.7.4.5_A1.3_T02 +description: direct usage of NaN +---*/ + +//CHECK#1 +if (Number.NaN.toFixed() !== "NaN") { + $ERROR('#1: Number.NaN.prototype.toFixed() === "NaN"'); +} + +//CHECK#2 +if (Number.NaN.toFixed(0) !== "NaN") { + $ERROR('#2: Number.NaN.prototype.toFixed(0) === "NaN"'); +} + +//CHECK#3 +if (Number.NaN.toFixed(1) !== "NaN") { + $ERROR('#3: Number.NaN.prototype.toFixed(1) === "NaN"'); +} + +//CHECK#4 +if (Number.NaN.toFixed(1.1) !== "NaN") { + $ERROR('#4: Number.NaN.toFixed(1.1) === "NaN"'); +} + +//CHECK#5 +if (Number.NaN.toFixed(0.9) !== "NaN") { + $ERROR('#5: Number.NaN.toFixed(0.9) === "NaN"'); +} + +//CHECK#6 +if (Number.NaN.toFixed("1") !== "NaN") { + $ERROR('#6: Number.NaN.toFixed("1") === "NaN"'); +} + +//CHECK#7 +if (Number.NaN.toFixed("1.1") !== "NaN") { + $ERROR('#7: Number.NaN.toFixed("1.1") === "NaN"'); +} + +//CHECK#8 +if (Number.NaN.toFixed("0.9") !== "NaN") { + $ERROR('#8: Number.NaN.toFixed("0.9") === "NaN"'); +} + +//CHECK#9 +if (Number.NaN.toFixed(Number.NaN) !== "NaN") { + $ERROR('#9: Number.NaN.toFixed(Number.NaN) === "NaN"'); +} + +//CHECK#10 +if (Number.NaN.toFixed("some string") !== "NaN") { + $ERROR('#9: Number.NaN.toFixed("some string") === "NaN"'); +} + +//CHECK#10 +try { + s = Number.NaN.toFixed(Number.POSITIVE_INFINITY); + $ERROR('#10: Number.NaN.toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not return NaN'); +} +catch (e) { + if (!(e instanceof RangeError)) { + $ERROR('#10: Number.NaN.toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.4_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.4_T01.js new file mode 100644 index 0000000000..8264d0e8ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.4_T01.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: "Step 9: If x >= 10^21, let m = ToString(x)" +es5id: 15.7.4.5_A1.4_T01 +description: x is 10^21 +---*/ + +//CHECK#1 +if ((new Number(1e21)).toFixed() !== String(1e21)) { + $ERROR('#1: (new Number(1e21)).prototype.toFixed() === String(1e21)'); +} + +//CHECK#2 +if ((new Number(1e21)).toFixed(0) !== String(1e21)) { + $ERROR('#2: (new Number(1e21)).prototype.toFixed(0) === String(1e21)'); +} + +//CHECK#3 +if ((new Number(1e21)).toFixed(1) !== String(1e21)) { + $ERROR('#3: (new Number(1e21)).prototype.toFixed(1) === String(1e21)'); +} + +//CHECK#4 +if ((new Number(1e21)).toFixed(1.1) !== String(1e21)) { + $ERROR('#4: (new Number(1e21)).toFixed(1.1) === String(1e21)'); +} + +//CHECK#5 +if ((new Number(1e21)).toFixed(0.9) !== String(1e21)) { + $ERROR('#5: (new Number(1e21)).toFixed(0.9) === String(1e21)'); +} + +//CHECK#6 +if ((new Number(1e21)).toFixed("1") !== String(1e21)) { + $ERROR('#6: (new Number(1e21)).toFixed("1") === String(1e21)'); +} + +//CHECK#7 +if ((new Number(1e21)).toFixed("1.1") !== String(1e21)) { + $ERROR('#7: (new Number(1e21)).toFixed("1.1") === String(1e21)'); +} + +//CHECK#8 +if ((new Number(1e21)).toFixed("0.9") !== String(1e21)) { + $ERROR('#8: (new Number(1e21)).toFixed("0.9") === String(1e21)'); +} + +//CHECK#9 +if ((new Number(1e21)).toFixed(Number.NaN) !== String(1e21)) { + $ERROR('#9: (new Number(1e21)).toFixed(Number.NaN) === String(1e21)'); +} + +//CHECK#10 +if ((new Number(1e21)).toFixed("some string") !== String(1e21)) { + $ERROR('#9: (new Number(1e21)).toFixed("some string") === String(1e21)'); +} + +//CHECK#10 +try { + s = (new Number(1e21)).toFixed(Number.POSITIVE_INFINITY); + $ERROR('#10: (new Number(1e21)).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not return NaN'); +} +catch (e) { + if (!(e instanceof RangeError)) { + $ERROR('#10: (new Number(1e21)).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A2_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A2_T01.js new file mode 100644 index 0000000000..dc8f85319f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A2_T01.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the toFixed method is 1 +es5id: 15.7.4.5_A2_T01 +description: Checking Number prototype itself +---*/ + +//CHECK#1 +if (Number.prototype.toFixed.hasOwnProperty("length") !== true) { + $ERROR('#1: The length property of the toFixed method is 1'); +} + +//CHECK#2 +if (Number.prototype.toFixed.length !== 1) { + $ERROR('#2: The length property of the toFixed method is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/browser.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/exactness.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/exactness.js new file mode 100644 index 0000000000..b9e3bebc30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/exactness.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tofixed +description: Number.prototype.toFixed does not use ToString's cleaner rounding +info: | + Number.prototype.toFixed ( fractionDigits ) + + ... + 8. Else x < 10^21, + a. Let n be an integer for which the exact mathematical value of n ÷ 10f - x is as close to zero as possible. If there are two such n, pick the larger n. + b. If n = 0, let m be the String "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes). + ... +---*/ + +// Test from a note in the specification +assert.sameValue((1000000000000000128).toString(), "1000000000000000100"); +assert.sameValue((1000000000000000128).toFixed(0), "1000000000000000128"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js new file mode 100644 index 0000000000..241a60ad57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Michael "Z" Goddard. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tofixed +description: > + Number.prototype.toFixed.length is 1. +info: | + Number.prototype.toFixed ( fractionDigits ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toFixed.length, 1); + +verifyNotEnumerable(Number.prototype.toFixed, "length"); +verifyNotWritable(Number.prototype.toFixed, "length"); +verifyConfigurable(Number.prototype.toFixed, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js new file mode 100644 index 0000000000..49a7dbd1a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.3 +description: > + Number.prototype.toFixed.name is "toFixed". +info: | + Number.prototype.toFixed ( fractionDigits ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toFixed.name, "toFixed"); + +verifyNotEnumerable(Number.prototype.toFixed, "name"); +verifyNotWritable(Number.prototype.toFixed, "name"); +verifyConfigurable(Number.prototype.toFixed, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js new file mode 100644 index 0000000000..639cedbd85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.prototype.toFixed does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Number.prototype.toFixed), + false, + 'isConstructor(Number.prototype.toFixed) must return false' +); + +assert.throws(TypeError, () => { + new Number.prototype.toFixed(); +}, '`new Number.prototype.toFixed()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/prop-desc.js new file mode 100644 index 0000000000..63e5f90153 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tofixed +description: > + "toFixed" property of Number.prototype +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number.prototype, "toFixed"); +verifyWritable(Number.prototype, "toFixed"); +verifyConfigurable(Number.prototype, "toFixed"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/range.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/range.js new file mode 100644 index 0000000000..03816c1e28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/range.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tofixed +description: Number.prototype.toFixed permits fractionDigits from 0 to 100 +info: | + Number.prototype.toFixed ( fractionDigits ) + + ... + 3. If _f_ < 0 or _f_ > 100, throw a *RangeError* exception. + ... +---*/ + +assert.sameValue((3).toFixed(-0), "3"); +assert.throws(RangeError, () => (3).toFixed(-1)); + +assert.sameValue((3).toFixed(100), "3.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); +assert.throws(RangeError, () => (3).toFixed(101)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/return-type.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/return-type.js new file mode 100644 index 0000000000..0f67d16857 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/return-type.js @@ -0,0 +1,12 @@ +// Copyright (C) 2017 K. Adam White. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tofixed +description: > + Number.prototype.toFixed returns a string value +---*/ + +assert.sameValue(typeof(123.456).toFixed(), "string"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/shell.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/browser.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js new file mode 100644 index 0000000000..0692c33edd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.4 +description: > + Number.prototype.toLocaleString.length is 0. +info: | + Number.prototype.toLocaleString( [ reserved1 [ , reserved2 ] ]) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toLocaleString.length, 0); + +verifyNotEnumerable(Number.prototype.toLocaleString, "length"); +verifyNotWritable(Number.prototype.toLocaleString, "length"); +verifyConfigurable(Number.prototype.toLocaleString, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js new file mode 100644 index 0000000000..35f6b9a62b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.4 +description: > + Number.prototype.toLocaleString.name is "toLocaleString". +info: | + Number.prototype.toLocaleString( [ reserved1 [ , reserved2 ] ]) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toLocaleString.name, "toLocaleString"); + +verifyNotEnumerable(Number.prototype.toLocaleString, "name"); +verifyNotWritable(Number.prototype.toLocaleString, "name"); +verifyConfigurable(Number.prototype.toLocaleString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js new file mode 100644 index 0000000000..d694532dcf --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.prototype.toLocaleString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Number.prototype.toLocaleString), + false, + 'isConstructor(Number.prototype.toLocaleString) must return false' +); + +assert.throws(TypeError, () => { + new Number.prototype.toLocaleString(); +}, '`new Number.prototype.toLocaleString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/prop-desc.js new file mode 100644 index 0000000000..ef08e78985 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tolocalestring +description: > + "toLocaleString" property of Number.prototype +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number.prototype, "toLocaleString"); +verifyWritable(Number.prototype, "toLocaleString"); +verifyConfigurable(Number.prototype, "toLocaleString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/shell.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/browser.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/exponential.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/exponential.js new file mode 100644 index 0000000000..172abfb596 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/exponential.js @@ -0,0 +1,110 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return string values using exponential character +info: | + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 5. Let s be the empty String. + [...] + 9. If x = 0, then + [...] + 10. Else x ≠ 0, + [...] + c. If e < -6 or e ≥ p, then + [...] + vii. Return the concatenation of s, m, code unit 0x0065 (LATIN SMALL + LETTER E), c, and d. + [...] +---*/ + +assert.sameValue((10).toPrecision(1), "1e+1"); +assert.sameValue((11).toPrecision(1), "1e+1"); +assert.sameValue((17).toPrecision(1), "2e+1"); +assert.sameValue((19).toPrecision(1), "2e+1"); +assert.sameValue((20).toPrecision(1), "2e+1"); + +assert.sameValue((100).toPrecision(1), "1e+2"); +assert.sameValue((1000).toPrecision(1), "1e+3"); +assert.sameValue((10000).toPrecision(1), "1e+4"); +assert.sameValue((100000).toPrecision(1), "1e+5"); + +assert.sameValue((100).toPrecision(2), "1.0e+2"); +assert.sameValue((1000).toPrecision(2), "1.0e+3"); +assert.sameValue((10000).toPrecision(2), "1.0e+4"); +assert.sameValue((100000).toPrecision(2), "1.0e+5"); + +assert.sameValue((1000).toPrecision(3), "1.00e+3"); +assert.sameValue((10000).toPrecision(3), "1.00e+4"); +assert.sameValue((100000).toPrecision(3), "1.00e+5"); + +assert.sameValue((42).toPrecision(1), "4e+1"); +assert.sameValue((-42).toPrecision(1), "-4e+1"); + +assert.sameValue((1.2345e+27).toPrecision(1), "1e+27"); +assert.sameValue((1.2345e+27).toPrecision(2), "1.2e+27"); +assert.sameValue((1.2345e+27).toPrecision(3), "1.23e+27"); +assert.sameValue((1.2345e+27).toPrecision(4), "1.234e+27"); +assert.sameValue((1.2345e+27).toPrecision(5), "1.2345e+27"); +assert.sameValue((1.2345e+27).toPrecision(6), "1.23450e+27"); +assert.sameValue((1.2345e+27).toPrecision(7), "1.234500e+27"); +assert.sameValue((1.2345e+27).toPrecision(16), "1.234500000000000e+27"); +assert.sameValue((1.2345e+27).toPrecision(17), "1.2345000000000000e+27"); +assert.sameValue((1.2345e+27).toPrecision(18), "1.23449999999999996e+27"); +assert.sameValue((1.2345e+27).toPrecision(19), "1.234499999999999962e+27"); +assert.sameValue((1.2345e+27).toPrecision(20), "1.2344999999999999618e+27"); +assert.sameValue((1.2345e+27).toPrecision(21), "1.23449999999999996184e+27"); + +assert.sameValue((-1.2345e+27).toPrecision(1), "-1e+27"); +assert.sameValue((-1.2345e+27).toPrecision(2), "-1.2e+27"); +assert.sameValue((-1.2345e+27).toPrecision(3), "-1.23e+27"); +assert.sameValue((-1.2345e+27).toPrecision(4), "-1.234e+27"); +assert.sameValue((-1.2345e+27).toPrecision(5), "-1.2345e+27"); +assert.sameValue((-1.2345e+27).toPrecision(6), "-1.23450e+27"); +assert.sameValue((-1.2345e+27).toPrecision(7), "-1.234500e+27"); +assert.sameValue((-1.2345e+27).toPrecision(16), "-1.234500000000000e+27"); +assert.sameValue((-1.2345e+27).toPrecision(17), "-1.2345000000000000e+27"); +assert.sameValue((-1.2345e+27).toPrecision(18), "-1.23449999999999996e+27"); +assert.sameValue((-1.2345e+27).toPrecision(19), "-1.234499999999999962e+27"); +assert.sameValue((-1.2345e+27).toPrecision(20), "-1.2344999999999999618e+27"); +assert.sameValue((-1.2345e+27).toPrecision(21), "-1.23449999999999996184e+27"); + +var n = new Number("1000000000000000000000"); // 1e+21 +assert.sameValue((n).toPrecision(1), "1e+21"); +assert.sameValue((n).toPrecision(2), "1.0e+21"); +assert.sameValue((n).toPrecision(3), "1.00e+21"); +assert.sameValue((n).toPrecision(4), "1.000e+21"); +assert.sameValue((n).toPrecision(5), "1.0000e+21"); +assert.sameValue((n).toPrecision(6), "1.00000e+21"); +assert.sameValue((n).toPrecision(7), "1.000000e+21"); +assert.sameValue((n).toPrecision(16), "1.000000000000000e+21"); +assert.sameValue((n).toPrecision(17), "1.0000000000000000e+21"); +assert.sameValue((n).toPrecision(18), "1.00000000000000000e+21"); +assert.sameValue((n).toPrecision(19), "1.000000000000000000e+21"); +assert.sameValue((n).toPrecision(20), "1.0000000000000000000e+21"); +assert.sameValue((n).toPrecision(21), "1.00000000000000000000e+21"); + +var n = new Number("0.000000000000000000001"); // 1e-21 +assert.sameValue((n).toPrecision(1), "1e-21"); +assert.sameValue((n).toPrecision(2), "1.0e-21"); +assert.sameValue((n).toPrecision(3), "1.00e-21"); +assert.sameValue((n).toPrecision(4), "1.000e-21"); +assert.sameValue((n).toPrecision(5), "1.0000e-21"); +assert.sameValue((n).toPrecision(6), "1.00000e-21"); +assert.sameValue((n).toPrecision(7), "1.000000e-21"); +assert.sameValue((n).toPrecision(16), "9.999999999999999e-22"); +assert.sameValue((n).toPrecision(17), "9.9999999999999991e-22"); +assert.sameValue((n).toPrecision(18), "9.99999999999999908e-22"); +assert.sameValue((n).toPrecision(19), "9.999999999999999075e-22"); +assert.sameValue((n).toPrecision(20), "9.9999999999999990754e-22"); +assert.sameValue((n).toPrecision(21), "9.99999999999999907537e-22"); + +assert.sameValue((0.00000001).toPrecision(1), "1e-8"); +assert.sameValue((-0.00000001).toPrecision(1), "-1e-8"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/infinity.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/infinity.js new file mode 100644 index 0000000000..6a0c519708 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/infinity.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return "NaN" if this is NaN +info: | + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 5. Let s be the empty String. + 6. If x < 0, then + a. Let s be code unit 0x002D (HYPHEN-MINUS). + b. Let x be -x. + 7. If x = +∞, then + a. Return the String that is the concatenation of s and "Infinity". + [...] +---*/ + +assert.sameValue((+Infinity).toPrecision(1000), "Infinity", "Infinity value"); +var n = new Number(+Infinity); +assert.sameValue(n.toPrecision(1000), "Infinity", "Number Infinity"); + +assert.sameValue((-Infinity).toPrecision(1000), "-Infinity", "-Infinity value"); +var n = new Number(-Infinity); +assert.sameValue(n.toPrecision(1000), "-Infinity", "Number -Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js new file mode 100644 index 0000000000..a5cecd54d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.5 +description: > + Number.prototype.toPrecision.length is 1. +info: | + Number.prototype.toPrecision ( precision ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toPrecision.length, 1); + +verifyNotEnumerable(Number.prototype.toPrecision, "length"); +verifyNotWritable(Number.prototype.toPrecision, "length"); +verifyConfigurable(Number.prototype.toPrecision, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js new file mode 100644 index 0000000000..946c5ad308 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.5 +description: > + Number.prototype.toPrecision.name is "toPrecision". +info: | + Number.prototype.toPrecision ( precision ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toPrecision.name, "toPrecision"); + +verifyNotEnumerable(Number.prototype.toPrecision, "name"); +verifyNotWritable(Number.prototype.toPrecision, "name"); +verifyConfigurable(Number.prototype.toPrecision, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/nan.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/nan.js new file mode 100644 index 0000000000..41bc08e922 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/nan.js @@ -0,0 +1,56 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return "NaN" if this is NaN +info: | + 20.1.3 Properties of the Number Prototype Object + + The Number prototype object is the intrinsic object %NumberPrototype%. The + Number prototype object is an ordinary object. The Number prototype is itself + a Number object; it has a [[NumberData]] internal slot with the value +0. + + [...] + The abstract operation thisNumberValue(value) performs the following steps: + + 1. If Type(value) is Number, return value. + 2. If Type(value) is Object and value has a [[NumberData]] internal slot, then + a. Assert: value's [[NumberData]] internal slot is a Number value. + b. Return the value of value's [[NumberData]] internal slot. + 3. Throw a TypeError exception. + + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + 2. If precision is undefined, return ! ToString(x). + 3. Let p be ? ToInteger(precision). + 4. If x is NaN, return the String "NaN". + [...] +---*/ + +assert.sameValue( + NaN.toPrecision(undefined), + "NaN", + "step 2: If precision is undefined, return ! ToString(x)" +); + +var calls = 0; + +var p = { + valueOf: function() { + calls++; + return Infinity; + } +}; + +assert.sameValue(NaN.toPrecision(p), "NaN", "value"); +assert.sameValue(calls, 1, "NaN is checked after ToInteger(precision)"); + +var n = new Number(NaN); +calls = 0; +assert.sameValue(n.toPrecision(p), "NaN", "object"); +assert.sameValue(calls, 1, "Number NaN is checked after ToInteger(precision)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js new file mode 100644 index 0000000000..5424e12b7e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.prototype.toPrecision does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Number.prototype.toPrecision), + false, + 'isConstructor(Number.prototype.toPrecision) must return false' +); + +assert.throws(TypeError, () => { + new Number.prototype.toPrecision(); +}, '`new Number.prototype.toPrecision()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/precision-cannot-be-coerced-to-a-number-in-range.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/precision-cannot-be-coerced-to-a-number-in-range.js new file mode 100644 index 0000000000..e3aa62e7cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/precision-cannot-be-coerced-to-a-number-in-range.js @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Throws a RangeError if precision cannot be coerced to a number in range. +info: | + Let p be ? ToInteger(precision). + If x is not finite, return ! Number::toString(x). + If p < 1 or p > 100, throw a RangeError exception. + +features: [Symbol] +---*/ + +var toPrecision = Number.prototype.toPrecision; + +assert.throws(RangeError, function() { + toPrecision.call(1, function() {}); +}, "`function() {}` doesn't coerce into a number in range (1-100)"); + +assert.throws(RangeError, function() { + toPrecision.call(1, NaN); +}, "NaN doesn't coerce into a number in range (1-100)"); + +assert.throws(RangeError, function() { + toPrecision.call(1, {}); +}, "{} doesn't coerce into a number in range (1-100)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/prop-desc.js new file mode 100644 index 0000000000..f46b260076 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/prop-desc.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + "toPrecision" property of Number.prototype +info: | + ES6 section 17: Every other data property described in clauses 18 through 26 + and in Annex B.2 has the attributes { [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number.prototype, "toPrecision"); +verifyWritable(Number.prototype, "toPrecision"); +verifyConfigurable(Number.prototype, "toPrecision"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/range.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/range.js new file mode 100644 index 0000000000..7c1043736f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/range.js @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: Number.prototype.toPrecision permits fractionDigits from 1 to 100 +info: | + Number.prototype.toPrecision ( fractionDigits ) + + ... + 8. If _p_ < 1 or _p_ > 100, throw a *RangeError* exception. + ... +---*/ + +assert.sameValue((3).toPrecision(1), "3"); +assert.throws(RangeError, () => (3).toPrecision(0)); +assert.throws(RangeError, () => (3).toPrecision(-10)); + +assert.sameValue((3).toPrecision(100), "3.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); +assert.throws(RangeError, () => (3).toPrecision(101)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision-symbol.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision-symbol.js new file mode 100644 index 0000000000..7a9374bb85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision-symbol.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return abrupt completion from ToInteger(symbol precision) +info: | + 20.1.3 Properties of the Number Prototype Object + + The Number prototype object is the intrinsic object %NumberPrototype%. The + Number prototype object is an ordinary object. The Number prototype is itself + a Number object; it has a [[NumberData]] internal slot with the value +0. + + [...] + The abstract operation thisNumberValue(value) performs the following steps: + + 1. If Type(value) is Number, return value. + 2. If Type(value) is Object and value has a [[NumberData]] internal slot, then + a. Assert: value's [[NumberData]] internal slot is a Number value. + b. Return the value of value's [[NumberData]] internal slot. + 3. Throw a TypeError exception. + + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + 2. If precision is undefined, return ! ToString(x). + 3. Let p be ? ToInteger(precision). + [...] +features: [Symbol] +---*/ + +var p = Symbol("1"); + +assert.throws(TypeError, function() { + Number.prototype.toPrecision(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision.js new file mode 100644 index 0000000000..4d972449be --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision.js @@ -0,0 +1,52 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return abrupt completion from ToInteger(precision) +info: | + 20.1.3 Properties of the Number Prototype Object + + The Number prototype object is the intrinsic object %NumberPrototype%. The + Number prototype object is an ordinary object. The Number prototype is itself + a Number object; it has a [[NumberData]] internal slot with the value +0. + + [...] + The abstract operation thisNumberValue(value) performs the following steps: + + 1. If Type(value) is Number, return value. + 2. If Type(value) is Object and value has a [[NumberData]] internal slot, then + a. Assert: value's [[NumberData]] internal slot is a Number value. + b. Return the value of value's [[NumberData]] internal slot. + 3. Throw a TypeError exception. + + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + 2. If precision is undefined, return ! ToString(x). + 3. Let p be ? ToInteger(precision). + [...] +---*/ + +var p1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var p2 = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + Number.prototype.toPrecision(p1); +}, "valueOf"); + +assert.throws(Test262Error, function() { + Number.prototype.toPrecision(p2); +}, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-values.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-values.js new file mode 100644 index 0000000000..b75141141a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/return-values.js @@ -0,0 +1,65 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return regular string values +info: | + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 5. Let s be the empty String. + [...] + 11. If e = p-1, return the concatenation of the Strings s and m. + 12. If e ≥ 0, then + a. Let m be the concatenation of the first e+1 elements of m, the code unit + 0x002E (FULL STOP), and the remaining p- (e+1) elements of m. + 13. Else e < 0, + a. Let m be the String formed by the concatenation of code unit 0x0030 + (DIGIT ZERO), code unit 0x002E (FULL STOP), -(e+1) occurrences of code unit + 0x0030 (DIGIT ZERO), and the String m. + 14. Return the String that is the concatenation of s and m. +---*/ + +assert.sameValue((7).toPrecision(1), "7"); +assert.sameValue((7).toPrecision(2), "7.0"); +assert.sameValue((7).toPrecision(3), "7.00"); +assert.sameValue((7).toPrecision(19), "7.000000000000000000"); +assert.sameValue((7).toPrecision(20), "7.0000000000000000000"); +assert.sameValue((7).toPrecision(21), "7.00000000000000000000"); + +assert.sameValue((-7).toPrecision(1), "-7"); +assert.sameValue((-7).toPrecision(2), "-7.0"); +assert.sameValue((-7).toPrecision(3), "-7.00"); +assert.sameValue((-7).toPrecision(19), "-7.000000000000000000"); +assert.sameValue((-7).toPrecision(20), "-7.0000000000000000000"); +assert.sameValue((-7).toPrecision(21), "-7.00000000000000000000"); + +assert.sameValue((10).toPrecision(2), "10"); +assert.sameValue((11).toPrecision(2), "11"); +assert.sameValue((17).toPrecision(2), "17"); +assert.sameValue((19).toPrecision(2), "19"); +assert.sameValue((20).toPrecision(2), "20"); + +assert.sameValue((-10).toPrecision(2), "-10"); +assert.sameValue((-11).toPrecision(2), "-11"); +assert.sameValue((-17).toPrecision(2), "-17"); +assert.sameValue((-19).toPrecision(2), "-19"); +assert.sameValue((-20).toPrecision(2), "-20"); + +assert.sameValue((42).toPrecision(2), "42"); +assert.sameValue((-42).toPrecision(2), "-42"); + +assert.sameValue((100).toPrecision(3), "100"); +assert.sameValue((100).toPrecision(7), "100.0000"); +assert.sameValue((1000).toPrecision(7), "1000.000"); +assert.sameValue((10000).toPrecision(7), "10000.00"); +assert.sameValue((100000).toPrecision(7), "100000.0"); + +assert.sameValue((0.000001).toPrecision(1), "0.000001"); +assert.sameValue((0.000001).toPrecision(2), "0.0000010"); +assert.sameValue((0.000001).toPrecision(3), "0.00000100"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/shell.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-is-0-precision-is-1.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-is-0-precision-is-1.js new file mode 100644 index 0000000000..eefebd7099 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-is-0-precision-is-1.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return "0" if this value is 0 and precision is 1 +info: | + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 5. Let s be the empty String. + [...] + 9. If x = 0, then + a. Let m be the String consisting of p occurrences of the code unit 0x0030 + (DIGIT ZERO). + b. Let e be 0. + [...] + 11. If e = p-1, return the concatenation of the Strings s and m. +---*/ + +assert.sameValue(Number.prototype.toPrecision(1), "0", "Number.prototype is 0"); + +assert.sameValue((-0).toPrecision(1), "0", "-0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-is-0-precision-is-gter-than-1.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-is-0-precision-is-gter-than-1.js new file mode 100644 index 0000000000..ba6c6f3ad4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-is-0-precision-is-gter-than-1.js @@ -0,0 +1,64 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return string value for this value = 0 and precision is > 1 +info: | + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + [...] + 5. Let s be the empty String. + [...] + 9. If x = 0, then + a. Let m be the String consisting of p occurrences of the code unit 0x0030 + (DIGIT ZERO). + b. Let e be 0. + [...] + 11. If e = p-1, return the concatenation of the Strings s and m. + 12. If e ≥ 0, then + a. Let m be the concatenation of the first e+1 elements of m, the code unit + 0x002E (FULL STOP), and the remaining p- (e+1) elements of m. + [...] + 14. Return the String that is the concatenation of s and m. +---*/ + +assert.sameValue( + (0).toPrecision(2), + "0.0", + "(0).toPrecision(2)" +); + +assert.sameValue( + (0).toPrecision(7), + "0.000000", + "(0).toPrecision(7)" +); + +assert.sameValue( + (0).toPrecision(21), + "0.00000000000000000000", + "(0).toPrecision(21)" +); + +assert.sameValue( + (-0).toPrecision(2), + "0.0", + "(-0).toPrecision(2)" +); + +assert.sameValue( + (-0).toPrecision(7), + "0.000000", + "(-0).toPrecision(7)" +); + +assert.sameValue( + (-0).toPrecision(21), + "0.00000000000000000000", + "(-0).toPrecision(21)" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-type-not-number-or-number-object.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-type-not-number-or-number-object.js new file mode 100644 index 0000000000..27d8f1eba6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/this-type-not-number-or-number-object.js @@ -0,0 +1,69 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Throws a TypeError if this value is not a number object or value +info: | + 20.1.3 Properties of the Number Prototype Object + + The Number prototype object is the intrinsic object %NumberPrototype%. The + Number prototype object is an ordinary object. The Number prototype is itself + a Number object; it has a [[NumberData]] internal slot with the value +0. + + [...] + The abstract operation thisNumberValue(value) performs the following steps: + + 1. If Type(value) is Number, return value. + 2. If Type(value) is Object and value has a [[NumberData]] internal slot, then + a. Assert: value's [[NumberData]] internal slot is a Number value. + b. Return the value of value's [[NumberData]] internal slot. + 3. Throw a TypeError exception. + + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + [...] +features: [Symbol] +---*/ + +var toPrecision = Number.prototype.toPrecision; + +assert.throws(TypeError, function() { + toPrecision.call({}, 1); +}, "{}"); + +assert.throws(TypeError, function() { + toPrecision.call("1", 1); +}, "string"); + +assert.throws(TypeError, function() { + toPrecision.call(Number, 1); +}, "Number"); + +assert.throws(TypeError, function() { + toPrecision.call(true, 1); +}, "true"); + +assert.throws(TypeError, function() { + toPrecision.call(false, 1); +}, "false"); + +assert.throws(TypeError, function() { + toPrecision.call(null, 1); +}, "null"); + +assert.throws(TypeError, function() { + toPrecision.call(undefined, 1); +}, "undefined"); + +assert.throws(TypeError, function() { + toPrecision.call(Symbol("1"), 1); +}, "symbol"); + +assert.throws(TypeError, function() { + toPrecision.call([], 1); +}, "[]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/tointeger-precision.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/tointeger-precision.js new file mode 100644 index 0000000000..90599f6589 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/tointeger-precision.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + ToInteger(precision) operations +info: | + Number.prototype.toPrecision ( precision ) + + [...] + 3. Let p be ? ToInteger(precision). + [...] +---*/ + +assert.sameValue((123.456).toPrecision(1.1), "1e+2", "1.1"); +assert.sameValue((123.456).toPrecision(1.9), "1e+2", "1.9"); + +assert.sameValue((123.456).toPrecision(true), "1e+2", "true"); + +assert.sameValue((123.456).toPrecision("2"), "1.2e+2", "string"); + +assert.sameValue((123.456).toPrecision([2]), "1.2e+2", "[2]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/undefined-precision-arg.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/undefined-precision-arg.js new file mode 100644 index 0000000000..54ebcc14e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/undefined-precision-arg.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.toprecision +description: > + Return a string containing the the number value of this if precision is + undefined +info: | + 20.1.3 Properties of the Number Prototype Object + + The Number prototype object is the intrinsic object %NumberPrototype%. The + Number prototype object is an ordinary object. The Number prototype is itself + a Number object; it has a [[NumberData]] internal slot with the value +0. + + [...] + The abstract operation thisNumberValue(value) performs the following steps: + + 1. If Type(value) is Number, return value. + 2. If Type(value) is Object and value has a [[NumberData]] internal slot, then + a. Assert: value's [[NumberData]] internal slot is a Number value. + b. Return the value of value's [[NumberData]] internal slot. + 3. Throw a TypeError exception. + + Number.prototype.toPrecision ( precision ) + + 1. Let x be ? thisNumberValue(this value). + 2. If precision is undefined, return ! ToString(x). + [...] +---*/ + +var n = new Number(7); + +assert.sameValue(n.toPrecision(undefined), "7"); +assert.sameValue((39).toPrecision(undefined), "39"); + +assert.sameValue(Number.prototype.toPrecision(), "0"); +assert.sameValue((42).toPrecision(), "42"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T01.js new file mode 100644 index 0000000000..b4082b6053 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T01.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + toString: If radix is the number 10 or undefined, then this + number value is given as an argument to the ToString operator. + the resulting string value is returned +es5id: 15.7.4.2_A1_T01 +description: undefined radix +---*/ + +//CHECK#1 +if (Number.prototype.toString() !== "0") { + $ERROR('#1: Number.prototype.toString() === "0"'); +} + +//CHECK#2 +if ((new Number()).toString() !== "0") { + $ERROR('#2: (new Number()).toString() === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString() !== "0") { + $ERROR('#3: (new Number(0)).toString() === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString() !== "-1") { + $ERROR('#4: (new Number(-1)).toString() === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString() !== "1") { + $ERROR('#5: (new Number(1)).toString() === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString() !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString() === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString() !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString() === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString() !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString() === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T02.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T02.js new file mode 100644 index 0000000000..c4b061964d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T02.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + toString: If radix is the number 10 or undefined, then this + number value is given as an argument to the ToString operator. + the resulting string value is returned +es5id: 15.7.4.2_A1_T02 +description: radix is 10 +---*/ + +//CHECK#1 +if (Number.prototype.toString(10) !== "0") { + $ERROR('#1: Number.prototype.toString(10) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(10) !== "0") { + $ERROR('#2: (new Number()).toString(10) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(10) !== "0") { + $ERROR('#3: (new Number(0)).toString(10) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(10) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(10) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(10) !== "1") { + $ERROR('#5: (new Number(1)).toString(10) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(10) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(10) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(10) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(10) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(10) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(10) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T03.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T03.js new file mode 100644 index 0000000000..970f6d490c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T03.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + toString: If radix is the number 10 or undefined, then this + number value is given as an argument to the ToString operator. + the resulting string value is returned +es5id: 15.7.4.2_A1_T03 +description: radix is undefined value +---*/ + +//CHECK#1 +if (Number.prototype.toString(undefined) !== "0") { + $ERROR('#1: Number.prototype.toString(undefined) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(undefined) !== "0") { + $ERROR('#2: (new Number()).toString(undefined) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(undefined) !== "0") { + $ERROR('#3: (new Number(0)).toString(undefined) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(undefined) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(undefined) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(undefined) !== "1") { + $ERROR('#5: (new Number(1)).toString(undefined) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(undefined) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(undefined) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(undefined) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(undefined) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(undefined) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(undefined) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T01.js new file mode 100644 index 0000000000..4b25223401 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T01.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T01 +description: radix is 2 +---*/ + +//CHECK#1 +if (Number.prototype.toString(2) !== "0") { + $ERROR('#1: Number.prototype.toString(2) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(2) !== "0") { + $ERROR('#2: (new Number()).toString(2) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(2) !== "0") { + $ERROR('#3: (new Number(0)).toString(2) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(2) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(2) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(2) !== "1") { + $ERROR('#5: (new Number(1)).toString(2) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(2) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(2) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(2) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(2) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(2) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(2) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T02.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T02.js new file mode 100644 index 0000000000..e0470fbcd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T02.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T02 +description: radix is 3 +---*/ + +//CHECK#1 +if (Number.prototype.toString(3) !== "0") { + $ERROR('#1: Number.prototype.toString(3) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(3) !== "0") { + $ERROR('#2: (new Number()).toString(3) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(3) !== "0") { + $ERROR('#3: (new Number(0)).toString(3) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(3) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(3) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(3) !== "1") { + $ERROR('#5: (new Number(1)).toString(3) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(3) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(3) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(3) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(3) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(3) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(3) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T03.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T03.js new file mode 100644 index 0000000000..c1f09fb27a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T03.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T03 +description: radix is 4 +---*/ + +//CHECK#1 +if (Number.prototype.toString(4) !== "0") { + $ERROR('#1: Number.prototype.toString(4) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(4) !== "0") { + $ERROR('#2: (new Number()).toString(4) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(4) !== "0") { + $ERROR('#3: (new Number(0)).toString(4) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(4) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(4) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(4) !== "1") { + $ERROR('#5: (new Number(1)).toString(4) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(4) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(4) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(4) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(4) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(4) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(4) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T04.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T04.js new file mode 100644 index 0000000000..86e1a4ad14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T04.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T04 +description: radix is 5 +---*/ + +//CHECK#1 +if (Number.prototype.toString(5) !== "0") { + $ERROR('#1: Number.prototype.toString(5) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(5) !== "0") { + $ERROR('#2: (new Number()).toString(5) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(5) !== "0") { + $ERROR('#3: (new Number(0)).toString(5) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(5) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(5) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(5) !== "1") { + $ERROR('#5: (new Number(1)).toString(5) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(5) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(5) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(5) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(5) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(5) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(5) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T05.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T05.js new file mode 100644 index 0000000000..6aa5e02e06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T05.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T05 +description: radix is 6 +---*/ + +//CHECK#1 +if (Number.prototype.toString(6) !== "0") { + $ERROR('#1: Number.prototype.toString(6) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(6) !== "0") { + $ERROR('#2: (new Number()).toString(6) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(6) !== "0") { + $ERROR('#3: (new Number(0)).toString(6) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(6) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(6) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(6) !== "1") { + $ERROR('#5: (new Number(1)).toString(6) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(6) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(6) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(6) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(6) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(6) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(6) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T06.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T06.js new file mode 100644 index 0000000000..b56c9413c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T06.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T06 +description: radix is 7 +---*/ + +//CHECK#1 +if (Number.prototype.toString(7) !== "0") { + $ERROR('#1: Number.prototype.toString(7) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(7) !== "0") { + $ERROR('#2: (new Number()).toString(7) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(7) !== "0") { + $ERROR('#3: (new Number(0)).toString(7) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(7) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(7) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(7) !== "1") { + $ERROR('#5: (new Number(1)).toString(7) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(7) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(7) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(7) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(7) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(7) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(7) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T07.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T07.js new file mode 100644 index 0000000000..bab5be25fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T07.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T07 +description: radix is 8 +---*/ + +//CHECK#1 +if (Number.prototype.toString(8) !== "0") { + $ERROR('#1: Number.prototype.toString(8) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(8) !== "0") { + $ERROR('#2: (new Number()).toString(8) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(8) !== "0") { + $ERROR('#3: (new Number(0)).toString(8) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(8) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(8) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(8) !== "1") { + $ERROR('#5: (new Number(1)).toString(8) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(8) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(8) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(8) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(8) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(8) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(8) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T08.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T08.js new file mode 100644 index 0000000000..2b9fc05bb4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T08.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T08 +description: radix is 9 +---*/ + +//CHECK#1 +if (Number.prototype.toString(9) !== "0") { + $ERROR('#1: Number.prototype.toString(9) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(9) !== "0") { + $ERROR('#2: (new Number()).toString(9) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(9) !== "0") { + $ERROR('#3: (new Number(0)).toString(9) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(9) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(9) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(9) !== "1") { + $ERROR('#5: (new Number(1)).toString(9) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(9) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(9) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(9) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(9) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(9) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(9) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T09.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T09.js new file mode 100644 index 0000000000..3375634226 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T09.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T09 +description: radix is 11 +---*/ + +//CHECK#1 +if (Number.prototype.toString(11) !== "0") { + $ERROR('#1: Number.prototype.toString(11) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(11) !== "0") { + $ERROR('#2: (new Number()).toString(11) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(11) !== "0") { + $ERROR('#3: (new Number(0)).toString(11) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(11) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(11) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(11) !== "1") { + $ERROR('#5: (new Number(1)).toString(11) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(11) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(11) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(11) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(11) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(11) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(11) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T10.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T10.js new file mode 100644 index 0000000000..c443710dec --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T10.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T10 +description: radix is 12 +---*/ + +//CHECK#1 +if (Number.prototype.toString(12) !== "0") { + $ERROR('#1: Number.prototype.toString(12) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(12) !== "0") { + $ERROR('#2: (new Number()).toString(12) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(12) !== "0") { + $ERROR('#3: (new Number(0)).toString(12) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(12) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(12) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(12) !== "1") { + $ERROR('#5: (new Number(1)).toString(12) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(12) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(12) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(12) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(12) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(12) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(12) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T11.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T11.js new file mode 100644 index 0000000000..f6d4cdf74e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T11.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T11 +description: radix is 13 +---*/ + +//CHECK#1 +if (Number.prototype.toString(13) !== "0") { + $ERROR('#1: Number.prototype.toString(13) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(13) !== "0") { + $ERROR('#2: (new Number()).toString(13) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(13) !== "0") { + $ERROR('#3: (new Number(0)).toString(13) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(13) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(13) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(13) !== "1") { + $ERROR('#5: (new Number(1)).toString(13) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(13) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(13) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(13) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(13) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(13) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(13) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T12.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T12.js new file mode 100644 index 0000000000..85cc011c06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T12.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T12 +description: radix is 14 +---*/ + +//CHECK#1 +if (Number.prototype.toString(14) !== "0") { + $ERROR('#1: Number.prototype.toString(14) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(14) !== "0") { + $ERROR('#2: (new Number()).toString(14) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(14) !== "0") { + $ERROR('#3: (new Number(0)).toString(14) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(14) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(14) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(14) !== "1") { + $ERROR('#5: (new Number(1)).toString(14) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(14) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(14) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(14) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(14) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(14) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(14) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T13.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T13.js new file mode 100644 index 0000000000..b2fa65f290 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T13.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T13 +description: radix is 15 +---*/ + +//CHECK#1 +if (Number.prototype.toString(15) !== "0") { + $ERROR('#1: Number.prototype.toString(15) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(15) !== "0") { + $ERROR('#2: (new Number()).toString(15) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(15) !== "0") { + $ERROR('#3: (new Number(0)).toString(15) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(15) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(15) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(15) !== "1") { + $ERROR('#5: (new Number(1)).toString(15) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(15) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(15) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(15) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(15) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(15) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(15) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T14.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T14.js new file mode 100644 index 0000000000..c0cc318778 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T14.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T14 +description: radix is 16 +---*/ + +//CHECK#1 +if (Number.prototype.toString(16) !== "0") { + $ERROR('#1: Number.prototype.toString(16) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(16) !== "0") { + $ERROR('#2: (new Number()).toString(16) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(16) !== "0") { + $ERROR('#3: (new Number(0)).toString(16) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(16) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(16) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(16) !== "1") { + $ERROR('#5: (new Number(1)).toString(16) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(16) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(16) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(16) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(16) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(16) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(16) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T15.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T15.js new file mode 100644 index 0000000000..50d122a6c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T15.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T15 +description: radix is 17 +---*/ + +//CHECK#1 +if (Number.prototype.toString(17) !== "0") { + $ERROR('#1: Number.prototype.toString(17) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(17) !== "0") { + $ERROR('#2: (new Number()).toString(17) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(17) !== "0") { + $ERROR('#3: (new Number(0)).toString(17) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(17) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(17) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(17) !== "1") { + $ERROR('#5: (new Number(1)).toString(17) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(17) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(17) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(17) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(17) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(17) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(17) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T16.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T16.js new file mode 100644 index 0000000000..27831bf8fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T16.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T16 +description: radix is 18 +---*/ + +//CHECK#1 +if (Number.prototype.toString(18) !== "0") { + $ERROR('#1: Number.prototype.toString(18) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(18) !== "0") { + $ERROR('#2: (new Number()).toString(18) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(18) !== "0") { + $ERROR('#3: (new Number(0)).toString(18) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(18) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(18) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(18) !== "1") { + $ERROR('#5: (new Number(1)).toString(18) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(18) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(18) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(18) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(18) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(18) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(18) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T17.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T17.js new file mode 100644 index 0000000000..54cc1f0582 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T17.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T17 +description: radix is 19 +---*/ + +//CHECK#1 +if (Number.prototype.toString(19) !== "0") { + $ERROR('#1: Number.prototype.toString(19) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(19) !== "0") { + $ERROR('#2: (new Number()).toString(19) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(19) !== "0") { + $ERROR('#3: (new Number(0)).toString(19) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(19) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(19) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(19) !== "1") { + $ERROR('#5: (new Number(1)).toString(19) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(19) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(19) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(19) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(19) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(19) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(19) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T18.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T18.js new file mode 100644 index 0000000000..7b2f39c805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T18.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T18 +description: radix is 20 +---*/ + +//CHECK#1 +if (Number.prototype.toString(20) !== "0") { + $ERROR('#1: Number.prototype.toString(20) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(20) !== "0") { + $ERROR('#2: (new Number()).toString(20) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(20) !== "0") { + $ERROR('#3: (new Number(0)).toString(20) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(20) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(20) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(20) !== "1") { + $ERROR('#5: (new Number(1)).toString(20) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(20) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(20) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(20) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(20) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(20) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(20) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T19.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T19.js new file mode 100644 index 0000000000..c38424424b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T19.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T19 +description: radix is 21 +---*/ + +//CHECK#1 +if (Number.prototype.toString(21) !== "0") { + $ERROR('#1: Number.prototype.toString(21) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(21) !== "0") { + $ERROR('#2: (new Number()).toString(21) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(21) !== "0") { + $ERROR('#3: (new Number(0)).toString(21) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(21) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(21) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(21) !== "1") { + $ERROR('#5: (new Number(1)).toString(21) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(21) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(21) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(21) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(21) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(21) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(21) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T20.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T20.js new file mode 100644 index 0000000000..522af87ed6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T20.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T20 +description: radix is 22 +---*/ + +//CHECK#1 +if (Number.prototype.toString(22) !== "0") { + $ERROR('#1: Number.prototype.toString(22) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(22) !== "0") { + $ERROR('#2: (new Number()).toString(22) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(22) !== "0") { + $ERROR('#3: (new Number(0)).toString(22) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(22) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(22) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(22) !== "1") { + $ERROR('#5: (new Number(1)).toString(22) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(22) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(22) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(22) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(22) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(22) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(22) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T21.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T21.js new file mode 100644 index 0000000000..fd5c6d8158 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T21.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T21 +description: radix is 23 +---*/ + +//CHECK#1 +if (Number.prototype.toString(23) !== "0") { + $ERROR('#1: Number.prototype.toString(23) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(23) !== "0") { + $ERROR('#2: (new Number()).toString(23) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(23) !== "0") { + $ERROR('#3: (new Number(0)).toString(23) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(23) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(23) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(23) !== "1") { + $ERROR('#5: (new Number(1)).toString(23) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(23) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(23) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(23) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(23) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(23) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(23) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T22.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T22.js new file mode 100644 index 0000000000..7171724ada --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T22.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T22 +description: radix is 24 +---*/ + +//CHECK#1 +if (Number.prototype.toString(24) !== "0") { + $ERROR('#1: Number.prototype.toString(24) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(24) !== "0") { + $ERROR('#2: (new Number()).toString(24) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(24) !== "0") { + $ERROR('#3: (new Number(0)).toString(24) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(24) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(24) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(24) !== "1") { + $ERROR('#5: (new Number(1)).toString(24) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(24) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(24) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(24) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(24) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(24) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(24) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T23.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T23.js new file mode 100644 index 0000000000..77bda579c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T23.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T23 +description: radix is 25 +---*/ + +//CHECK#1 +if (Number.prototype.toString(25) !== "0") { + $ERROR('#1: Number.prototype.toString(25) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(25) !== "0") { + $ERROR('#2: (new Number()).toString(25) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(25) !== "0") { + $ERROR('#3: (new Number(0)).toString(25) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(25) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(25) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(25) !== "1") { + $ERROR('#5: (new Number(1)).toString(25) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(25) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(25) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(25) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(25) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(25) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(25) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T24.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T24.js new file mode 100644 index 0000000000..c7fb3c8dee --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T24.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T24 +description: radix is 26 +---*/ + +//CHECK#1 +if (Number.prototype.toString(26) !== "0") { + $ERROR('#1: Number.prototype.toString(26) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(26) !== "0") { + $ERROR('#2: (new Number()).toString(26) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(26) !== "0") { + $ERROR('#3: (new Number(0)).toString(26) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(26) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(26) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(26) !== "1") { + $ERROR('#5: (new Number(1)).toString(26) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(26) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(26) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(26) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(26) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(26) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(26) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T25.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T25.js new file mode 100644 index 0000000000..65b1876022 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T25.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T25 +description: radix is 27 +---*/ + +//CHECK#1 +if (Number.prototype.toString(27) !== "0") { + $ERROR('#1: Number.prototype.toString(27) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(27) !== "0") { + $ERROR('#2: (new Number()).toString(27) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(27) !== "0") { + $ERROR('#3: (new Number(0)).toString(27) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(27) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(27) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(27) !== "1") { + $ERROR('#5: (new Number(1)).toString(27) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(27) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(27) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(27) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(27) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(27) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(27) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T26.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T26.js new file mode 100644 index 0000000000..2f766ffdc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T26.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T26 +description: radix is 28 +---*/ + +//CHECK#1 +if (Number.prototype.toString(28) !== "0") { + $ERROR('#1: Number.prototype.toString(28) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(28) !== "0") { + $ERROR('#2: (new Number()).toString(28) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(28) !== "0") { + $ERROR('#3: (new Number(0)).toString(28) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(28) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(28) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(28) !== "1") { + $ERROR('#5: (new Number(1)).toString(28) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(28) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(28) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(28) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(28) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(28) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(28) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T27.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T27.js new file mode 100644 index 0000000000..b09f468623 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T27.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T27 +description: radix is 29 +---*/ + +//CHECK#1 +if (Number.prototype.toString(29) !== "0") { + $ERROR('#1: Number.prototype.toString(29) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(29) !== "0") { + $ERROR('#2: (new Number()).toString(29) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(29) !== "0") { + $ERROR('#3: (new Number(0)).toString(29) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(29) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(29) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(29) !== "1") { + $ERROR('#5: (new Number(1)).toString(29) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(29) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(29) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(29) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(29) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(29) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(29) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T28.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T28.js new file mode 100644 index 0000000000..0613e053af --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T28.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T28 +description: radix is 30 +---*/ + +//CHECK#1 +if (Number.prototype.toString(30) !== "0") { + $ERROR('#1: Number.prototype.toString(30) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(30) !== "0") { + $ERROR('#2: (new Number()).toString(30) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(30) !== "0") { + $ERROR('#3: (new Number(0)).toString(30) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(30) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(30) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(30) !== "1") { + $ERROR('#5: (new Number(1)).toString(30) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(30) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(30) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(30) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(30) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(30) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(30) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T29.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T29.js new file mode 100644 index 0000000000..53b9c276a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T29.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T29 +description: radix is 31 +---*/ + +//CHECK#1 +if (Number.prototype.toString(31) !== "0") { + $ERROR('#1: Number.prototype.toString(31) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(31) !== "0") { + $ERROR('#2: (new Number()).toString(31) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(31) !== "0") { + $ERROR('#3: (new Number(0)).toString(31) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(31) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(31) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(31) !== "1") { + $ERROR('#5: (new Number(1)).toString(31) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(31) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(31) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(31) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(31) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(31) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(31) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T30.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T30.js new file mode 100644 index 0000000000..09aa92b0ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T30.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T30 +description: radix is 32 +---*/ + +//CHECK#1 +if (Number.prototype.toString(32) !== "0") { + $ERROR('#1: Number.prototype.toString(32) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(32) !== "0") { + $ERROR('#2: (new Number()).toString(32) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(32) !== "0") { + $ERROR('#3: (new Number(0)).toString(32) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(32) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(32) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(32) !== "1") { + $ERROR('#5: (new Number(1)).toString(32) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(32) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(32) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(32) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(32) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(32) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(32) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T31.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T31.js new file mode 100644 index 0000000000..d481f4de6c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T31.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T31 +description: radix is 33 +---*/ + +//CHECK#1 +if (Number.prototype.toString(33) !== "0") { + $ERROR('#1: Number.prototype.toString(33) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(33) !== "0") { + $ERROR('#2: (new Number()).toString(33) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(33) !== "0") { + $ERROR('#3: (new Number(0)).toString(33) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(33) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(33) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(33) !== "1") { + $ERROR('#5: (new Number(1)).toString(33) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(33) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(33) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(33) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(33) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(33) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(33) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T32.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T32.js new file mode 100644 index 0000000000..09457a31de --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T32.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T32 +description: radix is 34 +---*/ + +//CHECK#1 +if (Number.prototype.toString(34) !== "0") { + $ERROR('#1: Number.prototype.toString(34) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(34) !== "0") { + $ERROR('#2: (new Number()).toString(34) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(34) !== "0") { + $ERROR('#3: (new Number(0)).toString(34) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(34) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(34) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(34) !== "1") { + $ERROR('#5: (new Number(1)).toString(34) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(34) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(34) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(34) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(34) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(34) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(34) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T33.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T33.js new file mode 100644 index 0000000000..5044fa0a5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T33.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T33 +description: radix is 35 +---*/ + +//CHECK#1 +if (Number.prototype.toString(35) !== "0") { + $ERROR('#1: Number.prototype.toString(35) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(35) !== "0") { + $ERROR('#2: (new Number()).toString(35) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(35) !== "0") { + $ERROR('#3: (new Number(0)).toString(35) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(35) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(35) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(35) !== "1") { + $ERROR('#5: (new Number(1)).toString(35) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(35) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(35) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(35) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(35) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(35) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(35) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T34.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T34.js new file mode 100644 index 0000000000..891a35f84e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T34.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: | + toString: If radix is an integer from 2 to 36, but not 10, + the result is a string, the choice of which is implementation-dependent +es5id: 15.7.4.2_A2_T34 +description: radix is 36 +---*/ + +//CHECK#1 +if (Number.prototype.toString(36) !== "0") { + $ERROR('#1: Number.prototype.toString(36) === "0"'); +} + +//CHECK#2 +if ((new Number()).toString(36) !== "0") { + $ERROR('#2: (new Number()).toString(36) === "0"'); +} + +//CHECK#3 +if ((new Number(0)).toString(36) !== "0") { + $ERROR('#3: (new Number(0)).toString(36) === "0"'); +} + +//CHECK#4 +if ((new Number(-1)).toString(36) !== "-1") { + $ERROR('#4: (new Number(-1)).toString(36) === "-1"'); +} + +//CHECK#5 +if ((new Number(1)).toString(36) !== "1") { + $ERROR('#5: (new Number(1)).toString(36) === "1"'); +} + +//CHECK#6 +if ((new Number(Number.NaN)).toString(36) !== "NaN") { + $ERROR('#6: (new Number(Number.NaN)).toString(36) === "NaN"'); +} + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).toString(36) !== "Infinity") { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(36) === "Infinity"'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).toString(36) !== "-Infinity") { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(36) === "-Infinity"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T01.js new file mode 100644 index 0000000000..7b2dc941df --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T01.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "toString: radix should be an integer between 2 and 36" +es5id: 15.7.4.2_A3_T01 +description: radix is 1 +---*/ + +//CHECK#1 +try { + var n = Number.prototype.toString(1); + $ERROR('#1: Number.prototype.toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#2 +try { + var n = (new Number()).toString(1); + $ERROR('#2: (new Number()).toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#3 +try { + var n = (new Number(0)).toString(1); + $ERROR('#3: (new Number(0)).toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#4 +try { + var n = (new Number(-1)).toString(1); + $ERROR('#4: (new Number(-1)).toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#5 +try { + var n = (new Number(1)).toString(1); + $ERROR('#5: (new Number(1)).toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#6 +try { + var n = (new Number(Number.NaN)).toString(1); + $ERROR('#6: (new Number(Number.NaN)).toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#7 +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(1); + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(1) should throw an Error'); +} +catch (e) {} + +//CHECK#8 +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(1); + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(1) should throw an Error'); +} +catch (e) {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T02.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T02.js new file mode 100644 index 0000000000..6f934241f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T02.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "toString: radix should be an integer between 2 and 36" +es5id: 15.7.4.2_A3_T02 +description: radix is 37 +---*/ + +//CHECK#1 +try { + var n = Number.prototype.toString(37); + $ERROR('#1: Number.prototype.toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#2 +try { + var n = (new Number()).toString(37); + $ERROR('#2: (new Number()).toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#3 +try { + var n = (new Number(0)).toString(37); + $ERROR('#3: (new Number(0)).toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#4 +try { + var n = (new Number(-1)).toString(37); + $ERROR('#4: (new Number(-1)).toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#5 +try { + var n = (new Number(1)).toString(37); + $ERROR('#5: (new Number(1)).toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#6 +try { + var n = (new Number(Number.NaN)).toString(37); + $ERROR('#6: (new Number(Number.NaN)).toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#7 +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(37); + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(37) should throw an Error'); +} +catch (e) {} + +//CHECK#8 +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(37); + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(37) should throw an Error'); +} +catch (e) {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T03.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T03.js new file mode 100644 index 0000000000..7bb9f1fcd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T03.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "toString: radix should be an integer between 2 and 36" +es5id: 15.7.4.2_A3_T03 +description: radix is null value +---*/ + +//CHECK#1 +try { + var n = Number.prototype.toString(null); + $ERROR('#1: Number.prototype.toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#2 +try { + var n = (new Number()).toString(null); + $ERROR('#2: (new Number()).toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#3 +try { + var n = (new Number(0)).toString(null); + $ERROR('#3: (new Number(0)).toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#4 +try { + var n = (new Number(-1)).toString(null); + $ERROR('#4: (new Number(-1)).toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#5 +try { + var n = (new Number(1)).toString(null); + $ERROR('#5: (new Number(1)).toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#6 +try { + var n = (new Number(Number.NaN)).toString(null); + $ERROR('#6: (new Number(Number.NaN)).toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#7 +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(null); + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(null) should throw an Error'); +} +catch (e) {} + +//CHECK#8 +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(null); + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(null) should throw an Error'); +} +catch (e) {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T04.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T04.js new file mode 100644 index 0000000000..a0393dfc5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T04.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "toString: radix should be an integer between 2 and 36" +es5id: 15.7.4.2_A3_T04 +description: radix is 0 +---*/ + +//CHECK#1 +try { + var n = Number.prototype.toString(0); + $ERROR('#1: Number.prototype.toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#2 +try { + var n = (new Number()).toString(0); + $ERROR('#2: (new Number()).toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#3 +try { + var n = (new Number(0)).toString(0); + $ERROR('#3: (new Number(0)).toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#4 +try { + var n = (new Number(-1)).toString(0); + $ERROR('#4: (new Number(-1)).toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#5 +try { + var n = (new Number(1)).toString(0); + $ERROR('#5: (new Number(1)).toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#6 +try { + var n = (new Number(Number.NaN)).toString(0); + $ERROR('#6: (new Number(Number.NaN)).toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#7 +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(0); + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).toString(0) should throw an Error'); +} +catch (e) {} + +//CHECK#8 +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(0); + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).toString(0) should throw an Error'); +} +catch (e) {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T01.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T01.js new file mode 100644 index 0000000000..96787c83c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T01.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The toString function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.2_A4_T01 +description: transferring to the String objects +---*/ + +//CHECK#1 +try { + var s1 = new String(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new String(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T02.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T02.js new file mode 100644 index 0000000000..a0b589720d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T02.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The toString function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.2_A4_T02 +description: transferring to the Boolean objects +---*/ + +//CHECK#1 +try { + var s1 = new Boolean(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new Boolean(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T03.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T03.js new file mode 100644 index 0000000000..4d2d2780e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T03.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The toString function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.2_A4_T03 +description: transferring to the Date objects +---*/ + +//CHECK#1 +try { + var s1 = new Date(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new Date(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T04.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T04.js new file mode 100644 index 0000000000..7e378552ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T04.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The toString function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.2_A4_T04 +description: transferring to the Object objects +---*/ + +//CHECK#1 +try { + var s1 = new Object(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new Object(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T05.js b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T05.js new file mode 100644 index 0000000000..6586142acf --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T05.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: | + The toString function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.2_A4_T05 +description: transferring to the other objects +---*/ + +//CHECK#1 +try { + var s1 = { + x: 1 + }; + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = { + x: 1 + }; + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.toString on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/a-z.js b/js/src/tests/test262/built-ins/Number/prototype/toString/a-z.js new file mode 100644 index 0000000000..cb4ea122ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/a-z.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Letters a-z are used for digits with values 10 through 35 +info: | + 6. Return the String representation of this Number value using + the radix specified by radixNumber. Letters a-z are used for + digits with values 10 through 35. The precise algorithm is + implementation-dependent, however the algorithm should be a + generalization of that specified in 6.1.6.1.20. +---*/ + +for (let radix = 11; radix <= 36; radix++) { + for (let i = 10; i < radix; i++) { + assert.sameValue(i.toString(radix), String.fromCharCode(i + 87)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/browser.js b/js/src/tests/test262/built-ins/Number/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/length.js b/js/src/tests/test262/built-ins/Number/prototype/toString/length.js new file mode 100644 index 0000000000..0c57733f13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.6 +description: > + Number.prototype.toString.length is 1. +info: | + Number.prototype.toString ( [ radix ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toString.length, 1); + +verifyNotEnumerable(Number.prototype.toString, "length"); +verifyNotWritable(Number.prototype.toString, "length"); +verifyConfigurable(Number.prototype.toString, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/name.js b/js/src/tests/test262/built-ins/Number/prototype/toString/name.js new file mode 100644 index 0000000000..5072c7993b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.6 +description: > + Number.prototype.toString.name is "toString". +info: | + Number.prototype.toString ( [ radix ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.toString.name, "toString"); + +verifyNotEnumerable(Number.prototype.toString, "name"); +verifyNotWritable(Number.prototype.toString, "name"); +verifyConfigurable(Number.prototype.toString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..e7f1f2ae77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.prototype.toString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Number.prototype.toString), + false, + 'isConstructor(Number.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + new Number.prototype.toString(); +}, '`new Number.prototype.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-default-radix.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-default-radix.js new file mode 100644 index 0000000000..23c08abc7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-default-radix.js @@ -0,0 +1,22 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + If radix is undefined the Number 10 is used as the value of radix. +info: | + If radix is undefined, let radixNumber be 10. + ... + If radixNumber = 10, return ! ToString(x). + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in 6.1.6.1.20. + + The optional radix should be an integer value in the inclusive range 2 to 36. If radix is undefined the Number 10 is used as the value of radix. +---*/ + +assert.sameValue(0..toString(), "0"); +assert.sameValue(1..toString(), "1"); +assert.sameValue(NaN.toString(), "NaN"); +assert.sameValue(Infinity.toString(), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-1.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-1.js new file mode 100644 index 0000000000..4a2fc35f9e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-1.js @@ -0,0 +1,23 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + If radixNumber < 2 or radixNumber > 36, throw a RangeError exception. +---*/ + +assert.throws(RangeError, () => { + 0..toString(1); +}); +assert.throws(RangeError, () => { + 1..toString(1); +}); +assert.throws(RangeError, () => { + NaN.toString(1); +}); +assert.throws(RangeError, () => { + Infinity.toString(1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-10.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-10.js new file mode 100644 index 0000000000..0b563c0225 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-10.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (10) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(10), "0"); +assert.sameValue(1..toString(10), "1"); +assert.sameValue(NaN.toString(10), "NaN"); +assert.sameValue(Infinity.toString(10), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-11.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-11.js new file mode 100644 index 0000000000..14e3d0bc1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-11.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (11) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(11), "0"); +assert.sameValue(1..toString(11), "1"); +assert.sameValue(NaN.toString(11), "NaN"); +assert.sameValue(Infinity.toString(11), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-12.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-12.js new file mode 100644 index 0000000000..1d9688eaf4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-12.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (12) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(12), "0"); +assert.sameValue(1..toString(12), "1"); +assert.sameValue(NaN.toString(12), "NaN"); +assert.sameValue(Infinity.toString(12), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-13.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-13.js new file mode 100644 index 0000000000..3933d14c8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-13.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (13) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(13), "0"); +assert.sameValue(1..toString(13), "1"); +assert.sameValue(NaN.toString(13), "NaN"); +assert.sameValue(Infinity.toString(13), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-14.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-14.js new file mode 100644 index 0000000000..206642059c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-14.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (14) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(14), "0"); +assert.sameValue(1..toString(14), "1"); +assert.sameValue(NaN.toString(14), "NaN"); +assert.sameValue(Infinity.toString(14), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-15.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-15.js new file mode 100644 index 0000000000..1f97bbb355 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-15.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (15) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(15), "0"); +assert.sameValue(1..toString(15), "1"); +assert.sameValue(NaN.toString(15), "NaN"); +assert.sameValue(Infinity.toString(15), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-16.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-16.js new file mode 100644 index 0000000000..edba8ff1dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-16.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (16) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(16), "0"); +assert.sameValue(1..toString(16), "1"); +assert.sameValue(NaN.toString(16), "NaN"); +assert.sameValue(Infinity.toString(16), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-17.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-17.js new file mode 100644 index 0000000000..27cd43d04c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-17.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (17) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(17), "0"); +assert.sameValue(1..toString(17), "1"); +assert.sameValue(NaN.toString(17), "NaN"); +assert.sameValue(Infinity.toString(17), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-18.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-18.js new file mode 100644 index 0000000000..871b7fb65b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-18.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (18) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(18), "0"); +assert.sameValue(1..toString(18), "1"); +assert.sameValue(NaN.toString(18), "NaN"); +assert.sameValue(Infinity.toString(18), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-19.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-19.js new file mode 100644 index 0000000000..064a1bd37b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-19.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (19) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(19), "0"); +assert.sameValue(1..toString(19), "1"); +assert.sameValue(NaN.toString(19), "NaN"); +assert.sameValue(Infinity.toString(19), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-2.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-2.js new file mode 100644 index 0000000000..e0d85e3677 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-2.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (2) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(2), "0"); +assert.sameValue(1..toString(2), "1"); +assert.sameValue(NaN.toString(2), "NaN"); +assert.sameValue(Infinity.toString(2), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-20.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-20.js new file mode 100644 index 0000000000..8477992289 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-20.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (20) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(20), "0"); +assert.sameValue(1..toString(20), "1"); +assert.sameValue(NaN.toString(20), "NaN"); +assert.sameValue(Infinity.toString(20), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-21.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-21.js new file mode 100644 index 0000000000..2856146436 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-21.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (21) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(21), "0"); +assert.sameValue(1..toString(21), "1"); +assert.sameValue(NaN.toString(21), "NaN"); +assert.sameValue(Infinity.toString(21), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-22.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-22.js new file mode 100644 index 0000000000..18d2f4c3c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-22.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (22) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(22), "0"); +assert.sameValue(1..toString(22), "1"); +assert.sameValue(NaN.toString(22), "NaN"); +assert.sameValue(Infinity.toString(22), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-23.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-23.js new file mode 100644 index 0000000000..26ebd10a28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-23.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (23) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(23), "0"); +assert.sameValue(1..toString(23), "1"); +assert.sameValue(NaN.toString(23), "NaN"); +assert.sameValue(Infinity.toString(23), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-24.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-24.js new file mode 100644 index 0000000000..a261d64816 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-24.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (24) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(24), "0"); +assert.sameValue(1..toString(24), "1"); +assert.sameValue(NaN.toString(24), "NaN"); +assert.sameValue(Infinity.toString(24), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-25.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-25.js new file mode 100644 index 0000000000..84d8fbf728 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-25.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (25) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(25), "0"); +assert.sameValue(1..toString(25), "1"); +assert.sameValue(NaN.toString(25), "NaN"); +assert.sameValue(Infinity.toString(25), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-26.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-26.js new file mode 100644 index 0000000000..0f400d8390 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-26.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (26) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(26), "0"); +assert.sameValue(1..toString(26), "1"); +assert.sameValue(NaN.toString(26), "NaN"); +assert.sameValue(Infinity.toString(26), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-27.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-27.js new file mode 100644 index 0000000000..11678ab05b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-27.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (27) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(27), "0"); +assert.sameValue(1..toString(27), "1"); +assert.sameValue(NaN.toString(27), "NaN"); +assert.sameValue(Infinity.toString(27), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-28.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-28.js new file mode 100644 index 0000000000..955c503dbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-28.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (28) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(28), "0"); +assert.sameValue(1..toString(28), "1"); +assert.sameValue(NaN.toString(28), "NaN"); +assert.sameValue(Infinity.toString(28), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-29.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-29.js new file mode 100644 index 0000000000..62a32bc9b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-29.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (29) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(29), "0"); +assert.sameValue(1..toString(29), "1"); +assert.sameValue(NaN.toString(29), "NaN"); +assert.sameValue(Infinity.toString(29), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-3.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-3.js new file mode 100644 index 0000000000..8f33f9d970 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-3.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (3) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(3), "0"); +assert.sameValue(1..toString(3), "1"); +assert.sameValue(NaN.toString(3), "NaN"); +assert.sameValue(Infinity.toString(3), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-30.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-30.js new file mode 100644 index 0000000000..49304e9d98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-30.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (30) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(30), "0"); +assert.sameValue(1..toString(30), "1"); +assert.sameValue(NaN.toString(30), "NaN"); +assert.sameValue(Infinity.toString(30), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-31.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-31.js new file mode 100644 index 0000000000..42c62ae4c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-31.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (31) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(31), "0"); +assert.sameValue(1..toString(31), "1"); +assert.sameValue(NaN.toString(31), "NaN"); +assert.sameValue(Infinity.toString(31), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-32.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-32.js new file mode 100644 index 0000000000..20d6d86d58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-32.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (32) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(32), "0"); +assert.sameValue(1..toString(32), "1"); +assert.sameValue(NaN.toString(32), "NaN"); +assert.sameValue(Infinity.toString(32), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-33.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-33.js new file mode 100644 index 0000000000..d42fbcbc15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-33.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (33) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(33), "0"); +assert.sameValue(1..toString(33), "1"); +assert.sameValue(NaN.toString(33), "NaN"); +assert.sameValue(Infinity.toString(33), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-34.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-34.js new file mode 100644 index 0000000000..0734626dea --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-34.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (34) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(34), "0"); +assert.sameValue(1..toString(34), "1"); +assert.sameValue(NaN.toString(34), "NaN"); +assert.sameValue(Infinity.toString(34), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-35.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-35.js new file mode 100644 index 0000000000..1b946c453f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-35.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (35) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(35), "0"); +assert.sameValue(1..toString(35), "1"); +assert.sameValue(NaN.toString(35), "NaN"); +assert.sameValue(Infinity.toString(35), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-36.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-36.js new file mode 100644 index 0000000000..e38979ce67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-36.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (36) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(36), "0"); +assert.sameValue(1..toString(36), "1"); +assert.sameValue(NaN.toString(36), "NaN"); +assert.sameValue(Infinity.toString(36), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-37.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-37.js new file mode 100644 index 0000000000..0296101709 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-37.js @@ -0,0 +1,23 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + If radixNumber < 2 or radixNumber > 36, throw a RangeError exception. +---*/ + +assert.throws(RangeError, () => { + 0..toString(37); +}); +assert.throws(RangeError, () => { + 1..toString(37); +}); +assert.throws(RangeError, () => { + NaN.toString(37); +}); +assert.throws(RangeError, () => { + Infinity.toString(37); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-4.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-4.js new file mode 100644 index 0000000000..f8c5846548 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-4.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (4) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(4), "0"); +assert.sameValue(1..toString(4), "1"); +assert.sameValue(NaN.toString(4), "NaN"); +assert.sameValue(Infinity.toString(4), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-5.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-5.js new file mode 100644 index 0000000000..01417d0354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-5.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (5) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(5), "0"); +assert.sameValue(1..toString(5), "1"); +assert.sameValue(NaN.toString(5), "NaN"); +assert.sameValue(Infinity.toString(5), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-6.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-6.js new file mode 100644 index 0000000000..31bc954fdc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-6.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (6) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(6), "0"); +assert.sameValue(1..toString(6), "1"); +assert.sameValue(NaN.toString(6), "NaN"); +assert.sameValue(Infinity.toString(6), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-7.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-7.js new file mode 100644 index 0000000000..3ca919592d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-7.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (7) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(7), "0"); +assert.sameValue(1..toString(7), "1"); +assert.sameValue(NaN.toString(7), "NaN"); +assert.sameValue(Infinity.toString(7), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-8.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-8.js new file mode 100644 index 0000000000..7d0167c53f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-8.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (8) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(8), "0"); +assert.sameValue(1..toString(8), "1"); +assert.sameValue(NaN.toString(8), "NaN"); +assert.sameValue(Infinity.toString(8), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-9.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-9.js new file mode 100644 index 0000000000..14506ec9c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-9.js @@ -0,0 +1,17 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Calling toString(radix) (9) +info: | + Return the String representation of this Number value using the radix specified by radixNumber. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in sec-numeric-types-number-tostring. +---*/ + +assert.sameValue(0..toString(9), "0"); +assert.sameValue(1..toString(9), "1"); +assert.sameValue(NaN.toString(9), "NaN"); +assert.sameValue(Infinity.toString(9), "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-poisoned.js b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-poisoned.js new file mode 100644 index 0000000000..3c12cbd397 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/numeric-literal-tostring-radix-poisoned.js @@ -0,0 +1,28 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + Else, let radixNumber be ? ToInteger(radix). +---*/ + +var poisoned = { + valueOf() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, () => { + 0..toString(poisoned); +}); +assert.throws(Test262Error, () => { + 1..toString(poisoned); +}); +assert.throws(Test262Error, () => { + NaN.toString(poisoned); +}); +assert.throws(Test262Error, () => { + Infinity.toString(poisoned); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/toString/prop-desc.js new file mode 100644 index 0000000000..1e4160a879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.tostring +description: > + "toString" property of Number.prototype +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number.prototype, "toString"); +verifyWritable(Number.prototype, "toString"); +verifyConfigurable(Number.prototype, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/shell.js b/js/src/tests/test262/built-ins/Number/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/shell.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T01.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T01.js new file mode 100644 index 0000000000..72998f0547 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T01.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: Number.prototype.valueOf() returns this number value +es5id: 15.7.4.4_A1_T01 +description: Call without argument +---*/ + +//CHECK#1 +if (Number.prototype.valueOf() !== 0) { + $ERROR('#1: Number.prototype.valueOf() === 0'); +} + +//CHECK#2 +if ((new Number()).valueOf() !== 0) { + $ERROR('#2: (new Number()).valueOf() === 0'); +} + +//CHECK#3 +if ((new Number(0)).valueOf() !== 0) { + $ERROR('#3: (new Number(0)).valueOf() === 0'); +} + +//CHECK#4 +if ((new Number(-1)).valueOf() !== -1) { + $ERROR('#4: (new Number(-1)).valueOf() === -1'); +} + +//CHECK#5 +if ((new Number(1)).valueOf() !== 1) { + $ERROR('#5: (new Number(1)).valueOf() === 1'); +} + +//CHECK#6 +assert.sameValue( + new Number(NaN).valueOf(), + NaN, + "NaN" +); + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).valueOf() !== Number.POSITIVE_INFINITY) { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).valueOf() === Infinity'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).valueOf() !== Number.NEGATIVE_INFINITY) { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).valueOf() === -Infinity'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T02.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T02.js new file mode 100644 index 0000000000..a3f6c1e6b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T02.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: Number.prototype.valueOf() returns this number value +es5id: 15.7.4.4_A1_T02 +description: calling with argument +---*/ + +//CHECK#1 +if (Number.prototype.valueOf("argument") !== 0) { + $ERROR('#1: Number.prototype.valueOf("argument") === 0'); +} + +//CHECK#2 +if ((new Number()).valueOf("argument") !== 0) { + $ERROR('#2: (new Number()).valueOf("argument") === 0'); +} + +//CHECK#3 +if ((new Number(0)).valueOf("argument") !== 0) { + $ERROR('#3: (new Number(0)).valueOf("argument") === 0'); +} + +//CHECK#4 +if ((new Number(-1)).valueOf("argument") !== -1) { + $ERROR('#4: (new Number(-1)).valueOf("argument") === -1'); +} + +//CHECK#5 +if ((new Number(1)).valueOf("argument") !== 1) { + $ERROR('#5: (new Number(1)).valueOf("argument") === 1'); +} + +//CHECK#6 +assert.sameValue( + new Number(NaN).valueOf("argument"), + NaN, + "NaN" +); + +//CHECK#7 +if ((new Number(Number.POSITIVE_INFINITY)).valueOf("argument") !== Number.POSITIVE_INFINITY) { + $ERROR('#7: (new Number(Number.POSITIVE_INFINITY)).valueOf("argument") === Infinity'); +} + +//CHECK#8 +if ((new Number(Number.NEGATIVE_INFINITY)).valueOf("argument") !== Number.NEGATIVE_INFINITY) { + $ERROR('#8: (new Number(Number.NEGATIVE_INFINITY)).valueOf("argument") === -Infinity'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T01.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T01.js new file mode 100644 index 0000000000..5df9b5bec5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T01.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The valueOf function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.4_A2_T01 +description: transferring to the String objects +---*/ + +//CHECK#1 +try { + var s1 = new String(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new String(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T02.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T02.js new file mode 100644 index 0000000000..13c86916e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T02.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The valueOf function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.4_A2_T02 +description: transferring to the Boolean objects +---*/ + +//CHECK#1 +try { + var s1 = new Boolean(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new Boolean(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T03.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T03.js new file mode 100644 index 0000000000..959bd1e859 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T03.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The valueOf function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.4_A2_T03 +description: transferring to the Date objects +---*/ + +//CHECK#1 +try { + var s1 = new Date(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new Date(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T04.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T04.js new file mode 100644 index 0000000000..4bd9f50265 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T04.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The valueOf function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.4_A2_T04 +description: transferring to the Object objects +---*/ + +//CHECK#1 +try { + var s1 = new Object(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new Object(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T05.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T05.js new file mode 100644 index 0000000000..c20de49b45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T05.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: | + The valueOf function is not generic, it cannot be transferred + to other kinds of objects for use as a method and there is should be + a TypeError exception if its this value is not a Number object +es5id: 15.7.4.4_A2_T05 +description: transferring to the other objects +---*/ + +//CHECK#1 +try { + var s1 = { + x: 1 + }; + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = { + x: 1 + }; + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Number.prototype.valueOf on not a Number object should throw TypeError, not ' + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/browser.js diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js new file mode 100644 index 0000000000..65a31127ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.7 +description: > + Number.prototype.valueOf.length is 0. +info: | + Number.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.valueOf.length, 0); + +verifyNotEnumerable(Number.prototype.valueOf, "length"); +verifyNotWritable(Number.prototype.valueOf, "length"); +verifyConfigurable(Number.prototype.valueOf, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js new file mode 100644 index 0000000000..8c1830f5fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.3.7 +description: > + Number.prototype.valueOf.name is "valueOf". +info: | + Number.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Number.prototype.valueOf.name, "valueOf"); + +verifyNotEnumerable(Number.prototype.valueOf, "name"); +verifyNotWritable(Number.prototype.valueOf, "name"); +verifyConfigurable(Number.prototype.valueOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js new file mode 100644 index 0000000000..5037924ce3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Number.prototype.valueOf does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Number.prototype.valueOf), + false, + 'isConstructor(Number.prototype.valueOf) must return false' +); + +assert.throws(TypeError, () => { + new Number.prototype.valueOf(); +}, '`new Number.prototype.valueOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/prop-desc.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/prop-desc.js new file mode 100644 index 0000000000..9b7bcbe491 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.prototype.valueof +description: > + "valueOf" property of Number.prototype +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Number.prototype, "valueOf"); +verifyWritable(Number.prototype, "valueOf"); +verifyConfigurable(Number.prototype, "valueOf"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/shell.js diff --git a/js/src/tests/test262/built-ins/Number/return-abrupt-tonumber-value-symbol.js b/js/src/tests/test262/built-ins/Number/return-abrupt-tonumber-value-symbol.js new file mode 100644 index 0000000000..fba3917e60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/return-abrupt-tonumber-value-symbol.js @@ -0,0 +1,27 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number-constructor-number-value +description: > + Return abrupt from ToNumber(value) +info: | + Number ( value ) + + 1. If no arguments were passed to this function invocation, let n be +0. + 2. Else, let n be ? ToNumber(value). + [...] +features: [Symbol] +---*/ + +var s = Symbol("66"); + +assert.throws(TypeError, function() { + Number(s); +}, "NewTarget is undefined"); + +assert.throws(TypeError, function() { + new Number(s); +}, "NewTarget is defined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/return-abrupt-tonumber-value.js b/js/src/tests/test262/built-ins/Number/return-abrupt-tonumber-value.js new file mode 100644 index 0000000000..b3e75d14ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/return-abrupt-tonumber-value.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number-constructor-number-value +description: > + Return abrupt from ToNumber(value) +info: | + Number ( value ) + + 1. If no arguments were passed to this function invocation, let n be +0. + 2. Else, let n be ? ToNumber(value). + [...] +---*/ + +var obj1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var obj2 = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + Number(obj1); +}, "NewTarget is undefined, {}.valueOf"); + +assert.throws(Test262Error, function() { + Number(obj2); +}, "NewTarget is undefined, {}.toString"); + +assert.throws(Test262Error, function() { + new Number(obj1); +}, "NewTarget is defined, {}.valueOf"); + +assert.throws(Test262Error, function() { + new Number(obj2); +}, "NewTarget is defined, {}.toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/shell.js b/js/src/tests/test262/built-ins/Number/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Number/string-binary-literal-invalid.js b/js/src/tests/test262/built-ins/Number/string-binary-literal-invalid.js new file mode 100644 index 0000000000..28b5b0a5ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-binary-literal-invalid.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.1.1 +description: Invalid binary literals yield NaN +info: | + BinaryIntegerLiteral :: + 0b BinaryDigits + 0B BinaryDigits + BinaryDigits :: + BinaryDigit + BinaryDigits BinaryDigit + BinaryDigit :: one of + 0 1 +---*/ + +assert.sameValue(Number('0b2'), NaN, 'invalid digit'); +assert.sameValue(Number('00b0'), NaN, 'leading zero'); +assert.sameValue(Number('0b'), NaN, 'omitted digits'); +assert.sameValue(Number('+0b1'), NaN, 'plus sign'); +assert.sameValue(Number('-0b1'), NaN, 'minus sign'); +assert.sameValue(Number('0b1.01'), NaN, 'fractional part'); +assert.sameValue(Number('0b1e10'), NaN, 'exponent part'); +assert.sameValue(Number('0b1e-10'), NaN, 'exponent part with a minus sign'); +assert.sameValue(Number('0b1e+10'), NaN, 'exponent part with a plus sign'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-binary-literal.js b/js/src/tests/test262/built-ins/Number/string-binary-literal.js new file mode 100644 index 0000000000..b598551cc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-binary-literal.js @@ -0,0 +1,53 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.1.1 +description: Mathematical value of valid binary integer literals +info: | + 20.1.1.1 Number ( [ value ] ) + + When Number is called with argument number, the following steps are taken: + + 1. If no arguments were passed to this function invocation, let n be +0. + 2. Else, let n be ToNumber(value). + + [...] + + 7.1.3.1 ToNumber Applied to the String Type + + All grammar symbols not explicitly defined above have the definitions used + in the Lexical Grammar for numeric literals (11.8.3) + + [...] + + The MV of BinaryIntegerLiteral :: 0b BinaryDigits is the MV of + BinaryDigits. + The MV of BinaryIntegerLiteral :: 0B BinaryDigits is the MV of + BinaryDigits. + The MV of BinaryDigits :: BinaryDigit is the MV of BinaryDigit. + The MV of BinaryDigits :: BinaryDigits BinaryDigit is (the MV of + BinaryDigits × 2) plus the MV of BinaryDigit. +---*/ + +assert.sameValue(Number('0b0'), 0, 'lower-case head'); +assert.sameValue(Number('0B0'), 0, 'upper-case head'); +assert.sameValue(Number('0b00'), 0, 'lower-case head with leading zeros'); +assert.sameValue(Number('0B00'), 0, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0b1'), 1, 'lower-case head'); +assert.sameValue(Number('0B1'), 1, 'upper-case head'); +assert.sameValue(Number('0b01'), 1, 'lower-case head with leading zeros'); +assert.sameValue(Number('0B01'), 1, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0b10'), 2, 'lower-case head'); +assert.sameValue(Number('0B10'), 2, 'upper-case head'); +assert.sameValue(Number('0b010'), 2, 'lower-case head with leading zeros'); +assert.sameValue(Number('0B010'), 2, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0b11'), 3, 'lower-case head'); +assert.sameValue(Number('0B11'), 3, 'upper-case head'); +assert.sameValue(Number('0b011'), 3, 'lower-case head with leading zeros'); +assert.sameValue(Number('0B011'), 3, 'upper-case head with leading zeros'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-hex-literal-invalid.js b/js/src/tests/test262/built-ins/Number/string-hex-literal-invalid.js new file mode 100644 index 0000000000..6e82f0b743 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-hex-literal-invalid.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Ivan Vyshnevskyi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number-constructor-number-value +description: Invalid hex literals yield NaN +info: | + HexIntegerLiteral :: + 0x HexDigits + 0X HexDigits + HexDigits :: + HexDigit + HexDigits HexDigit + HexDigit :: one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F +---*/ + +assert.sameValue(Number('0xG'), NaN, 'invalid digit'); +assert.sameValue(Number('00x0'), NaN, 'leading zero'); +assert.sameValue(Number('0x'), NaN, 'omitted digits'); +assert.sameValue(Number('+0x10'), NaN, 'plus sign'); +assert.sameValue(Number('-0x10'), NaN, 'minus sign'); +assert.sameValue(Number('0x10.01'), NaN, 'fractional part'); +assert.sameValue(Number('0x1e-10'), NaN, 'exponent part with a minus sign'); +assert.sameValue(Number('0x1e+10'), NaN, 'exponent part with a plus sign'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bd-nsl-bd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bd-nsl-bd.js new file mode 100644 index 0000000000..b8c36812b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bd-nsl-bd.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0b` | `0B` BinaryDigit NumericLiteralSeparator BinaryDigit + + NumericLiteralSeparator :: + _ + + BinaryIntegerLiteral :: + 0b BinaryDigits + 0B BinaryDigits + + BinaryDigits :: + BinaryDigit + BinaryDigits BinaryDigit + BinaryDigits NumericLiteralSeparator BinaryDigit + + BinaryDigit :: one of + 0 1 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0b0_1"), NaN, "0b0_1"); +assert.sameValue(Number("0B0_1"), NaN, "0B0_1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bd-nsl-bds.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bd-nsl-bds.js new file mode 100644 index 0000000000..e48ed74a22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bd-nsl-bds.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0b` | `0B` BinaryDigit NumericLiteralSeparator BinaryDigit + + NumericLiteralSeparator :: + _ + + BinaryIntegerLiteral :: + 0b BinaryDigits + 0B BinaryDigits + + BinaryDigits :: + BinaryDigit + BinaryDigits BinaryDigit + BinaryDigits NumericLiteralSeparator BinaryDigit + + BinaryDigit :: one of + 0 1 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0b0_10"), NaN, "0b0_10"); +assert.sameValue(Number("0B0_10"), NaN, "0B0_10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bds-nsl-bd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bds-nsl-bd.js new file mode 100644 index 0000000000..e442bb3555 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bds-nsl-bd.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0b` | `0B` BinaryDigits NumericLiteralSeparator BinaryDigit + + NumericLiteralSeparator :: + _ + + BinaryIntegerLiteral :: + 0b BinaryDigits + 0B BinaryDigits + + BinaryDigits :: + BinaryDigit + BinaryDigits BinaryDigit + BinaryDigits NumericLiteralSeparator BinaryDigit + + BinaryDigit :: one of + 0 1 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0b01_0"), NaN, "0b01_0"); +assert.sameValue(Number("0B01_0"), NaN, "0B01_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bds-nsl-bds.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bds-nsl-bds.js new file mode 100644 index 0000000000..81c5685cdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-bil-bds-nsl-bds.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0b` | `0B` BinaryDigits NumericLiteralSeparator BinaryDigit + + NumericLiteralSeparator :: + _ + + BinaryIntegerLiteral :: + 0b BinaryDigits + 0B BinaryDigits + + BinaryDigits :: + BinaryDigit + BinaryDigits BinaryDigit + BinaryDigits NumericLiteralSeparator BinaryDigit + + BinaryDigit :: one of + 0 1 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0b01_00"), NaN, "0b01_00"); +assert.sameValue(Number("0B01_00"), NaN, "0B01_00"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-minus-dd-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-minus-dd-nsl-dd.js new file mode 100644 index 0000000000..590223c11d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-minus-dd-nsl-dd.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits `.` DecimalDigits ExponentPart_opt `-` DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + DecimalIntegerLiteral . DecimalDigits_opt ExponentPart_opt + + DecimalDigits :: + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + SignedInteger :: + ... + - DecimalDigits + ... + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1.0e-1_0"), NaN, "1.0e-1_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-minus-dds-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-minus-dds-nsl-dd.js new file mode 100644 index 0000000000..4435a742d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-minus-dds-nsl-dd.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits `.` DecimalDigits ExponentPart_opt `-` DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + DecimalIntegerLiteral . DecimalDigits_opt ExponentPart_opt + + DecimalDigits :: + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + SignedInteger :: + ... + - DecimalDigits + ... + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1.0e-10_0"), NaN, "1.0e-10_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-plus-dd-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-plus-dd-nsl-dd.js new file mode 100644 index 0000000000..f59661d470 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-plus-dd-nsl-dd.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits `.` DecimalDigits ExponentPart_opt `+` DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + DecimalIntegerLiteral . DecimalDigits_opt ExponentPart_opt + + DecimalDigits :: + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + SignedInteger :: + ... + + DecimalDigits + ... + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1.0e+1_0"), NaN, "1.0e+1_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-plus-dds-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-plus-dds-nsl-dd.js new file mode 100644 index 0000000000..379f3ca818 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-dot-dd-ep-sign-plus-dds-nsl-dd.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits `.` DecimalDigits ExponentPart_opt `+` DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + DecimalIntegerLiteral . DecimalDigits_opt ExponentPart_opt + + DecimalDigits :: + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + SignedInteger :: + ... + + DecimalDigits + ... + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1.0e+10_0"), NaN, "1.0e+10_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-nsl-dd-one-of.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-nsl-dd-one-of.js new file mode 100644 index 0000000000..fce333d9e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dd-nsl-dd-one-of.js @@ -0,0 +1,39 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + NonZeroDigit NumericLiteralSeparator DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalIntegerLiteral :: + ... + NonZeroDigit NumericLiteralSeparator_opt DecimalDigits + + + DecimalDigits :: + DecimalDigit + ... + + DecimalDigit :: one of + 0 1 2 3 4 5 6 7 8 9 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1_0"), NaN, "1_0"); +assert.sameValue(Number("1_1"), NaN, "1_1"); +assert.sameValue(Number("1_2"), NaN, "1_2"); +assert.sameValue(Number("1_3"), NaN, "1_3"); +assert.sameValue(Number("1_4"), NaN, "1_4"); +assert.sameValue(Number("1_5"), NaN, "1_5"); +assert.sameValue(Number("1_6"), NaN, "1_6"); +assert.sameValue(Number("1_7"), NaN, "1_7"); +assert.sameValue(Number("1_8"), NaN, "1_8"); +assert.sameValue(Number("1_9"), NaN, "1_9"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dds-dot-dd-nsl-dd-ep-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dds-dot-dd-nsl-dd-ep-dd.js new file mode 100644 index 0000000000..812c46efaf --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dds-dot-dd-nsl-dd-ep-dd.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits `.` DecimalDigits NumericLiteralSeparator DecimalDigits + ExponentPart SignedInteger + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + . DecimalDigits ExponentPart_opt + + DecimalDigits :: + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + ExponentIndicator :: one of + e E + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("10.00_01e2"), NaN, "10.00_01e2"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dds-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dds-nsl-dd.js new file mode 100644 index 0000000000..d6918ca684 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dds-nsl-dd.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: DecimalDigits NumericLiteralSeparator DecimalDigit +info: | + NumericLiteralSeparator :: _ + + DecimalDigits :: + ... + DecimalDigits NumericLiteralSeparator DecimalDigit +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("123456789_0"), NaN, "123456789_0"); +assert.sameValue(Number("123456789_1"), NaN, "123456789_1"); +assert.sameValue(Number("123456789_2"), NaN, "123456789_2"); +assert.sameValue(Number("123456789_3"), NaN, "123456789_3"); +assert.sameValue(Number("123456789_4"), NaN, "123456789_4"); +assert.sameValue(Number("123456789_5"), NaN, "123456789_5"); +assert.sameValue(Number("123456789_6"), NaN, "123456789_6"); +assert.sameValue(Number("123456789_7"), NaN, "123456789_7"); +assert.sameValue(Number("123456789_8"), NaN, "123456789_8"); +assert.sameValue(Number("123456789_9"), NaN, "123456789_9"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dd-nsl-dd-ep.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dd-nsl-dd-ep.js new file mode 100644 index 0000000000..5aff7d756d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dd-nsl-dd-ep.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `.` DecimalDigit NumericLiteralSeparator DecimalDigit ExponentPart + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + . DecimalDigits ExponentPart_opt + + DecimalDigits :: + DecimalDigit + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + ExponentIndicator :: one of + e E + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number(".0_1e2"), NaN, ".0_1e2"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dd-nsl-dds-ep.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dd-nsl-dds-ep.js new file mode 100644 index 0000000000..8cafa0a18e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dd-nsl-dds-ep.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `.` DecimalDigit NumericLiteralSeparator DecimalDigits ExponentPart + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + . DecimalDigits ExponentPart_opt + + DecimalDigits :: + DecimalDigit + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + ExponentIndicator :: one of + e E + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number(".1_01e2"), NaN, ".1_01e2"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dds-nsl-dd-ep.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dds-nsl-dd-ep.js new file mode 100644 index 0000000000..93524be2b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dds-nsl-dd-ep.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `.` DecimalDigits NumericLiteralSeparator DecimalDigit ExponentPart + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + . DecimalDigits ExponentPart_opt + + DecimalDigits :: + DecimalDigit + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + ExponentIndicator :: one of + e E + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number(".10_1e2"), NaN, ".10_1e2"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dds-nsl-dds-ep.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dds-nsl-dds-ep.js new file mode 100644 index 0000000000..2f37d267d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-dot-dds-nsl-dds-ep.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `.` DecimalDigits NumericLiteralSeparator DecimalDigits ExponentPart + + NumericLiteralSeparator :: + _ + + DecimalLiteral :: + . DecimalDigits ExponentPart_opt + + DecimalDigits :: + DecimalDigit + ... + DecimalDigits NumericLiteralSeparator DecimalDigit + + ExponentIndicator :: one of + e E + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number(".00_01e2"), NaN, ".00_01e2"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hd-nsl-hd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hd-nsl-hd.js new file mode 100644 index 0000000000..ca45936143 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hd-nsl-hd.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0x` | `0X` HexDigit NumericLiteralSeparator HexDigit + + NumericLiteralSeparator :: + _ + + HexIntegerLiteral :: + 0x HexDigits + 0X HexDigits + + HexDigits :: + HexDigit + HexDigits HexDigit + HexDigits NumericLiteralSeparator HexDigit + + HexDigit::one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0x0_1"), NaN, "0x0_1"); +assert.sameValue(Number("0X0_1"), NaN, "0X0_1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hd-nsl-hds.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hd-nsl-hds.js new file mode 100644 index 0000000000..5030011e50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hd-nsl-hds.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0x` | `0X` HexDigit NumericLiteralSeparator HexDigit + + NumericLiteralSeparator :: + _ + + HexIntegerLiteral :: + 0x HexDigits + 0X HexDigits + + HexDigits :: + HexDigit + HexDigits HexDigit + HexDigits NumericLiteralSeparator HexDigit + + HexDigit::one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0x0_10"), NaN, "0x0_10"); +assert.sameValue(Number("0X0_10"), NaN, "0X0_10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hds-nsl-hd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hds-nsl-hd.js new file mode 100644 index 0000000000..a2d39e5f06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hds-nsl-hd.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0x` | `0X` HexDigits NumericLiteralSeparator HexDigit + + NumericLiteralSeparator :: + _ + + HexIntegerLiteral :: + 0x HexDigits + 0X HexDigits + + HexDigits :: + HexDigit + HexDigits HexDigit + HexDigits NumericLiteralSeparator HexDigit + + HexDigit::one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0x01_0"), NaN, "0x01_0"); +assert.sameValue(Number("0X01_0"), NaN, "0X01_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hds-nsl-hds.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hds-nsl-hds.js new file mode 100644 index 0000000000..7686a00477 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-hds-nsl-hds.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0x` | `0X` HexDigits NumericLiteralSeparator HexDigit + + NumericLiteralSeparator :: + _ + + HexIntegerLiteral :: + 0x HexDigits + 0X HexDigits + + HexDigits :: + HexDigit + HexDigits HexDigit + HexDigits NumericLiteralSeparator HexDigit + + HexDigit::one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0x01_00"), NaN, "0x01_00"); +assert.sameValue(Number("0X01_00"), NaN, "0X01_00"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-od-nsl-od-one-of.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-od-nsl-od-one-of.js new file mode 100644 index 0000000000..43be4b72a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-hil-od-nsl-od-one-of.js @@ -0,0 +1,51 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0x` | `0X` HexDigit NumericLiteralSeparator HexDigit + + NumericLiteralSeparator :: + _ + + HexIntegerLiteral :: + 0x HexDigits + 0X HexDigits + + HexDigits :: + HexDigit + HexDigits HexDigit + HexDigits NumericLiteralSeparator HexDigit + + HexDigit::one of + 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0x0_0"), NaN, "0x0_0"); +assert.sameValue(Number("0x1_1"), NaN, "0x1_1"); +assert.sameValue(Number("0x2_2"), NaN, "0x2_2"); +assert.sameValue(Number("0x3_3"), NaN, "0x3_3"); +assert.sameValue(Number("0x4_4"), NaN, "0x4_4"); +assert.sameValue(Number("0x5_5"), NaN, "0x5_5"); +assert.sameValue(Number("0x6_6"), NaN, "0x6_6"); +assert.sameValue(Number("0x7_7"), NaN, "0x7_7"); +assert.sameValue(Number("0x8_8"), NaN, "0x8_8"); +assert.sameValue(Number("0x9_9"), NaN, "0x9_9"); +assert.sameValue(Number("0xa_a"), NaN, "0xa_a"); +assert.sameValue(Number("0xb_b"), NaN, "0xb_b"); +assert.sameValue(Number("0xc_c"), NaN, "0xc_c"); +assert.sameValue(Number("0xd_d"), NaN, "0xd_d"); +assert.sameValue(Number("0xe_e"), NaN, "0xe_e"); +assert.sameValue(Number("0xf_f"), NaN, "0xf_f"); +assert.sameValue(Number("0xA_A"), NaN, "0xA_A"); +assert.sameValue(Number("0xB_B"), NaN, "0xB_B"); +assert.sameValue(Number("0xC_C"), NaN, "0xC_C"); +assert.sameValue(Number("0xD_D"), NaN, "0xD_D"); +assert.sameValue(Number("0xE_E"), NaN, "0xE_E"); +assert.sameValue(Number("0xF_F"), NaN, "0xF_F"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dd-one-of.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dd-one-of.js new file mode 100644 index 0000000000..600c65fe5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dd-one-of.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + NonZeroDigit NumericLiteralSeparator DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalIntegerLiteral :: + ... + NonZeroDigit NumericLiteralSeparator_opt DecimalDigits + + NonZeroDigit :: one of + 1 2 3 4 5 6 7 8 9 + + DecimalDigits :: + DecimalDigit + ... + + DecimalDigit :: one of + 0 1 2 3 4 5 6 7 8 9 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1_0"), NaN, "1_0"); +assert.sameValue(Number("1_1"), NaN, "1_1"); +assert.sameValue(Number("2_2"), NaN, "2_2"); +assert.sameValue(Number("3_3"), NaN, "3_3"); +assert.sameValue(Number("4_4"), NaN, "4_4"); +assert.sameValue(Number("5_5"), NaN, "5_5"); +assert.sameValue(Number("6_6"), NaN, "6_6"); +assert.sameValue(Number("7_7"), NaN, "7_7"); +assert.sameValue(Number("8_8"), NaN, "8_8"); +assert.sameValue(Number("9_9"), NaN, "9_9"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dd.js new file mode 100644 index 0000000000..7d62e77898 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dd.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + NonZeroDigit NumericLiteralSeparator DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalIntegerLiteral :: + ... + NonZeroDigit NumericLiteralSeparator_opt DecimalDigits + + NonZeroDigit :: one of + 1 2 3 4 5 6 7 8 9 + + DecimalDigits :: + ... + DecimalDigits DecimalDigit + ... + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1_1"), NaN, "1_1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dds.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dds.js new file mode 100644 index 0000000000..c4257f601f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-nzd-nsl-dds.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + NonZeroDigit NumericLiteralSeparator DecimalDigits + + NumericLiteralSeparator :: + _ + + DecimalIntegerLiteral :: + ... + NonZeroDigit NumericLiteralSeparator_opt DecimalDigits + + NonZeroDigit :: one of + 1 2 3 4 5 6 7 8 9 + + DecimalDigits :: + ... + DecimalDigits DecimalDigit + ... + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("1_0123456789"), NaN, "1_0123456789"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-od-one-of.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-od-one-of.js new file mode 100644 index 0000000000..e1aa72ae24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-od-one-of.js @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0o` | `0O` OctalDigit NumericLiteralSeparator OctalDigit + + NumericLiteralSeparator :: + _ + + OctalIntegerLiteral :: + 0o OctalDigits + 0O OctalDigits + + OctalDigits :: + OctalDigit + OctalDigits OctalDigit + OctalDigits NumericLiteralSeparator OctalDigit + + OctalDigit :: one of + 0 1 2 3 4 5 6 7 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0o0_0"), NaN, "0o0_0"); +assert.sameValue(Number("0o1_1"), NaN, "0o1_1"); +assert.sameValue(Number("0o2_2"), NaN, "0o2_2"); +assert.sameValue(Number("0o3_3"), NaN, "0o3_3"); +assert.sameValue(Number("0o4_4"), NaN, "0o4_4"); +assert.sameValue(Number("0o5_5"), NaN, "0o5_5"); +assert.sameValue(Number("0o6_6"), NaN, "0o6_6"); +assert.sameValue(Number("0o7_7"), NaN, "0o7_7"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-od.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-od.js new file mode 100644 index 0000000000..b254c86108 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-od.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0o` | `0O` OctalDigit NumericLiteralSeparator OctalDigit + + NumericLiteralSeparator :: + _ + + OctalIntegerLiteral :: + 0o OctalDigits + 0O OctalDigits + + OctalDigits :: + OctalDigit + OctalDigits OctalDigit + OctalDigits NumericLiteralSeparator OctalDigit + + OctalDigit :: one of + 0 1 2 3 4 5 6 7 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0o0_1"), NaN, "0o0_1"); +assert.sameValue(Number("0O0_1"), NaN, "0O0_1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-ods.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-ods.js new file mode 100644 index 0000000000..5400d38a51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-od-nsl-ods.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0o` | `0O` OctalDigit NumericLiteralSeparator OctalDigit + + NumericLiteralSeparator :: + _ + + OctalIntegerLiteral :: + 0o OctalDigits + 0O OctalDigits + + OctalDigits :: + OctalDigit + OctalDigits OctalDigit + OctalDigits NumericLiteralSeparator OctalDigit + + OctalDigit :: one of + 0 1 2 3 4 5 6 7 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0o0_10"), NaN, "0o0_10"); +assert.sameValue(Number("0O0_10"), NaN, "0O0_10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-ods-nsl-od.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-ods-nsl-od.js new file mode 100644 index 0000000000..1f51eae66b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-ods-nsl-od.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0o` | `0O` OctalDigits NumericLiteralSeparator OctalDigit + + NumericLiteralSeparator :: + _ + + OctalIntegerLiteral :: + 0o OctalDigits + 0O OctalDigits + + OctalDigits :: + OctalDigit + OctalDigits OctalDigit + OctalDigits NumericLiteralSeparator OctalDigit + + OctalDigit :: one of + 0 1 2 3 4 5 6 7 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0o01_0"), NaN, "0o01_0"); +assert.sameValue(Number("0O01_0"), NaN, "0O01_0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-ods-nsl-ods.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-ods-nsl-ods.js new file mode 100644 index 0000000000..e6e059f5ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-oil-ods-nsl-ods.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + `0o` | `0O` OctalDigits NumericLiteralSeparator OctalDigit + + NumericLiteralSeparator :: + _ + + OctalIntegerLiteral :: + 0o OctalDigits + 0O OctalDigits + + OctalDigits :: + OctalDigit + OctalDigits OctalDigit + OctalDigits NumericLiteralSeparator OctalDigit + + OctalDigit :: one of + 0 1 2 3 4 5 6 7 + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("0o01_00"), NaN, "0o01_00"); +assert.sameValue(Number("0O01_00"), NaN, "0O01_00"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-sign-minus-dds-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-sign-minus-dds-nsl-dd.js new file mode 100644 index 0000000000..7663b8d208 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-sign-minus-dds-nsl-dd.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits NumericLiteralSeparator DecimalDigit + + NumericLiteralSeparator :: + _ + + SignedInteger :: + ... + - DecimalDigits + +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("-123456789_0"), NaN, "-123456789_0"); +assert.sameValue(Number("-123456789_1"), NaN, "-123456789_1"); +assert.sameValue(Number("-123456789_2"), NaN, "-123456789_2"); +assert.sameValue(Number("-123456789_3"), NaN, "-123456789_3"); +assert.sameValue(Number("-123456789_4"), NaN, "-123456789_4"); +assert.sameValue(Number("-123456789_5"), NaN, "-123456789_5"); +assert.sameValue(Number("-123456789_6"), NaN, "-123456789_6"); +assert.sameValue(Number("-123456789_7"), NaN, "-123456789_7"); +assert.sameValue(Number("-123456789_8"), NaN, "-123456789_8"); +assert.sameValue(Number("-123456789_9"), NaN, "-123456789_9"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-sign-plus-dds-nsl-dd.js b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-sign-plus-dds-nsl-dd.js new file mode 100644 index 0000000000..d5a3d05a4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-numeric-separator-literal-sign-plus-dds-nsl-dd.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-NumericLiteralSeparator +description: NumericLiteralSeparator is not valid on string conversions for ToNumber operations +info: | + DecimalDigits NumericLiteralSeparator DecimalDigit + + NumericLiteralSeparator :: + _ + + SignedInteger :: + ... + + DecimalDigits + ... +features: [numeric-separator-literal] +---*/ + +assert.sameValue(Number("+123456789_0"), NaN, "+123456789_0"); +assert.sameValue(Number("+123456789_1"), NaN, "+123456789_1"); +assert.sameValue(Number("+123456789_2"), NaN, "+123456789_2"); +assert.sameValue(Number("+123456789_3"), NaN, "+123456789_3"); +assert.sameValue(Number("+123456789_4"), NaN, "+123456789_4"); +assert.sameValue(Number("+123456789_5"), NaN, "+123456789_5"); +assert.sameValue(Number("+123456789_6"), NaN, "+123456789_6"); +assert.sameValue(Number("+123456789_7"), NaN, "+123456789_7"); +assert.sameValue(Number("+123456789_8"), NaN, "+123456789_8"); +assert.sameValue(Number("+123456789_9"), NaN, "+123456789_9"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-octal-literal-invald.js b/js/src/tests/test262/built-ins/Number/string-octal-literal-invald.js new file mode 100644 index 0000000000..932b40486a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-octal-literal-invald.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.1.1 +description: Invalid octal literals yield NaN +info: | + OctalIntegerLiteral :: + 0o OctalDigits + 0O OctalDigits + OctalDigits :: + OctalDigit + OctalDigits OctalDigit + OctalDigit :: one of + 0 1 2 3 4 5 6 7 +---*/ + +assert.sameValue(Number('0o8'), NaN, 'invalid digit'); +assert.sameValue(Number('00o0'), NaN, 'leading zero'); +assert.sameValue(Number('0o'), NaN, 'omitted digits'); +assert.sameValue(Number('+0o10'), NaN, 'plus sign'); +assert.sameValue(Number('-0o10'), NaN, 'minus sign'); +assert.sameValue(Number('0o10.01'), NaN, 'fractional part'); +assert.sameValue(Number('0o1e10'), NaN, 'exponent part'); +assert.sameValue(Number('0o1e-10'), NaN, 'exponent part with a minus sign'); +assert.sameValue(Number('0o1e+10'), NaN, 'exponent part with a plus sign'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/string-octal-literal.js b/js/src/tests/test262/built-ins/Number/string-octal-literal.js new file mode 100644 index 0000000000..0cd813805a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/string-octal-literal.js @@ -0,0 +1,61 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.1.1.1 +description: Mathematical value of valid octal integer literals +info: | + 20.1.1.1 Number ( [ value ] ) + + When Number is called with argument number, the following steps are taken: + + 1. If no arguments were passed to this function invocation, let n be +0. + 2. Else, let n be ToNumber(value). + + [...] + + 7.1.3.1 ToNumber Applied to the String Type + + All grammar symbols not explicitly defined above have the definitions used + in the Lexical Grammar for numeric literals (11.8.3) + + [...] + + The MV of OctalIntegerLiteral :: 0o OctalDigits is the MV of OctalDigits. + The MV of OctalIntegerLiteral :: 0O OctalDigits is the MV of OctalDigits. + The MV of OctalDigits :: OctalDigit is the MV of OctalDigit. + The MV of OctalDigits :: OctalDigits OctalDigit is (the MV of OctalDigits × + 8) plus the MV of OctalDigit. +---*/ + +assert.sameValue(Number('0o0'), 0, 'lower-case head'); +assert.sameValue(Number('0O0'), 0, 'upper-case head'); +assert.sameValue(Number('0o00'), 0, 'lower-case head with leading zeros'); +assert.sameValue(Number('0O00'), 0, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0o1'), 1, 'lower-case head'); +assert.sameValue(Number('0O1'), 1, 'upper-case head'); +assert.sameValue(Number('0o01'), 1, 'lower-case head with leading zeros'); +assert.sameValue(Number('0O01'), 1, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0o7'), 7, 'lower-case head'); +assert.sameValue(Number('0O7'), 7, 'upper-case head'); +assert.sameValue(Number('0o07'), 7, 'lower-case head with leading zeros'); +assert.sameValue(Number('0O07'), 7, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0o10'), 8, 'lower-case head'); +assert.sameValue(Number('0O10'), 8, 'upper-case head'); +assert.sameValue(Number('0o010'), 8, 'lower-case head with leading zeros'); +assert.sameValue(Number('0O010'), 8, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0o11'), 9, 'lower-case head'); +assert.sameValue(Number('0O11'), 9, 'upper-case head'); +assert.sameValue(Number('0o011'), 9, 'lower-case head with leading zeros'); +assert.sameValue(Number('0O011'), 9, 'upper-case head with leading zeros'); + +assert.sameValue(Number('0o77'), 63, 'lower-case head'); +assert.sameValue(Number('0O77'), 63, 'upper-case head'); +assert.sameValue(Number('0o077'), 63, 'lower-case head with leading zeros'); +assert.sameValue(Number('0O077'), 63, 'upper-case head with leading zeros'); + +reportCompare(0, 0); |