diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Boolean | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Boolean')
61 files changed, 1260 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..c55a7cc866 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T1.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: | + 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 +---*/ +assert.sameValue(typeof Boolean(), "boolean", 'The value of `typeof Boolean()` is expected to be "boolean"'); +assert.sameValue(typeof Boolean(1), "boolean", 'The value of `typeof Boolean(1)` is expected to be "boolean"'); + +assert.sameValue( + typeof Boolean(new String("1")), + "boolean", + 'The value of `typeof Boolean(new String("1"))` is expected to be "boolean"' +); + +assert.sameValue( + typeof Boolean(new Object(1)), + "boolean", + 'The value of `typeof Boolean(new Object(1))` is expected to be "boolean"' +); + +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..83fd28fca6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_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. + +/*--- +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 +---*/ +assert.sameValue(typeof Boolean(0), "boolean", 'The value of `typeof Boolean(0)` is expected to be "boolean"'); +assert.sameValue(Boolean(0), false, 'Boolean(0) must return false'); +assert.sameValue(typeof Boolean(-1), "boolean", 'The value of `typeof Boolean(-1)` is expected to be "boolean"'); +assert.sameValue(Boolean(-1), true, 'Boolean(-1) must return true'); + +assert.sameValue( + typeof Boolean(-Infinity), + "boolean", + 'The value of `typeof Boolean(-Infinity)` is expected to be "boolean"' +); + +assert.sameValue(Boolean(-Infinity), true, 'Boolean(-Infinity) must return true'); +assert.sameValue(typeof Boolean(NaN), "boolean", 'The value of `typeof Boolean(NaN)` is expected to be "boolean"'); +assert.sameValue(Boolean(NaN), false, 'Boolean(NaN) must return false'); + +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..08be621238 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T3.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 various string values as argument +---*/ + +assert.sameValue(typeof Boolean("0"), "boolean", 'The value of `typeof Boolean("0")` is expected to be "boolean"'); +assert.sameValue(Boolean("0"), true, 'Boolean("0") must return true'); +assert.sameValue(typeof Boolean("-1"), "boolean", 'The value of `typeof Boolean("-1")` is expected to be "boolean"'); +assert.sameValue(Boolean("-1"), true, 'Boolean("-1") must return true'); +assert.sameValue(typeof Boolean("1"), "boolean", 'The value of `typeof Boolean("1")` is expected to be "boolean"'); +assert.sameValue(Boolean("1"), true, 'Boolean("1") must return true'); + +assert.sameValue( + typeof Boolean("false"), + "boolean", + 'The value of `typeof Boolean("false")` is expected to be "boolean"' +); + +assert.sameValue(Boolean("false"), true, 'Boolean("false") must return true'); + +assert.sameValue( + typeof Boolean("true"), + "boolean", + 'The value of `typeof Boolean("true")` is expected to be "boolean"' +); + +assert.sameValue(Boolean("true"), true, 'Boolean("true") must return 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..d52fb031da --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_T4.js @@ -0,0 +1,41 @@ +// 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 +---*/ + +assert.sameValue( + typeof Boolean(undefined), + "boolean", + 'The value of `typeof Boolean(undefined)` is expected to be "boolean"' +); + +assert.sameValue(Boolean(undefined), false, 'Boolean(undefined) must return false'); + +assert.sameValue( + typeof Boolean(void 0), + "boolean", + 'The value of `typeof Boolean(void 0)` is expected to be "boolean"' +); + +assert.sameValue(Boolean(void 0), false, 'Boolean(void 0) must return false'); + +assert.sameValue( + typeof Boolean(function() {}()), + "boolean", + 'The value of `typeof Boolean(function() {}())` is expected to be "boolean"' +); + +assert.sameValue(Boolean(function() {}()), false, 'Boolean(function() {}()) must return false'); +assert.sameValue(typeof Boolean(null), "boolean", 'The value of `typeof Boolean(null)` is expected to be "boolean"'); +assert.sameValue(Boolean(null), false, 'Boolean(null) must return false'); +assert.sameValue(typeof Boolean(x), "boolean", 'The value of `typeof Boolean(x)` is expected to be "boolean"'); +assert.sameValue(Boolean(x), false, 'Boolean() must return 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..0bb2c7f497 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A1_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: | + 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; + +assert.sameValue(typeof Boolean(x = 0), "boolean", 'The value of `typeof Boolean(x = 0)` is expected to be "boolean"'); +assert.sameValue(Boolean(x = 0), false, 'Boolean(x = 0) must return false'); +assert.sameValue(typeof Boolean(x = 1), "boolean", 'The value of `typeof Boolean(x = 1)` is expected to be "boolean"'); +assert.sameValue(Boolean(x = 1), true, 'Boolean(x = 1) must return true'); + +assert.sameValue( + typeof Boolean(x = false), + "boolean", + 'The value of `typeof Boolean(x = false)` is expected to be "boolean"' +); + +assert.sameValue(Boolean(x = false), false, 'Boolean(x = false) must return false'); + +assert.sameValue( + typeof Boolean(x = true), + "boolean", + 'The value of `typeof Boolean(x = true)` is expected to be "boolean"' +); + +assert.sameValue(Boolean(x = true), true, 'Boolean(x = true) must return true'); + +assert.sameValue( + typeof Boolean(x = null), + "boolean", + 'The value of `typeof Boolean(x = null)` is expected to be "boolean"' +); + +assert.sameValue(Boolean(x = null), false, 'Boolean(x = null) must return 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..b5e504ce55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.1.1_A2.js @@ -0,0 +1,12 @@ +// 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 +---*/ +assert.sameValue(typeof Boolean(), "boolean", 'The value of `typeof Boolean()` is expected to be "boolean"'); +assert.sameValue(Boolean(), false, 'Boolean() must return 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..d2de136876 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A1.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 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 +---*/ + +assert.sameValue(typeof new Boolean(), "object", 'The value of `typeof new Boolean()` is expected to be "object"'); +assert.notSameValue(new Boolean(), undefined, 'new Boolean() is expected to not equal ``undefined``'); + +var x3 = new Boolean(); +assert.sameValue(typeof x3, "object", 'The value of `typeof x3` is expected to be "object"'); + +var x4 = new Boolean(); +assert.notSameValue(x4, undefined, 'The value of x4 is expected to not equal ``undefined``'); +assert.sameValue(typeof new Boolean(1), "object", 'The value of `typeof new Boolean(1)` is expected to be "object"'); +assert.notSameValue(new Boolean(1), undefined, 'new Boolean(1) is expected to not equal ``undefined``'); + +var x7 = new Boolean(1); +assert.sameValue(typeof x7, "object", 'The value of `typeof x7` is expected to be "object"'); + +var x8 = new Boolean(1); +assert.notSameValue(x8, undefined, 'The value of x8 is expected to not equal ``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..5a31cc11bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A2.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[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); + +assert.sameValue( + typeof x1.constructor.prototype, + "object", + 'The value of `typeof x1.constructor.prototype` is expected to be "object"' +); + +var x2 = new Boolean(2); +assert(Boolean.prototype.isPrototypeOf(x2), 'Boolean.prototype.isPrototypeOf(x2) must return true'); + +var x3 = new Boolean(3); + +assert.sameValue( + Boolean.prototype, + x3.constructor.prototype, + 'The value of Boolean.prototype is expected to equal the value of 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..5776bd7a5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A3.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 [[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); +assert.sameValue(x1.valueOf(), true, 'x1.valueOf() must return true'); + +var x2 = new Boolean(); +assert.sameValue(x2.valueOf(), false, 'x2.valueOf() must return false'); + +var x2 = new Boolean(0); +assert.sameValue(x2.valueOf(), false, 'x2.valueOf() must return false'); + +var x2 = new Boolean(new Object()); +assert.sameValue(x2.valueOf(), true, 'x2.valueOf() must return 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..c2695184cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.2.1_A4.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: | + 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(); + +assert.sameValue(obj.toString(), "[object Boolean]", 'obj.toString() must return "[object 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..2ea4b61e28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A1.js @@ -0,0 +1,11 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Boolean constructor has the property "prototype" +esid: sec-boolean.prototype +description: Checking existence of the property "prototype" +---*/ +assert(Boolean.hasOwnProperty("prototype"), 'Boolean.hasOwnProperty("prototype") must return true'); + +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..a9017ef6dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A2.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the Boolean + constructor is the Function prototype object +esid: sec-boolean.prototype +description: Checking prototype of the Boolean constructor +---*/ +assert( + Function.prototype.isPrototypeOf(Boolean), + 'Function.prototype.isPrototypeOf(Boolean) must return true' +); + +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..8b84f5f7b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S15.6.3_A3.js @@ -0,0 +1,12 @@ +// 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 +---*/ +assert(Boolean.hasOwnProperty("length"), 'Boolean.hasOwnProperty("length") must return true'); +assert.sameValue(Boolean.length, 1, 'The value of Boolean.length is expected to be 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..ef74e43f64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A1_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 undefined value is false +esid: sec-toboolean +description: > + Undefined, void and others are converted to Boolean by explicit + transformation +---*/ + +assert.sameValue(Boolean(undefined), false, 'Boolean(undefined) must return false'); +assert.sameValue(Boolean(void 0), false, 'Boolean(void 0) must return false'); +assert.sameValue(Boolean(eval("var x")), false, 'Boolean(eval("var x")) must return false'); +assert.sameValue(Boolean(), false, 'Boolean() must return false'); + +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..f35a62eb8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A2_T1.js @@ -0,0 +1,11 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Result of boolean conversion from null value is false +esid: sec-toboolean +description: null convert to Boolean by explicit transformation +---*/ +assert.sameValue(Boolean(null), false, 'Boolean(null) must return false'); + +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..478031caa4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A3_T1.js @@ -0,0 +1,12 @@ +// 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 +---*/ +assert.sameValue(Boolean(true), true, 'Boolean(true) must return true'); +assert.sameValue(Boolean(false), false, 'Boolean(false) must return 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..1c178f1fa0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A4_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 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 +---*/ +assert.sameValue(Boolean(+0), false, 'Boolean(+0) must return false'); +assert.sameValue(Boolean(-0), false, 'Boolean(-0) must return false'); +assert.sameValue(Boolean(Number.NaN), false, 'Boolean(Number.NaN) must return false'); + +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..b357ab9052 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A4_T3.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: | + 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 +---*/ +assert.sameValue(Boolean(Number.POSITIVE_INFINITY), true, 'Boolean(Number.POSITIVE_INFINITY) must return true'); +assert.sameValue(Boolean(Number.NEGATIVE_INFINITY), true, 'Boolean(Number.NEGATIVE_INFINITY) must return true'); +assert.sameValue(Boolean(Number.MAX_VALUE), true, 'Boolean(Number.MAX_VALUE) must return true'); +assert.sameValue(Boolean(Number.MIN_VALUE), true, 'Boolean(Number.MIN_VALUE) must return true'); +assert.sameValue(Boolean(13), true, 'Boolean(13) must return true'); +assert.sameValue(Boolean(-13), true, 'Boolean(-13) must return true'); +assert.sameValue(Boolean(1.3), true, 'Boolean(1.3) must return true'); +assert.sameValue(Boolean(-1.3), true, 'Boolean(-1.3) must return true'); + +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..78111566c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T1.js @@ -0,0 +1,13 @@ +// 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" +---*/ +assert.sameValue(Boolean(""), false, 'Boolean("") must return false'); + +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..3122ff8eed --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A5_T3.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: | + 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 +---*/ +assert.sameValue(Boolean(" "), true, 'Boolean(" ") must return true'); +assert.sameValue(Boolean("Nonempty String"), true, 'Boolean("Nonempty String") must return true'); + +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..bfacbb758a --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/S9.2_A6_T1.js @@ -0,0 +1,41 @@ +// 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 +---*/ + +assert.sameValue(Boolean(new Object()), true, 'Boolean(new Object()) must return true'); +assert.sameValue(Boolean(new String("")), true, 'Boolean(new String("")) must return true'); +assert.sameValue(Boolean(new String()), true, 'Boolean(new String()) must return true'); +assert.sameValue(Boolean(new Boolean(true)), true, 'Boolean(new Boolean(true)) must return true'); +assert.sameValue(Boolean(new Boolean(false)), true, 'Boolean(new Boolean(false)) must return true'); +assert.sameValue(Boolean(new Boolean()), true, 'Boolean(new Boolean()) must return true'); +assert.sameValue(Boolean(new Array()), true, 'Boolean(new Array()) must return true'); +assert.sameValue(Boolean(new Number()), true, 'Boolean(new Number()) must return true'); +assert.sameValue(Boolean(new Number(-0)), true, 'Boolean(new Number(-0)) must return true'); +assert.sameValue(Boolean(new Number(0)), true, 'Boolean(new Number(0)) must return true'); +assert.sameValue(Boolean(new Number()), true, 'Boolean(new Number()) must return true'); +assert.sameValue(Boolean(new Number(Number.NaN)), true, 'Boolean(new Number(Number.NaN)) must return true'); +assert.sameValue(Boolean(new Number(-1)), true, 'Boolean(new Number(-1)) must return true'); +assert.sameValue(Boolean(new Number(1)), true, 'Boolean(new Number(1)) must return true'); + +assert.sameValue( + Boolean(new Number(Number.POSITIVE_INFINITY)), + true, + 'Boolean(new Number(Number.POSITIVE_INFINITY)) must return true' +); + +assert.sameValue( + Boolean(new Number(Number.NEGATIVE_INFINITY)), + true, + 'Boolean(new Number(Number.NEGATIVE_INFINITY)) must return true' +); + +assert.sameValue(Boolean(new Function()), true, 'Boolean(new Function()) must return true'); +assert.sameValue(Boolean(new Date()), true, 'Boolean(new Date()) must return true'); +assert.sameValue(Boolean(new Date(0)), true, 'Boolean(new Date(0)) must return true'); + +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..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 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..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Boolean/shell.js @@ -0,0 +1,24 @@ +// 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] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + 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); |