diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Boolean/prototype')
34 files changed, 674 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A1.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A1.js new file mode 100644 index 0000000000..506250ab6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The initial value of Boolean.prototype is the Boolean + prototype object +esid: sec-boolean.prototype +description: Checking Boolean.prototype property +---*/ + +assert.sameValue( + typeof Boolean.prototype, + "object", + 'The value of `typeof Boolean.prototype` is expected to be "object"' +); + +assert(Boolean.prototype == false, 'The value of Boolean.prototype is expected to be false'); + +delete Boolean.prototype.toString; + +assert.sameValue( + Boolean.prototype.toString(), + "[object Boolean]", + 'Boolean.prototype.toString() must return "[object Boolean]"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A2.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A2.js new file mode 100644 index 0000000000..712c4846eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_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: Boolean.prototype has the attribute ReadOnly +esid: sec-boolean.prototype +description: Checking if varying the Boolean.prototype property fails +includes: [propertyHelper.js] +---*/ + +// CHECK#1 +var x = Boolean.prototype; +verifyNotWritable(Boolean, "prototype", null, 1); +assert.sameValue(Boolean.prototype, x, 'The value of Boolean.prototype is expected to equal the value of x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A3-strict.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A3-strict.js new file mode 100644 index 0000000000..9f4025f160 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A3-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Boolean.prototype has the attribute DontDelete +esid: sec-boolean.prototype +description: Checking if deleting the Boolean.prototype property fails +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +// CHECK#1 +verifyNotConfigurable(Boolean, "prototype"); + +assert.throws(TypeError, () => { + delete Boolean.prototype; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A4.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A4.js new file mode 100644 index 0000000000..fb25477820 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A4.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Boolean.prototype has the attribute DontEnum +esid: sec-boolean.prototype +description: Checking if enumerating the Boolean.prototype property fails +---*/ + +for (x in Boolean) { + assert.notSameValue(x, "prototype", 'The value of x is not "prototype"'); +} + +assert( + !Boolean.propertyIsEnumerable('prototype'), + 'The value of !Boolean.propertyIsEnumerable(\'prototype\') is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.4_A2.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.4_A2.js new file mode 100644 index 0000000000..f5ce2c97cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.4_A2.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the Boolean + prototype object is the Object prototype object +esid: sec-properties-of-the-boolean-prototype-object +description: Checking Object.prototype.isPrototypeOf(Boolean.prototype) +---*/ + +assert( + Object.prototype.isPrototypeOf(Boolean.prototype), + 'Object.prototype.isPrototypeOf(Boolean.prototype) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/browser.js b/js/src/tests/test262/built-ins/Boolean/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/constructor/S15.6.4.1_A1.js b/js/src/tests/test262/built-ins/Boolean/prototype/constructor/S15.6.4.1_A1.js new file mode 100644 index 0000000000..cf579e8690 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/constructor/S15.6.4.1_A1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The initial value of Boolean.prototype.constructor is the + built-in Boolean constructor +esid: sec-boolean-constructor +description: Compare Boolean.prototype.constructor with Boolean +---*/ +assert.sameValue( + Boolean.prototype.constructor, + Boolean, + 'The value of Boolean.prototype.constructor is expected to equal the value of Boolean' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/Boolean/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/constructor/browser.js diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/Boolean/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/constructor/shell.js diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/shell.js b/js/src/tests/test262/built-ins/Boolean/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/shell.js 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 diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T1.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T1.js new file mode 100644 index 0000000000..e0edbaf641 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T1.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: Boolean.prototype.valueOf() returns this boolean value +esid: sec-boolean.prototype.valueof +description: no arguments +---*/ +assert.sameValue(Boolean.prototype.valueOf(), false, 'Boolean.prototype.valueOf() must return false'); +assert.sameValue((new Boolean()).valueOf(), false, '(new Boolean()).valueOf() must return false'); +assert.sameValue((new Boolean(0)).valueOf(), false, '(new Boolean(0)).valueOf() must return false'); +assert.sameValue((new Boolean(-1)).valueOf(), true, '(new Boolean(-1)).valueOf() must return true'); +assert.sameValue((new Boolean(1)).valueOf(), true, '(new Boolean(1)).valueOf() must return true'); + +assert.sameValue( + (new Boolean(new Object())).valueOf(), + true, + '(new Boolean(new Object())).valueOf() must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T2.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T2.js new file mode 100644 index 0000000000..28d0045fb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T2.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: Boolean.prototype.valueOf() returns this boolean value +esid: sec-boolean.prototype.valueof +description: calling with argument +---*/ +assert.sameValue(Boolean.prototype.valueOf(true), false, 'Boolean.prototype.valueOf(true) must return false'); +assert.sameValue((new Boolean()).valueOf(true), false, '(new Boolean()).valueOf(true) must return false'); +assert.sameValue((new Boolean(0)).valueOf(true), false, '(new Boolean(0)).valueOf(true) must return false'); +assert.sameValue((new Boolean(-1)).valueOf(false), true, '(new Boolean(-1)).valueOf(false) must return true'); +assert.sameValue((new Boolean(1)).valueOf(false), true, '(new Boolean(1)).valueOf(false) must return true'); + +assert.sameValue( + (new Boolean(new Object())).valueOf(false), + true, + '(new Boolean(new Object())).valueOf(false) must return true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T1.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T1.js new file mode 100644 index 0000000000..00e3caf526 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_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: | + 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 Boolean object +esid: sec-boolean.prototype.valueof +description: transferring to the String objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new String(); + s1.valueOf = Boolean.prototype.valueOf; + s1.valueOf(); +}); + +assert.throws(TypeError, () => { + var s2 = new String(); + s2.myvalueOf = Boolean.prototype.valueOf; + s2.myvalueOf(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T2.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T2.js new file mode 100644 index 0000000000..129656b888 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_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: | + 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 Boolean object +esid: sec-boolean.prototype.valueof +description: transferring to the Number objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new Number(); + s1.valueOf = Boolean.prototype.valueOf; + s1.valueOf(); +}); + +assert.throws(TypeError, () => { + var s2 = new Number(); + s2.myvalueOf = Boolean.prototype.valueOf; + s2.myvalueOf(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T3.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T3.js new file mode 100644 index 0000000000..7782764edc --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 Boolean object +esid: sec-boolean.prototype.valueof +description: transferring to the Date objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new Date(); + s1.valueOf = Boolean.prototype.valueOf; + s1.valueOf(); +}); + +assert.throws(TypeError, () => { + var s2 = new Date(); + s2.myvalueOf = Boolean.prototype.valueOf; + s2.myvalueOf(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T4.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T4.js new file mode 100644 index 0000000000..90d3c95ab7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 Boolean object +esid: sec-boolean.prototype.valueof +description: transferring to the Object objects +---*/ + +assert.throws(TypeError, () => { + var s1 = new Object(); + s1.valueOf = Boolean.prototype.valueOf; + s1.valueOf(); +}); + +assert.throws(TypeError, () => { + var s2 = new Object(); + s2.myvalueOf = Boolean.prototype.valueOf; + s2.myvalueOf(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T5.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T5.js new file mode 100644 index 0000000000..6d51c07605 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T5.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 Boolean object +esid: sec-boolean.prototype.valueof +description: transferring to the other objects +---*/ + +assert.throws(TypeError, () => { + var s1 = { + x: 1 + }; + s1.valueOf = Boolean.prototype.valueOf; + s1.valueOf(); +}); + +assert.throws(TypeError, () => { + var s2 = { + x: 1 + }; + s2.myvalueOf = Boolean.prototype.valueOf; + s2.myvalueOf(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/browser.js diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/length.js new file mode 100644 index 0000000000..0d49d0670b --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/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. + +/*--- +esid: sec-boolean.prototype.valueof +description: > + Boolean.prototype.valueOf.length is 0. +info: | + Boolean.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(Boolean.prototype.valueOf.length, 0); + +verifyNotEnumerable(Boolean.prototype.valueOf, "length"); +verifyNotWritable(Boolean.prototype.valueOf, "length"); +verifyConfigurable(Boolean.prototype.valueOf, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/name.js new file mode 100644 index 0000000000..bb0b1138eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/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. + +/*--- +esid: sec-boolean.prototype.valueof +description: > + Boolean.prototype.valueOf.name is "valueOf". +info: | + Boolean.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(Boolean.prototype.valueOf.name, "valueOf"); + +verifyNotEnumerable(Boolean.prototype.valueOf, "name"); +verifyNotWritable(Boolean.prototype.valueOf, "name"); +verifyConfigurable(Boolean.prototype.valueOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/not-a-constructor.js new file mode 100644 index 0000000000..f3c549e341 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/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: > + Boolean.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(Boolean.prototype.valueOf), + false, + 'isConstructor(Boolean.prototype.valueOf) must return false' +); + +assert.throws(TypeError, () => { + new Boolean.prototype.valueOf(); +}, '`new Boolean.prototype.valueOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/shell.js |