diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Boolean')
62 files changed, 1773 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T1.js b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T1.js new file mode 100644 index 0000000000..165f66c59b --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T1.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: | + Returns a boolean value (not a Boolean object) computed by + ToBoolean(value) +esid: sec-terms-and-definitions-boolean-value +description: > + Used values 1, new String("1"), new Object(1) and called without + argument +---*/ + +//CHECK#1 +if (typeof Boolean() !== "boolean") { + $ERROR('#1: typeof Boolean() should be "boolean", actual is "' + typeof Boolean() + '"'); +} + +//CHECK#2 +if (typeof Boolean(1) !== "boolean") { + $ERROR('#2: typeof Boolean(1) should be "boolean", actual is "' + typeof Boolean(1) + '"'); +} + +//CHECK#3 +if (typeof Boolean(new String("1")) !== "boolean") { + $ERROR('#3: typeof Boolean(new String("1")) should be "boolean", actual is "' + typeof Boolean(new String("1")) + '"'); +} + +//CHECK#4 +if (typeof Boolean(new Object(1)) !== "boolean") { + $ERROR('#4: typeof Boolean(new Object(1)) should be "boolean", actual is "' + typeof Boolean(new Object(1)) + '"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T2.js b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T2.js new file mode 100644 index 0000000000..3fea7a96c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T2.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Returns a boolean value (not a Boolean object) computed by + ToBoolean(value) +esid: sec-terms-and-definitions-boolean-value +description: Used various number values as argument +---*/ + +//CHECK#1 +if (typeof Boolean(0) !== "boolean") { + $ERROR('#1.1: typeof Boolean(0) should be "boolean", actual is "' + typeof Boolean(0) + '"'); +} +if (Boolean(0) !== false) { + $ERROR('#1.2: Boolean(0) should be false, actual is ' + Boolean(0)); +} + +//CHECK#2 +if (typeof Boolean(-1) !== "boolean") { + $ERROR('#2.1: typeof Boolean(-1) should be "boolean", actual is "' + typeof Boolean(-1) + '"'); +} +if (Boolean(-1) !== true) { + $ERROR('#2.2: Boolean(-1) should be true, actual is ' + Boolean(-1)); +} + +//CHECK#3 +if (typeof Boolean(-Infinity) !== "boolean") { + $ERROR('#3.1: typeof Boolean(-Infinity) should be "boolean", actual is "' + typeof Boolean(-Infinity) + '"'); +} +if (Boolean(-Infinity) !== true) { + $ERROR('#3.2: Boolean(-Infinity) should be true, actual is ' + Boolean(-Infinity)); +} + +//CHECK#4 +if (typeof Boolean(NaN) !== "boolean") { + $ERROR('#4.1: typeof Boolean(NaN) should be "boolean", actual is "' + typeof Boolean(NaN) + '"'); +} +if (Boolean(NaN) !== false) { + $ERROR('#4.2: Boolean(NaN) should be false, actual is ' + Boolean(NaN)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T3.js b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T3.js new file mode 100644 index 0000000000..5fd57b456f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T3.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Returns a boolean value (not a Boolean object) computed by + ToBoolean(value) +esid: sec-terms-and-definitions-boolean-value +description: Used various string values as argument +---*/ + +//CHECK#1 +if (typeof Boolean("0") !== "boolean") { + $ERROR('#1.1: typeof Boolean("0") should be "boolean", actual is "' + typeof Boolean("0") + '"'); +} +if (Boolean("0") !== true) { + $ERROR('#1.2: Boolean("0") should be true'); +} + +//CHECK#2 +if (typeof Boolean("-1") !== "boolean") { + $ERROR('#2.1: typeof Boolean("-1") should be "boolean", actual is "' + typeof Boolean("-1") + '"'); +} +if (Boolean("-1") !== true) { + $ERROR('#2.2: Boolean("-1") should be true'); +} + +//CHECK#3 +if (typeof Boolean("1") !== "boolean") { + $ERROR('#3.1: typeof Boolean("1") should be "boolean", actual is "' + typeof Boolean("1") + '"'); +} +if (Boolean("1") !== true) { + $ERROR('#3.2: Boolean("1") should be true'); +} + +//CHECK#4 +if (typeof Boolean("false") !== "boolean") { + $ERROR('#4.1: typeof Boolean("false") should be "boolean", actual is "' + typeof Boolean("false") + '"'); +} +if (Boolean("false") !== true) { + $ERROR('#4.2: Boolean("false") should be true'); +} + +//CHECK#5 +if (typeof Boolean("true") !== "boolean") { + $ERROR('#5.1: typeof Boolean("true") should be "boolean", actual is "' + typeof Boolean("true") + '"'); +} +if (Boolean("true") !== true) { + $ERROR('#5.2: Boolean("true") should be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T4.js b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T4.js new file mode 100644 index 0000000000..f23427aa86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T4.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Returns a boolean value (not a Boolean object) computed by + ToBoolean(value) +esid: sec-terms-and-definitions-boolean-value +description: Used various undefined values and null as argument +---*/ + +//CHECK#1 +if (typeof Boolean(undefined) !== "boolean") { + $ERROR('#1.1: typeof Boolean(undefined) should be "boolean", actual is "' + typeof Boolean(undefined) + '"'); +} +if (Boolean(undefined) !== false) { + $ERROR('#1.2: Boolean(undefined) should be false'); +} + +//CHECK#2 +if (typeof Boolean(void 0) !== "boolean") { + $ERROR('#2.1: typeof Boolean(void 0) should be "boolean", actual is "' + typeof Boolean(void 0) + '"'); +} +if (Boolean(void 0) !== false) { + $ERROR('#2.2: Boolean(void 0) should be false'); +} + +//CHECK#3 +if (typeof Boolean(function() {}()) !== "boolean") { + $ERROR('#3.1: typeof Boolean(function(){}()) should be "boolean", actual is "' + typeof Boolean(function() {}()) + '"'); +} +if (Boolean(function() {}()) !== false) { + $ERROR('#3.2: Boolean(function(){}()) should be false'); +} + +//CHECK#4 +if (typeof Boolean(null) !== "boolean") { + $ERROR('#4.1: typeof Boolean(null) should be "boolean", actual is "' + typeof Boolean(null) + '"'); +} +if (Boolean(null) !== false) { + $ERROR('#4.2: Boolean(null) should be false'); +} + +//CHECK#5 +if (typeof Boolean(x) !== "boolean") { + $ERROR('#5.1: var x; typeof Boolean(x) should be "boolean", actual is "' + typeof Boolean(x) + '"'); +} +if (Boolean(x) !== false) { + $ERROR('#5.2: var x; Boolean(x) should be false'); +} +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T5.js b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T5.js new file mode 100644 index 0000000000..8d0bd4a0dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T5.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Returns a boolean value (not a Boolean object) computed by + ToBoolean(value) +esid: sec-terms-and-definitions-boolean-value +description: Used various assigning values to any variable as argument +---*/ + +var x; + +//CHECK#1 +if (typeof Boolean(x = 0) !== "boolean") { + $ERROR('#1.1: typeof Boolean(x=0) should be "boolean", actual is "' + typeof Boolean(x = 0) + '"'); +} +if (Boolean(x = 0) !== false) { + $ERROR('#1.2: Boolean(x=0) should be false'); +} + +//CHECK#2 +if (typeof Boolean(x = 1) !== "boolean") { + $ERROR('#2.1: typeof Boolean(x=1) should be "boolean", actual is "' + typeof Boolean(x = 1) + '"'); +} +if (Boolean(x = 1) !== true) { + $ERROR('#2.2: Boolean(x=1) should be true'); +} + +//CHECK#3 +if (typeof Boolean(x = false) !== "boolean") { + $ERROR('#3.1: typeof Boolean(x=false) should be "boolean", actual is "' + typeof Boolean(x = false) + '"'); +} +if (Boolean(x = false) !== false) { + $ERROR('#3.2: Boolean(x=false) should be false'); +} + +//CHECK#4 +if (typeof Boolean(x = true) !== "boolean") { + $ERROR('#4.1: typeof Boolean(x=true) should be "boolean", actual is "' + typeof Boolean(x = true) + '"'); +} +if (Boolean(x = true) !== true) { + $ERROR('#4.2: Boolean(x=true) should be true'); +} + +//CHECK#5 +if (typeof Boolean(x = null) !== "boolean") { + $ERROR('#5.1: typeof Boolean(x=null) should be "boolean", actual is "' + typeof Boolean(x = null) + '"'); +} +if (Boolean(x = null) !== false) { + $ERROR('#5.2: Boolean(x=null) should be false'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A2.js b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A2.js new file mode 100644 index 0000000000..d96699a6fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A2.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: Boolean() returns false +esid: sec-terms-and-definitions-boolean-value +description: Call Boolean() and check result +---*/ + +//CHECK#1 +if (typeof Boolean() !== "boolean") { + $ERROR('#1: typeof Boolean() should be "boolean", actual is "' + typeof Boolean() + '"'); +} + +//CHECK#2 +if (Boolean() !== false) { + $ERROR('#2: Boolean() should be false'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A1.js b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A1.js new file mode 100644 index 0000000000..7c7fc42757 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A1.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Boolean is called as part of a new expression it is + a constructor: it initialises the newly created object +esid: sec-boolean-constructor +description: Checking type of the newly created object and it value +---*/ + +//CHECK#1 +if (typeof new Boolean() !== "object") { + $ERROR("#1: typeof new Boolean() === 'object'"); +} + +//CHECK#2 +if (new Boolean() === undefined) { + $ERROR("#2: new Boolean() should not be undefined"); +} + +//CHECK#3 +var x3 = new Boolean(); +if (typeof x3 !== "object") { + $ERROR("#3: typeof new Boolean() !== 'object'"); +} + +//CHECK#4 +var x4 = new Boolean(); +if (x4 === undefined) { + $ERROR("#4: new Boolean() should not be undefined"); +} + +//CHECK#5 +if (typeof new Boolean(1) !== "object") { + $ERROR("#5: typeof new Boolean(10) === 'object'"); +} + +//CHECK#6 +if (new Boolean(1) === undefined) { + $ERROR("#6: new Boolean(1) should not be undefined"); +} + +//CHECK#7 +var x7 = new Boolean(1); +if (typeof x7 !== "object") { + $ERROR("#7: typeof new Boolean(1) !== 'object'"); +} + +//CHECK#8 +var x8 = new Boolean(1); +if (x8 === undefined) { + $ERROR("#8: new Boolean(1) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A2.js b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A2.js new file mode 100644 index 0000000000..0a29b8fbd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A2.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: | + The [[Prototype]] property of the newly constructed object + is set to the original Boolean prototype object, the one that is the + initial value of Boolean.prototype +esid: sec-boolean-constructor +description: Checking prototype property of the newly created object +---*/ + +// CHECK#1 +var x1 = new Boolean(1); +if (typeof x1.constructor.prototype !== "object") { + $ERROR('#1: typeof x1.constructor.prototype === "object"'); +} + +//CHECK#2 +var x2 = new Boolean(2); +if (!Boolean.prototype.isPrototypeOf(x2)) { + $ERROR('#2: Boolean.prototype.isPrototypeOf(x2)'); +} + +//CHECK#3 +var x3 = new Boolean(3); +if (Boolean.prototype !== x3.constructor.prototype) { + $ERROR('#3: Boolean.prototype === x3.constructor.prototype'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A3.js b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A3.js new file mode 100644 index 0000000000..618492ea1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A3.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set to ToBoolean(value) +esid: sec-boolean-constructor +description: Checking value of the newly created object +---*/ + +// CHECK#1 +var x1 = new Boolean(1); +if (x1.valueOf() !== true) { + $ERROR('#1: var x1 = new Boolean(1); x1.valueOf() === true'); +} + +//CHECK#2 +var x2 = new Boolean(); +if (x2.valueOf() !== false) { + $ERROR('#2: var x2 = new Boolean(); x2.valueOf() === false'); +} + +//CHECK#3 +var x2 = new Boolean(0); +if (x2.valueOf() !== false) { + $ERROR('#3: var x2 = new Boolean(0); x2.valueOf() === false'); +} + +//CHECK#4 +var x2 = new Boolean(new Object()); +if (x2.valueOf() !== true) { + $ERROR('#4: var x2 = new Boolean(new Object()); x2.valueOf() === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A4.js b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A4.js new file mode 100644 index 0000000000..e5692c8e32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A4.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Boolean" +esid: sec-boolean-constructor +description: For testing toString function is used +---*/ + +delete Boolean.prototype.toString; + +var obj = new Boolean(); + +//CHECK#1 +if (obj.toString() !== "[object Boolean]") { + $ERROR('#1: The [[Class]] property of the newly constructed object is set to "Boolean"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.3_A1.js b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A1.js new file mode 100644 index 0000000000..e619749ad4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Boolean constructor has the property "prototype" +esid: sec-boolean.prototype +description: Checking existence of the property "prototype" +---*/ + +if (!Boolean.hasOwnProperty("prototype")) { + $ERROR('#1: The Boolean constructor has the property "prototype"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.3_A2.js b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A2.js new file mode 100644 index 0000000000..d9eb71b5b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.3_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 + constructor is the Function prototype object +esid: sec-boolean.prototype +description: Checking prototype of the Boolean constructor +---*/ + +//CHECK#1 +if (!(Function.prototype.isPrototypeOf(Boolean))) { + $ERROR('#1: the value of the internal [[Prototype]] property of the Boolean constructor is the Function prototype object.'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S15.6.3_A3.js b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A3.js new file mode 100644 index 0000000000..b8758154dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A3.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: Boolean constructor has length property whose value is 1 +esid: sec-boolean.prototype +description: Checking Boolean.length property +---*/ + +//CHECK#1 +if (!Boolean.hasOwnProperty("length")) { + $ERROR('#1: Boolean constructor has length property'); +} + +//CHECK#2 +if (Boolean.length !== 1) { + $ERROR('#2: Boolean constructor length property value is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A1_T1.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A1_T1.js new file mode 100644 index 0000000000..53e48174f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A1_T1.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Result of boolean conversion from undefined value is false +esid: sec-toboolean +description: > + Undefined, void and others are converted to Boolean by explicit + transformation +---*/ + +// CHECK#1 +if (Boolean(undefined) !== false) { + $ERROR('#1: Boolean(undefined) === false. Actual: ' + (Boolean(undefined))); +} + +// CHECK#2 +if (Boolean(void 0) !== false) { + $ERROR('#2: Boolean(undefined) === false. Actual: ' + (Boolean(undefined))); +} + +// CHECK#3 +if (Boolean(eval("var x")) !== false) { + $ERROR('#3: Boolean(eval("var x")) === false. Actual: ' + (Boolean(eval("var x")))); +} + +// CHECK#4 +if (Boolean() !== false) { + $ERROR('#4: Boolean() === false. Actual: ' + (Boolean())); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A2_T1.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A2_T1.js new file mode 100644 index 0000000000..54fd9c6098 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A2_T1.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: Result of boolean conversion from null value is false +esid: sec-toboolean +description: null convert to Boolean by explicit transformation +---*/ + +// CHECK#1 +if (Boolean(null) !== false) { + $ERROR('#1: Boolean(null) === false. Actual: ' + (Boolean(null))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A3_T1.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A3_T1.js new file mode 100644 index 0000000000..b80ce9e811 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A3_T1.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: Result of boolean conversion from boolean value is no conversion +esid: sec-toboolean +description: true and false convert to Boolean by explicit transformation +---*/ + +// CHECK#1 +if (Boolean(true) !== true) { + $ERROR('#1: Boolean(true) === true. Actual: ' + (Boolean(true))); +} + +// CHECK#2 +if (Boolean(false) !== false) { + $ERROR('#2: Boolean(false) === false. Actual: ' + (Boolean(false))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T1.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T1.js new file mode 100644 index 0000000000..792111a5ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T1.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: | + Result of boolean conversion from number value is false if the argument + is +0, -0, or NaN; otherwise, is true +esid: sec-toboolean +description: +0, -0 and NaN convert to Boolean by explicit transformation +---*/ + +// CHECK#1 +if (Boolean(+0) !== false) { + $ERROR('#1: Boolean(+0) === false. Actual: ' + (Boolean(+0))); +} + +// CHECK#2 +if (Boolean(-0) !== false) { + $ERROR('#2: Boolean(-0) === false. Actual: ' + (Boolean(-0))); +} + +// CHECK#3 +if (Boolean(Number.NaN) !== false) { + $ERROR('#3: Boolean(Number.NaN) === false. Actual: ' + (Boolean(Number.NaN))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T3.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T3.js new file mode 100644 index 0000000000..494f61ad69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T3.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of boolean conversion from number value is false if the argument + is +0, -0, or NaN; otherwise, is true +esid: sec-toboolean +description: > + Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, + Number.MAX_VALUE, Number.MIN_VALUE and some numbers convert to + Boolean by explicit transformation +---*/ + +// CHECK#1 +if (Boolean(Number.POSITIVE_INFINITY) !== true) { + $ERROR('#1: Boolean(+Infinity) === true. Actual: ' + (Boolean(+Infinity))); +} + +// CHECK#2; +if (Boolean(Number.NEGATIVE_INFINITY) !== true) { + $ERROR('#2: Boolean(-Infinity) === true. Actual: ' + (Boolean(-Infinity))); +} + +// CHECK#3 +if (Boolean(Number.MAX_VALUE) !== true) { + $ERROR('#3: Boolean(Number.MAX_VALUE) === true. Actual: ' + (Boolean(Number.MAX_VALUE))); +} + +// CHECK#4 +if (Boolean(Number.MIN_VALUE) !== true) { + $ERROR('#4: Boolean(Number.MIN_VALUE) === true. Actual: ' + (Boolean(Number.MIN_VALUE))); +} + +// CHECK#5 +if (Boolean(13) !== true) { + $ERROR('#5: Boolean(13) === true. Actual: ' + (Boolean(13))); +} + +// CHECK#6 +if (Boolean(-13) !== true) { + $ERROR('#6: Boolean(-13) === true. Actual: ' + (Boolean(-13))); +} + +// CHECK#7 +if (Boolean(1.3) !== true) { + $ERROR('#7: Boolean(1.3) === true. Actual: ' + (Boolean(1.3))); +} + +// CHECK#8 +if (Boolean(-1.3) !== true) { + $ERROR('#8: Boolean(-1.3) === true. Actual: ' + (Boolean(-1.3))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T1.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T1.js new file mode 100644 index 0000000000..70e10220d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T1.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: | + Result of boolean conversion from nonempty string value (length is not + zero) is true; from empty String (length is zero) is false +esid: sec-toboolean +description: "\"\" is converted to Boolean by explicit transformation" +---*/ + +// CHECK#1 +if (Boolean("") !== false) { + $ERROR('#1: Boolean("") === false. Actual: ' + (Boolean(""))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T3.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T3.js new file mode 100644 index 0000000000..51ec321409 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of boolean conversion from nonempty string value (length is not + zero) is true; from empty String (length is zero) is false +esid: sec-toboolean +description: Any nonempty string convert to Boolean by explicit transformation +---*/ + +// CHECK#1 +if (Boolean(" ") !== true) { + $ERROR('#1: Boolean(" ") === true. Actual: ' + (Boolean(" "))); +} + +// CHECK#2 +if (Boolean("Nonempty String") !== true) { + $ERROR('#2: Boolean("Nonempty String") === true. Actual: ' + (Boolean("Nonempty String"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/S9.2_A6_T1.js b/js/src/tests/test262/built-ins/Boolean/S9.2_A6_T1.js new file mode 100644 index 0000000000..12a7f0dee5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A6_T1.js @@ -0,0 +1,105 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Result of boolean conversion from object is true +esid: sec-toboolean +description: Different objects convert to Boolean by explicit transformation +---*/ + +// CHECK#1 +if (Boolean(new Object()) !== true) { + $ERROR('#1: Boolean(new Object()) === true. Actual: ' + (Boolean(new Object()))); +} + +// CHECK#2 +if (Boolean(new String("")) !== true) { + $ERROR('#2: Boolean(new String("")) === true. Actual: ' + (Boolean(new String("")))); +} + +// CHECK#3 +if (Boolean(new String()) !== true) { + $ERROR('#3: Boolean(new String()) === true. Actual: ' + (Boolean(new String()))); +} + +// CHECK#4 +if (Boolean(new Boolean(true)) !== true) { + $ERROR('#4: Boolean(new Boolean(true)) === true. Actual: ' + (Boolean(new Boolean(true)))); +} + +// CHECK#5 +if (Boolean(new Boolean(false)) !== true) { + $ERROR('#5: Boolean(new Boolean(false)) === true. Actual: ' + (Boolean(new Boolean(false)))); +} + +// CHECK#6 +if (Boolean(new Boolean()) !== true) { + $ERROR('#6: Boolean(new Boolean()) === true. Actual: ' + (Boolean(new Boolean()))); +} + +// CHECK#7 +if (Boolean(new Array()) !== true) { + $ERROR('#7: Boolean(new Array()) === true. Actual: ' + (Boolean(new Array()))); +} + +// CHECK#8 +if (Boolean(new Number()) !== true) { + $ERROR('#8: Boolean(new Number()) === true. Actual: ' + (Boolean(new Number()))); +} + +// CHECK#9 +if (Boolean(new Number(-0)) !== true) { + $ERROR('#9: Boolean(new Number(-0)) === true. Actual: ' + (Boolean(new Number(-0)))); +} + +// CHECK#10 +if (Boolean(new Number(0)) !== true) { + $ERROR('#10: Boolean(new Number(0)) === true. Actual: ' + (Boolean(new Number(0)))); +} + +// CHECK#11 +if (Boolean(new Number()) !== true) { + $ERROR('#11: Boolean(new Number()) === true. Actual: ' + (Boolean(new Number()))); +} + +// CHECK#12 +if (Boolean(new Number(Number.NaN)) !== true) { + $ERROR('#12: Boolean(new Number(Number.NaN)) === true. Actual: ' + (Boolean(new Number(Number.NaN)))); +} + +// CHECK#13 +if (Boolean(new Number(-1)) !== true) { + $ERROR('#13: Boolean(new Number(-1)) === true. Actual: ' + (Boolean(new Number(-1)))); +} + +// CHECK#14 +if (Boolean(new Number(1)) !== true) { + $ERROR('#14: Boolean(new Number(1)) === true. Actual: ' + (Boolean(new Number(1)))); +} + +// CHECK#15 +if (Boolean(new Number(Number.POSITIVE_INFINITY)) !== true) { + $ERROR('#15: Boolean(new Number(Number.POSITIVE_INFINITY)) === true. Actual: ' + (Boolean(new Number(Number.POSITIVE_INFINITY)))); +} + +// CHECK#16 +if (Boolean(new Number(Number.NEGATIVE_INFINITY)) !== true) { + $ERROR('#16: Boolean(new Number(Number.NEGATIVE_INFINITY)) === true. Actual: ' + (Boolean(new Number(Number.NEGATIVE_INFINITY)))); +} + +// CHECK#17 +if (Boolean(new Function()) !== true) { + $ERROR('#17: Boolean(new Function()) === true. Actual: ' + (Boolean(new Function()))); +} + +// CHECK#18 +if (Boolean(new Date()) !== true) { + $ERROR('#18: Boolean(new Date()) === true. Actual: ' + (Boolean(new Date()))); +} + +// CHECK#19 +if (Boolean(new Date(0)) !== true) { + $ERROR('#19: Boolean(new Date(0)) === true. Actual: ' + (Boolean(new Date(0)))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/browser.js b/js/src/tests/test262/built-ins/Boolean/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/browser.js diff --git a/js/src/tests/test262/built-ins/Boolean/is-a-constructor.js b/js/src/tests/test262/built-ins/Boolean/is-a-constructor.js new file mode 100644 index 0000000000..69bbe98760 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/is-a-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The Boolean constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(Boolean), true, 'isConstructor(Boolean) must return true'); +new Boolean(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prop-desc.js b/js/src/tests/test262/built-ins/Boolean/prop-desc.js new file mode 100644 index 0000000000..c467269653 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-boolean +description: Property descriptor for Boolean +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Boolean"); +verifyWritable(this, "Boolean"); +verifyConfigurable(this, "Boolean"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Boolean/proto-from-ctor-realm.js new file mode 100644 index 0000000000..213b2d0024 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/proto-from-ctor-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-boolean-constructor-boolean-value +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 3. Let O be ? OrdinaryCreateFromConstructor(NewTarget, + "%BooleanPrototype%", « [[BooleanData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Boolean, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Boolean.prototype); + +reportCompare(0, 0); 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..8a3566ecdc --- /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 +---*/ + +//CHECK#1 +if (typeof Boolean.prototype !== "object") { + $ERROR('#1: typeof Boolean.prototype === "object"'); +} + +//CHECK#2 +if (Boolean.prototype != false) { + $ERROR('#2: Boolean.prototype == false'); +} + +delete Boolean.prototype.toString; + +if (Boolean.prototype.toString() !== "[object Boolean]") { + $ERROR('#3: The [[Class]] property of the Boolean prototype object is set to "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..8bcc7a0b4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 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); +if (Boolean.prototype !== x) { + $ERROR('#1: Boolean.prototype has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A3.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A3.js new file mode 100644 index 0000000000..2e762145cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Boolean.prototype has the attribute DontDelete +esid: sec-boolean.prototype +description: Checking if deleting the Boolean.prototype property fails +includes: [propertyHelper.js] +---*/ + +// CHECK#1 +verifyNotConfigurable(Boolean, "prototype"); + +try { + if (delete Boolean.prototype !== false) { + $ERROR('#1: Boolean.prototype has the attribute DontDelete'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} + +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..922cda2e88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.3.1_A4.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Boolean.prototype has the attribute DontEnum +esid: sec-boolean.prototype +description: Checking if enumerating the Boolean.prototype property fails +---*/ + +//CHECK#1 +for (x in Boolean) { + if (x === "prototype") { + $ERROR('#1: Boolean.prototype has the attribute DontEnum'); + } +} + +if (Boolean.propertyIsEnumerable('prototype')) { + $ERROR('#2: Boolean.prototype has the attribute DontEnum'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.4_A1.js b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.4_A1.js new file mode 100644 index 0000000000..4bfacae9c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/S15.6.4_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 Boolean prototype object is itself a Boolean object + (its [[Class]] is "Boolean") whose value is false +esid: sec-properties-of-the-boolean-prototype-object +description: Checking type and value of Boolean.prototype +---*/ + +//CHECK#1 +if (typeof Boolean.prototype !== "object") { + $ERROR('#1: typeof Boolean.prototype === "object"'); +} + +//CHECK#2 +if (Boolean.prototype != false) { + $ERROR('#2: Boolean.prototype == false'); +} + +delete Boolean.prototype.toString; + +if (Boolean.prototype.toString() !== "[object Boolean]") { + $ERROR('#3: The [[Class]] property of the Boolean prototype object is set to "Boolean"'); +} + +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..9530653374 --- /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) +---*/ + +//CHECK#1 +if (!Object.prototype.isPrototypeOf(Boolean.prototype)) { + $ERROR('#1: Object prototype object is the prototype of Boolean prototype object'); +} + +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..ce4f315074 --- /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 +---*/ + +//CHECK#1 +if (Boolean.prototype.constructor !== Boolean) { + $ERROR('#1: Boolean.prototype.constructor === 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..6aec22b96d --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T1.js @@ -0,0 +1,49 @@ +// 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 +---*/ + +//CHECK#1 +if (Boolean.prototype.toString() !== "false") { + $ERROR('#1: Boolean.prototype.toString() === "false"'); +} + +//CHECK#2 +if ((new Boolean()).toString() !== "false") { + $ERROR('#2: (new Boolean()).toString() === "false"'); +} + +//CHECK#3 +if ((new Boolean(false)).toString() !== "false") { + $ERROR('#3: (new Boolean(false)).toString() === "false"'); +} + +//CHECK#4 +if ((new Boolean(true)).toString() !== "true") { + $ERROR('#4: (new Boolean(true)).toString() === "true"'); +} + +//CHECK#5 +if ((new Boolean(1)).toString() !== "true") { + $ERROR('#5: (new Boolean(1)).toString() === "true"'); +} + +//CHECK#6 +if ((new Boolean(0)).toString() !== "false") { + $ERROR('#6: (new Boolean(0)).toString() === "false"'); +} + +//CHECK#7 +if ((new Boolean(new Object())).toString() !== "true") { + $ERROR('#7: (new Boolean(new Object())).toString() === "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..2f4c41032c --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A1_T2.js @@ -0,0 +1,49 @@ +// 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 +---*/ + +//CHECK#1 +if (Boolean.prototype.toString(true) !== "false") { + $ERROR('#1: Boolean.prototype.toString(true) === "false"'); +} + +//CHECK#2 +if ((new Boolean()).toString(true) !== "false") { + $ERROR('#2: (new Boolean()).toString(true) === "false"'); +} + +//CHECK#3 +if ((new Boolean(false)).toString(true) !== "false") { + $ERROR('#3: (new Boolean(false)).toString(true) === "false"'); +} + +//CHECK#4 +if ((new Boolean(true)).toString(false) !== "true") { + $ERROR('#4: (new Boolean(true)).toString(false) === "true"'); +} + +//CHECK#5 +if ((new Boolean(1)).toString(false) !== "true") { + $ERROR('#5: (new Boolean(1)).toString(false) === "true"'); +} + +//CHECK#6 +if ((new Boolean(0)).toString(true) !== "false") { + $ERROR('#6: (new Boolean(0)).toString(true) === "false"'); +} + +//CHECK#7 +if ((new Boolean(new Object())).toString(false) !== "true") { + $ERROR('#7: (new Boolean(new Object())).toString(false) === "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..cdb84def86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T1.js @@ -0,0 +1,40 @@ +// 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 +---*/ + +//CHECK#1 +try { + var s1 = new String(); + s1.toString = Boolean.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#2 +try { + var s2 = new String(); + s2.myToString = Boolean.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..20ba21d1e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T2.js @@ -0,0 +1,40 @@ +// 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 +---*/ + +//CHECK#1 +try { + var s1 = new Number(); + s1.toString = Boolean.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new Number(); + s2.myToString = Boolean.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..97cef0a882 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T3.js @@ -0,0 +1,40 @@ +// 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 +---*/ + +//CHECK#1 +try { + var s1 = new Date(); + s1.toString = Boolean.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new Date(); + s2.myToString = Boolean.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..dc7926f6e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T4.js @@ -0,0 +1,40 @@ +// 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 +---*/ + +//CHECK#1 +try { + var s1 = new Object(); + s1.toString = Boolean.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new Object(); + s2.myToString = Boolean.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..d156b27c18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/S15.6.4.2_A2_T5.js @@ -0,0 +1,44 @@ +// 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 +---*/ + +//CHECK#1 +try { + var s1 = { + x: 1 + }; + s1.toString = Boolean.prototype.toString; + var v1 = s1.toString(); + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = { + x: 1 + }; + s2.myToString = Boolean.prototype.toString; + var v2 = s2.myToString(); + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.toString on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..1352952522 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T1.js @@ -0,0 +1,40 @@ +// 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 +---*/ + +//CHECK#1 +if (Boolean.prototype.valueOf() !== false) { + $ERROR('#1: Boolean.prototype.valueOf() === false'); +} + +//CHECK#2 +if ((new Boolean()).valueOf() !== false) { + $ERROR('#2: (new Boolean()).valueOf() === false'); +} + +//CHECK#3 +if ((new Boolean(0)).valueOf() !== false) { + $ERROR('#3: (new Boolean(0)).valueOf() === false'); +} + +//CHECK#4 +if ((new Boolean(-1)).valueOf() !== true) { + $ERROR('#4: (new Boolean(-1)).valueOf() === true'); +} + +//CHECK#5 +if ((new Boolean(1)).valueOf() !== true) { + $ERROR('#5: (new Boolean(1)).valueOf() === true'); +} + +//CHECK#6 +if ((new Boolean(new Object())).valueOf() !== true) { + $ERROR('#6: (new Boolean(new Object())).valueOf() === 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..c47229c2a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A1_T2.js @@ -0,0 +1,40 @@ +// 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 +---*/ + +//CHECK#1 +if (Boolean.prototype.valueOf(true) !== false) { + $ERROR('#1: Boolean.prototype.valueOf(true) === false'); +} + +//CHECK#2 +if ((new Boolean()).valueOf(true) !== false) { + $ERROR('#2: (new Boolean()).valueOf(true) === false'); +} + +//CHECK#3 +if ((new Boolean(0)).valueOf(true) !== false) { + $ERROR('#3: (new Boolean(0)).valueOf(true) === false'); +} + +//CHECK#4 +if ((new Boolean(-1)).valueOf(false) !== true) { + $ERROR('#4: (new Boolean(-1)).valueOf(false) === true'); +} + +//CHECK#5 +if ((new Boolean(1)).valueOf(false) !== true) { + $ERROR('#5: (new Boolean(1)).valueOf(false) === true'); +} + +//CHECK#6 +if ((new Boolean(new Object())).valueOf(false) !== true) { + $ERROR('#6: (new Boolean(new Object())).valueOf(false) === 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..7b654c755c --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T1.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 +---*/ + +//CHECK#1 +try { + var s1 = new String(); + s1.valueOf = Boolean.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new String(); + s2.myValueOf = Boolean.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..71eeb9dd9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T2.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 +---*/ + +//CHECK#1 +try { + var s1 = new Number(); + s1.valueOf = Boolean.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new Number(); + s2.myValueOf = Boolean.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..2ad55618de --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T3.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 +---*/ + +//CHECK#1 +try { + var s1 = new Date(); + s1.valueOf = Boolean.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new Date(); + s2.myValueOf = Boolean.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..dd483313d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T4.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 +---*/ + +//CHECK#1 +try { + var s1 = new Object(); + s1.valueOf = Boolean.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = new Object(); + s2.myValueOf = Boolean.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +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..aa5bf1c2b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T5.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The 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 +---*/ + +//CHECK#1 +try { + var s1 = { + x: 1 + }; + s1.valueOf = Boolean.prototype.valueOf; + var v1 = s1.valueOf(); + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#1: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +//CHECK#1 +try { + var s2 = { + x: 1 + }; + s2.myValueOf = Boolean.prototype.valueOf; + var v2 = s2.myValueOf(); + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError'); +} +catch (e) { + if (!(e instanceof TypeError)) { + $ERROR('#2: Boolean.prototype.valueOf on not a Boolean object should throw TypeError, not ' + e); + } +} + +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 diff --git a/js/src/tests/test262/built-ins/Boolean/shell.js b/js/src/tests/test262/built-ins/Boolean/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Boolean/symbol-coercion.js b/js/src/tests/test262/built-ins/Boolean/symbol-coercion.js new file mode 100644 index 0000000000..bf712f2a2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/symbol-coercion.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-toboolean +description: > + Boolean coercion operations on Symbols +features: [Symbol] +---*/ +var sym = Symbol(); + +assert.sameValue(Boolean(sym).valueOf(), true, "`Boolean(sym).valueOf()` returns `true`"); + +reportCompare(0, 0); |