diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects')
14 files changed, 1232 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.1.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.1.1.js new file mode 100644 index 0000000..cbc1783 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.1.1.js @@ -0,0 +1,151 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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 testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var NULL_OBJECT = Object(null); + + array[item++] = new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) ); + array[item++] = new TestCase( SECTION, "Object(null).__proto__", Object.prototype, (Object(null)).__proto__ ); + + var UNDEFINED_OBJECT = Object( void 0 ); + + array[item++] = new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) ); + array[item++] = new TestCase( SECTION, "Object(void 0).__proto__", Object.prototype, (Object(void 0)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); + array[item++] = 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()") ); + + array[item++] = 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() ); + array[item++] = new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); +// array[item++] = 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()") ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += + ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.1.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.1.2.js new file mode 100644 index 0000000..6a619b6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.1.2.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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 testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MYOB = Object(); + + array[item++] = new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += + ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.2.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.2.1.js new file mode 100644 index 0000000..cf04ce4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.2.1.js @@ -0,0 +1,139 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new Object(null)", "object", typeof new Object(null) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "typeof new Object(void 0)", "object", typeof new Object(void 0) ); + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "typeof new Object('string')", "object", typeof new Object('string') ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object('string').valueOf()", "string", (new Object('string')).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object('')", "object", typeof new Object('') ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object('').valueOf()", "", (new Object('')).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(Number.NaN)", "object", typeof new Object(Number.NaN) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(Number.NaN).valueOf()", Number.NaN, (new Object(Number.NaN)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(0)", "object", typeof new Object(0) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(0).valueOf()", 0, (new Object(0)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(-0)", "object", typeof new Object(-0) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(-0).valueOf()", -0, (new Object(-0)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(1)", "object", typeof new Object(1) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(1).valueOf()", 1, (new Object(1)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(-1)", "object", typeof new Object(-1) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(-1).valueOf()", -1, (new Object(-1)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(true)", "object", typeof new Object(true) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(true).valueOf()", true, (new Object(true)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(false)", "object", typeof new Object(false) ); + array[item++] = 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()") ); + array[item++] = new TestCase( SECTION, "(new Object(false).valueOf()", false, (new Object(false)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(Boolean())", "object", typeof new Object(Boolean()) ); + array[item++] = 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()") ); + array[item++] = 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; + + array[item++] = new TestCase( SECTION, "myglobal = new Object( this )", myglobal, new Object(this) ); + array[item++] = new TestCase( SECTION, "myobject = new Object('my new object'); new Object(myobject)", myobject, new Object(myobject) ); + array[item++] = new TestCase( SECTION, "myarray = new Array(); new Object(myarray)", myarray, new Object(myarray) ); + array[item++] = new TestCase( SECTION, "myboolean = new Boolean(); new Object(myboolean)", myboolean, new Object(myboolean) ); + array[item++] = new TestCase( SECTION, "mynumber = new Number(); new Object(mynumber)", mynumber, new Object(mynumber) ); + array[item++] = new TestCase( SECTION, "mystring = new String9); new Object(mystring)", mystring, new Object(mystring) ); + array[item++] = new TestCase( SECTION, "myobject = new Object(); new Object(mynobject)", myobject, new Object(myobject) ); + array[item++] = new TestCase( SECTION, "myfunction = new Function(); new Object(myfunction)", myfunction, new Object(myfunction) ); + array[item++] = new TestCase( SECTION, "mymath = Math; new Object(mymath)", mymath, new Object(mymath) ); + + return ( array ); +} +function test() { + for (tc = 0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.2.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.2.2.js new file mode 100644 index 0000000..eddedfa --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.2.2.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); + array[item++] = new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); + array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value+''" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3-1.js new file mode 100644 index 0000000..06f50ce --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3-1.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Properties of the Object Constructor"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + array[item++] = new TestCase( SECTION, "Object.length", 1, Object.length ); + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js new file mode 100644 index 0000000..ee0539a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var str = '';for ( p in Object ) { str += p; }; str", + "", + eval( "var str = ''; for ( p in Object ) { str += p; }; str" ) + ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js new file mode 100644 index 0000000..fc2c735 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete( Object.prototype )", + false, + "delete( Object.prototype )" + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js new file mode 100644 index 0000000..eb3a79d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Object.prototype = null; Object.prototype", + Object.prototype, + "Object.prototype = null; Object.prototype" + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js new file mode 100644 index 0000000..8a39d7e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete( Object.prototype ); Object.prototype", + Object.prototype, + "delete(Object.prototype); Object.prototype" + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.js new file mode 100644 index 0000000..152add9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.3.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + array[item++] = new TestCase( SECTION, "Object.length", 1, Object.length ); + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.1.js new file mode 100644 index 0000000..61f2898 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Object.prototype.constructor", + Object, + Object.prototype.constructor + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.2.js new file mode 100644 index 0000000..40eca1b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.2.js @@ -0,0 +1,128 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + + array[item++] = new TestCase( SECTION, "myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()", + GLOBAL, + eval("myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = 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()") ); + + array[item++] = 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()") ); + + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Math]", + eval("myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = 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()") ); + + array[item++] = 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()") ); + + array[item++] = 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()") ); + + array[item++] = 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()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object( this ); MYVAR.toString()", + GLOBAL, + eval("var MYVAR = new Object( this ); MYVAR.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object(); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(); MYVAR.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object(void 0); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(void 0); MYVAR.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object(null); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(null); MYVAR.toString()") ); + + return ( array ); +} +function test( array ) { + for ( tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = new Function( "return this.value" ); + this.toString = new Function ( "return this.value+''"); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.3.js new file mode 100644 index 0000000..1daf04a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.3.js @@ -0,0 +1,115 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + 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 testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + 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; + + array[item++] = new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); + + array[item++] = new TestCase( SECTION, + "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", + myarray, + myarray.valueOf() ); + array[item++] = new TestCase( SECTION, + "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", + myboolean, + myboolean.valueOf() ); + array[item++] = new TestCase( SECTION, + "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", + myfunction, + myfunction.valueOf() ); + array[item++] = new TestCase( SECTION, + "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", + myobject, + myobject.valueOf() ); + array[item++] = new TestCase( SECTION, + "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", + mymath, + mymath.valueOf() ); + array[item++] = new TestCase( SECTION, + "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", + mynumber, + mynumber.valueOf() ); + array[item++] = new TestCase( SECTION, + "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", + mystring, + mystring.valueOf() ); + array[item++] = new TestCase( SECTION, + "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", + mydate, + mydate.valueOf() ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.js new file mode 100644 index 0000000..5a018c0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ObjectObjects/15.2.4.js @@ -0,0 +1,60 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.4.js + ECMA Section: 15.2.4 Properties of the Object prototype object + + Description: The value of the internal [[Prototype]] property of + the Object prototype object is null + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.2.4"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Object.prototype object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + testcases[tc++] = new TestCase( SECTION, "Object.prototype.__proto__", + null, + Object.prototype.__proto__ + ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} |