diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Number')
371 files changed, 9324 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..11e996f7df --- /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); +assert.sameValue(Number.MAX_VALUE, x, 'The value of Number.MAX_VALUE is expected to equal the value of x'); + +// TODO: Convert to verifyProperty() format. + +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..17717c902c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MAX_VALUE/S15.7.3.2_A3.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: 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 { + assert.sameValue(delete Number.MAX_VALUE, false); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } + assert(e instanceof TypeError); +} + +// TODO: Convert to verifyProperty() format. + +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..03668588ec --- /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 +---*/ + +for (var x in Number) { + assert.notSameValue(x, "MAX_VALUE", 'The value of x is not "MAX_VALUE"'); +} + +assert( + !Number.propertyIsEnumerable('MAX_VALUE'), + 'The value of !Number.propertyIsEnumerable(\'MAX_VALUE\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..450fcf96b8 --- /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); +assert.sameValue(Number.MIN_VALUE, x, 'The value of Number.MIN_VALUE is expected to equal the value of x'); + +// TODO: Convert to verifyProperty() format. + +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..9411c6c300 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/MIN_VALUE/S15.7.3.3_A3.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: 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"); + +try { + assert.sameValue(delete Number.MIN_VALUE, false); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } + assert(e instanceof TypeError); +} + +// TODO: Convert to verifyProperty() format. + +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..3bbbd9f516 --- /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 +---*/ + +for (var x in Number) { + assert.notSameValue(x, "MIN_VALUE", 'The value of x is not "MIN_VALUE"'); +} + +assert( + !Number.propertyIsEnumerable('MIN_VALUE'), + 'The value of !Number.propertyIsEnumerable(\'MIN_VALUE\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..aa19a869b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/NEGATIVE_INFINITY/S15.7.3.5_A1.js @@ -0,0 +1,11 @@ +// 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 +---*/ +assert.sameValue(isFinite(Number.NEGATIVE_INFINITY), false, 'isFinite(Number.NEGATIVE_INFINITY) must return false'); + +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..483c818acc --- /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); + +assert( + !isFinite(Number.NEGATIVE_INFINITY), + 'The value of !isFinite(Number.NEGATIVE_INFINITY) is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..952ffa04ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/POSITIVE_INFINITY/S15.7.3.6_A1.js @@ -0,0 +1,11 @@ +// 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 +---*/ +assert.sameValue(isFinite(Number.POSITIVE_INFINITY), false, 'isFinite(Number.POSITIVE_INFINITY) must return false'); + +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..f4cb7e4165 --- /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); + +assert( + !isFinite(Number.POSITIVE_INFINITY), + 'The value of !isFinite(Number.POSITIVE_INFINITY) is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..0e4eb4fc92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.1.1_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: | + 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" +---*/ +assert.sameValue(typeof Number("10"), "number", 'The value of `typeof Number("10")` is expected to be "number"'); +assert.sameValue(typeof Number(10), "number", 'The value of `typeof Number(10)` is expected to be "number"'); + +assert.sameValue( + typeof Number(new String("10")), + "number", + 'The value of `typeof Number(new String("10"))` is expected to be "number"' +); + +assert.sameValue( + typeof Number(new Object(10)), + "number", + 'The value of `typeof Number(new Object(10))` is expected to be "number"' +); + +assert.sameValue(Number("abc"), NaN, 'Number("abc") returns NaN'); +assert.sameValue(Number("INFINITY"), NaN, 'Number("INFINITY") returns NaN'); +assert.sameValue(Number("infinity"), NaN, 'Number("infinity") returns NaN'); + +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..33366b121c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.1.1_A2.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: Number() returns +0 +es5id: 15.7.1.1_A2 +description: Call Number() and check result +---*/ +assert.sameValue(typeof Number(), "number", 'The value of `typeof Number()` is expected to be "number"'); +assert.sameValue(Number(), 0, 'Number() must return 0'); + +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..098440c68a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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 +---*/ +assert.sameValue(typeof new Number(), "object", 'The value of `typeof new Number()` is expected to be "object"'); +assert.notSameValue(new Number(), undefined, 'new Number() is expected to not equal ``undefined``'); + +var x3 = new Number(); +assert.sameValue(typeof x3, "object", 'The value of `typeof x3` is expected to be "object"'); + +var x4 = new Number(); +assert.notSameValue(x4, undefined, 'The value of x4 is expected to not equal ``undefined``'); +assert.sameValue(typeof new Number(10), "object", 'The value of `typeof new Number(10)` is expected to be "object"'); +assert.notSameValue(new Number(10), undefined, 'new Number(10) is expected to not equal ``undefined``'); + +var x7 = new Number(10); +assert.sameValue(typeof x7, "object", 'The value of `typeof x7` is expected to be "object"'); + +var x8 = new Number(10); +assert.notSameValue(x8, undefined, 'The value of x8 is expected to not equal ``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..a20ca2036a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A2.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 [[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); + +assert.sameValue( + typeof x1.constructor.prototype, + "object", + 'The value of `typeof x1.constructor.prototype` is expected to be "object"' +); + +var x2 = new Number(2); +assert(Number.prototype.isPrototypeOf(x2), 'Number.prototype.isPrototypeOf(x2) must return true'); + +var x3 = new Number(3); + +assert.sameValue( + Number.prototype, + x3.constructor.prototype, + 'The value of Number.prototype is expected to equal the value of 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..769160fe47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A3.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 [[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 +---*/ + +var x1 = new Number(1); +assert.sameValue(x1.valueOf(), 1, 'x1.valueOf() must return 1'); + +var x2 = new Number(); +assert.sameValue(x2.valueOf(), 0, 'x2.valueOf() must return 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..828f6ee7e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.2.1_A4.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 [[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(); + +assert.sameValue(obj.toString(), "[object Number]", 'obj.toString() must return "[object 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..6c437d1647 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A1.js @@ -0,0 +1,11 @@ +// 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" +---*/ +assert(Number.hasOwnProperty("prototype"), 'Number.hasOwnProperty("prototype") must return true'); + +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..461661c927 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A2.js @@ -0,0 +1,11 @@ +// 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" +---*/ +assert(Number.hasOwnProperty("MAX_VALUE"), 'Number.hasOwnProperty("MAX_VALUE") must return true'); + +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..667be90e5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A3.js @@ -0,0 +1,11 @@ +// 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" +---*/ +assert(Number.hasOwnProperty("MIN_VALUE"), 'Number.hasOwnProperty("MIN_VALUE") must return true'); + +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..a29ab88e7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A4.js @@ -0,0 +1,11 @@ +// 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" +---*/ +assert(Number.hasOwnProperty("NaN"), 'Number.hasOwnProperty("NaN") must return true'); + +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..1532cb5547 --- /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" +---*/ +assert( + Number.hasOwnProperty("NEGATIVE_INFINITY"), + 'Number.hasOwnProperty("NEGATIVE_INFINITY") must return true' +); + +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..6128b1e3b1 --- /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" +---*/ +assert( + Number.hasOwnProperty("POSITIVE_INFINITY"), + 'Number.hasOwnProperty("POSITIVE_INFINITY") must return true' +); + +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..ddeff380b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A7.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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) +---*/ +assert( + Function.prototype.isPrototypeOf(Number), + 'Function.prototype.isPrototypeOf(Number) must return true' +); + +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..d2a8008e13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.3_A8.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: Number constructor has length property whose value is 1 +es5id: 15.7.3_A8 +description: Checking Number.length property +---*/ +assert(Number.hasOwnProperty("length"), 'Number.hasOwnProperty("length") must return true'); +assert.sameValue(Number.length, 1, 'The value of Number.length is expected to be 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..17087e7beb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T01.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T01 +description: Checking property constructor +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("constructor"), + false, + '(new Number()).hasOwnProperty("constructor") must return false' +); + +assert.sameValue( + (new Number()).constructor, + Number.prototype.constructor, + 'The value of (new Number()).constructor is expected to equal the value of Number.prototype.constructor' +); + +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..0133a53635 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T02.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T02 +description: Checking property toString +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("toString"), + false, + '(new Number()).hasOwnProperty("toString") must return false' +); + +assert.sameValue( + (new Number()).toString, + Number.prototype.toString, + 'The value of (new Number()).toString is expected to equal the value of Number.prototype.toString' +); + +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..e44a4fca30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T03.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T03 +description: Checking property toLocaleString +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("toLocaleString"), + false, + '(new Number()).hasOwnProperty("toLocaleString") must return false' +); + +assert.sameValue( + (new Number()).toLocaleString, + Number.prototype.toLocaleString, + 'The value of (new Number()).toLocaleString is expected to equal the value of Number.prototype.toLocaleString' +); + +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..15fc2b0174 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T04.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T04 +description: Checking property valueOf +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("valueOf"), + false, + '(new Number()).hasOwnProperty("valueOf") must return false' +); + +assert.sameValue( + (new Number()).valueOf, + Number.prototype.valueOf, + 'The value of (new Number()).valueOf is expected to equal the value of Number.prototype.valueOf' +); + +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..9018d69437 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T05.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T05 +description: Checking property toFixed +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("toFixed"), + false, + '(new Number()).hasOwnProperty("toFixed") must return false' +); + +assert.sameValue( + (new Number()).toFixed, + Number.prototype.toFixed, + 'The value of (new Number()).toFixed is expected to equal the value of Number.prototype.toFixed' +); + +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..171fee6baa --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T06.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T06 +description: Checking property toExponential +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("toExponential"), + false, + '(new Number()).hasOwnProperty("toExponential") must return false' +); + +assert.sameValue( + (new Number()).toExponential, + Number.prototype.toExponential, + 'The value of (new Number()).toExponential is expected to equal the value of Number.prototype.toExponential' +); + +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..0425a8f39d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S15.7.5_A1_T07.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 instances have no special properties beyond those + inherited from the Number prototype object +es5id: 15.7.5_A1_T07 +description: Checking property toPrecision +---*/ +assert.sameValue( + (new Number()).hasOwnProperty("toPrecision"), + false, + '(new Number()).hasOwnProperty("toPrecision") must return false' +); + +assert.sameValue( + (new Number()).toPrecision, + Number.prototype.toPrecision, + 'The value of (new Number()).toPrecision is expected to equal the value of Number.prototype.toPrecision' +); + +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..8026aeb04e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S8.12.8_A3.js @@ -0,0 +1,36 @@ +// 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(); + } + } + + assert.sameValue( + Number(__obj), + 1, + 'Number("{toString: function() {return "1"}, valueOf: function() {return new Object();}}) must return 1' + ); +} +catch (e) +{ + throw new Test262Error('#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..368cccc2af --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S8.12.8_A4.js @@ -0,0 +1,36 @@ +// 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); + throw new Test262Error('#1.1: var __obj = {valueOf:function(){return new Object;},toNumber: function() {return new Object();}}; Number(__obj) throw TypeError. Actual: ' + (Number(__obj))); +} +catch (e) +{ + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +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..0b1ba8b0b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.1_A1_T1.js @@ -0,0 +1,46 @@ +// 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 + } +}; + +assert.sameValue( + Number(object), + 1, + 'Number({valueOf: function() {return "1"}, toString: function() {return 0}}) must return 1' +); + +// CHECK#2 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "0" + } +}; + +assert.sameValue( + Number(object), + 0, + 'Number({valueOf: function() {return {}}, toString: function() {return "0"}}) must return 0' +); + +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..dc7a2cbbfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A1.js @@ -0,0 +1,11 @@ +// 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 +---*/ +assert.sameValue(Number(""), 0, 'Number("") must return 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..c472cc68ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A10.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 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 +---*/ +assert.sameValue(+('12345')*1e-5, 0.12345); + +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..7c6fd6935a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A11.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 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 +---*/ +assert.sameValue(+('12345')*1e1, 0.12345e6); + +assert.sameValue( + Number(".12345e-3"), + 0.00012345 +); + +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..9c46205506 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A12.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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 +---*/ +assert.sameValue(Number("12345e6"), 12345000000, 'Number("12345e6") must return 12345000000'); +assert.sameValue(Number("12345e-6"), 0.012345, 'Number("12345e-6") must return 0.012345'); + +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..75eff28871 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A13.js @@ -0,0 +1,29 @@ +// 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 +---*/ +assert.sameValue( + +("12"), + 12, + 'The value of `+("12")` is expected to be 12' +); + +assert.sameValue( + Number("123"), + 123, + 'Number("123") must return 123' +); + +assert.sameValue( + Number("1234"), + 1234, + 'Number("1234") must return 1234' +); + +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..fd93b601f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A14.js @@ -0,0 +1,11 @@ +// 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') +---*/ +assert.sameValue(Number("+1234567890"), 1234567890, 'Number("+1234567890") must return 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..f0ca373bd0 --- /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') +---*/ +assert.sameValue( + +("-1234567890"), + -1234567890, + 'The value of `+("-1234567890")` is expected to be -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..f8736d7d62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A16.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("0"), 0, 'Number("0") must return 0'); +assert.sameValue(+("0x0"), 0, 'The value of `+("0x0")` is expected to be 0'); +assert.sameValue(Number("0X0"), 0, 'Number("0X0") must return 0'); + +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..a2890bf77c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A17.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("1"), 1, 'Number("1") must return 1'); +assert.sameValue(Number("0x1"), 1, 'Number("0x1") must return 1'); +assert.sameValue(+("0X1"), 1, 'The value of `+("0X1")` is expected to be 1'); + +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..624beabf60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A18.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(+("2"), 2, 'The value of `+("2")` is expected to be 2'); +assert.sameValue(Number("0x2"), 2, 'Number("0x2") must return 2'); +assert.sameValue(Number("0X2"), 2, 'Number("0X2") must return 2'); + +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..0a8dce1020 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A19.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("3"), 3, 'Number("3") must return 3'); +assert.sameValue(+("0x3"), 3, 'The value of `+("0x3")` is expected to be 3'); +assert.sameValue(Number("0X3"), 3, 'Number("0X3") must return 3'); + +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..69a8293140 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A2.js @@ -0,0 +1,47 @@ +// 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 +---*/ +assert.sameValue( + 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, + 'Number("u0009u000Cu0020u00A0u000Bu000Au000Du2028u2029u1680u2000u2001u2002u2003u2004u2005u2006u2007u2008u2009u200Au202Fu205Fu3000") must return 0' +); + +assert.sameValue(Number(" "), 0, 'Number(" ") must return 0'); +assert.sameValue(Number("\t"), 0, 'Number("t") must return 0'); +assert.sameValue(Number("\r"), 0, 'Number("r") must return 0'); +assert.sameValue(Number("\n"), 0, 'Number("n") must return 0'); +assert.sameValue(Number("\f"), 0, 'Number("f") must return 0'); +assert.sameValue(Number("\u0009"), 0, 'Number("u0009") must return 0'); +assert.sameValue(Number("\u000A"), 0, 'Number("u000A") must return 0'); +assert.sameValue(Number("\u000B"), 0, 'Number("u000B") must return 0'); +assert.sameValue(Number("\u000C"), 0, 'Number("u000C") must return 0'); +assert.sameValue(Number("\u000D"), 0, 'Number("u000D") must return 0'); +assert.sameValue(Number("\u00A0"), 0, 'Number("u00A0") must return 0'); +assert.sameValue(Number("\u0020"), 0, 'Number("u0020") must return 0'); +assert.sameValue(Number("\u2028"), 0, 'Number("u2028") must return 0'); +assert.sameValue(Number("\u2029"), 0, 'Number("u2029") must return 0'); +assert.sameValue(Number("\u1680"), 0, 'Number("u1680") must return 0'); +assert.sameValue(Number("\u2000"), 0, 'Number("u2000") must return 0'); +assert.sameValue(Number("\u2001"), 0, 'Number("u2001") must return 0'); +assert.sameValue(Number("\u2002"), 0, 'Number("u2002") must return 0'); +assert.sameValue(Number("\u2003"), 0, 'Number("u2003") must return 0'); +assert.sameValue(Number("\u2004"), 0, 'Number("u2004") must return 0'); +assert.sameValue(Number("\u2005"), 0, 'Number("u2005") must return 0'); +assert.sameValue(Number("\u2006"), 0, 'Number("u2006") must return 0'); +assert.sameValue(Number("\u2007"), 0, 'Number("u2007") must return 0'); +assert.sameValue(Number("\u2008"), 0, 'Number("u2008") must return 0'); +assert.sameValue(Number("\u2009"), 0, 'Number("u2009") must return 0'); +assert.sameValue(Number("\u200A"), 0, 'Number("u200A") must return 0'); +assert.sameValue(Number("\u202F"), 0, 'Number("u202F") must return 0'); +assert.sameValue(Number("\u205F"), 0, 'Number("u205F") must return 0'); +assert.sameValue(Number("\u3000"), 0, 'Number("u3000") must return 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..8e97858fb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A20.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("4"), 4, 'Number("4") must return 4'); +assert.sameValue(Number("0x4"), 4, 'Number("0x4") must return 4'); +assert.sameValue(+("0X4"), 4, 'The value of `+("0X4")` is expected to be 4'); + +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..016c5c98a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A21.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(+("5"), 5, 'The value of `+("5")` is expected to be 5'); +assert.sameValue(Number("0x5"), 5, 'Number("0x5") must return 5'); +assert.sameValue(Number("0X5"), 5, 'Number("0X5") must return 5'); + +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..d7100193f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A22.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("6"), 6, 'Number("6") must return 6'); +assert.sameValue(+("0x6"), 6, 'The value of `+("0x6")` is expected to be 6'); +assert.sameValue(Number("0X6"), 6, 'Number("0X6") must return 6'); + +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..ddcf4e1947 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A23.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("7"), 7, 'Number("7") must return 7'); +assert.sameValue(Number("0x7"), 7, 'Number("0x7") must return 7'); +assert.sameValue(+("0X7"), 7, 'The value of `+("0X7")` is expected to be 7'); + +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..8de2e10e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A24.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(+("8"), 8, 'The value of `+("8")` is expected to be 8'); +assert.sameValue(Number("0x8"), 8, 'Number("0x8") must return 8'); +assert.sameValue(Number("0X8"), 8, 'Number("0X8") must return 8'); + +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..fe774d5ef7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A25.js @@ -0,0 +1,13 @@ +// 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 +---*/ +assert.sameValue(Number("9"), 9, 'Number("9") must return 9'); +assert.sameValue(+("0x9"), 9, 'The value of `+("0x9")` is expected to be 9'); +assert.sameValue(Number("0X9"), 9, 'Number("0X9") must return 9'); + +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..d4478fb675 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A26.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(Number("0xa"), 10, 'Number("0xa") must return 10'); +assert.sameValue(Number("0xA"), 10, 'Number("0xA") must return 10'); +assert.sameValue(Number("0Xa"), 10, 'Number("0Xa") must return 10'); +assert.sameValue(+("0XA"), 10, 'The value of `+("0XA")` is expected to be 10'); + +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..4734892980 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A27.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(Number("0xb"), 11, 'Number("0xb") must return 11'); +assert.sameValue(Number("0xB"), 11, 'Number("0xB") must return 11'); +assert.sameValue(+("0Xb"), 11, 'The value of `+("0Xb")` is expected to be 11'); +assert.sameValue(Number("0XB"), 11, 'Number("0XB") must return 11'); + +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..788a12d4f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A28.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(Number("0xc"), 12, 'Number("0xc") must return 12'); +assert.sameValue(+("0xC"), 12, 'The value of `+("0xC")` is expected to be 12'); +assert.sameValue(Number("0Xc"), 12, 'Number("0Xc") must return 12'); +assert.sameValue(Number("0XC"), 12, 'Number("0XC") must return 12'); + +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..096a492fa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A29.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(+("0xd"), 13, 'The value of `+("0xd")` is expected to be 13'); +assert.sameValue(Number("0xD"), 13, 'Number("0xD") must return 13'); +assert.sameValue(Number("0Xd"), 13, 'Number("0Xd") must return 13'); +assert.sameValue(Number("0XD"), 13, 'Number("0XD") must return 13'); + +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..bff5be512c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A30.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(Number("0xe"), 14, 'Number("0xe") must return 14'); +assert.sameValue(Number("0xE"), 14, 'Number("0xE") must return 14'); +assert.sameValue(Number("0Xe"), 14, 'Number("0Xe") must return 14'); +assert.sameValue(+("0XE"), 14, 'The value of `+("0XE")` is expected to be 14'); + +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..7df3cba8f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A31.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(Number("0xf"), 15, 'Number("0xf") must return 15'); +assert.sameValue(Number("0xF"), 15, 'Number("0xF") must return 15'); +assert.sameValue(+("0Xf"), 15, 'The value of `+("0Xf")` is expected to be 15'); +assert.sameValue(Number("0XF"), 15, 'Number("0XF") must return 15'); + +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..b0318e12cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A32.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: | + 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 +---*/ +assert.sameValue( + Number("1234567890.1234567890"), + 1234567890.1234567890, + 'Number("1234567890.1234567890") must return 1234567890.1234567890' +); + +assert.sameValue( + Number("1234567890.1234567890"), + 1234567890.1234567000, + 'Number("1234567890.1234567890") must return 1234567890.1234567000' +); + +assert.notSameValue( + +("1234567890.1234567890"), + 1234567890.123456, + 'The value of +("1234567890.1234567890") is not 1234567890.123456' +); + +assert.sameValue( + Number("0.12345678901234567890"), + 0.123456789012345678, + 'Number("0.12345678901234567890") must return 0.123456789012345678' +); + +assert.sameValue( + Number("00.12345678901234567890"), + 0.123456789012345678, + 'Number("00.12345678901234567890") must return 0.123456789012345678' +); + +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..263c04c186 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A3_T1.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 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 +---*/ +assert.sameValue( + 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 +); + +assert.sameValue( + 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"), + 1234567890 +); + +assert.sameValue( + +("\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"), + Infinity +); + +assert.sameValue( + 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"), + -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..96eb32fd0d --- /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); +} + +assert.sameValue( + 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")), + 0 +); + +assert.sameValue( + +(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")), + 1234567890 +); + +assert.sameValue( + 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")), + Infinity +); + +assert.sameValue( + 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")), + -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..193062e2cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T1.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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') +---*/ +assert.sameValue(Number("+0"), Number("0"), 'Number("+0") must return the same value returned by Number("0")'); + +assert.sameValue( + Number("+Infinity"), + Infinity +); + +assert.sameValue( + Number("+1234.5678"), + 1234.5678 +); + +assert.sameValue( + Number("+1234.5678e90"), + 1234.5678e90 +); + +assert.sameValue( + Number("+1234.5678E90"), + 1234.5678E90 +); + +assert.sameValue( + Number("+1234.5678e-90"), + 1234.5678e-90 +); + +assert.sameValue( + Number("+1234.5678E-90"), + 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..35e753fe19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A4_T2.js @@ -0,0 +1,51 @@ +// 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); +} + +assert.sameValue( + Number(dynaString("+", "0")), + 0 +); + +assert.sameValue( + Number(dynaString("+Infi", "nity")), + Infinity +); + +assert.sameValue( + Number(dynaString("+1234.", "5678")), + 1234.5678 +); + +assert.sameValue( + Number(dynaString("+1234.", "5678e90")), + 1234.5678e90 +); + +assert.sameValue( + Number(dynaString("+1234.", "5678E90")), + 1234.5678E90 +); + +assert.sameValue( + Number(dynaString("+1234.", "5678e-90")), + 1234.5678e-90 +); + +assert.sameValue( + Number(dynaString("+1234.", "5678E-90")), + 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..ffdeced459 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T1.js @@ -0,0 +1,46 @@ +// 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') +---*/ +assert.sameValue(Number("-0"), -0); +assert.sameValue(Number("-Infinity"), -Infinity); + +assert.sameValue( + Number("-1234567890"), + -1234567890 +); + +assert.sameValue(Number("-1234.5678"), -1234.5678); + +assert.sameValue( + Number("-1234.5678e90"), + -1234.5678e90 +); + +assert.sameValue( + Number("-1234.5678E90"), + -1234.5678E90 +); + +assert.sameValue( + Number("-1234.5678e-90"), + -1234.5678e-90 +); + +assert.sameValue( + Number("-1234.5678E-90"), + -1234.5678E-90 +); + +assert.sameValue( + 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..4aa454f6c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_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 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) +---*/ +assert.sameValue(Number("1"), 1, 'Number("1") must return 1'); +assert.sameValue(Number("+1"), 1, 'Number("+1") must return 1'); +assert.sameValue(Number("-1"), -1, 'Number("-1") must return -1'); +assert.sameValue(Number("2"), 2, 'Number("2") must return 2'); +assert.sameValue(Number("+2"), 2, 'Number("+2") must return 2'); +assert.sameValue(Number("-2"), -2, 'Number("-2") must return -2'); +assert.sameValue(Number("3"), 3, 'Number("3") must return 3'); +assert.sameValue(Number("+3"), 3, 'Number("+3") must return 3'); +assert.sameValue(Number("-3"), -3, 'Number("-3") must return -3'); +assert.sameValue(Number("4"), 4, 'Number("4") must return 4'); +assert.sameValue(Number("+4"), 4, 'Number("+4") must return 4'); +assert.sameValue(Number("-4"), -4, 'Number("-4") must return -4'); +assert.sameValue(Number("5"), 5, 'Number("5") must return 5'); +assert.sameValue(Number("+5"), 5, 'Number("+5") must return 5'); +assert.sameValue(Number("-5"), -5, 'Number("-5") must return -5'); +assert.sameValue(Number("6"), 6, 'Number("6") must return 6'); +assert.sameValue(Number("+6"), 6, 'Number("+6") must return 6'); +assert.sameValue(Number("-6"), -6, 'Number("-6") must return -6'); +assert.sameValue(Number("7"), 7, 'Number("7") must return 7'); +assert.sameValue(Number("+7"), 7, 'Number("+7") must return 7'); +assert.sameValue(Number("-7"), -7, 'Number("-7") must return -7'); +assert.sameValue(Number("8"), 8, 'Number("8") must return 8'); +assert.sameValue(Number("+8"), 8, 'Number("+8") must return 8'); +assert.sameValue(Number("-8"), -8, 'Number("-8") must return -8'); +assert.sameValue(Number("9"), 9, 'Number("9") must return 9'); +assert.sameValue(Number("+9"), 9, 'Number("+9") must return 9'); +assert.sameValue(Number("-9"), -9, 'Number("-9") must return -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..a1f4896faf --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A5_T3.js @@ -0,0 +1,58 @@ +// 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); +} + +assert.sameValue(Number(dynaString("-", "0")), -0, 'Number(dynaString("-", "0")) must return -Number("0")'); + +assert.sameValue( + Number(dynaString("-Infi", "nity")), + -Infinity +); + +assert.sameValue( + Number(dynaString("-12345", "67890")), + -1234567890 +); + +assert.sameValue( + Number(dynaString("-1234.", "5678")), + -1234.5678 +); + +assert.sameValue( + Number(dynaString("-1234.", "5678e90")), + -1234.5678e90 +); + +assert.sameValue( + Number(dynaString("-1234.", "5678E90")), + -1234.5678E90 +); + +assert.sameValue( + Number(dynaString("-1234.", "5678e-90")), + -1234.5678e-90 +); + +assert.sameValue( + Number(dynaString("-1234.", "5678E-90")), + -1234.5678E-90 +); + +assert.sameValue( + Number(dynaString("-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..d82b6b027f --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A6_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: | + 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") +---*/ +assert.sameValue(Number("Infinity"), Number.POSITIVE_INFINITY, 'Number("Infinity") returns Number.POSITIVE_INFINITY'); +assert.sameValue(Number("Infinity"), 10e10000, 'Number("Infinity") must return 10e10000'); +assert.sameValue(Number("Infinity"), 10E10000, 'Number("Infinity") must return 10E10000'); + +assert.sameValue( + Number("Infinity"), + 10e10000, + 'Number("Infinity") must return the same value returned by 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..68c3bf1dd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A6_T2.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 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); +} + + +assert.sameValue( + Number(dynaString("Infi", "nity")), + Number.POSITIVE_INFINITY, + 'Number(dynaString("Infi", "nity")) returns Number.POSITIVE_INFINITY' +); + +assert.sameValue( + Number(dynaString("Infi", "nity")), + 10e10000, + 'Number(dynaString("Infi", "nity")) must return 10e10000' +); + +assert.sameValue( + Number(dynaString("Infi", "nity")), + 10E10000, + 'Number(dynaString("Infi", "nity")) must return 10E10000' +); + +assert.sameValue( + Number(dynaString("Infi", "nity")), + Number("10e10000"), + 'Number(dynaString("Infi", "nity")) must return the same value returned by 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..84428ab914 --- /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) +---*/ +assert.sameValue( + Number("1234.5678"), + 1234.5678, + 'Number("1234.5678") must return 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..f4b6b2dcae --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A8.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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 +---*/ +assert.sameValue(Number("1234e5"), 123400000, 'Number("1234e5") must return 123400000'); +assert.sameValue(Number("1234.e5"), 123400000, 'Number("1234.e5") must return 123400000'); + +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..da31d06033 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3.1_A9.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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 +---*/ +assert.sameValue( + (Number("1234") + (Number("5678") * 1e-4)) * 1e9, + 1234.5678e9, + 'Number("1234.5678e9") must return (Number("1234") + (Number("5678") * 1e-4)) * 1e9' +); + +assert.sameValue( + (Number("1234") + (Number("5678") * 1e-4)) * 1e-9, + 1234.5678e-9, + 'The value of `+("1234.5678e-9")` is expected to be (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..c8617f836d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A2_T1.js @@ -0,0 +1,11 @@ +// 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 +---*/ +assert.sameValue(Number(null), 0, 'Number(null) must return 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..0debe6b2d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A3_T1.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: | + 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 +---*/ +assert.sameValue(Number(false), +0, 'Number(false) must return +0'); +assert.sameValue(Number(true), 1, 'Number(true) must return 1'); + +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..38479ba182 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A4.1_T1.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: | + 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 +---*/ +assert.sameValue(Number(13), 13, 'Number(13) must return 13'); +assert.sameValue(Number(-13), -13, 'Number(-13) must return -13'); +assert.sameValue(Number(1.3), 1.3, 'Number(1.3) must return 1.3'); +assert.sameValue(Number(-1.3), -1.3, 'Number(-1.3) must return -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..fcd7b55203 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A4.2_T1.js @@ -0,0 +1,36 @@ +// 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, 'Number(true) returns NaN'); + +assert.sameValue(Number(+0), +0, 'Number(+0) must return +0'); +assert.sameValue(Number(-0), -0, 'Number(-0) must return -0'); + +assert.sameValue( + Number(Number.POSITIVE_INFINITY), + Number.POSITIVE_INFINITY, + 'Number(Number.POSITIVE_INFINITY) returns Number.POSITIVE_INFINITY' +); + +assert.sameValue( + Number(Number.NEGATIVE_INFINITY), + Number.NEGATIVE_INFINITY, + 'Number(Number.NEGATIVE_INFINITY) returns Number.NEGATIVE_INFINITY' +); + +assert.sameValue(Number(Number.MAX_VALUE), Number.MAX_VALUE, 'Number(Number.MAX_VALUE) returns Number.MAX_VALUE'); +assert.sameValue(Number(Number.MIN_VALUE), Number.MIN_VALUE, 'Number(Number.MIN_VALUE) returns 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..c9f8dc311c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/S9.3_A5_T1.js @@ -0,0 +1,105 @@ +// 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 +---*/ +assert.sameValue(Number(new Number()), 0, 'Number(new Number()) must return 0'); +assert.sameValue(Number(new Number(0)), 0, 'Number(new Number(0)) must return 0'); + +// CHECK#3 +assert.sameValue(Number(new Number(NaN)), NaN, 'Number(new Number(NaN)) returns NaN'); + +assert.sameValue(Number(new Number(null)), 0, 'Number(new Number(null)) must return 0'); + +// CHECK#5 +assert.sameValue(Number(new Number(void 0)), NaN, 'Number(new Number(void 0)) returns NaN'); + +assert.sameValue(Number(new Number(true)), 1, 'Number(new Number(true)) must return 1'); +assert.sameValue(Number(new Number(false)), +0, 'Number(new Number(false)) must return +0'); +assert.sameValue(Number(new Boolean(true)), 1, 'Number(new Boolean(true)) must return 1'); +assert.sameValue(Number(new Boolean(false)), +0, 'Number(new Boolean(false)) must return +0'); + +// CHECK#10 +assert.sameValue(Number(new Array(2, 4, 8, 16, 32)), NaN, 'Number(new Array(2, 4, 8, 16, 32)) returns NaN'); + +// CHECK#11 +var myobj1 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "67890"; + }, + valueOf: function() { + return "[object MyObj]"; + } +}; + +assert.sameValue(Number(myobj1), NaN, 'Number("{ToNumber: function() {return 12345;}, toString: function() {return "67890";}, valueOf: function() {return "[object MyObj]";}}) returns NaN'); + +// CHECK#12 +var myobj2 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "67890"; + }, + valueOf: function() { + return "9876543210"; + } +}; + +assert.sameValue( + Number(myobj2), + 9876543210, + 'Number("{ToNumber: function() {return 12345;}, toString: function() {return "67890";}, valueOf: function() {return "9876543210";}}) must return 9876543210' +); + + +// CHECK#13 +var myobj3 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "[object MyObj]"; + } +}; + +assert.sameValue(Number(myobj3), NaN, 'Number("{ToNumber: function() {return 12345;}, toString: function() {return "[object MyObj]";}}) returns NaN'); + +// CHECK#14 +var myobj4 = { + ToNumber: function() { + return 12345; + }, + toString: function() { + return "67890"; + } +}; + +assert.sameValue( + Number(myobj4), + 67890, + 'Number("{ToNumber: function() {return 12345;}, toString: function() {return "67890";}}) must return 67890' +); + +// CHECK#15 +var myobj5 = { + ToNumber: function() { + return 12345; + } +}; + +assert.sameValue(Number(myobj5), NaN, 'Number({ToNumber: function() {return 12345;}}) returns NaN'); + +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..489ff429c1 --- /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, exponentiation] +---*/ + +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..9ce9c44993 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T1.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: 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 +---*/ +assert.sameValue( + typeof Number.prototype, + "object", + 'The value of `typeof Number.prototype` is expected to be "object"' +); + +delete Number.prototype.toString; + +assert.sameValue( + Number.prototype.toString(), + "[object Number]", + 'Number.prototype.toString() must return "[object 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..5a866328c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A2_T2.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: 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 +---*/ +assert.sameValue( + typeof Number.prototype, + "object", + 'The value of `typeof Number.prototype` is expected to be "object"' +); + +Number.prototype.toString = Object.prototype.toString; + +assert.sameValue( + Number.prototype.toString(), + "[object Number]", + 'Number.prototype.toString() must return "[object 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..27619d9983 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.3.1_A3.js @@ -0,0 +1,11 @@ +// 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 +---*/ +assert(Number.prototype == 0, 'The value of Number.prototype is expected to be 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..f745482371 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A1.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 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 +---*/ +assert.sameValue( + typeof Number.prototype, + "object", + 'The value of `typeof Number.prototype` is expected to be "object"' +); + +assert(Number.prototype == 0, 'The value of Number.prototype is expected to be 0'); + +delete Number.prototype.toString; + +assert.sameValue( + Number.prototype.toString(), + "[object Number]", + 'Number.prototype.toString() must return "[object 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..f0636b0f94 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/S15.7.4_A2.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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) +---*/ +assert( + Object.prototype.isPrototypeOf(Number.prototype), + 'Object.prototype.isPrototypeOf(Number.prototype) must return true' +); + +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..40104551bd --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("constructor"), + true, + 'Number.prototype.hasOwnProperty("constructor") must return true' +); + +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..df9d69b88b --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("toString"), + true, + 'Number.prototype.hasOwnProperty("toString") must return true' +); + +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..3df204dac0 --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("toLocaleString"), + true, + 'Number.prototype.hasOwnProperty("toLocaleString") must return true' +); + +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..68b4e1b318 --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("valueOf"), + true, + 'Number.prototype.hasOwnProperty("valueOf") must return true' +); + +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..06331dba95 --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("toFixed"), + true, + 'Number.prototype.hasOwnProperty("toFixed") must return true' +); + +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..ae91098e19 --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("toExponential"), + true, + 'Number.prototype.hasOwnProperty("toExponential") must return true' +); + +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..31dbd09de3 --- /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 +---*/ +assert.sameValue( + Number.prototype.hasOwnProperty("toPrecision"), + true, + 'Number.prototype.hasOwnProperty("toPrecision") must return true' +); + +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..153d63b923 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T01.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toFixed(), "0", 'Number.prototype.toFixed() must return "0"'); +assert.sameValue(Number.prototype.toFixed(0), "0", 'Number.prototype.toFixed(0) must return "0"'); +assert.sameValue(Number.prototype.toFixed(1), "0.0", 'Number.prototype.toFixed(1) must return "0.0"'); +assert.sameValue(Number.prototype.toFixed(1.1), "0.0", 'Number.prototype.toFixed(1.1) must return "0.0"'); +assert.sameValue(Number.prototype.toFixed(0.9), "0", 'Number.prototype.toFixed(0.9) must return "0"'); +assert.sameValue(Number.prototype.toFixed("1"), "0.0", 'Number.prototype.toFixed("1") must return "0.0"'); +assert.sameValue(Number.prototype.toFixed("1.1"), "0.0", 'Number.prototype.toFixed("1.1") must return "0.0"'); +assert.sameValue(Number.prototype.toFixed("0.9"), "0", 'Number.prototype.toFixed("0.9") must return "0"'); +assert.sameValue(Number.prototype.toFixed(Number.NaN), "0", 'Number.prototype.toFixed(Number.NaN) must return "0"'); + +assert.sameValue( + Number.prototype.toFixed("some string"), + "0", + 'Number.prototype.toFixed("some string") must return "0"' +); + +try { + assert.sameValue(Number.prototype.toFixed(-0.1), "0", 'Number.prototype.toFixed(-0.1) must return "0"'); +} +catch (e) { + throw new Test262Error('#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..a1dbd88b8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.1_T02.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: | + 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 +---*/ +assert.sameValue((new Number(1)).toFixed(), "1", '(new Number(1)).toFixed() must return "1"'); +assert.sameValue((new Number(1)).toFixed(0), "1", '(new Number(1)).toFixed(0) must return "1"'); +assert.sameValue((new Number(1)).toFixed(1), "1.0", '(new Number(1)).toFixed(1) must return "1.0"'); +assert.sameValue((new Number(1)).toFixed(1.1), "1.0", '(new Number(1)).toFixed(1.1) must return "1.0"'); +assert.sameValue((new Number(1)).toFixed(0.9), "1", '(new Number(1)).toFixed(0.9) must return "1"'); +assert.sameValue((new Number(1)).toFixed("1"), "1.0", '(new Number(1)).toFixed("1") must return "1.0"'); +assert.sameValue((new Number(1)).toFixed("1.1"), "1.0", '(new Number(1)).toFixed("1.1") must return "1.0"'); +assert.sameValue((new Number(1)).toFixed("0.9"), "1", '(new Number(1)).toFixed("0.9") must return "1"'); +assert.sameValue((new Number(1)).toFixed(Number.NaN), "1", '(new Number(1)).toFixed(Number.NaN) must return "1"'); + +assert.sameValue( + (new Number(1)).toFixed("some string"), + "1", + '(new Number(1)).toFixed("some string") must return "1"' +); + +try { + assert.sameValue((new Number(1)).toFixed(-0.1), "1", '(new Number(1)).toFixed(-0.1) must return "1"'); +} +catch (e) { + throw new Test262Error('#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..70468a816a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T01.js @@ -0,0 +1,38 @@ +// 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") +---*/ +assert.sameValue((new Number("a")).toFixed(), "NaN", '(new Number("a")).toFixed() must return "NaN"'); +assert.sameValue((new Number("a")).toFixed(0), "NaN", '(new Number("a")).toFixed(0) must return "NaN"'); +assert.sameValue((new Number("a")).toFixed(1), "NaN", '(new Number("a")).toFixed(1) must return "NaN"'); +assert.sameValue((new Number("a")).toFixed(1.1), "NaN", '(new Number("a")).toFixed(1.1) must return "NaN"'); +assert.sameValue((new Number("a")).toFixed(0.9), "NaN", '(new Number("a")).toFixed(0.9) must return "NaN"'); +assert.sameValue((new Number("a")).toFixed("1"), "NaN", '(new Number("a")).toFixed("1") must return "NaN"'); +assert.sameValue((new Number("a")).toFixed("1.1"), "NaN", '(new Number("a")).toFixed("1.1") must return "NaN"'); +assert.sameValue((new Number("a")).toFixed("0.9"), "NaN", '(new Number("a")).toFixed("0.9") must return "NaN"'); + +assert.sameValue( + (new Number("a")).toFixed(Number.NaN), + "NaN", + '(new Number("a")).toFixed(Number.NaN) must return "NaN"' +); + +assert.sameValue( + (new Number("a")).toFixed("some string"), + "NaN", + '(new Number("a")).toFixed("some string") must return "NaN"' +); + +try { + s = (new Number("a")).toFixed(Number.POSITIVE_INFINITY); + throw new Test262Error('#10: (new Number("a")).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not return NaN'); +} +catch (e) { + assert(e instanceof RangeError, 'The result of evaluating (e instanceof RangeError) is expected to be true'); +} + +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..31cc85182c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.3_T02.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "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 +---*/ +assert.sameValue(Number.NaN.toFixed(), "NaN", 'Number.NaN.toFixed() must return "NaN"'); +assert.sameValue(Number.NaN.toFixed(0), "NaN", 'Number.NaN.toFixed(0) must return "NaN"'); +assert.sameValue(Number.NaN.toFixed(1), "NaN", 'Number.NaN.toFixed(1) must return "NaN"'); +assert.sameValue(Number.NaN.toFixed(1.1), "NaN", 'Number.NaN.toFixed(1.1) must return "NaN"'); +assert.sameValue(Number.NaN.toFixed(0.9), "NaN", 'Number.NaN.toFixed(0.9) must return "NaN"'); +assert.sameValue(Number.NaN.toFixed("1"), "NaN", 'Number.NaN.toFixed("1") must return "NaN"'); +assert.sameValue(Number.NaN.toFixed("1.1"), "NaN", 'Number.NaN.toFixed("1.1") must return "NaN"'); +assert.sameValue(Number.NaN.toFixed("0.9"), "NaN", 'Number.NaN.toFixed("0.9") must return "NaN"'); +assert.sameValue(Number.NaN.toFixed(Number.NaN), "NaN", 'Number.NaN.toFixed(Number.NaN) must return "NaN"'); +assert.sameValue(Number.NaN.toFixed("some string"), "NaN", 'Number.NaN.toFixed("some string") must return "NaN"'); + +try { + s = Number.NaN.toFixed(Number.POSITIVE_INFINITY); + throw new Test262Error('#10: Number.NaN.toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not return NaN'); +} +catch (e) { + assert(e instanceof RangeError, 'The result of evaluating (e instanceof RangeError) is expected to be true'); +} + +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..c5e9de87a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A1.4_T01.js @@ -0,0 +1,77 @@ +// 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 +---*/ +assert.sameValue( + (new Number(1e21)).toFixed(), + String(1e21), + '(new Number(1e21)).toFixed() must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed(0), + String(1e21), + '(new Number(1e21)).toFixed(0) must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed(1), + String(1e21), + '(new Number(1e21)).toFixed(1) must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed(1.1), + String(1e21), + '(new Number(1e21)).toFixed(1.1) must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed(0.9), + String(1e21), + '(new Number(1e21)).toFixed(0.9) must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed("1"), + String(1e21), + '(new Number(1e21)).toFixed("1") must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed("1.1"), + String(1e21), + '(new Number(1e21)).toFixed("1.1") must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed("0.9"), + String(1e21), + '(new Number(1e21)).toFixed("0.9") must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed(Number.NaN), + String(1e21), + '(new Number(1e21)).toFixed(Number.NaN) must return the same value returned by String(1e21)' +); + +assert.sameValue( + (new Number(1e21)).toFixed("some string"), + String(1e21), + '(new Number(1e21)).toFixed("some string") must return the same value returned by String(1e21)' +); + +try { + s = (new Number(1e21)).toFixed(Number.POSITIVE_INFINITY); + throw new Test262Error('#10: (new Number(1e21)).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not return NaN'); +} +catch (e) { + assert(e instanceof RangeError, 'The result of evaluating (e instanceof RangeError) is expected to be true'); +} + +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..2d7ef86f1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/S15.7.4.5_A2_T01.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 length property of the toFixed method is 1 +es5id: 15.7.4.5_A2_T01 +description: Checking Number prototype itself +---*/ +assert.sameValue( + Number.prototype.toFixed.hasOwnProperty("length"), + true, + 'Number.prototype.toFixed.hasOwnProperty("length") must return true' +); + +assert.sameValue( + Number.prototype.toFixed.length, + 1, + 'The value of Number.prototype.toFixed.length is expected to be 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..09d10b50e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T01.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(), "0", 'Number.prototype.toString() must return "0"'); +assert.sameValue((new Number()).toString(), "0", '(new Number()).toString() must return "0"'); +assert.sameValue((new Number(0)).toString(), "0", '(new Number(0)).toString() must return "0"'); +assert.sameValue((new Number(-1)).toString(), "-1", '(new Number(-1)).toString() must return "-1"'); +assert.sameValue((new Number(1)).toString(), "1", '(new Number(1)).toString() must return "1"'); +assert.sameValue((new Number(Number.NaN)).toString(), "NaN", '(new Number(Number.NaN)).toString() must return "NaN"'); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString() must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString() must return "-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..1d7e7b6693 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T02.js @@ -0,0 +1,36 @@ +// 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 +---*/ +assert.sameValue(Number.prototype.toString(10), "0", 'Number.prototype.toString(10) must return "0"'); +assert.sameValue((new Number()).toString(10), "0", '(new Number()).toString(10) must return "0"'); +assert.sameValue((new Number(0)).toString(10), "0", '(new Number(0)).toString(10) must return "0"'); +assert.sameValue((new Number(-1)).toString(10), "-1", '(new Number(-1)).toString(10) must return "-1"'); +assert.sameValue((new Number(1)).toString(10), "1", '(new Number(1)).toString(10) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(10), + "NaN", + '(new Number(Number.NaN)).toString(10) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(10), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(10) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(10), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(10) must return "-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..68820bd382 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A1_T03.js @@ -0,0 +1,36 @@ +// 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 +---*/ +assert.sameValue(Number.prototype.toString(undefined), "0", 'Number.prototype.toString(undefined) must return "0"'); +assert.sameValue((new Number()).toString(undefined), "0", '(new Number()).toString(undefined) must return "0"'); +assert.sameValue((new Number(0)).toString(undefined), "0", '(new Number(0)).toString(undefined) must return "0"'); +assert.sameValue((new Number(-1)).toString(undefined), "-1", '(new Number(-1)).toString(undefined) must return "-1"'); +assert.sameValue((new Number(1)).toString(undefined), "1", '(new Number(1)).toString(undefined) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(undefined), + "NaN", + '(new Number(Number.NaN)).toString(undefined) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(undefined), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(undefined) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(undefined), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(undefined) must return "-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..85dff6174d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T01.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(2), "0", 'Number.prototype.toString(2) must return "0"'); +assert.sameValue((new Number()).toString(2), "0", '(new Number()).toString(2) must return "0"'); +assert.sameValue((new Number(0)).toString(2), "0", '(new Number(0)).toString(2) must return "0"'); +assert.sameValue((new Number(-1)).toString(2), "-1", '(new Number(-1)).toString(2) must return "-1"'); +assert.sameValue((new Number(1)).toString(2), "1", '(new Number(1)).toString(2) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(2), + "NaN", + '(new Number(Number.NaN)).toString(2) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(2), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(2) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(2), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(2) must return "-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..11f498aa1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T02.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(3), "0", 'Number.prototype.toString(3) must return "0"'); +assert.sameValue((new Number()).toString(3), "0", '(new Number()).toString(3) must return "0"'); +assert.sameValue((new Number(0)).toString(3), "0", '(new Number(0)).toString(3) must return "0"'); +assert.sameValue((new Number(-1)).toString(3), "-1", '(new Number(-1)).toString(3) must return "-1"'); +assert.sameValue((new Number(1)).toString(3), "1", '(new Number(1)).toString(3) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(3), + "NaN", + '(new Number(Number.NaN)).toString(3) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(3), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(3) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(3), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(3) must return "-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..d928cfe256 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T03.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(4), "0", 'Number.prototype.toString(4) must return "0"'); +assert.sameValue((new Number()).toString(4), "0", '(new Number()).toString(4) must return "0"'); +assert.sameValue((new Number(0)).toString(4), "0", '(new Number(0)).toString(4) must return "0"'); +assert.sameValue((new Number(-1)).toString(4), "-1", '(new Number(-1)).toString(4) must return "-1"'); +assert.sameValue((new Number(1)).toString(4), "1", '(new Number(1)).toString(4) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(4), + "NaN", + '(new Number(Number.NaN)).toString(4) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(4), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(4) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(4), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(4) must return "-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..f5d29c3615 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T04.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(5), "0", 'Number.prototype.toString(5) must return "0"'); +assert.sameValue((new Number()).toString(5), "0", '(new Number()).toString(5) must return "0"'); +assert.sameValue((new Number(0)).toString(5), "0", '(new Number(0)).toString(5) must return "0"'); +assert.sameValue((new Number(-1)).toString(5), "-1", '(new Number(-1)).toString(5) must return "-1"'); +assert.sameValue((new Number(1)).toString(5), "1", '(new Number(1)).toString(5) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(5), + "NaN", + '(new Number(Number.NaN)).toString(5) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(5), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(5) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(5), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(5) must return "-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..dad8b71694 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T05.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(6), "0", 'Number.prototype.toString(6) must return "0"'); +assert.sameValue((new Number()).toString(6), "0", '(new Number()).toString(6) must return "0"'); +assert.sameValue((new Number(0)).toString(6), "0", '(new Number(0)).toString(6) must return "0"'); +assert.sameValue((new Number(-1)).toString(6), "-1", '(new Number(-1)).toString(6) must return "-1"'); +assert.sameValue((new Number(1)).toString(6), "1", '(new Number(1)).toString(6) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(6), + "NaN", + '(new Number(Number.NaN)).toString(6) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(6), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(6) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(6), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(6) must return "-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..0eed1bd918 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T06.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(7), "0", 'Number.prototype.toString(7) must return "0"'); +assert.sameValue((new Number()).toString(7), "0", '(new Number()).toString(7) must return "0"'); +assert.sameValue((new Number(0)).toString(7), "0", '(new Number(0)).toString(7) must return "0"'); +assert.sameValue((new Number(-1)).toString(7), "-1", '(new Number(-1)).toString(7) must return "-1"'); +assert.sameValue((new Number(1)).toString(7), "1", '(new Number(1)).toString(7) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(7), + "NaN", + '(new Number(Number.NaN)).toString(7) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(7), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(7) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(7), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(7) must return "-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..95a98e7edd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T07.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(8), "0", 'Number.prototype.toString(8) must return "0"'); +assert.sameValue((new Number()).toString(8), "0", '(new Number()).toString(8) must return "0"'); +assert.sameValue((new Number(0)).toString(8), "0", '(new Number(0)).toString(8) must return "0"'); +assert.sameValue((new Number(-1)).toString(8), "-1", '(new Number(-1)).toString(8) must return "-1"'); +assert.sameValue((new Number(1)).toString(8), "1", '(new Number(1)).toString(8) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(8), + "NaN", + '(new Number(Number.NaN)).toString(8) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(8), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(8) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(8), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(8) must return "-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..c19c015f01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T08.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(9), "0", 'Number.prototype.toString(9) must return "0"'); +assert.sameValue((new Number()).toString(9), "0", '(new Number()).toString(9) must return "0"'); +assert.sameValue((new Number(0)).toString(9), "0", '(new Number(0)).toString(9) must return "0"'); +assert.sameValue((new Number(-1)).toString(9), "-1", '(new Number(-1)).toString(9) must return "-1"'); +assert.sameValue((new Number(1)).toString(9), "1", '(new Number(1)).toString(9) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(9), + "NaN", + '(new Number(Number.NaN)).toString(9) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(9), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(9) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(9), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(9) must return "-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..139c6c40b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T09.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(11), "0", 'Number.prototype.toString(11) must return "0"'); +assert.sameValue((new Number()).toString(11), "0", '(new Number()).toString(11) must return "0"'); +assert.sameValue((new Number(0)).toString(11), "0", '(new Number(0)).toString(11) must return "0"'); +assert.sameValue((new Number(-1)).toString(11), "-1", '(new Number(-1)).toString(11) must return "-1"'); +assert.sameValue((new Number(1)).toString(11), "1", '(new Number(1)).toString(11) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(11), + "NaN", + '(new Number(Number.NaN)).toString(11) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(11), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(11) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(11), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(11) must return "-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..8cd2862ac4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T10.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(12), "0", 'Number.prototype.toString(12) must return "0"'); +assert.sameValue((new Number()).toString(12), "0", '(new Number()).toString(12) must return "0"'); +assert.sameValue((new Number(0)).toString(12), "0", '(new Number(0)).toString(12) must return "0"'); +assert.sameValue((new Number(-1)).toString(12), "-1", '(new Number(-1)).toString(12) must return "-1"'); +assert.sameValue((new Number(1)).toString(12), "1", '(new Number(1)).toString(12) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(12), + "NaN", + '(new Number(Number.NaN)).toString(12) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(12), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(12) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(12), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(12) must return "-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..2e6279cf97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T11.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(13), "0", 'Number.prototype.toString(13) must return "0"'); +assert.sameValue((new Number()).toString(13), "0", '(new Number()).toString(13) must return "0"'); +assert.sameValue((new Number(0)).toString(13), "0", '(new Number(0)).toString(13) must return "0"'); +assert.sameValue((new Number(-1)).toString(13), "-1", '(new Number(-1)).toString(13) must return "-1"'); +assert.sameValue((new Number(1)).toString(13), "1", '(new Number(1)).toString(13) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(13), + "NaN", + '(new Number(Number.NaN)).toString(13) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(13), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(13) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(13), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(13) must return "-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..ef1ac373a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T12.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(14), "0", 'Number.prototype.toString(14) must return "0"'); +assert.sameValue((new Number()).toString(14), "0", '(new Number()).toString(14) must return "0"'); +assert.sameValue((new Number(0)).toString(14), "0", '(new Number(0)).toString(14) must return "0"'); +assert.sameValue((new Number(-1)).toString(14), "-1", '(new Number(-1)).toString(14) must return "-1"'); +assert.sameValue((new Number(1)).toString(14), "1", '(new Number(1)).toString(14) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(14), + "NaN", + '(new Number(Number.NaN)).toString(14) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(14), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(14) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(14), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(14) must return "-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..a424274e28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T13.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(15), "0", 'Number.prototype.toString(15) must return "0"'); +assert.sameValue((new Number()).toString(15), "0", '(new Number()).toString(15) must return "0"'); +assert.sameValue((new Number(0)).toString(15), "0", '(new Number(0)).toString(15) must return "0"'); +assert.sameValue((new Number(-1)).toString(15), "-1", '(new Number(-1)).toString(15) must return "-1"'); +assert.sameValue((new Number(1)).toString(15), "1", '(new Number(1)).toString(15) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(15), + "NaN", + '(new Number(Number.NaN)).toString(15) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(15), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(15) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(15), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(15) must return "-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..2f65b2b23c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T14.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(16), "0", 'Number.prototype.toString(16) must return "0"'); +assert.sameValue((new Number()).toString(16), "0", '(new Number()).toString(16) must return "0"'); +assert.sameValue((new Number(0)).toString(16), "0", '(new Number(0)).toString(16) must return "0"'); +assert.sameValue((new Number(-1)).toString(16), "-1", '(new Number(-1)).toString(16) must return "-1"'); +assert.sameValue((new Number(1)).toString(16), "1", '(new Number(1)).toString(16) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(16), + "NaN", + '(new Number(Number.NaN)).toString(16) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(16), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(16) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(16), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(16) must return "-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..ea4c92bf85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T15.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(17), "0", 'Number.prototype.toString(17) must return "0"'); +assert.sameValue((new Number()).toString(17), "0", '(new Number()).toString(17) must return "0"'); +assert.sameValue((new Number(0)).toString(17), "0", '(new Number(0)).toString(17) must return "0"'); +assert.sameValue((new Number(-1)).toString(17), "-1", '(new Number(-1)).toString(17) must return "-1"'); +assert.sameValue((new Number(1)).toString(17), "1", '(new Number(1)).toString(17) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(17), + "NaN", + '(new Number(Number.NaN)).toString(17) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(17), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(17) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(17), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(17) must return "-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..293b161a25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T16.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(18), "0", 'Number.prototype.toString(18) must return "0"'); +assert.sameValue((new Number()).toString(18), "0", '(new Number()).toString(18) must return "0"'); +assert.sameValue((new Number(0)).toString(18), "0", '(new Number(0)).toString(18) must return "0"'); +assert.sameValue((new Number(-1)).toString(18), "-1", '(new Number(-1)).toString(18) must return "-1"'); +assert.sameValue((new Number(1)).toString(18), "1", '(new Number(1)).toString(18) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(18), + "NaN", + '(new Number(Number.NaN)).toString(18) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(18), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(18) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(18), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(18) must return "-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..8abf41383e --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T17.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(19), "0", 'Number.prototype.toString(19) must return "0"'); +assert.sameValue((new Number()).toString(19), "0", '(new Number()).toString(19) must return "0"'); +assert.sameValue((new Number(0)).toString(19), "0", '(new Number(0)).toString(19) must return "0"'); +assert.sameValue((new Number(-1)).toString(19), "-1", '(new Number(-1)).toString(19) must return "-1"'); +assert.sameValue((new Number(1)).toString(19), "1", '(new Number(1)).toString(19) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(19), + "NaN", + '(new Number(Number.NaN)).toString(19) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(19), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(19) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(19), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(19) must return "-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..d6802a9329 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T18.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(20), "0", 'Number.prototype.toString(20) must return "0"'); +assert.sameValue((new Number()).toString(20), "0", '(new Number()).toString(20) must return "0"'); +assert.sameValue((new Number(0)).toString(20), "0", '(new Number(0)).toString(20) must return "0"'); +assert.sameValue((new Number(-1)).toString(20), "-1", '(new Number(-1)).toString(20) must return "-1"'); +assert.sameValue((new Number(1)).toString(20), "1", '(new Number(1)).toString(20) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(20), + "NaN", + '(new Number(Number.NaN)).toString(20) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(20), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(20) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(20), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(20) must return "-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..a4a4bf68fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T19.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(21), "0", 'Number.prototype.toString(21) must return "0"'); +assert.sameValue((new Number()).toString(21), "0", '(new Number()).toString(21) must return "0"'); +assert.sameValue((new Number(0)).toString(21), "0", '(new Number(0)).toString(21) must return "0"'); +assert.sameValue((new Number(-1)).toString(21), "-1", '(new Number(-1)).toString(21) must return "-1"'); +assert.sameValue((new Number(1)).toString(21), "1", '(new Number(1)).toString(21) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(21), + "NaN", + '(new Number(Number.NaN)).toString(21) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(21), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(21) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(21), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(21) must return "-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..995190f0fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T20.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(22), "0", 'Number.prototype.toString(22) must return "0"'); +assert.sameValue((new Number()).toString(22), "0", '(new Number()).toString(22) must return "0"'); +assert.sameValue((new Number(0)).toString(22), "0", '(new Number(0)).toString(22) must return "0"'); +assert.sameValue((new Number(-1)).toString(22), "-1", '(new Number(-1)).toString(22) must return "-1"'); +assert.sameValue((new Number(1)).toString(22), "1", '(new Number(1)).toString(22) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(22), + "NaN", + '(new Number(Number.NaN)).toString(22) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(22), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(22) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(22), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(22) must return "-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..6519b68065 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T21.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(23), "0", 'Number.prototype.toString(23) must return "0"'); +assert.sameValue((new Number()).toString(23), "0", '(new Number()).toString(23) must return "0"'); +assert.sameValue((new Number(0)).toString(23), "0", '(new Number(0)).toString(23) must return "0"'); +assert.sameValue((new Number(-1)).toString(23), "-1", '(new Number(-1)).toString(23) must return "-1"'); +assert.sameValue((new Number(1)).toString(23), "1", '(new Number(1)).toString(23) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(23), + "NaN", + '(new Number(Number.NaN)).toString(23) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(23), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(23) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(23), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(23) must return "-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..1aa40777a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T22.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(24), "0", 'Number.prototype.toString(24) must return "0"'); +assert.sameValue((new Number()).toString(24), "0", '(new Number()).toString(24) must return "0"'); +assert.sameValue((new Number(0)).toString(24), "0", '(new Number(0)).toString(24) must return "0"'); +assert.sameValue((new Number(-1)).toString(24), "-1", '(new Number(-1)).toString(24) must return "-1"'); +assert.sameValue((new Number(1)).toString(24), "1", '(new Number(1)).toString(24) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(24), + "NaN", + '(new Number(Number.NaN)).toString(24) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(24), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(24) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(24), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(24) must return "-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..0ce411e3d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T23.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(25), "0", 'Number.prototype.toString(25) must return "0"'); +assert.sameValue((new Number()).toString(25), "0", '(new Number()).toString(25) must return "0"'); +assert.sameValue((new Number(0)).toString(25), "0", '(new Number(0)).toString(25) must return "0"'); +assert.sameValue((new Number(-1)).toString(25), "-1", '(new Number(-1)).toString(25) must return "-1"'); +assert.sameValue((new Number(1)).toString(25), "1", '(new Number(1)).toString(25) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(25), + "NaN", + '(new Number(Number.NaN)).toString(25) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(25), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(25) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(25), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(25) must return "-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..55f666850d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T24.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(26), "0", 'Number.prototype.toString(26) must return "0"'); +assert.sameValue((new Number()).toString(26), "0", '(new Number()).toString(26) must return "0"'); +assert.sameValue((new Number(0)).toString(26), "0", '(new Number(0)).toString(26) must return "0"'); +assert.sameValue((new Number(-1)).toString(26), "-1", '(new Number(-1)).toString(26) must return "-1"'); +assert.sameValue((new Number(1)).toString(26), "1", '(new Number(1)).toString(26) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(26), + "NaN", + '(new Number(Number.NaN)).toString(26) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(26), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(26) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(26), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(26) must return "-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..4930fce27c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T25.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(27), "0", 'Number.prototype.toString(27) must return "0"'); +assert.sameValue((new Number()).toString(27), "0", '(new Number()).toString(27) must return "0"'); +assert.sameValue((new Number(0)).toString(27), "0", '(new Number(0)).toString(27) must return "0"'); +assert.sameValue((new Number(-1)).toString(27), "-1", '(new Number(-1)).toString(27) must return "-1"'); +assert.sameValue((new Number(1)).toString(27), "1", '(new Number(1)).toString(27) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(27), + "NaN", + '(new Number(Number.NaN)).toString(27) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(27), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(27) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(27), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(27) must return "-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..c59ab5d6a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T26.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(28), "0", 'Number.prototype.toString(28) must return "0"'); +assert.sameValue((new Number()).toString(28), "0", '(new Number()).toString(28) must return "0"'); +assert.sameValue((new Number(0)).toString(28), "0", '(new Number(0)).toString(28) must return "0"'); +assert.sameValue((new Number(-1)).toString(28), "-1", '(new Number(-1)).toString(28) must return "-1"'); +assert.sameValue((new Number(1)).toString(28), "1", '(new Number(1)).toString(28) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(28), + "NaN", + '(new Number(Number.NaN)).toString(28) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(28), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(28) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(28), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(28) must return "-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..cb6064d059 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T27.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(29), "0", 'Number.prototype.toString(29) must return "0"'); +assert.sameValue((new Number()).toString(29), "0", '(new Number()).toString(29) must return "0"'); +assert.sameValue((new Number(0)).toString(29), "0", '(new Number(0)).toString(29) must return "0"'); +assert.sameValue((new Number(-1)).toString(29), "-1", '(new Number(-1)).toString(29) must return "-1"'); +assert.sameValue((new Number(1)).toString(29), "1", '(new Number(1)).toString(29) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(29), + "NaN", + '(new Number(Number.NaN)).toString(29) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(29), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(29) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(29), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(29) must return "-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..5151f803ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T28.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(30), "0", 'Number.prototype.toString(30) must return "0"'); +assert.sameValue((new Number()).toString(30), "0", '(new Number()).toString(30) must return "0"'); +assert.sameValue((new Number(0)).toString(30), "0", '(new Number(0)).toString(30) must return "0"'); +assert.sameValue((new Number(-1)).toString(30), "-1", '(new Number(-1)).toString(30) must return "-1"'); +assert.sameValue((new Number(1)).toString(30), "1", '(new Number(1)).toString(30) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(30), + "NaN", + '(new Number(Number.NaN)).toString(30) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(30), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(30) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(30), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(30) must return "-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..41ae187cce --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T29.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(31), "0", 'Number.prototype.toString(31) must return "0"'); +assert.sameValue((new Number()).toString(31), "0", '(new Number()).toString(31) must return "0"'); +assert.sameValue((new Number(0)).toString(31), "0", '(new Number(0)).toString(31) must return "0"'); +assert.sameValue((new Number(-1)).toString(31), "-1", '(new Number(-1)).toString(31) must return "-1"'); +assert.sameValue((new Number(1)).toString(31), "1", '(new Number(1)).toString(31) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(31), + "NaN", + '(new Number(Number.NaN)).toString(31) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(31), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(31) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(31), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(31) must return "-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..a0b322c94a --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T30.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(32), "0", 'Number.prototype.toString(32) must return "0"'); +assert.sameValue((new Number()).toString(32), "0", '(new Number()).toString(32) must return "0"'); +assert.sameValue((new Number(0)).toString(32), "0", '(new Number(0)).toString(32) must return "0"'); +assert.sameValue((new Number(-1)).toString(32), "-1", '(new Number(-1)).toString(32) must return "-1"'); +assert.sameValue((new Number(1)).toString(32), "1", '(new Number(1)).toString(32) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(32), + "NaN", + '(new Number(Number.NaN)).toString(32) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(32), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(32) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(32), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(32) must return "-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..43ed5864b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T31.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(33), "0", 'Number.prototype.toString(33) must return "0"'); +assert.sameValue((new Number()).toString(33), "0", '(new Number()).toString(33) must return "0"'); +assert.sameValue((new Number(0)).toString(33), "0", '(new Number(0)).toString(33) must return "0"'); +assert.sameValue((new Number(-1)).toString(33), "-1", '(new Number(-1)).toString(33) must return "-1"'); +assert.sameValue((new Number(1)).toString(33), "1", '(new Number(1)).toString(33) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(33), + "NaN", + '(new Number(Number.NaN)).toString(33) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(33), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(33) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(33), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(33) must return "-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..ffb7cabf2b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T32.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(34), "0", 'Number.prototype.toString(34) must return "0"'); +assert.sameValue((new Number()).toString(34), "0", '(new Number()).toString(34) must return "0"'); +assert.sameValue((new Number(0)).toString(34), "0", '(new Number(0)).toString(34) must return "0"'); +assert.sameValue((new Number(-1)).toString(34), "-1", '(new Number(-1)).toString(34) must return "-1"'); +assert.sameValue((new Number(1)).toString(34), "1", '(new Number(1)).toString(34) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(34), + "NaN", + '(new Number(Number.NaN)).toString(34) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(34), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(34) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(34), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(34) must return "-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..89e3f740bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T33.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(35), "0", 'Number.prototype.toString(35) must return "0"'); +assert.sameValue((new Number()).toString(35), "0", '(new Number()).toString(35) must return "0"'); +assert.sameValue((new Number(0)).toString(35), "0", '(new Number(0)).toString(35) must return "0"'); +assert.sameValue((new Number(-1)).toString(35), "-1", '(new Number(-1)).toString(35) must return "-1"'); +assert.sameValue((new Number(1)).toString(35), "1", '(new Number(1)).toString(35) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(35), + "NaN", + '(new Number(Number.NaN)).toString(35) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(35), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(35) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(35), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(35) must return "-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..d80367d1ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A2_T34.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: | + 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 +---*/ +assert.sameValue(Number.prototype.toString(36), "0", 'Number.prototype.toString(36) must return "0"'); +assert.sameValue((new Number()).toString(36), "0", '(new Number()).toString(36) must return "0"'); +assert.sameValue((new Number(0)).toString(36), "0", '(new Number(0)).toString(36) must return "0"'); +assert.sameValue((new Number(-1)).toString(36), "-1", '(new Number(-1)).toString(36) must return "-1"'); +assert.sameValue((new Number(1)).toString(36), "1", '(new Number(1)).toString(36) must return "1"'); + +assert.sameValue( + (new Number(Number.NaN)).toString(36), + "NaN", + '(new Number(Number.NaN)).toString(36) must return "NaN"' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).toString(36), + "Infinity", + '(new Number(Number.POSITIVE_INFINITY)).toString(36) must return "Infinity"' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).toString(36), + "-Infinity", + '(new Number(Number.NEGATIVE_INFINITY)).toString(36) must return "-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..665dd22563 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T01.js @@ -0,0 +1,58 @@ +// 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 +---*/ + +try { + var n = Number.prototype.toString(1); + throw new Test262Error('#1: Number.prototype.toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number()).toString(1); + throw new Test262Error('#2: (new Number()).toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(0)).toString(1); + throw new Test262Error('#3: (new Number(0)).toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(-1)).toString(1); + throw new Test262Error('#4: (new Number(-1)).toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(1)).toString(1); + throw new Test262Error('#5: (new Number(1)).toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NaN)).toString(1); + throw new Test262Error('#6: (new Number(Number.NaN)).toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(1); + throw new Test262Error('#7: (new Number(Number.POSITIVE_INFINITY)).toString(1) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(1); + throw new Test262Error('#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..f283f03013 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T02.js @@ -0,0 +1,58 @@ +// 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 +---*/ + +try { + var n = Number.prototype.toString(37); + throw new Test262Error('#1: Number.prototype.toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number()).toString(37); + throw new Test262Error('#2: (new Number()).toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(0)).toString(37); + throw new Test262Error('#3: (new Number(0)).toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(-1)).toString(37); + throw new Test262Error('#4: (new Number(-1)).toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(1)).toString(37); + throw new Test262Error('#5: (new Number(1)).toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NaN)).toString(37); + throw new Test262Error('#6: (new Number(Number.NaN)).toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(37); + throw new Test262Error('#7: (new Number(Number.POSITIVE_INFINITY)).toString(37) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(37); + throw new Test262Error('#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..7da1bd7e60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T03.js @@ -0,0 +1,58 @@ +// 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 +---*/ + +try { + var n = Number.prototype.toString(null); + throw new Test262Error('#1: Number.prototype.toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number()).toString(null); + throw new Test262Error('#2: (new Number()).toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(0)).toString(null); + throw new Test262Error('#3: (new Number(0)).toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(-1)).toString(null); + throw new Test262Error('#4: (new Number(-1)).toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(1)).toString(null); + throw new Test262Error('#5: (new Number(1)).toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NaN)).toString(null); + throw new Test262Error('#6: (new Number(Number.NaN)).toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(null); + throw new Test262Error('#7: (new Number(Number.POSITIVE_INFINITY)).toString(null) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(null); + throw new Test262Error('#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..d88823a152 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A3_T04.js @@ -0,0 +1,58 @@ +// 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 +---*/ + +try { + var n = Number.prototype.toString(0); + throw new Test262Error('#1: Number.prototype.toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number()).toString(0); + throw new Test262Error('#2: (new Number()).toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(0)).toString(0); + throw new Test262Error('#3: (new Number(0)).toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(-1)).toString(0); + throw new Test262Error('#4: (new Number(-1)).toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(1)).toString(0); + throw new Test262Error('#5: (new Number(1)).toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NaN)).toString(0); + throw new Test262Error('#6: (new Number(Number.NaN)).toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.POSITIVE_INFINITY)).toString(0); + throw new Test262Error('#7: (new Number(Number.POSITIVE_INFINITY)).toString(0) should throw an Error'); +} +catch (e) {} + +try { + var n = (new Number(Number.NEGATIVE_INFINITY)).toString(0); + throw new Test262Error('#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..bdbbf070bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T01.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 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 +---*/ + +try { + var s1 = new String(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + throw new Test262Error('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new String(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + throw new Test262Error('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..3ecdb81232 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T02.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 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 +---*/ + +try { + var s1 = new Boolean(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + throw new Test262Error('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new Boolean(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + throw new Test262Error('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..d1c96dd6b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T03.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 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 +---*/ + +try { + var s1 = new Date(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + throw new Test262Error('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new Date(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + throw new Test262Error('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..028c78e8a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T04.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 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 +---*/ + +try { + var s1 = new Object(); + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + throw new Test262Error('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new Object(); + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + throw new Test262Error('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..14fa638ed1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/S15.7.4.2_A4_T05.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 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 +---*/ + +try { + var s1 = { + x: 1 + }; + s1.toString = Number.prototype.toString; + var v1 = s1.toString(); + throw new Test262Error('#1: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = { + x: 1 + }; + s2.myToString = Number.prototype.toString; + var v2 = s2.myToString(); + throw new Test262Error('#2: Number.prototype.toString on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..22f0607f0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T01.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: Number.prototype.valueOf() returns this number value +es5id: 15.7.4.4_A1_T01 +description: Call without argument +---*/ +assert.sameValue(Number.prototype.valueOf(), 0, 'Number.prototype.valueOf() must return 0'); +assert.sameValue((new Number()).valueOf(), 0, '(new Number()).valueOf() must return 0'); +assert.sameValue((new Number(0)).valueOf(), 0, '(new Number(0)).valueOf() must return 0'); +assert.sameValue((new Number(-1)).valueOf(), -1, '(new Number(-1)).valueOf() must return -1'); +assert.sameValue((new Number(1)).valueOf(), 1, '(new Number(1)).valueOf() must return 1'); + +assert.sameValue( + new Number(NaN).valueOf(), + NaN, + 'new Number(NaN).valueOf() returns NaN' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).valueOf(), + Number.POSITIVE_INFINITY, + '(new Number(Number.POSITIVE_INFINITY)).valueOf() returns Number.POSITIVE_INFINITY' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).valueOf(), + Number.NEGATIVE_INFINITY, + '(new Number(Number.NEGATIVE_INFINITY)).valueOf() returns Number.NEGATIVE_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..0b5df3987c --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A1_T02.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: Number.prototype.valueOf() returns this number value +es5id: 15.7.4.4_A1_T02 +description: calling with argument +---*/ +assert.sameValue(Number.prototype.valueOf("argument"), 0, 'Number.prototype.valueOf("argument") must return 0'); +assert.sameValue((new Number()).valueOf("argument"), 0, '(new Number()).valueOf("argument") must return 0'); +assert.sameValue((new Number(0)).valueOf("argument"), 0, '(new Number(0)).valueOf("argument") must return 0'); +assert.sameValue((new Number(-1)).valueOf("argument"), -1, '(new Number(-1)).valueOf("argument") must return -1'); +assert.sameValue((new Number(1)).valueOf("argument"), 1, '(new Number(1)).valueOf("argument") must return 1'); + +assert.sameValue( + new Number(NaN).valueOf("argument"), + NaN, + 'new Number(NaN).valueOf("argument") returns NaN' +); + +assert.sameValue( + (new Number(Number.POSITIVE_INFINITY)).valueOf("argument"), + Number.POSITIVE_INFINITY, + '(new Number(Number.POSITIVE_INFINITY)).valueOf("argument") returns Number.POSITIVE_INFINITY' +); + +assert.sameValue( + (new Number(Number.NEGATIVE_INFINITY)).valueOf("argument"), + Number.NEGATIVE_INFINITY, + '(new Number(Number.NEGATIVE_INFINITY)).valueOf("argument") returns Number.NEGATIVE_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..15d7fa57b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T01.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 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 +---*/ + +try { + var s1 = new String(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + throw new Test262Error('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new String(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + throw new Test262Error('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..94c443f74d --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T02.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 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 +---*/ + +try { + var s1 = new Boolean(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + throw new Test262Error('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new Boolean(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + throw new Test262Error('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..3363f17cd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T03.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 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 +---*/ + +try { + var s1 = new Date(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + throw new Test262Error('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new Date(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + throw new Test262Error('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..3eee5d784b --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T04.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 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 +---*/ + +try { + var s1 = new Object(); + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + throw new Test262Error('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = new Object(); + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + throw new Test262Error('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..504b834cb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/S15.7.4.4_A2_T05.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 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 +---*/ + +try { + var s1 = { + x: 1 + }; + s1.valueOf = Number.prototype.valueOf; + var v1 = s1.valueOf(); + throw new Test262Error('#1: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +try { + var s2 = { + x: 1 + }; + s2.myValueOf = Number.prototype.valueOf; + var v2 = s2.myValueOf(); + throw new Test262Error('#2: Number.prototype.valueOf on not a Number object should throw TypeError'); +} +catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +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..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Number/shell.js @@ -0,0 +1,24 @@ +// 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] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + 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); |