diff options
Diffstat (limited to 'js/src/tests/ecma/ObjectObjects')
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.1.1.js | 112 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.1.2.js | 47 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.2.1.js | 104 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.2.2.js | 40 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.3-1.js | 30 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.3.1-1.js | 35 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.3.1-2.js | 36 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.3.1-3.js | 36 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.3.1-4.js | 36 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.3.js | 33 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.4.1.js | 30 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.4.2.js | 96 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/15.2.4.3.js | 83 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma/ObjectObjects/shell.js | 0 |
15 files changed, 718 insertions, 0 deletions
diff --git a/js/src/tests/ecma/ObjectObjects/15.2.1.1.js b/js/src/tests/ecma/ObjectObjects/15.2.1.1.js new file mode 100644 index 000000000..11195e018 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.1.1.js @@ -0,0 +1,112 @@ +/* -*- 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.2.1.1.js + ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no properties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var SECTION = "15.2.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object( value )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var NULL_OBJECT = Object(null); + +new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() ); +new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) ); + +var UNDEFINED_OBJECT = Object( void 0 ); + +new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() ); +new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) ); + +new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); +new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); +new TestCase( SECTION, "var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); +new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); +new TestCase( SECTION, "var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); +new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); +new TestCase( SECTION, "var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); +new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); +new TestCase( SECTION, "var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); +new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); +new TestCase( SECTION, "var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); +new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); +new TestCase( SECTION, "var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); +new TestCase( SECTION, "var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); +new TestCase( SECTION, "var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); +new TestCase( SECTION, "var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); +new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); +new TestCase( SECTION, "var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); +new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); +new TestCase( SECTION, "var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); +new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); +new TestCase( SECTION, "var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); +new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); +// new TestCase( SECTION, "var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.1.2.js b/js/src/tests/ecma/ObjectObjects/15.2.1.2.js new file mode 100644 index 000000000..2cbbe06d7 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.1.2.js @@ -0,0 +1,47 @@ +/* -*- 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.2.1.2.js + ECMA Section: 15.2.1.2 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no proerties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var SECTION = "15.2.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MYOB = Object(); + +new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); +new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); +new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.2.1.js b/js/src/tests/ecma/ObjectObjects/15.2.2.1.js new file mode 100644 index 000000000..f9d15c9e0 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.2.1.js @@ -0,0 +1,104 @@ +/* -*- 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.2.2.1.js + ECMA Section: 15.2.2.1 The Object Constructor: new Object( value ) + + 1.If the type of the value is not Object, go to step 4. + 2.If the value is a native ECMAScript object, do not create a new object; simply return value. + 3.If the value is a host object, then actions are taken and a result is returned in an + implementation-dependent manner that may depend on the host object. + 4.If the type of the value is String, return ToObject(value). + 5.If the type of the value is Boolean, return ToObject(value). + 6.If the type of the value is Number, return ToObject(value). + 7.(The type of the value must be Null or Undefined.) Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to the Object prototype object. + The [[Class]] property of the newly constructed object is set to "Object". + The newly constructed object has no [[Value]] property. + Return the newly created native object. + + Description: This does not test cases where the object is a host object. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.2.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Object( value )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "typeof new Object(null)", "object", typeof new Object(null) ); +new TestCase( SECTION, "MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "typeof new Object(void 0)", "object", typeof new Object(void 0) ); +new TestCase( SECTION, "MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "typeof new Object('string')", "object", typeof new Object('string') ); +new TestCase( SECTION, "MYOB = (new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object('string').valueOf()", "string", (new Object('string')).valueOf() ); + +new TestCase( SECTION, "typeof new Object('')", "object", typeof new Object('') ); +new TestCase( SECTION, "MYOB = (new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object('').valueOf()", "", (new Object('')).valueOf() ); + +new TestCase( SECTION, "typeof new Object(Number.NaN)", "object", typeof new Object(Number.NaN) ); +new TestCase( SECTION, "MYOB = (new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(Number.NaN).valueOf()", Number.NaN, (new Object(Number.NaN)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(0)", "object", typeof new Object(0) ); +new TestCase( SECTION, "MYOB = (new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(0).valueOf()", 0, (new Object(0)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(-0)", "object", typeof new Object(-0) ); +new TestCase( SECTION, "MYOB = (new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(-0).valueOf()", -0, (new Object(-0)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(1)", "object", typeof new Object(1) ); +new TestCase( SECTION, "MYOB = (new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(1).valueOf()", 1, (new Object(1)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(-1)", "object", typeof new Object(-1) ); +new TestCase( SECTION, "MYOB = (new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(-1).valueOf()", -1, (new Object(-1)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(true)", "object", typeof new Object(true) ); +new TestCase( SECTION, "MYOB = (new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(true).valueOf()", true, (new Object(true)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(false)", "object", typeof new Object(false) ); +new TestCase( SECTION, "MYOB = (new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(false).valueOf()", false, (new Object(false)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(Boolean())", "object", typeof new Object(Boolean()) ); +new TestCase( SECTION, "MYOB = (new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(Boolean()).valueOf()", Boolean(), (new Object(Boolean())).valueOf() ); + + +var myglobal = this; +var myobject = new Object( "my new object" ); +var myarray = new Array(); +var myboolean = new Boolean(); +var mynumber = new Number(); +var mystring = new String(); +var myobject = new Object(); +var myfunction = new Function( "x", "return x"); +var mymath = Math; + +new TestCase( SECTION, "myglobal = new Object( this )", myglobal, new Object(this) ); +new TestCase( SECTION, "myobject = new Object('my new object'); new Object(myobject)", myobject, new Object(myobject) ); +new TestCase( SECTION, "myarray = new Array(); new Object(myarray)", myarray, new Object(myarray) ); +new TestCase( SECTION, "myboolean = new Boolean(); new Object(myboolean)", myboolean, new Object(myboolean) ); +new TestCase( SECTION, "mynumber = new Number(); new Object(mynumber)", mynumber, new Object(mynumber) ); +new TestCase( SECTION, "mystring = new String9); new Object(mystring)", mystring, new Object(mystring) ); +new TestCase( SECTION, "myobject = new Object(); new Object(mynobject)", myobject, new Object(myobject) ); +new TestCase( SECTION, "myfunction = new Function(); new Object(myfunction)", myfunction, new Object(myfunction) ); +new TestCase( SECTION, "mymath = Math; new Object(mymath)", mymath, new Object(mymath) ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.2.2.js b/js/src/tests/ecma/ObjectObjects/15.2.2.2.js new file mode 100644 index 000000000..f93895e7b --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.2.2.js @@ -0,0 +1,40 @@ +/* -*- 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.2.2.2.js + ECMA Section: 15.2.2.2 new Object() + Description: + + When the Object constructor is called with no argument, the following + step is taken: + + 1. Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to + the Object prototype object. + + The [[Class]] property of the newly constructed object is set + to "Object". + + The newly constructed object has no [[Value]] property. + + Return the newly created native object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.2.2.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Object()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); +new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); +new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.3-1.js b/js/src/tests/ecma/ObjectObjects/15.2.3-1.js new file mode 100644 index 000000000..1e48b82b8 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.3-1.js @@ -0,0 +1,30 @@ +/* -*- 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.2.3-1.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.3"; +var VERSION = "ECMA_2"; +startTest(); + +writeHeaderToLog( SECTION + " Properties of the Object Constructor"); + +new TestCase( SECTION, "Object.length", 1, Object.length ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.3.1-1.js b/js/src/tests/ecma/ObjectObjects/15.2.3.1-1.js new file mode 100644 index 000000000..8742b37e4 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.3.1-1.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.2.3.1-1.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontEnum] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var str = '';for ( p in Object ) { str += p; }; str", + "", + eval( "var str = ''; for ( p in Object ) { str += p; }; str" ) ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.3.1-2.js b/js/src/tests/ecma/ObjectObjects/15.2.3.1-2.js new file mode 100644 index 000000000..8dae5f2fd --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.3.1-2.js @@ -0,0 +1,36 @@ +/* -*- 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.2.3.1-2.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontDelete] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Object.prototype )", + false, + eval("delete( Object.prototype )") ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.3.1-3.js b/js/src/tests/ecma/ObjectObjects/15.2.3.1-3.js new file mode 100644 index 000000000..609f49d3d --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.3.1-3.js @@ -0,0 +1,36 @@ +/* -*- 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.2.3.1-3.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [ReadOnly] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Object.prototype = null; Object.prototype", + Object.prototype, + eval("Object.prototype = null; Object.prototype")); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.3.1-4.js b/js/src/tests/ecma/ObjectObjects/15.2.3.1-4.js new file mode 100644 index 000000000..6c0320642 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.3.1-4.js @@ -0,0 +1,36 @@ +/* -*- 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.2.3.1-4.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontDelete] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Object.prototype ); Object.prototype", + Object.prototype, + eval("delete(Object.prototype); Object.prototype") ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.3.js b/js/src/tests/ecma/ObjectObjects/15.2.3.js new file mode 100644 index 000000000..2dcd9dfb9 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.3.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.2.3.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Object Constructor"; + +writeHeaderToLog( SECTION + " " + TITLE); + +// new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); +new TestCase( SECTION, "Object.length", 1, Object.length ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.4.1.js b/js/src/tests/ecma/ObjectObjects/15.2.4.1.js new file mode 100644 index 000000000..1fda30d39 --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.4.1.js @@ -0,0 +1,30 @@ +/* -*- 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.2.4.1.js + ECMA Section: 15.2.4 Object.prototype.constructor + + Description: The initial value of the Object.prototype.constructor + is the built-in Object constructor. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Object.prototype.constructor", + Object, + Object.prototype.constructor ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.4.2.js b/js/src/tests/ecma/ObjectObjects/15.2.4.2.js new file mode 100644 index 000000000..eb461f7ea --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.4.2.js @@ -0,0 +1,96 @@ +/* -*- 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.2.4.2.js + ECMA Section: 15.2.4.2 Object.prototype.toString() + + Description: When the toString method is called, the following + steps are taken: + 1. Get the [[Class]] property of this object + 2. Call ToString( Result(1) ) + 3. Compute a string value by concatenating the three + strings "[object " + Result(2) + "]" + 4. Return Result(3). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.toString()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + +new TestCase( SECTION, "myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()", + GLOBAL.replace(/ @ 0x[0-9a-fA-F]+ \(native @ 0x[0-9a-fA-F]+\)/, ''), + eval("myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()") + ); + +new TestCase( SECTION, "myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()", + '[object Object]', + eval("myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Number]", + eval("myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object String]", + eval("myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Math]", + eval("myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Array]", + eval("myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Boolean]", + eval("myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Date]", + eval("myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "var MYVAR = new Object( this ); MYVAR.toString()", + GLOBAL.replace(/ @ 0x[0-9a-fA-F]+ \(native @ 0x[0-9a-fA-F]+\)/, ''), + eval("var MYVAR = new Object( this ); MYVAR.toString()") + ); + +new TestCase( SECTION, "var MYVAR = new Object(); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(); MYVAR.toString()") ); + +new TestCase( SECTION, "var MYVAR = new Object(void 0); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(void 0); MYVAR.toString()") ); + +new TestCase( SECTION, "var MYVAR = new Object(null); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(null); MYVAR.toString()") ); + + +function MyObject( value ) { + this.value = new Function( "return this.value" ); + this.toString = new Function ( "return this.value+''"); +} + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/15.2.4.3.js b/js/src/tests/ecma/ObjectObjects/15.2.4.3.js new file mode 100644 index 000000000..6842a6f1a --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/15.2.4.3.js @@ -0,0 +1,83 @@ +/* -*- 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.2.4.3.js + ECMA Section: 15.2.4.3 Object.prototype.valueOf() + + Description: As a rule, the valueOf method for an object simply + returns the object; but if the object is a "wrapper" + for a host object, as may perhaps be created by the + Object constructor, then the contained host object + should be returned. + + This only covers native objects. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.4.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var myarray = new Array(); +myarray.valueOf = Object.prototype.valueOf; +var myboolean = new Boolean(); +myboolean.valueOf = Object.prototype.valueOf; +var myfunction = new Function(); +myfunction.valueOf = Object.prototype.valueOf; +var myobject = new Object(); +myobject.valueOf = Object.prototype.valueOf; +var mymath = Math; +mymath.valueOf = Object.prototype.valueOf; +var mydate = new Date(); +mydate.valueOf = Object.prototype.valueOf; +var mynumber = new Number(); +mynumber.valueOf = Object.prototype.valueOf; +var mystring = new String(); +mystring.valueOf = Object.prototype.valueOf; + +new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); + +new TestCase( SECTION, + "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", + myarray, + myarray.valueOf() ); +new TestCase( SECTION, + "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", + myboolean, + myboolean.valueOf() ); +new TestCase( SECTION, + "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", + myfunction, + myfunction.valueOf() ); +new TestCase( SECTION, + "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", + myobject, + myobject.valueOf() ); +new TestCase( SECTION, + "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", + mymath, + mymath.valueOf() ); +new TestCase( SECTION, + "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", + mynumber, + mynumber.valueOf() ); +new TestCase( SECTION, + "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", + mystring, + mystring.valueOf() ); +new TestCase( SECTION, + "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", + mydate, + mydate.valueOf() ); + +test(); diff --git a/js/src/tests/ecma/ObjectObjects/browser.js b/js/src/tests/ecma/ObjectObjects/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/browser.js diff --git a/js/src/tests/ecma/ObjectObjects/shell.js b/js/src/tests/ecma/ObjectObjects/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/ObjectObjects/shell.js |