diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Boolean/prototype/toString')
12 files changed, 292 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T1.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T1.js new file mode 100644 index 0000000000..ddbefc2213 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T1.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-boolean.prototype.tostring +info: | + toString: If this boolean value is true, then the string "true" + is returned, otherwise, this boolean value must be false, and the string + "false" is returned +es5id: 15.6.4.2_A1_T1 +description: no arguments +---*/ +assert.sameValue(Boolean.prototype.toString(), "false", 'Boolean.prototype.toString() must return "false"'); +assert.sameValue((new Boolean()).toString(), "false", '(new Boolean()).toString() must return "false"'); +assert.sameValue((new Boolean(false)).toString(), "false", '(new Boolean(false)).toString() must return "false"'); +assert.sameValue((new Boolean(true)).toString(), "true", '(new Boolean(true)).toString() must return "true"'); +assert.sameValue((new Boolean(1)).toString(), "true", '(new Boolean(1)).toString() must return "true"'); +assert.sameValue((new Boolean(0)).toString(), "false", '(new Boolean(0)).toString() must return "false"'); + +assert.sameValue( + (new Boolean(new Object())).toString(), + "true", + '(new Boolean(new Object())).toString() must return "true"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T2.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T2.js new file mode 100644 index 0000000000..8f1cc3d223 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T2.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-boolean.prototype.tostring +info: | + toString: If this boolean value is true, then the string "true" + is returned, otherwise, this boolean value must be false, and the string + "false" is returned +es5id: 15.6.4.2_A1_T2 +description: with some argument +---*/ +assert.sameValue(Boolean.prototype.toString(true), "false", 'Boolean.prototype.toString(true) must return "false"'); +assert.sameValue((new Boolean()).toString(true), "false", '(new Boolean()).toString(true) must return "false"'); + +assert.sameValue( + (new Boolean(false)).toString(true), + "false", + '(new Boolean(false)).toString(true) must return "false"' +); + +assert.sameValue( + (new Boolean(true)).toString(false), + "true", + '(new Boolean(true)).toString(false) must return "true"' +); + +assert.sameValue((new Boolean(1)).toString(false), "true", '(new Boolean(1)).toString(false) must return "true"'); +assert.sameValue((new Boolean(0)).toString(true), "false", '(new Boolean(0)).toString(true) must return "false"'); + +assert.sameValue( + (new Boolean(new Object())).toString(false), + "true", + '(new Boolean(new Object())).toString(false) must return "true"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T1.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T1.js new file mode 100644 index 0000000000..f1a849b325 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T1.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-boolean.prototype.tostring +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 Boolean object +es5id: 15.6.4.2_A2_T1 +description: transferring to the String objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new String(); + s1.toString = Boolean.prototype.toString; + var v1 = s1.toString(); +}); + +assert.throws(TypeError, () => { + var s2 = new String(); + s2.myToString = Boolean.prototype.toString; + var v2 = s2.myToString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T2.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T2.js new file mode 100644 index 0000000000..e4837f700f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-boolean.prototype.tostring +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 Boolean object +es5id: 15.6.4.2_A2_T2 +description: transferring to the Number objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new Number(); + s1.toString = Boolean.prototype.toString; + s1.toString(); +}); + +assert.throws(TypeError, () => { + var s2 = new Number(); + s2.myToString = Boolean.prototype.toString; + s2.myToString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T3.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T3.js new file mode 100644 index 0000000000..f6a6519a1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T3.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-boolean.prototype.tostring +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 Boolean object +es5id: 15.6.4.2_A2_T3 +description: transferring to the Date objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new Date(); + s1.toString = Boolean.prototype.toString; + s1.toString(); +}); + +assert.throws(TypeError, () => { + var s2 = new Date(); + s2.myToString = Boolean.prototype.toString; + s2.myToString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T4.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T4.js new file mode 100644 index 0000000000..7b7bbfad10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T4.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. + +/*--- +esid: sec-boolean.prototype.tostring +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 Boolean object +es5id: 15.6.4.2_A2_T4 +description: transferring to the Object objects +---*/ + + +assert.throws(TypeError, () => { + var s1 = new Object(); + s1.toString = Boolean.prototype.toString; + s1.toString(); +}); + +assert.throws(TypeError, () => { + var s2 = new Object(); + s2.myToString = Boolean.prototype.toString; + s2.myToString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T5.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T5.js new file mode 100644 index 0000000000..a3fa1b565f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T5.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. + +/*--- +esid: sec-boolean.prototype.tostring +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 Boolean object +es5id: 15.6.4.2_A2_T5 +description: transferring to the other objects +---*/ + +assert.throws(TypeError, () => { + var s1 = { + x: 1 + }; + s1.toString = Boolean.prototype.toString; + s1.toString(); +}); + +assert.throws(TypeError, () => { + var s2 = { + x: 1 + }; + s2.myToString = Boolean.prototype.toString; + s2.myToString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/browser.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/browser.js diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/length.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/length.js new file mode 100644 index 0000000000..a61183ebe0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/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. + +/*--- +esid: sec-boolean.prototype.tostring +description: > + Boolean.prototype.toString.length is 0. +info: | + Boolean.prototype.toString ( ) + + 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(Boolean.prototype.toString.length, 0); + +verifyNotEnumerable(Boolean.prototype.toString, "length"); +verifyNotWritable(Boolean.prototype.toString, "length"); +verifyConfigurable(Boolean.prototype.toString, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/name.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/name.js new file mode 100644 index 0000000000..55b337eaad --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/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. + +/*--- +esid: sec-boolean.prototype.tostring +description: > + Boolean.prototype.toString.name is "toString". +info: | + Boolean.prototype.toString ( ) + + 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(Boolean.prototype.toString.name, "toString"); + +verifyNotEnumerable(Boolean.prototype.toString, "name"); +verifyNotWritable(Boolean.prototype.toString, "name"); +verifyConfigurable(Boolean.prototype.toString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..548a4e70c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/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: > + Boolean.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(Boolean.prototype.toString), + false, + 'isConstructor(Boolean.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + new Boolean.prototype.toString(); +}, '`new Boolean.prototype.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/shell.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/shell.js |