diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/prototype/toLocaleString')
14 files changed, 301 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A1.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A1.js new file mode 100644 index 0000000000..1875921aa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A1.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: toLocaleString function returns the result of calling toString() +es5id: 15.2.4.3_A1 +description: > + Checking the type of Object.prototype.toLocaleString and the + returned result +---*/ +assert.sameValue( + typeof Object.prototype.toLocaleString, + "function", + 'The value of `typeof Object.prototype.toLocaleString` is expected to be "function"' +); + +assert.sameValue( + Object.prototype.toLocaleString(), + Object.prototype.toString(), + 'Object.prototype.toLocaleString() must return the same value returned by Object.prototype.toString()' +); + +assert.sameValue( + {}.toLocaleString(), + {}.toString(), + '({}).toLocaleString() must return the same value returned by ({}).toString()' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.js new file mode 100644 index 0000000000..788bc27196 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.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 Object.prototype.toLocaleString.length property has the attribute + ReadOnly +es5id: 15.2.4.3_A10 +description: > + Checking if varying the Object.prototype.toLocaleString.length + property fails +includes: [propertyHelper.js] +---*/ +assert( + !!Object.prototype.toLocaleString.hasOwnProperty('length'), + 'The value of !!Object.prototype.toLocaleString.hasOwnProperty("length") is expected to be true' +); + +var obj = Object.prototype.toLocaleString.length; + +verifyNotWritable(Object.prototype.toLocaleString, "length", null, function() { + return "shifted"; +}); + +assert.sameValue( + Object.prototype.toLocaleString.length, + obj, + 'The value of Object.prototype.toLocaleString.length is expected to equal the value of obj' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A11.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A11.js new file mode 100644 index 0000000000..1afdd3a546 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A11.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the toLocaleString method is 0 +es5id: 15.2.4.3_A11 +description: Checking the Object.prototype.toLocaleString.length +---*/ +assert( + !!Object.prototype.toLocaleString.hasOwnProperty("length"), + 'The value of !!Object.prototype.toLocaleString.hasOwnProperty("length") is expected to be true' +); + +assert.sameValue( + Object.prototype.toLocaleString.length, + 0, + 'The value of Object.prototype.toLocaleString.length is expected to be 0' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A12.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A12.js new file mode 100644 index 0000000000..299609daed --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A12.js @@ -0,0 +1,15 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.4.3_A12 +description: > + Let O be the result of calling ToObject passing the this value as + the argument. +---*/ + +assert.throws(TypeError, function() { + Object.prototype.toLocaleString.call(undefined); +}, 'Object.prototype.toLocaleString.call(undefined) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A13.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A13.js new file mode 100644 index 0000000000..c51669fa64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A13.js @@ -0,0 +1,15 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.4.3_A13 +description: > + Let O be the result of calling ToObject passing the this value as + the argument. +---*/ + +assert.throws(TypeError, function() { + Object.prototype.toLocaleString.call(null); +}, 'Object.prototype.toLocaleString.call(null) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A6.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A6.js new file mode 100644 index 0000000000..8f316e0dd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A6.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Object.prototype.toLocaleString has not prototype property +es5id: 15.2.4.3_A6 +description: > + Checking if obtaining the prototype property of + Object.prototype.toLocaleString fails +---*/ +assert.sameValue( + Object.prototype.toLocaleString.prototype, + undefined, + 'The value of Object.prototype.toLocaleString.prototype is expected to equal undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A8.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A8.js new file mode 100644 index 0000000000..4b67335a4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A8.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Object.prototype.toLocaleString.length property has the attribute + DontEnum +es5id: 15.2.4.3_A8 +description: > + Checking if enumerating the Object.prototype.toLocaleString.length + property fails +---*/ +assert( + !!Object.prototype.toLocaleString.hasOwnProperty('length'), + 'The value of !!Object.prototype.toLocaleString.hasOwnProperty("length") is expected to be true' +); + +assert( + !Object.prototype.toLocaleString.propertyIsEnumerable('length'), + 'The value of !Object.prototype.toLocaleString.propertyIsEnumerable("length") is expected to be true' +); + +for (var p in Object.prototype.toLocaleString) { + assert.notSameValue(p, "length", 'The value of p is not "length"'); +} +// + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A9.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A9.js new file mode 100644 index 0000000000..861a0728d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A9.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Object.prototype.toLocaleString.length property does not have the + attribute DontDelete +es5id: 15.2.4.3_A9 +description: > + Checknig if deleting of the Object.prototype.toLocaleString.length + property fails +---*/ +assert( + !!Object.prototype.toLocaleString.hasOwnProperty('length'), + 'The value of !!Object.prototype.toLocaleString.hasOwnProperty("length") is expected to be true' +); + +assert( + !!delete Object.prototype.toLocaleString.length, + 'The value of !!delete Object.prototype.toLocaleString.length is expected to be true' +); + +assert( + !Object.prototype.toLocaleString.hasOwnProperty('length'), + 'The value of !Object.prototype.toLocaleString.hasOwnProperty("length") is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/browser.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/browser.js diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/name.js new file mode 100644 index 0000000000..5f258165ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/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: 19.1.3.5 +description: > + Object.prototype.toLocaleString.name is "toLocaleString". +info: | + Object.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(Object.prototype.toLocaleString.name, "toLocaleString"); + +verifyNotEnumerable(Object.prototype.toLocaleString, "name"); +verifyNotWritable(Object.prototype.toLocaleString, "name"); +verifyConfigurable(Object.prototype.toLocaleString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/not-a-constructor.js new file mode 100644 index 0000000000..49fc0525db --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/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: > + Object.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(Object.prototype.toLocaleString), + false, + 'isConstructor(Object.prototype.toLocaleString) must return false' +); + +assert.throws(TypeError, () => { + new Object.prototype.toLocaleString(''); +}, '`new Object.prototype.toLocaleString(\'\')` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/primitive_this_value-strict.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/primitive_this_value-strict.js new file mode 100644 index 0000000000..d606e49552 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/primitive_this_value-strict.js @@ -0,0 +1,22 @@ +'use strict'; +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.toLocaleString called with primitive thisValue +info: | + 19.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 2. Return Invoke(O, "toString"). +es6id: 19.1.3.5 +flags: [onlyStrict] +---*/ + +Boolean.prototype.toString = function() { + return typeof this; +}; + +assert.sameValue(true.toLocaleString(), "boolean"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter-strict.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter-strict.js new file mode 100644 index 0000000000..b7281954d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter-strict.js @@ -0,0 +1,27 @@ +'use strict'; +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.toLocaleString called with primitive thisValue in getter +info: | + 19.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 2. Return Invoke(O, "toString"). +es6id: 19.1.3.5 +flags: [onlyStrict] +---*/ + +Object.defineProperty(Boolean.prototype, "toString", { + get: function() { + var v = typeof this; + return function() { + return v; + }; + } +}); + +assert.sameValue(true.toLocaleString(), "boolean"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/shell.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/shell.js |