diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Number/prototype')
179 files changed, 4920 insertions, 0 deletions
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 |