diff options
Diffstat (limited to 'js/src/tests/ecma/Boolean')
21 files changed, 860 insertions, 0 deletions
diff --git a/js/src/tests/ecma/Boolean/15.6.1.js b/js/src/tests/ecma/Boolean/15.6.1.js new file mode 100644 index 000000000..8725c978b --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.1.js @@ -0,0 +1,62 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.1.js + ECMA Section: 15.6.1 The Boolean Function + 15.6.1.1 Boolean( value ) + 15.6.1.2 Boolean () + Description: Boolean( value ) should return a Boolean value + not a Boolean object) computed by + Boolean.toBooleanValue( value) + + 15.6.1.2 Boolean() returns false + + Author: christine@netscape.com + Date: 27 jun 1997 + + + Data File Fields: + VALUE Argument passed to the Boolean function + TYPE typeof VALUE (not used, but helpful in understanding + the data file) + E_RETURN Expected return value of Boolean( VALUE ) +*/ +var SECTION = "15.6.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); +new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); +new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); +new TestCase( SECTION, "Boolean('1')", true, Boolean("1") ); +new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); +new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") ); +new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); +new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); + +new TestCase( SECTION, "Boolean('true')", true, Boolean("true") ); +new TestCase( SECTION, "Boolean('false')", true, Boolean("false") ); +new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); + +new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); +new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) ); +new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) ); +new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) ); +new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) ); +new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) ); +new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) ); +new TestCase( SECTION, "Boolean()", false, Boolean() ); +// array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.2.js b/js/src/tests/ecma/Boolean/15.6.2.js new file mode 100644 index 000000000..781e39618 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.2.js @@ -0,0 +1,127 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.2.js + ECMA Section: 15.6.2 The Boolean Constructor + 15.6.2.1 new Boolean( value ) + 15.6.2.2 new Boolean() + + This test verifies that the Boolean constructor + initializes a new object (typeof should return + "object"). The prototype of the new object should + be Boolean.prototype. The value of the object + should be ToBoolean( value ) (a boolean value). + + Description: + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) ); +new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) ); +new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) ); +new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) ); +new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') ); +new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') ); +new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') ); +new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) ); +new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) ); +new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) ); +new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) ); +new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase( "15.6.2.2", + "TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() ); +new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.3.1-1.js b/js/src/tests/ecma/Boolean/15.6.3.1-1.js new file mode 100644 index 000000000..5ab8d98c3 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.3.1-1.js @@ -0,0 +1,38 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.3.1-1.js + ECMA Section: 15.6.3 Boolean.prototype + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontEnum property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, + "var str='';for ( p in Boolean ) { str += p } str;", + "", + eval("var str='';for ( p in Boolean ) { str += p } str;") ); +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.3.1-2.js b/js/src/tests/ecma/Boolean/15.6.3.1-2.js new file mode 100644 index 000000000..ae9a52da5 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.3.1-2.js @@ -0,0 +1,37 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.3.1-2.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, + "delete( Boolean.prototype)", + false, + delete( Boolean.prototype) ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.3.1-3.js b/js/src/tests/ecma/Boolean/15.6.3.1-3.js new file mode 100644 index 000000000..f682294f6 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.3.1-3.js @@ -0,0 +1,37 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.3.1-3.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, + "delete( Boolean.prototype); Boolean.prototype", + Boolean.prototype, + eval("delete( Boolean.prototype); Boolean.prototype") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.3.1-4.js b/js/src/tests/ecma/Boolean/15.6.3.1-4.js new file mode 100644 index 000000000..baca269f8 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.3.1-4.js @@ -0,0 +1,41 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.3.1-4.js + ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the ReadOnly property of Boolean.prototype + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ +var SECTION = "15.6.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + +var BOOL_PROTO = Boolean.prototype; + +new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO", + true, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") ); + +new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null", + false, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.3.1.js b/js/src/tests/ecma/Boolean/15.6.3.1.js new file mode 100644 index 000000000..b47524356 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.3.1.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.3.1.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + It has the internal [[Call]] and [[Construct]] + properties (not tested), and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + +var SECTION = "15.6.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); +new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4-1.js b/js/src/tests/ecma/Boolean/15.6.4-1.js new file mode 100644 index 000000000..e1e53b5c2 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4-1.js @@ -0,0 +1,38 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4-1.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + +var VERSION = "ECMA_1" + startTest(); +var SECTION = "15.6.4-1"; + +writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + +new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) ); +new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) ); +new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); +new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.1.js b/js/src/tests/ecma/Boolean/15.6.4.1.js new file mode 100644 index 000000000..d2cf73c9c --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.1.js @@ -0,0 +1,28 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.1.js + ECMA Section: 15.6.4.1 Boolean.prototype.constructor + + Description: The initial value of Boolean.prototype.constructor + is the built-in Boolean constructor. + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ +var SECTION = "15.6.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.constructor" + writeHeaderToLog( SECTION + TITLE ); + +new TestCase( SECTION, + "( Boolean.prototype.constructor == Boolean )", + true , + (Boolean.prototype.constructor == Boolean) ); +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.2-1.js b/js/src/tests/ecma/Boolean/15.6.4.2-1.js new file mode 100644 index 000000000..f2f3e1a45 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.2-1.js @@ -0,0 +1,63 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.2.js + ECMA Section: 15.6.4.2-1 Boolean.prototype.toString() + Description: 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. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + +new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() ); +new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() ); +new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() ); +new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() ); +new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() ); +new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() ); +new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() ); +new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() ); +new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() ); + +new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() ); +new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() ); +new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() ); +new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() ); +new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() ); +new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() ); +new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() ); +new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() ); +new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() ); +new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() ); +new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() ); +new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() ); +new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() ); + +new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() ); +new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).toString() ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + return this; +} diff --git a/js/src/tests/ecma/Boolean/15.6.4.2-2.js b/js/src/tests/ecma/Boolean/15.6.4.2-2.js new file mode 100644 index 000000000..93c6ba4ba --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.2-2.js @@ -0,0 +1,39 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.2-2.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()", + "false", + eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") ); +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()", + "true", + eval("tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()") ); +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()", + "false", + eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") ); +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.2-3.js b/js/src/tests/ecma/Boolean/15.6.4.2-3.js new file mode 100644 index 000000000..1dbb63af0 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.2-3.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.2-3.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + +var SECTION = "15.6.4.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + +new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") ); +new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.2-4-n.js b/js/src/tests/ecma/Boolean/15.6.4.2-4-n.js new file mode 100644 index 000000000..3539a80c5 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.2-4-n.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.2-4.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.2-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()"; +writeHeaderToLog( SECTION +" "+ TITLE ); + +DESCRIPTION = "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()", + "error", + eval("tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.3-1.js b/js/src/tests/ecma/Boolean/15.6.4.3-1.js new file mode 100644 index 000000000..8f139f940 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.3-1.js @@ -0,0 +1,54 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + +new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() ); +new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); +new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() ); +new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() ); +new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() ); +new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() ); +new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() ); +new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + +new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() ); +new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() ); +new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); +new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() ); + +new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); +new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); +new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.3-2.js b/js/src/tests/ecma/Boolean/15.6.4.3-2.js new file mode 100644 index 000000000..527524117 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.3-2.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.3-2.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") ); + +new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.3-3.js b/js/src/tests/ecma/Boolean/15.6.4.3-3.js new file mode 100644 index 000000000..06d7ecb84 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.3-3.js @@ -0,0 +1,32 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.3-3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()", + true, + eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") ); +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.3-4-n.js b/js/src/tests/ecma/Boolean/15.6.4.3-4-n.js new file mode 100644 index 000000000..cdba1210c --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.3-4-n.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.3-4.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ +var SECTION = "15.6.4.3-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" + EXPECTED = "error"; + +new TestCase( SECTION, + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()", + "error", + eval("valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.3.js b/js/src/tests/ecma/Boolean/15.6.4.3.js new file mode 100644 index 000000000..ca622ebb3 --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.3.js @@ -0,0 +1,49 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + + +new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + +new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + +new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() ); + +new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + +test(); diff --git a/js/src/tests/ecma/Boolean/15.6.4.js b/js/src/tests/ecma/Boolean/15.6.4.js new file mode 100644 index 000000000..df98a67ee --- /dev/null +++ b/js/src/tests/ecma/Boolean/15.6.4.js @@ -0,0 +1,46 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.6.4.js + ECMA Section: Properties of the Boolean Prototype Object + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is " + Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Boolean + prototype object, the phrase "this Boolean object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Boolean". Also, the phrase "this boolean value" + refers to the boolean value represented by this Boolean object, that is, + the value of the internal [[Value]] property of this Boolean object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.6.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Boolean Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Boolean.prototype == false", + true, + Boolean.prototype == false ); + +new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); + +test(); diff --git a/js/src/tests/ecma/Boolean/browser.js b/js/src/tests/ecma/Boolean/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Boolean/browser.js diff --git a/js/src/tests/ecma/Boolean/shell.js b/js/src/tests/ecma/Boolean/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Boolean/shell.js |