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 | |
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')
592 files changed, 72125 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4-1.js new file mode 100644 index 0000000..c5c3178 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4-1.js @@ -0,0 +1,126 @@ +/* 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.4-1.js + ECMA Section: 15.4 Array Objects + + Description: Every Array object has a length property whose value + is always an integer with positive sign and less than + Math.pow(2,32). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length", + (Math.pow(2,32)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length", + (Math.pow(2,32)-2), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length") + ); + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length", + (Math.pow(2,31)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length") + ); + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length", + (Math.pow(2,31)), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length") + ); + + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length", + (Math.pow(2,31)+1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length") + ); + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length", + (Math.pow(2,30)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length") + ); + 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/Array/15.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4-2.js new file mode 100644 index 0000000..ca046e6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4-2.js @@ -0,0 +1,83 @@ +/* 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.4-2.js + ECMA Section: 15.4 Array Objects + + Description: Whenever a property is added whose name is an array + index, the length property is changed, if necessary, + to be one more than the numeric value of that array + index; and whenever the length property is changed, + every property whose name is an array index whose value + is not smaller than the new length is automatically + deleted. This constraint applies only to the Array + object itself, and is unaffected by length or array + index properties that may be inherited from its + prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", Math.pow(2,16)+1, eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") ); + + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", Math.pow(2,30)-1, eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", Math.pow(2,30), eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", Math.pow(2,30)+1, eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") ); + + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", Math.pow(2,31)-1, eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", Math.pow(2,31), eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", Math.pow(2,31)+1, eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") ); + + array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", "0,1", eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") ); + array[item++] = new TestCase( SECTION, "var arr = new Array(0,1); arr.length = 3; String(arr)", "0,1,", eval("var arr = new Array(0,1); arr.length = 3; String(arr)") ); +// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length") ); +// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length") ); + + 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/Array/15.4.1.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.1.js new file mode 100644 index 0000000..315aa2c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.1.js @@ -0,0 +1,88 @@ +/* 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.4.1.1.js + ECMA Section: 15.4.1 Array( item0, item1,... ) + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creation new Array(...) with + the same arguments. + + An array is created and returned as if by the expression + new Array( item0, item1, ... ). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.1.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function ToUint32( n ) { + n = Number( n ); + if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY || + n == Number.NEGATIVE_INFINITY ) { + return 0; + } + var sign = n < 0 ? -1 : 1; + + return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32); +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof Array(1,2)", "object", typeof Array(1,2) ); + array[item++] = new TestCase( SECTION, "(Array(1,2)).toString", Array.prototype.toString, (Array(1,2)).toString ); + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") ); + + + array[item++] = new TestCase( SECTION, "(Array(1,2)).length", 2, (Array(1,2)).length ); + array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[0]", 1, eval("var arr = (Array(1,2)); arr[0]") ); + array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[1]", 2, eval("var arr = (Array(1,2)); arr[1]") ); + array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); String(arr)", "1,2", eval("var arr = (Array(1,2)); String(arr)") ); + + 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/Array/15.4.1.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.2.js new file mode 100644 index 0000000..29352e1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.2.js @@ -0,0 +1,98 @@ +/* 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.4.1.2.js + ECMA Section: 15.4.1.2 Array(len) + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + An array is created and returned as if by the + expression new Array(len). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.1.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Constructor Called as a Function: Array(len)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "(Array()).length", 0, (Array()).length ); + array[item++] = new TestCase( SECTION, "(Array(0)).length", 0, (Array(0)).length ); + array[item++] = new TestCase( SECTION, "(Array(1)).length", 1, (Array(1)).length ); + array[item++] = new TestCase( SECTION, "(Array(10)).length", 10, (Array(10)).length ); + array[item++] = new TestCase( SECTION, "(Array('1')).length", 1, (Array('1')).length ); + array[item++] = new TestCase( SECTION, "(Array(1000)).length", 1000, (Array(1000)).length ); + array[item++] = new TestCase( SECTION, "(Array('1000')).length", 1, (Array('1000')).length ); + array[item++] = new TestCase( SECTION, "(Array(4294967295)).length", ToUint32(4294967295), (Array(4294967295)).length ); + array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)-1)).length", ToUint32(Math.pow(2,31)-1), (Array(Math.pow(2,31)-1)).length ); + array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31))).length", ToUint32(Math.pow(2,31)), (Array(Math.pow(2,31))).length ); + array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)+1)).length", ToUint32(Math.pow(2,31)+1), (Array(Math.pow(2,31)+1)).length ); + array[item++] = new TestCase( SECTION, "(Array('8589934592')).length", 1, (Array("8589934592")).length ); + array[item++] = new TestCase( SECTION, "(Array('4294967296')).length", 1, (Array("4294967296")).length ); + array[item++] = new TestCase( SECTION, "(Array(1073741823)).length", ToUint32(1073741823), (Array(1073741823)).length ); + array[item++] = new TestCase( SECTION, "(Array(1073741824)).length", ToUint32(1073741824), (Array(1073741824)).length ); + array[item++] = new TestCase( SECTION, "(Array('a string')).length", 1, (Array("a string")).length ); + + 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 ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.3.js new file mode 100644 index 0000000..4c3393e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.3.js @@ -0,0 +1,86 @@ +/* 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.4.1.3.js + ECMA Section: 15.4.1.3 Array() + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + An array is created and returned as if by the + expression new Array(len). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.1.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Constructor Called as a Function: Array()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + + array[item++] = new TestCase( SECTION, + "MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()", + "[object Array]", + eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") ); + + array[item++] = new TestCase( SECTION, + "(Array()).length", + 0, ( + Array()).length ); + + array[item++] = new TestCase( SECTION, + "Array().toString()", + "", + Array().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/Array/15.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.js new file mode 100644 index 0000000..5640584 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.1.js @@ -0,0 +1,133 @@ +/* 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.4.1.js + ECMA Section: 15.4.1 The Array Constructor Called as a Function + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "Array() +''", + "", + Array() +"" ); + + array[item++] = new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(); arr.toString == Array.prototype.toString") ); + + array[item++] = new TestCase( SECTION, + "Array().length", + 0, + Array().length ); + + + array[item++] = new TestCase( SECTION, + "Array(1,2,3) +''", + "1,2,3", + Array(1,2,3) +"" ); + + array[item++] = new TestCase( SECTION, + "typeof Array(1,2,3)", + "object", + typeof Array(1,2,3) ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); + + array[item++] = new TestCase( SECTION, + "Array(1,2,3).length", + 3, + Array(1,2,3).length ); + + array[item++] = new TestCase( SECTION, + "typeof Array(12345)", + "object", + typeof Array(12345) ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); + + array[item++] = new TestCase( SECTION, + "Array(12345).length", + 12345, + Array(12345).length ); + + 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/Array/15.4.2.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-1.js new file mode 100644 index 0000000..4c1c0c6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-1.js @@ -0,0 +1,92 @@ +/* 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.4.2.1-1.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + This file tests the typeof the newly constructed object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new Array(1,2)", "object", typeof new Array(1,2) ); + array[item++] = new TestCase( SECTION, "(new Array(1,2)).toString", Array.prototype.toString, (new Array(1,2)).toString ); + array[item++] = new TestCase( SECTION, + "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, "(new Array(1,2)).length", 2, (new Array(1,2)).length ); + array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[0]", 1, eval("var arr = (new Array(1,2)); arr[0]") ); + array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[1]", 2, eval("var arr = (new Array(1,2)); arr[1]") ); + array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); String(arr)", "1,2", eval("var arr = (new Array(1,2)); String(arr)") ); + + 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/Array/15.4.2.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-2.js new file mode 100644 index 0000000..d5a65de --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-2.js @@ -0,0 +1,83 @@ +/* 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.4.2.1-2.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + + var TEST_STRING = "new Array("; + var ARGUMENTS = "" + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); + + for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; + } + + TEST_STRING += ARGUMENTS + ")"; + + TEST_ARRAY = eval( TEST_STRING ); + + for ( item = 0; item < TEST_LENGTH; item++ ) { + array[item] = new TestCase( SECTION, "["+item+"]", item, TEST_ARRAY[item] ); + } + + array[item++ ] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-3.js new file mode 100644 index 0000000..b299183 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.1-3.js @@ -0,0 +1,112 @@ +/* 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.4.2.1-3.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + This test stresses the number of arguments presented to + the Array constructor. Should support up to Math.pow + (2,32) arguments, since that is the maximum length of an + ECMAScript array. + + ***Change TEST_LENGTH to Math.pow(2,32) when larger array + lengths are supported. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + + var TEST_STRING = "new Array("; + var ARGUMENTS = "" + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); + + for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; + } + + TEST_STRING += ARGUMENTS + ")"; + + TEST_ARRAY = eval( TEST_STRING ); + + for ( item = 0; item < TEST_LENGTH; item++ ) { + array[item] = new TestCase( SECTION, "TEST_ARRAY["+item+"]", item, TEST_ARRAY[item] ); + } + + array[item++] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.toString", Array.prototype.toString, TEST_ARRAY.toString ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.join", Array.prototype.join, TEST_ARRAY.join ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.sort", Array.prototype.sort, TEST_ARRAY.sort ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.reverse", Array.prototype.reverse, TEST_ARRAY.reverse ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.length", TEST_LENGTH, TEST_ARRAY.length ); + array[item++] = new TestCase( SECTION, + "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", + "[object Array]", + eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.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/Array/15.4.2.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.2-1.js new file mode 100644 index 0000000..a2e41ef --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.2-1.js @@ -0,0 +1,124 @@ +/* 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.4.2.2-1.js + ECMA Section: 15.4.2.2 new Array(len) + + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). + + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. + + This file tests cases where len is a number. + + The cases in this test need to be updated since the + ToUint32 description has changed. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( len )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "new Array(0)", "", (new Array(0)).toString() ); + array[item++] = new TestCase( SECTION, "typeof new Array(0)", "object", (typeof new Array(0)) ); + array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length ); + array[item++] = new TestCase( SECTION, "(new Array(0)).toString", Array.prototype.toString, (new Array(0)).toString ); + + array[item++] = new TestCase( SECTION, "new Array(1)", "", (new Array(1)).toString() ); + array[item++] = new TestCase( SECTION, "new Array(1).length", 1, (new Array(1)).length ); + array[item++] = new TestCase( SECTION, "(new Array(1)).toString", Array.prototype.toString, (new Array(1)).toString ); + + array[item++] = new TestCase( SECTION, "(new Array(-0)).length", 0, (new Array(-0)).length ); + array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length ); + + array[item++] = new TestCase( SECTION, "(new Array(10)).length", 10, (new Array(10)).length ); + array[item++] = new TestCase( SECTION, "(new Array('1')).length", 1, (new Array('1')).length ); + array[item++] = new TestCase( SECTION, "(new Array(1000)).length", 1000, (new Array(1000)).length ); + array[item++] = new TestCase( SECTION, "(new Array('1000')).length", 1, (new Array('1000')).length ); + + array[item++] = new TestCase( SECTION, "(new Array(4294967295)).length", ToUint32(4294967295), (new Array(4294967295)).length ); + + array[item++] = new TestCase( SECTION, "(new Array('8589934592')).length", 1, (new Array("8589934592")).length ); + array[item++] = new TestCase( SECTION, "(new Array('4294967296')).length", 1, (new Array("4294967296")).length ); + array[item++] = new TestCase( SECTION, "(new Array(1073741824)).length", ToUint32(1073741824), (new Array(1073741824)).length ); + + 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 ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.2-2.js new file mode 100644 index 0000000..c360702 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.2-2.js @@ -0,0 +1,89 @@ +/* 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.4.2.2-2.js + ECMA Section: 15.4.2.2 new Array(len) + + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). + + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. + + This file tests length of the newly constructed array + when len is not a number. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( len )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "(new Array(new Number(1073741823))).length", 1, (new Array(new Number(1073741823))).length ); + array[item++] = new TestCase( SECTION, "(new Array(new Number(0))).length", 1, (new Array(new Number(0))).length ); + array[item++] = new TestCase( SECTION, "(new Array(new Number(1000))).length", 1, (new Array(new Number(1000))).length ); + array[item++] = new TestCase( SECTION, "(new Array('mozilla, larryzilla, curlyzilla')).length", 1, (new Array('mozilla, larryzilla, curlyzilla')).length ); + array[item++] = new TestCase( SECTION, "(new Array(true)).length", 1, (new Array(true)).length ); + array[item++] = new TestCase( SECTION, "(new Array(false)).length", 1, (new Array(false)).length); + array[item++] = new TestCase( SECTION, "(new Array(new Boolean(true)).length", 1, (new Array(new Boolean(true))).length ); + array[item++] = new TestCase( SECTION, "(new Array(new Boolean(false)).length", 1, (new Array(new Boolean(false))).length ); + 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/Array/15.4.2.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.3.js new file mode 100644 index 0000000..2ddd31b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.2.3.js @@ -0,0 +1,74 @@ +/* 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.4.2.3.js + ECMA Section: 15.4.2.3 new Array() + Description: The [[Prototype]] property of the newly constructed + object is set to the origianl Array prototype object, + the one that is the initial value of Array.prototype. + The [[Class]] property of the new object is set to + "Array". The length of the object is set to 0. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.2.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "new Array() +''", "", (new Array()) +"" ); + array[item++] = new TestCase( SECTION, "typeof new Array()", "object", (typeof new Array()) ); + array[item++] = new TestCase( SECTION, + "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, "(new Array()).length", 0, (new Array()).length ); + array[item++] = new TestCase( SECTION, "(new Array()).toString == Array.prototype.toString", true, (new Array()).toString == Array.prototype.toString ); + array[item++] = new TestCase( SECTION, "(new Array()).join == Array.prototype.join", true, (new Array()).join == Array.prototype.join ); + array[item++] = new TestCase( SECTION, "(new Array()).reverse == Array.prototype.reverse", true, (new Array()).reverse == Array.prototype.reverse ); + array[item++] = new TestCase( SECTION, "(new Array()).sort == Array.prototype.sort", true, (new Array()).sort == Array.prototype.sort ); + + 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/Array/15.4.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.3.1-2.js new file mode 100644 index 0000000..994ce5e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.3.1-2.js @@ -0,0 +1,66 @@ +/* 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.4.3.1-1.js + ECMA Section: 15.4.3.1 Array.prototype + Description: The initial value of Array.prototype is the built-in + Array prototype object (15.4.4). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + var ARRAY_PROTO = Array.prototype; + + array[item++] = new TestCase( SECTION, "var props = ''; for ( p in Array ) { props += p } props", "", eval("var props = ''; for ( p in Array ) { props += p } props") ); + + array[item++] = new TestCase( SECTION, "Array.prototype = null; Array.prototype", ARRAY_PROTO, eval("Array.prototype = null; Array.prototype") ); + + array[item++] = new TestCase( SECTION, "delete Array.prototype", false, delete Array.prototype ); + array[item++] = new TestCase( SECTION, "delete Array.prototype; Array.prototype", ARRAY_PROTO, eval("delete Array.prototype; Array.prototype") ); + + 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/Array/15.4.3.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.3.2.js new file mode 100644 index 0000000..43c2b4c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.3.2.js @@ -0,0 +1,57 @@ +/* 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.4.3.2.js + ECMA Section: 15.4.3.2 Array.length + Description: The length property is 1. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.3.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Array.length", 1, Array.length ); + 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/Array/15.4.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.3.js new file mode 100644 index 0000000..b44c6cb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.3.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.4.3.js + ECMA Section: 15.4.3 Properties of the Array Constructor + Description: The value of the internal [[Prototype]] property of the + Array constructor is the Function prototype object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Array Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); + + 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/Array/15.4.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.1.js new file mode 100644 index 0000000..4b46136 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.1.js @@ -0,0 +1,57 @@ +/* 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.4.4.1.js + ECMA Section: 15.4.4.1 Array.prototype.constructor + Description: The initial value of Array.prototype.constructor + is the built-in Array constructor. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Array.prototype.constructor == Array", true, Array.prototype.constructor == Array); + 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/Array/15.4.4.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.2.js new file mode 100644 index 0000000..9565798 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.2.js @@ -0,0 +1,83 @@ +/* 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.4.4.2.js + ECMA Section: 15.4.4.2 Array.prototype.toString() + Description: The elements of this object are converted to strings + and these strings are then concatenated, separated by + comma characters. The result is the same as if the + built-in join method were invoiked for this object + with no argument. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Array.prototype.toString.length", 0, Array.prototype.toString.length ); + + array[item++] = new TestCase( SECTION, "(new Array()).toString()", "", (new Array()).toString() ); + array[item++] = new TestCase( SECTION, "(new Array(2)).toString()", ",", (new Array(2)).toString() ); + array[item++] = new TestCase( SECTION, "(new Array(0,1)).toString()", "0,1", (new Array(0,1)).toString() ); + array[item++] = new TestCase( SECTION, "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", "NaN,Infinity,-Infinity", (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); + + array[item++] = new TestCase( SECTION, "(new Array( Boolean(1), Boolean(0))).toString()", "true,false", (new Array(Boolean(1),Boolean(0))).toString() ); + array[item++] = new TestCase( SECTION, "(new Array(void 0,null)).toString()", ",", (new Array(void 0,null)).toString() ); + + var EXPECT_STRING = ""; + var MYARR = new Array(); + + for ( var i = -50; i < 50; i+= 0.25 ) { + MYARR[MYARR.length] = i; + EXPECT_STRING += i +","; + } + + EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); + + array[item++] = new TestCase( SECTION, "MYARR.toString()", EXPECT_STRING, MYARR.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/Array/15.4.4.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.3-1.js new file mode 100644 index 0000000..63ec5b0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.3-1.js @@ -0,0 +1,159 @@ +/* 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.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.join() + Description: The elements of this object are converted to strings and + these strings are then concatenated, separated by comma + characters. The result is the same as if the built-in join + method were invoiked for this object with no argument. + Author: christine@netscape.com, pschwartau@netscape.com + Date: 07 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285 + ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join() + Step 3: If |separator| is |undefined|, let |separator| + be the single-character string "," +* +*/ + + var SECTION = "15.4.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Array.prototype.join()"); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var ARR_PROTOTYPE = Array.prototype; + + array[item++] = new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length ); + array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length ); + array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") ); + + // case where array length is 0 + + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join()", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") ); + + // array length is 0, but spearator is specified + + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')") ); + + // length is greater than 0, separator is supplied + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')", + "&&true&false&123&[object Object]&true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')") ); + + // length is greater than 0, separator is empty string + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')", + "truefalse123[object Object]true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')") ); + // length is greater than 0, separator is undefined + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)") ); + + // length is greater than 0, separator is not supplied + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()") ); + + // separator is a control character + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')", + unescape("%u000B%u000Btrue%u000Bfalse%u000B123%u000B[object Object]%u000Btrue"), + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')") ); + + // length of array is 1 + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(true) ); TEST_ARRAY.join('\v')", + "true", + eval("var TEST_ARRAY = new Array(true); TEST_ARRAY.join('\v')") ); + + + SEPARATOR = "\t" + TEST_LENGTH = 100; + TEST_STRING = ""; + ARGUMENTS = ""; + TEST_RESULT = ""; + + for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += ( index == TEST_LENGTH -1 ) ? "" : ","; + + TEST_RESULT += index; + TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR; + } + + TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" ); + + array[item++] = new TestCase( SECTION, "TEST_ARRAY.join("+SEPARATOR+")", TEST_RESULT, TEST_ARRAY.join( SEPARATOR ) ); + + array[item++] = new TestCase( SECTION, "(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join()", + "true,false,,,1e+21,1e-7", + (new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join() ); + + // this is not an Array object + array[item++] = new TestCase( SECTION, + "var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')", + "true:false:111:0.5:1230000:NaN::", + eval("var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')") ); + + + + 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 Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.join; + this.getClass = Object.prototype.toString; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.4-1.js new file mode 100644 index 0000000..c8e7422 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.4-1.js @@ -0,0 +1,272 @@ +/* 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.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 3. Compute floor(Result(2)/2). + 4. Let k be 0. + 5. If k equals Result(3), return this object. + 6. Compute Result(2)k1. + 7. Call ToString(k). + 8. ToString(Result(6)). + 9. Call the [[Get]] method of this object with argument Result(7). + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. + +Note that the reverse function is intentionally generic; it does not require +that its this value be an Array object. Therefore it can be transferred to other +kinds of objects for use as a method. Whether the reverse function can be applied +successfully to a host object is implementation dependent. + + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.4.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="123724"; + + writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var ARR_PROTOTYPE = Array.prototype; + + testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); + + // length of array is 0 + testcases[testcases.length] = new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + + // length of array is 1 + var A = new Array(true); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + "var A = new Array(true); A.reverse(); A.length", + R.length, + eval("var A = new Array(true); A.reverse(); A.length") ); + CheckItems( R, A ); + + // length of array is 2 + var S = "var A = new Array( true,false )"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( + SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + + CheckItems( R, A ); + + // length of array is 3 + var S = "var A = new Array( true,false,null )"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + // length of array is 4 + var S = "var A = new Array( true,false,null,void 0 )"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + + // some array indexes have not been set + var S = "var A = new Array(); A[8] = 'hi', A[3] = 'yo'"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + + var OBJECT_OBJECT = new Object(); + var FUNCTION_OBJECT = new Function( 'return this' ); + var BOOLEAN_OBJECT = new Boolean; + var DATE_OBJECT = new Date(0); + var STRING_OBJECT = new String('howdy'); + var NUMBER_OBJECT = new Number(Math.PI); + var ARRAY_OBJECT= new Array(1000); + + var args = "null, void 0, Math.pow(2,32), 1.234e-32, OBJECT_OBJECT, BOOLEAN_OBJECT, FUNCTION_OBJECT, DATE_OBJECT, STRING_OBJECT,"+ + "ARRAY_OBJECT, NUMBER_OBJECT, Math, true, false, 123, '90210'"; + + var S = "var A = new Array("+args+")"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + var limit = 1000; + var args = ""; + for (var i = 0; i < limit; i++ ) { + args += i +""; + if ( i + 1 < limit ) { + args += ","; + } + } + + var S = "var A = new Array("+args+")"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + var S = "var MYOBJECT = new Object_1( \"void 0, 1, null, 2, \'\'\" )"; + eval(S); + var R = Reverse( A ); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + return ( testcases ); +} +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} +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 Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} +function Reverse( array ) { + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { + return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; +} +function Iterate( array ) { + for ( var i = 0; i < array.length; i++ ) { +// print( i+": "+ array[String(i)] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.4-2.js new file mode 100644 index 0000000..1d0d850 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.4-2.js @@ -0,0 +1,163 @@ +/* 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.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 3. Compute floor(Result(2)/2). + 4. Let k be 0. + 5. If k equals Result(3), return this object. + 6. Compute Result(2)k1. + 7. Call ToString(k). + 8. ToString(Result(6)). + 9. Call the [[Get]] method of this object with argument Result(7). + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. + +Note that the reverse function is intentionally generic; it does not require +that its this value be an Array object. Therefore it can be transferred to other +kinds of objects for use as a method. Whether the reverse function can be applied +successfully to a host object is implementation dependent. + + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = new Array(); + + writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + + getTestCases(); + test(); + +function getTestCases() { + var ARR_PROTOTYPE = Array.prototype; + + testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); + + // length of array is 0 + testcases[testcases.length] = new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + return ( testcases ); +} +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} +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 Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} +function Reverse( array ) { + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { + return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; +} +function Iterate( array ) { + for ( var i = 0; i < array.length; i++ ) { +// print( i+": "+ array[String(i)] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-1.js new file mode 100644 index 0000000..0a759c3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-1.js @@ -0,0 +1,223 @@ +/* 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.4.4.5.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This test file tests cases in which the compare function is not supplied. + + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. + + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. + +Note that, because undefined always compared greater than any other value, undefined and nonexistent +property values always sort to the end of the result. It is implementation-dependent whether or not such +properties will exist or not at the end of the array when the sort is concluded. + +Note that the sort function is intentionally generic; it does not require that its this value be an Array object. +Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be +applied successfully to a host object is implementation dependent . + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.4.4.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.sort(comparefn)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + getTestCases(); + 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 ); +} +function getTestCases() { + var S = new Array(); + var item = 0; + + // array is empty. + S[item++] = "var A = new Array()"; + + // array contains one item + S[item++] = "var A = new Array( true )"; + + // length of array is 2 + S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + + S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + + S[item] = "var A = new Array( "; + + var limit = 0x0061; + for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } + } + + S[item] += ")"; + + item++; + + for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); + } +} +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.sort(); A.length", + E.length, + eval( S + "; A.sort(); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + testcases[testcases.length] = new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); + } + } +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; +} +function Sort( a ) { + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } + } + } + return a; +} +function Compare( x, y ) { + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return -1; + } + if ( x > y ) { + return 1; + } + return 0; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-2.js new file mode 100644 index 0000000..23e1eac --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-2.js @@ -0,0 +1,224 @@ +/* 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.4.4.5-2.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This test file tests cases in which the compare function is supplied. + In this cases, the sort creates a reverse sort. + + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. + + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. + +Note that, because undefined always compared greater than any other value, undefined and nonexistent +property values always sort to the end of the result. It is implementation-dependent whether or not such +properties will exist or not at the end of the array when the sort is concluded. + +Note that the sort function is intentionally generic; it does not require that its this value be an Array object. +Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be +applied successfully to a host object is implementation dependent . + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.4.4.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.sort(comparefn)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + getTestCases(); + 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 ); +} +function getTestCases() { + var S = new Array(); + var item = 0; + + // array is empty. + S[item++] = "var A = new Array()"; + + // array contains one item + S[item++] = "var A = new Array( true )"; + + // length of array is 2 + S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + + S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + + S[item] = "var A = new Array( "; + + var limit = 0x0061; + for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } + } + + S[item] += ")"; + + for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); + } + +} +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.sort(Compare); A.length", + E.length, + eval( S + "; A.sort(Compare); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + testcases[testcases.length] = new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); + } + } +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; +} +function Sort( a ) { + var r1 = a.length; + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } + } + } + return a; +} +function Compare( x, y ) { + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return 1; + } + if ( x > y ) { + return -1; + } + return 0; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-3.js new file mode 100644 index 0000000..47bbe5d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.5-3.js @@ -0,0 +1,181 @@ +/* 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.4.4.5-3.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This is a regression test for + http://scopus/bugsplat/show_bug.cgi?id=117144 + + Verify that sort is successfull, even if the sort compare function returns + a very large negative or positive value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.4.4.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.sort(comparefn)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + var array = new Array(); + + array[array.length] = new Date( TIME_2000 * Math.PI ); + array[array.length] = new Date( TIME_2000 * 10 ); + array[array.length] = new Date( TIME_1900 + TIME_1900 ); + array[array.length] = new Date(0); + array[array.length] = new Date( TIME_2000 ); + array[array.length] = new Date( TIME_1900 + TIME_1900 +TIME_1900 ); + array[array.length] = new Date( TIME_1900 * Math.PI ); + array[array.length] = new Date( TIME_1900 * 10 ); + array[array.length] = new Date( TIME_1900 ); + array[array.length] = new Date( TIME_2000 + TIME_2000 ); + array[array.length] = new Date( 1899, 0, 1 ); + array[array.length] = new Date( 2000, 1, 29 ); + array[array.length] = new Date( 2000, 0, 1 ); + array[array.length] = new Date( 1999, 11, 31 ); + + var testarr1 = new Array() + clone( array, testarr1 ); + testarr1.sort( comparefn1 ); + + var testarr2 = new Array() + clone( array, testarr2 ); + testarr2.sort( comparefn2 ); + + testarr3 = new Array(); + clone( array, testarr3 ); + testarr3.sort( comparefn3 ); + + // when there's no sort function, sort sorts by the toString value of Date. + + var testarr4 = new Array() + clone( array, testarr4 ); + testarr4.sort(); + + var realarr = new Array(); + clone( array, realarr ); + realarr.sort( realsort ); + + var stringarr = new Array(); + clone( array, stringarr ); + stringarr.sort( stringsort ); + + for ( var i = 0, tc = 0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr1["+i+"]", + realarr[i], + testarr1[i] ); + } + + for ( var i=0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr2["+i+"]", + realarr[i], + testarr2[i] ); + } + + for ( var i=0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr3["+i+"]", + realarr[i], + testarr3[i] ); + } + + for ( var i=0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr4["+i+"]", + stringarr[i].toString(), + testarr4[i].toString() ); + } + +} +function comparefn1( x, y ) { + return x - y; +} +function comparefn2( x, y ) { + return x.valueOf() - y.valueOf(); +} +function realsort( x, y ) { + return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) ); +} +function comparefn3( x, y ) { + return ( +x == +y ? 0 : ( x > y ? 1 : -1 ) ); +} +function clone( source, target ) { + for (i = 0; i < source.length; i++ ) { + target[i] = source[i]; + } +} +function stringsort( x, y ) { + for ( var i = 0; i < x.toString().length; i++ ) { + var d = (x.toString()).charCodeAt(i) - (y.toString()).charCodeAt(i); + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } else { + continue; + } + } + + var d = x.length - y.length; + + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } + } + } + return 0; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.js new file mode 100644 index 0000000..4197dfb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.4.js @@ -0,0 +1,77 @@ +/* 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.4.4.js + ECMA Section: 15.4.4 Properties of the Array Prototype Object + Description: The value of the internal [[Prototype]] property of + the Array prototype object is the Object prototype + object. + + Note that the Array prototype object is itself an + array; it has a length property (whose initial value + is (0) and the special [[Put]] method. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Array Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// these testcases are ECMA_2 +// array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); +// array[item++] = new TestCase( SECTION, "Array.__proto__.valueOf == Object.__proto__.valueOf", true, (Array.__proto__.valueOf == Object.__proto__.valueOf) ); + + array[item++] = new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length ); + +// verify that prototype object is an Array object. + array[item++] = new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype ); + + array[item++] = new TestCase( SECTION, + "Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()", + "[object Array]", + eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.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/Array/15.4.5.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.1-1.js new file mode 100644 index 0000000..e57408b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.1-1.js @@ -0,0 +1,172 @@ +/* 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.4.5.1-1.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). + + Assume A is an Array object and P is a string. + + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: + + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.4.5.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array [[Put]] (P, V)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + + var item = 0; + + // P is "length" + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 1000; A.length", + 1000, + eval("var A = new Array(); A.length = 1000; A.length") ); + + // A has Property P, and P is not length or an array index + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.name", + 'name of this array', + eval("var A = new Array(1000); A.name = 'name of this array'; A.name") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.length", + 1000, + eval("var A = new Array(1000); A.name = 'name of this array'; A.length") ); + + + // A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the + // value of length + + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A[123]", + 'hola', + eval("var A = new Array(1000); A[123] = 'hola'; A[123]") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A.length", + 1000, + eval("var A = new Array(1000); A[123] = 'hola'; A.length") ); + + + for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) { + TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'"; + if ( i < 0x00FF - 1 ) { + TEST_STRING += ","; + } else { + TEST_STRING += ");" + } + } + + var LENGTH = 0x00ff - 0x0020; + + array[item++] = new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + 'hello', + eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) ); + + array[item++] = new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + LENGTH, + eval( TEST_STRING + " A[150] = 'hello'; A.length" ) ); + + // A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the + // value of length + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A[123] = true; A.length", + 124, + eval("var A = new Array(); A[123] = true; A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length", + 16, + eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") ); + + for ( var i = 0; i < A.length; i++, item++ ) { + array[item] = new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]", + (i <= 10) ? i : ( i == 15 ? '15' : void 0 ), + A[i] ); + } + // P is not an array index, and P is not "length" + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.join.length", + 1, + eval("var A = new Array(); A.join.length = 4; A.join.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.length", + 0, + eval("var A = new Array(); A.join.length = 4; A.length") ); + + 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/Array/15.4.5.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.1-2.js new file mode 100644 index 0000000..08b4721 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.1-2.js @@ -0,0 +1,150 @@ +/* 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.4.5.1-2.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). + + Assume A is an Array object and P is a string. + + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: + + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + + + These are testcases from Waldemar, detailed in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552 + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "15.4.5.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array [[Put]] (P,V)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var a = new Array(); + + AddCase( "3.00", "three" ); + AddCase( "00010", "eight" ); + AddCase( "37xyz", "thirty-five" ); + AddCase("5000000000", 5) + AddCase( "-2", -3 ); + + testcases[tc++] = new TestCase( SECTION, + "a[10]", + void 0, + a[10] ); + + testcases[tc++] = new TestCase( SECTION, + "a[3]", + void 0, + a[3] ); + + a[4] = "four"; + + testcases[tc++] = new TestCase( SECTION, + "a[4] = \"four\"; a[4]", + "four", + a[4] ); + + testcases[tc++] = new TestCase( SECTION, + "a[\"4\"]", + "four", + a["4"] ); + + testcases[tc++] = new TestCase( SECTION, + "a[\"4.00\"]", + void 0, + a["4.00"] ); + + testcases[tc++] = new TestCase( SECTION, + "a.length", + 5, + a.length ); + + + a["5000000000"] = 5; + + testcases[tc++] = new TestCase( SECTION, + "a[\"5000000000\"] = 5; a.length", + 5, + a.length ); + + testcases[tc++] = new TestCase( SECTION, + "a[\"-2\"] = -3; a.length", + 5, + a.length ); + + test(); + +function AddCase ( arg, value ) { + + a[arg] = value; + + testcases[tc++] = new TestCase( SECTION, + "a[\"" + arg + "\"] = "+ value +"; a.length", + 0, + a.length ); +} + + +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/Array/15.4.5.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.2-1.js new file mode 100644 index 0000000..069ae57 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.2-1.js @@ -0,0 +1,93 @@ +/* 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.4.5.2-1.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.4.5.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length", + 0, + eval("var A = new Array(); A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length", + Math.pow(2,32)-1, + eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; A.length", + 123, + eval("var A = new Array(); A.length = 123; A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS", + "", + eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") ); + + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length", + false , + eval("var A = new Array(); A.length = 123; delete A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length; A.length", + 123, + eval("var A = new Array(); A.length = 123; delete A.length; A.length") ); + 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/Array/15.4.5.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.2-2.js new file mode 100644 index 0000000..9d65b2c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Array/15.4.5.2-2.js @@ -0,0 +1,123 @@ +/* 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.4.5.2-2.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + + This test verifies that the Array.length property is not Read Only. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.4.5.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) ); + + addCase( new Array(), 0, 1, 1 ); + + addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 ); + addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) ); + addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) ); + addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) ) + + // some tests where array is not empty + // array is populated with strings + for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) { + arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" ); + + } +// print(i +":"+arg); + + var a = eval( "new Array("+arg+")" ); + + addCase( a, i, i, i ); + addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true ); + addCase( a, Math.pow(2,12)+5, 0, 0, true ); + + test(); + +function addCase( object, old_len, set_len, new_len, checkitems ) { + object.length = set_len; + + testcases[testcases.length] = new TestCase( SECTION, + "array = new Array("+ old_len+"); array.length = " + set_len + + "; array.length", + new_len, + object.length ); + + if ( checkitems ) { + // verify that items between old and newlen are all undefined + if ( new_len < old_len ) { + var passed = true; + for ( var i = new_len; i < old_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + testcases[testcases.length] = new TestCase( SECTION, + "verify that array items have been deleted", + true, + passed ); + } + if ( new_len > old_len ) { + var passed = true; + for ( var i = old_len; i < new_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + testcases[testcases.length] = new TestCase( SECTION, + "verify that new items are undefined", + true, + passed ); + } + } + +} + +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/Boolean/15.6.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.1.js new file mode 100644 index 0000000..762b06d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.1.js @@ -0,0 +1,96 @@ +/* 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.6.1.js + ECMA Section: 15.6.1 The Boolean Function + 15.6.1.1 Boolean( value ) + 15.6.1.2 Boolean () + Description: Boolean( value ) should return a Boolean value + not a Boolean object) computed by + Boolean.toBooleanValue( value) + + 15.6.1.2 Boolean() returns false + + Author: christine@netscape.com + Date: 27 jun 1997 + + + Data File Fields: + VALUE Argument passed to the Boolean function + TYPE typeof VALUE (not used, but helpful in understanding + the data file) + E_RETURN Expected return value of Boolean( VALUE ) +*/ + var SECTION = "15.6.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); + array[item++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); + array[item++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); + array[item++] = new TestCase( SECTION, "Boolean('1')", true, Boolean("1") ); + array[item++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); + array[item++] = new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") ); + array[item++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); + array[item++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); + + array[item++] = new TestCase( SECTION, "Boolean('true')", true, Boolean("true") ); + array[item++] = new TestCase( SECTION, "Boolean('false')", true, Boolean("false") ); + array[item++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); + + array[item++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) ); + array[item++] = new TestCase( SECTION, "Boolean()", false, Boolean() ); +// array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) ); + + 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/Boolean/15.6.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.2.js new file mode 100644 index 0000000..2d4e142 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.2.js @@ -0,0 +1,160 @@ +/* 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.6.2.js + ECMA Section: 15.6.2 The Boolean Constructor + 15.6.2.1 new Boolean( value ) + 15.6.2.2 new Boolean() + + This test verifies that the Boolean constructor + initializes a new object (typeof should return + "object"). The prototype of the new object should + be Boolean.prototype. The value of the object + should be ToBoolean( value ) (a boolean value). + + Description: + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) ); + array[item++] = new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) ); + array[item++] = new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) ); + array[item++] = new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) ); + array[item++] = new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') ); + array[item++] = new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') ); + array[item++] = new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') ); + array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) ); + array[item++] = new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) ); + array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); + array[item++] = new TestCase( "15.6.2.2", + "TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() ); + array[item++] = new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() ); + + 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/Boolean/15.6.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-1.js new file mode 100644 index 0000000..c3897e4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-1.js @@ -0,0 +1,72 @@ +/* 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.6.3.1-1.js + ECMA Section: 15.6.3 Boolean.prototype + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontEnum property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var str='';for ( p in Boolean ) { str += p } str;", + "", + eval("var str='';for ( p in Boolean ) { 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-2.js new file mode 100644 index 0000000..0ff248a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-2.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.6.3.1-2.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "delete( Boolean.prototype)", + false, + delete( Boolean.prototype) ); + 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/Boolean/15.6.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-3.js new file mode 100644 index 0000000..5ba5c95 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.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.6.3.1-3.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "delete( Boolean.prototype); Boolean.prototype", + Boolean.prototype, + eval("delete( Boolean.prototype); Boolean.prototype") ); + 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/Boolean/15.6.3.1-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-4.js new file mode 100644 index 0000000..56972e8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-4.js @@ -0,0 +1,79 @@ +/* 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.6.3.1-4.js + ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the ReadOnly property of Boolean.prototype + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + var SECTION = "15.6.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var BOOL_PROTO = Boolean.prototype; + + array[item++] = new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO", + true, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") ); + + array[item++] = new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null", + false, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") ); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-5.js new file mode 100644 index 0000000..fb3605c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1-5.js @@ -0,0 +1,61 @@ +/* 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.6.3.1-5.js + ECMA Section: 15.6.3.1 Boolean.prototype + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var VERSION = "ECMA_2"; + startTest(); + var SECTION = "15.6.3.1-5"; + var TITLE = "Boolean.prototype" + + writeHeaderToLog( SECTION + " " + TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ ); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1.js new file mode 100644 index 0000000..55614f5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.1.js @@ -0,0 +1,72 @@ +/* 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.6.3.1.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + It has the internal [[Call]] and [[Construct]] + properties (not tested), and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + + var SECTION = "15.6.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); + array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + + 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/Boolean/15.6.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.js new file mode 100644 index 0000000..0e9a252 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.3.js @@ -0,0 +1,67 @@ +/* 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.6.3.js + ECMA Section: 15.6.3 Properties of the Boolean Constructor + + Description: The value of the internal prototype property is + the Function prototype object. + + It has the internal [[Call]] and [[Construct]] + properties, and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Boolean Constructor" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype ); + array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4-1.js new file mode 100644 index 0000000..e40d71a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4-1.js @@ -0,0 +1,73 @@ +/* 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.6.4-1.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + + var VERSION = "ECMA_1" + startTest(); + var SECTION = "15.6.4-1"; + + writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) ); + array[item++] = new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) ); + array[item++] = new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); + array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.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/Boolean/15.6.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4-2.js new file mode 100644 index 0000000..760272e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4-2.js @@ -0,0 +1,67 @@ +/* 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.6.4-2.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + + var VERSION = "ECMA_2" + startTest(); + var SECTION = "15.6.4-2"; + + writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + + 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/Boolean/15.6.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.1.js new file mode 100644 index 0000000..848b1f4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.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.6.4.1.js + ECMA Section: 15.6.4.1 Boolean.prototype.constructor + + Description: The initial value of Boolean.prototype.constructor + is the built-in Boolean constructor. + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + var SECTION = "15.6.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.constructor" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "( Boolean.prototype.constructor == Boolean )", + true , + (Boolean.prototype.constructor == Boolean) ); + + 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/Boolean/15.6.4.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-1.js new file mode 100644 index 0000000..85514fd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-1.js @@ -0,0 +1,97 @@ +/* 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.6.4.2.js + ECMA Section: 15.6.4.2-1 Boolean.prototype.toString() + Description: If this boolean value is true, then the string "true" + is returned; otherwise this boolean value must be false, + and the string "false" is returned. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() ); + + array[item++] = new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() ); + + array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).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" ); + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-2.js new file mode 100644 index 0000000..d46c49b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-2.js @@ -0,0 +1,79 @@ +/* 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.6.4.2-2.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()", + "false", + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" ); + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()", + "true", + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()" ); + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()", + "false", + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" ); + return ( array ); + +} +function test() { + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-3.js new file mode 100644 index 0000000..faf0a94 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-3.js @@ -0,0 +1,67 @@ +/* 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.6.4.2-3.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + + var SECTION = "15.6.4.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") ); + array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") ); + + 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/Boolean/15.6.4.2-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-4-n.js new file mode 100644 index 0000000..a86ba51 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.2-4-n.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.6.4.2-4.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.2-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()"; + writeHeaderToLog( SECTION +" "+ TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()", + "error", + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()" ); + return ( array ); +} + +function test() { + 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/Boolean/15.6.4.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-1.js new file mode 100644 index 0000000..3589197 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-1.js @@ -0,0 +1,91 @@ +/* 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.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + + array[item++] = new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + + array[item++] = new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() ); + + array[item++] = new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).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/Boolean/15.6.4.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-2.js new file mode 100644 index 0000000..f1bc83d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-2.js @@ -0,0 +1,67 @@ +/* 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.6.4.3-2.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") ); + array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") ); + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-3.js new file mode 100644 index 0000000..f19c168 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-3.js @@ -0,0 +1,71 @@ +/* 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.6.4.3-3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()", + true, + eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js new file mode 100644 index 0000000..fe7b17c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js @@ -0,0 +1,71 @@ +/* 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.6.4.3-4.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + var SECTION = "15.6.4.3-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()", + "error", + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" ); + return ( array ); +} + +function test() { + 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/Boolean/15.6.4.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3.js new file mode 100644 index 0000000..67b9a1b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.3.js @@ -0,0 +1,97 @@ +/* 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.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + + array[item++] = new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + + array[item++] = new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() ); + + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + + return ( array ); +} + +function test( array ) { + var passed = true; + + writeHeaderToLog("15.8.6.4.3 Properties of the Boolean Object: valueOf"); + + for ( i = 0; i < array.length; i++ ) { + + array[i].passed = writeTestCaseResult( + array[i].expect, + array[i].actual, + "( "+ array[i].description +" ).valueOf() = "+ array[i].actual ); + + array[i].reason += ( array[i].passed ) ? "" : "wrong value "; + + passed = ( array[i].passed ) ? passed : false; + + } + + stopTest(); + + // all tests must return a boolean value + return ( array ); +} + +// for TCMS, the testcases array must be global. + var testcases = getTestCases(); + +// all tests must call a function that returns a boolean value + test( testcases ); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.js new file mode 100644 index 0000000..44d12c1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Boolean/15.6.4.js @@ -0,0 +1,77 @@ +/* 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.6.4.js + ECMA Section: Properties of the Boolean Prototype Object + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is " + Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Boolean + prototype object, the phrase "this Boolean object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Boolean". Also, the phrase "this boolean value" + refers to the boolean value represented by this Boolean object, that is, + the value of the internal [[Value]] property of this Boolean object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.6.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Boolean Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Boolean.prototype == false", + true, + Boolean.prototype == false ); + + testcases[tc++] = new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); + + test(); + +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/Date/15.9.1.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.1.1-1.js new file mode 100644 index 0000000..4d936af --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.1.1-1.js @@ -0,0 +1,87 @@ +/* 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.9.1.1-1.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + + - this test generates its own data -- it does not + read data from a file. + Author: christine@netscape.com + Date: 7 july 1997 + + Static variables: + FOUR_HUNDRED_YEARS + +*/ + +function test() { + writeHeaderToLog("15.8.1.1 Time Range"); + + for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS < 8640000000000000; + tc++, M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) { + + testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS)).getUTCFullYear() ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + if ( ! testcases[tc].passed ) { + testcases[tc].reason = "wrong year value"; + } + } + + stopTest(); + + return ( testcases ); +} + +// every one hundred years contains: +// 24 years with 366 days +// +// every four hundred years contains: +// 97 years with 366 days +// 303 years with 365 days +// +// 86400000*365*97 = 3067372800000 +// +86400000*366*303 = + 9555408000000 +// = 1.26227808e+13 + var FOUR_HUNDRED_YEARS = 1.26227808e+13; + var SECTION = "15.9.1.1-1"; + var tc = 0; + var testcases = new Array(); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.1.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.1.1-2.js new file mode 100644 index 0000000..c66ce38 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.1.1-2.js @@ -0,0 +1,82 @@ +/* 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.9.1.1-2.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + Author: christine@netscape.com + Date: 9 july 1997 +*/ + +function test() { + + writeHeaderToLog("15.8.1.1 Time Range"); + + for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS > -8640000000000000; + tc++, M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) { + + testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS )).getUTCFullYear() ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description + " = " + + testcases[tc].actual ); + + if ( ! testcases[tc].passed ) { + testcases[tc].reason = "wrong year value"; + } + } + + stopTest(); + + return ( testcases ); +} + // every one hundred years contains: + // 24 years with 366 days + // + // every four hundred years contains: + // 97 years with 366 days + // 303 years with 365 days + // + // 86400000*366*97 = 3067372800000 + // +86400000*365*303 = + 9555408000000 + // = 1.26227808e+13 + + var FOUR_HUNDRED_YEARS = 1.26227808e+13; + var SECTION = "15.9.1.1-2"; + var tc = 0; + var testcases = new Array(); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.1.js new file mode 100644 index 0000000..3545806 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.1.js @@ -0,0 +1,108 @@ +/* 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.9.2.1.js + ECMA Section: 15.9.2.1 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds, ms ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.2.1"; + var TITLE = "Date Constructor used as a function"; + var TYPEOF = "string"; + var TOLERANCE = 1000; + + writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " + + "Date( year, month, date, hours, minutes, seconds, ms )" ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var TODAY = new Date(); + + // Dates around 1970 + + array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1)) + + // Dates around 2000 + array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0)); + array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) ); + + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0,0)); + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0,0)); + + 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/Date/15.9.2.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-1.js new file mode 100644 index 0000000..8ad5694 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-1.js @@ -0,0 +1,105 @@ +/* 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.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around 1970 + + array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,1)) +/* + // Dates around 2000 + array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); + array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); + array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); + + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + 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/Date/15.9.2.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-2.js new file mode 100644 index 0000000..5baaf53 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-2.js @@ -0,0 +1,99 @@ +/* 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.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around 2000 + array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); + array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); + array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); + +/* + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + 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/Date/15.9.2.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-3.js new file mode 100644 index 0000000..59255e2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-3.js @@ -0,0 +1,92 @@ +/* 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.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + +/* + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + 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/Date/15.9.2.2-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-4.js new file mode 100644 index 0000000..b63bb3e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-4.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.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + +/* + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + 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/Date/15.9.2.2-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-5.js new file mode 100644 index 0000000..5422682 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-5.js @@ -0,0 +1,78 @@ +/* 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.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +/* + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + 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/Date/15.9.2.2-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-6.js new file mode 100644 index 0000000..8e269d0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.2.2-6.js @@ -0,0 +1,72 @@ +/* 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.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); + + 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/Date/15.9.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-1.js new file mode 100644 index 0000000..3090055 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-1.js @@ -0,0 +1,274 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 1970 + + addNewTestCase( new Date( 1969,11,31,15,59,59,999), + "new Date( 1969,11,31,15,59,59,999)", + [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); + + addNewTestCase( new Date( 1969,11,31,23,59,59,999), + "new Date( 1969,11,31,23,59,59,999)", + [TIME_1970-TZ_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); + + addNewTestCase( new Date( 1970,0,1,0,0,0,0), + "new Date( 1970,0,1,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date( 1969,11,31,16,0,0,0), + "new Date( 1969,11,31,16,0,0,0)", + [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date(1969,12,1,0,0,0,0), + "new Date(1969,12,1,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,32,0,0,0,0), + "new Date(1969,11,32,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,24,0,0,0), + "new Date(1969,11,31,24,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,23,60,0,0), + "new Date(1969,11,31,23,60,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,23,59,60,0), + "new Date(1969,11,31,23,59,60,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,23,59,59,1000), + "new Date(1969,11,31,23,59,59,1000)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); + + // Dates around 29 Feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + + +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 ); + } + stopTest(); + return testcases; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-2.js new file mode 100644 index 0000000..13d0ab6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-2.js @@ -0,0 +1,231 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); +/* + // Dates around 29 Feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + return testcases; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-3.js new file mode 100644 index 0000000..ced3027 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-3.js @@ -0,0 +1,209 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 29 Feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +/* + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + return testcases; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-4.js new file mode 100644 index 0000000..0f18b12 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-4.js @@ -0,0 +1,193 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +/* + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + return testcases; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-5.js new file mode 100644 index 0000000..0b7d436 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.1-5.js @@ -0,0 +1,170 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + return testcases; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-1.js new file mode 100644 index 0000000..718d314 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-1.js @@ -0,0 +1,241 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around 1970 + + addNewTestCase( new Date( 1969,11,31,15,59,59), + "new Date( 1969,11,31,15,59,59)", + [-1000,1969,11,31,3,23,59,59,0,1969,11,31,3,15,59,59,0] ); + + addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( 1969,11,31,23,59,59), + "new Date( 1969,11,31,23,59,59)", + [28799000,1970,0,1,4,7,59,59,0,1969,11,31,3,23,59,59,0] ); + + addNewTestCase( new Date( 1970, 0, 1, 0, 0, 0), + "new Date( 1970, 0, 1, 0, 0, 0)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +/* + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59), + "new Date( 1999,11,31,15,59,59)", + [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0), + "new Date( 1999,11,31,16,0,0)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0), + "new Date( 2000,0,1,0,0,0)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); + + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +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 ); + } + stopTest(); + return testcases; +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-2.js new file mode 100644 index 0000000..b110f52 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-2.js @@ -0,0 +1,219 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59), + "new Date( 1999,11,31,15,59,59)", + [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0), + "new Date( 1999,11,31,16,0,0)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0), + "new Date( 2000,0,1,0,0,0)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +/* + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); + + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +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 ); + } + stopTest(); + return testcases; +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-3.js new file mode 100644 index 0000000..9e57730 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-3.js @@ -0,0 +1,205 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); +/* + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +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 ); + } + stopTest(); + return testcases; +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-4.js new file mode 100644 index 0000000..6b6b0c4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-4.js @@ -0,0 +1,188 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); +/* + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +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 ); + } + stopTest(); + return testcases; +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-5.js new file mode 100644 index 0000000..798320b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.2-5.js @@ -0,0 +1,170 @@ +/* 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.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +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 ); + } + stopTest(); + return testcases; +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-1.js new file mode 100644 index 0000000..644f37c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-1.js @@ -0,0 +1,300 @@ +/* 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.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + + // Dates around 1970 + addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date(1), + "new Date(1)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); + + addNewTestCase( new Date(true), + "new Date(true)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); + + addNewTestCase( new Date(false), + "new Date(false)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(0)).toString() ), + "new Date(\""+ (new Date(0)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +/* +// addNewTestCase( "new Date(\""+ (new Date(0)).toLocaleString()+"\")", [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date((new Date(0)).toUTCString()), + "new Date(\""+ (new Date(0)).toUTCString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date((new Date(1)).toString()), + "new Date(\""+ (new Date(1)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( TZ_ADJUST ), + "new Date(" + TZ_ADJUST+")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), + "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+ (new Date(TZ_ADJUST)).toLocaleString()+"\")",[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), + "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + // Dates around 2000 + + addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Parsing toLocaleString() is not guaranteed by ECMA. +// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-2.js new file mode 100644 index 0000000..4cfcb04 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-2.js @@ -0,0 +1,275 @@ +/* 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.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + addNewTestCase( new Date((new Date(0)).toUTCString()), + "new Date(\""+ (new Date(0)).toUTCString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date((new Date(1)).toString()), + "new Date(\""+ (new Date(1)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( TZ_ADJUST ), + "new Date(" + TZ_ADJUST+")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), + "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + + addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), + "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +/* + // Dates around 2000 + + addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Parsing toLocaleString() is not guaranteed by ECMA. +// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-3.js new file mode 100644 index 0000000..aaf430d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-3.js @@ -0,0 +1,253 @@ +/* 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.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + + // Dates around 2000 + + addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +/* + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Parsing toLocaleString() is not guaranteed by ECMA. +// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-4.js new file mode 100644 index 0000000..c25bda8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-4.js @@ -0,0 +1,222 @@ +/* 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.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +/* + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-5.js new file mode 100644 index 0000000..00b3b47 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.3.8-5.js @@ -0,0 +1,190 @@ +/* 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.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +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 ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.2-1.js new file mode 100644 index 0000000..2fa4cbf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.2-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.org code. +* +* 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: + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=4088 + * Description: Date parsing gets 12:30 AM wrong. + * New behavior: + * js> d = new Date('1/1/1999 13:30 AM') + * Invalid Date + * js> d = new Date('1/1/1999 13:30 PM') + * Invalid Date + * js> d = new Date('1/1/1999 12:30 AM') + * Fri Jan 01 00:30:00 GMT-0800 (PST) 1999 + * js> d = new Date('1/1/1999 12:30 PM') + * Fri Jan 01 12:30:00 GMT-0800 (PST) 1999 + * Author: christine@netscape.com + */ + + var SECTION = "15.9.4.2-1"; // provide a document reference (ie, ECMA section) + var VERSION = "ECMA"; // Version of JavaScript or ECMA + var TITLE = "Regression Test for Date.parse"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=4088"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + AddTestCase( "new Date('1/1/1999 12:30 AM').toString()", + new Date(1999,0,1,0,30).toString(), + new Date('1/1/1999 12:30 AM').toString() ); + + AddTestCase( "new Date('1/1/1999 12:30 PM').toString()", + new Date( 1999,0,1,12,30 ).toString(), + new Date('1/1/1999 12:30 PM').toString() ); + + AddTestCase( "new Date('1/1/1999 13:30 AM')", + "Invalid Date", + new Date('1/1/1999 13:30 AM').toString() ); + + + AddTestCase( "new Date('1/1/1999 13:30 PM')", + "Invalid Date", + new Date('1/1/1999 13:30 PM').toString() ); + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.2.js new file mode 100644 index 0000000..5fd15ba --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.2.js @@ -0,0 +1,213 @@ +/* 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.9.4.2.js + ECMA Section: 15.9.4.2 Date.parse() + Description: The parse() function applies the to ToString() operator + to its argument and interprets the resulting string as + a date. It returns a number, the UTC time value + corresponding to the date. + + The string may be interpreted as a local time, a UTC + time, or a time in some other time zone, depending on + the contents of the string. + + (need to test strings containing stuff with the time + zone specified, and verify that parse() returns the + correct GMT time) + + so for any Date object x, all of these things should + be equal: + + value tested in function: + x.valueOf() test_value() + Date.parse(x.toString()) test_tostring() + Date.parse(x.toGMTString()) test_togmt() + + Date.parse(x.toLocaleString()) is not required to + produce the same number value as the preceeding three + expressions. in general the value produced by + Date.parse is implementation dependent when given any + string value that could not be produced in that + implementation by the toString or toGMTString method. + + value tested in function: + Date.parse( x.toLocaleString()) test_tolocale() + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.4.2"; + var TITLE = "Date.parse()"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + var TYPEOF = "object"; + +// for TCMS, the testcases array must be global. + writeHeaderToLog("15.9.4.2 Date.parse()" ); + var tc= 0; + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + + // Dates around 1970 + + addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date(-1), + "new Date(-1)", + [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); + addNewTestCase( new Date(28799999), + "new Date(28799999)", + [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); + addNewTestCase( new Date(28800000), + "new Date(28800000)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + // Dates around 2000 + + addNewTestCase( new Date(946684799999), + "new Date(946684799999)", + [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + addNewTestCase( new Date(946713599999), + "new Date(946713599999)", + [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + addNewTestCase( new Date(946684800000), + "new Date(946684800000)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + addNewTestCase( new Date(946713600000), + "new Date(946713600000)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(-2208988800000), + "new Date(-2208988800000)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(-2208988800001), + "new Date(-2208988800001)", + [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(-2208960000001), + "new Date(-2208960000001)", + [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] ); + addNewTestCase( new Date(-2208960000000), + "new Date(-2208960000000)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + addNewTestCase( new Date(-2208959999999), + "new Date(-2208959999999)", + [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date(" + UTC_FEB_29_2000 +")", + [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date(" + PST_FEB_29_2000 +")", + [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]); + + // Dates around Jan 1 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(UTC_JAN_1_2005), + "new Date("+ UTC_JAN_1_2005 +")", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + addNewTestCase( new Date(PST_JAN_1_2005), + "new Date("+ PST_JAN_1_2005 +")", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + +} +function addNewTestCase( DateCase, DateString, ResultArray ) { + DateCase = DateCase; + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) ); + testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) ); +/* + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() z inutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +*/ +} +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 ); + } + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.3.js new file mode 100644 index 0000000..e56f971 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.4.3.js @@ -0,0 +1,209 @@ +/* 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): + * + */ + + + var testcases = new Array(); + var SECTION = "15.9.4.3"; + var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )"; + + getTestCases(); + test(); + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} + +function utc( year, month, date, hours, minutes, seconds, ms ) { + d = new MyDate(); + d.year = Number(year); + + if (month) + d.month = Number(month); + if (date) + d.date = Number(date); + if (hours) + d.hours = Number(hours); + if (minutes) + d.minutes = Number(minutes); + if (seconds) + d.seconds = Number(seconds); + if (ms) + d.ms = Number(ms); + + if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) { + d.year = 1900 + ToInteger(d.year); + } + + if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) || + isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) { + d.year = Number.NaN; + d.month = Number.NaN; + d.date = Number.NaN; + d.hours = Number.NaN; + d.minutes = Number.NaN; + d.seconds = Number.NaN; + d.ms = Number.NaN; + d.value = Number.NaN; + d.time = Number.NaN; + d.day =Number.NaN; + return d; + } + + d.day = MakeDay( d.year, d.month, d.date ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = (TimeClip( MakeDate(d.day,d.time))); + + return d; +} + +function UTCTime( t ) { + sign = ( t < 0 ) ? -1 : 1; + return ( (t +(TZ_DIFF*msPerHour)) ); +} + +function getTestCases() { + + // Dates around 1970 + + addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0), + "Date.UTC( 1970,0,1,0,0,0,0)", + utc(1970,0,1,0,0,0,0) ); + + addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999), + "Date.UTC( 1969,11,31,23,59,59,999)", + utc(1969,11,31,23,59,59,999) ); + addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999), + "Date.UTC( 1972,1,29,23,59,59,999)", + utc(1972,1,29,23,59,59,999) ); + addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999), + "Date.UTC( 1972,2,1,23,59,59,999)", + utc(1972,2,1,23,59,59,999) ); + addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999), + "Date.UTC( 1968,1,29,23,59,59,999)", + utc(1968,1,29,23,59,59,999) ); + addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999), + "Date.UTC( 1968,2,1,23,59,59,999)", + utc(1968,2,1,23,59,59,999) ); + addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0), + "Date.UTC( 1969,0,1,0,0,0,0)", + utc(1969,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000), + "Date.UTC( 1969,11,31,23,59,59,1000)", + utc(1970,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999), + "Date.UTC( 1969,Number.NaN,31,23,59,59,999)", + utc(1969,Number.NaN,31,23,59,59,999) ); + + // Dates around 2000 + + addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999), + "Date.UTC( 1999,11,31,23,59,59,999)", + utc(1999,11,31,23,59,59,999) ); + addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0), + "Date.UTC( 2000,0,1,0,0,0,0)", + utc(2000,0,1,0,0,0,0) ); + + // Dates around 1900 + addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999), + "Date.UTC( 1899,11,31,23,59,59,999)", + utc(1899,11,31,23,59,59,999) ); + addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0), + "Date.UTC( 1900,0,1,0,0,0,0)", + utc(1900,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0), + "Date.UTC( 1973,0,1,0,0,0,0)", + utc(1973,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111), + "Date.UTC( 1776,6,4,12,36,13,111)", + utc(1776,6,4,12,36,13,111) ); + addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123), + "Date.UTC( 2525,9,18,15,30,1,123)", + utc(2525,9,18,15,30,1,123) ); + + // Dates around 29 Feb 2000 + + addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ), + "Date.UTC( 2000,1,29,0,0,0,0 )", + utc(2000,1,29,0,0,0,0) ); + addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ), + "Date.UTC( 2000,1,29,8,0,0,0 )", + utc(2000,1,29,8,0,0,0) ); + + // Dates around 1 Jan 2005 + + addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ), + "Date.UTC( 2005,0,1,0,0,0,0 )", + utc(2005,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ), + "Date.UTC( 2004,11,31,16,0,0,0 )", + utc(2004,11,31,16,0,0,0) ); +} + +function addNewTestCase( DateCase, DateString, ExpectDate) { + DateCase = DateCase; + + item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); + testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); +/* + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ExpectDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ExpectDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ExpectDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ExpectDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ExpectDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ExpectDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ExpectDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ExpectDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ExpectDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ExpectDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ExpectDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ExpectDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ExpectDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ExpectDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ExpectDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ExpectDate.ms, DateCase.getMilliseconds() ); +*/ +} +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 ); + } + + stopTest(); + return testcases; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.1.js new file mode 100644 index 0000000..d605896 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.1.js @@ -0,0 +1,59 @@ +/* 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.9.5.1.js + ECMA Section: 15.9.5.1 Date.prototype.constructor + Description: + The initial value of Date.prototype.constructor is the built-in Date + constructor. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.constructor == Date", + true, + Date.prototype.constructor == Date ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-1.js new file mode 100644 index 0000000..f13e9d7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-1.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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + +/* + // We don't use |now| because it fails every night at midnight. + // The test is more reproducable if we use concrete times. + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); +*/ + addTestCase( UTC_JAN_1_2005 ); +/* + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-10.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-10.js new file mode 100644 index 0000000..1d8060d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-10.js @@ -0,0 +1,102 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_START_1998+1 ); +/* + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-11.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-11.js new file mode 100644 index 0000000..752b114 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-11.js @@ -0,0 +1,101 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_END_1998 ); +/* + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-12.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-12.js new file mode 100644 index 0000000..587b023 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-12.js @@ -0,0 +1,100 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_END_1998-1 ); +/* + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-13.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-13.js new file mode 100644 index 0000000..bf9027a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-13.js @@ -0,0 +1,97 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_END_1998+1 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-2.js new file mode 100644 index 0000000..a775643 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-2.js @@ -0,0 +1,110 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-3.js new file mode 100644 index 0000000..56fee4b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-3.js @@ -0,0 +1,109 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_1970 ); +/* + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-4.js new file mode 100644 index 0000000..1f22d11 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-4.js @@ -0,0 +1,107 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_1900 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-5.js new file mode 100644 index 0000000..4e7c80a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-5.js @@ -0,0 +1,107 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_2000 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-6.js new file mode 100644 index 0000000..6408622 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-6.js @@ -0,0 +1,106 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( UTC_FEB_29_2000 ); +/* + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-7.js new file mode 100644 index 0000000..d1741e3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-7.js @@ -0,0 +1,105 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( UTC_JAN_1_2005 ); +/* + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-8.js new file mode 100644 index 0000000..3ef0398 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-8.js @@ -0,0 +1,104 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_START_1998 ); +/* + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.10-9.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-9.js new file mode 100644 index 0000000..1d8325c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.10-9.js @@ -0,0 +1,103 @@ +/* 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.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_START_1998-1 ); +/* + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +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/Date/15.9.5.11-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-1.js new file mode 100644 index 0000000..9b425e8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-1.js @@ -0,0 +1,99 @@ +/* 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.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + addTestCase( now ); + + test() + +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.11-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-2.js new file mode 100644 index 0000000..ed946ea --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-2.js @@ -0,0 +1,96 @@ +/* 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.9.5.11 + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + + addTestCase( TIME_YEAR_0 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.11-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-3.js new file mode 100644 index 0000000..f596a83 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-3.js @@ -0,0 +1,95 @@ +/* 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.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1970 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.11-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-4.js new file mode 100644 index 0000000..3b9d480 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-4.js @@ -0,0 +1,95 @@ +/* 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.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1900 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7* msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.11-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-5.js new file mode 100644 index 0000000..d76f392 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-5.js @@ -0,0 +1,95 @@ +/* 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.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_2000 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.11-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-6.js new file mode 100644 index 0000000..7cb0509 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-6.js @@ -0,0 +1,96 @@ +/* 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.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addTestCase( UTC_FEB_29_2000 ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.11-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-7.js new file mode 100644 index 0000000..08eb7f6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.11-7.js @@ -0,0 +1,98 @@ +/* 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.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +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/Date/15.9.5.12-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-1.js new file mode 100644 index 0000000..8dcf1a4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-1.js @@ -0,0 +1,110 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + +/* + // We don't use |now| because it fails every night at midnight. + // The test is more reproducable if we use concrete times. + addTestCase( now ); + + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); +*/ + addTestCase( UTC_JAN_1_2005 ); +/* + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-2.js new file mode 100644 index 0000000..dd58cb0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-2.js @@ -0,0 +1,104 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-3.js new file mode 100644 index 0000000..6212458 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-3.js @@ -0,0 +1,103 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1970 ); +/* + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-4.js new file mode 100644 index 0000000..e7bde15 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-4.js @@ -0,0 +1,102 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1900 ); +/* + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-5.js new file mode 100644 index 0000000..796187a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-5.js @@ -0,0 +1,101 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_2000 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-6.js new file mode 100644 index 0000000..1aa0a1d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-6.js @@ -0,0 +1,100 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_FEB_29_2000 ); +/* + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-7.js new file mode 100644 index 0000000..c638614 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-7.js @@ -0,0 +1,98 @@ +/* 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.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.12-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-8.js new file mode 100644 index 0000000..54260ca --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.12-8.js @@ -0,0 +1,95 @@ +/* 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.9.5.12 + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +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/Date/15.9.5.13-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-1.js new file mode 100644 index 0000000..06bd92e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-1.js @@ -0,0 +1,78 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + addTestCase( now ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-2.js new file mode 100644 index 0000000..bec562c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-2.js @@ -0,0 +1,75 @@ +/* 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.9.5.13 + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + + addTestCase( TIME_YEAR_0 ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-3.js new file mode 100644 index 0000000..6124d86 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-3.js @@ -0,0 +1,75 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1970 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-4.js new file mode 100644 index 0000000..37fd989 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-4.js @@ -0,0 +1,75 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1900 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-5.js new file mode 100644 index 0000000..2af2e9e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-5.js @@ -0,0 +1,75 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_2000 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-6.js new file mode 100644 index 0000000..ce5e335 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-6.js @@ -0,0 +1,78 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + addTestCase( UTC_FEB_29_2000 ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-7.js new file mode 100644 index 0000000..2870bc5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-7.js @@ -0,0 +1,80 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.13-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-8.js new file mode 100644 index 0000000..703483e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.13-8.js @@ -0,0 +1,95 @@ +/* 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.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCDay()", + NaN, + (new Date(NaN)).getUTCDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCDay.length", + 0, + Date.prototype.getUTCDay.length ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +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/Date/15.9.5.14.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.14.js new file mode 100644 index 0000000..4d95ada --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.14.js @@ -0,0 +1,96 @@ +/* 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.9.5.14.js + ECMA Section: 15.9.5.14 + Description: Date.prototype.getHours + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.14"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getHours()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getHours()", + NaN, + (new Date(NaN)).getHours() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getHours.length", + 0, + Date.prototype.getHours.length ); + test(); +function addTestCase( t ) { + for ( h = 0; h < 24; h+=4 ) { + t += msPerHour; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getHours()", + HourFromTime((LocalTime(t))), + (new Date(t)).getHours() ); + } +} +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/Date/15.9.5.15.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.15.js new file mode 100644 index 0000000..de4a132 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.15.js @@ -0,0 +1,97 @@ +/* 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.9.5.15.js + ECMA Section: 15.9.5.15 + Description: Date.prototype.getUTCHours + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.15"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCHours()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCHours()", + NaN, + (new Date(NaN)).getUTCHours() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCHours.length", + 0, + Date.prototype.getUTCHours.length ); + test(); +function addTestCase( t ) { + for ( h = 0; h < 24; h+=3 ) { + t += msPerHour; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCHours()", + HourFromTime((t)), + (new Date(t)).getUTCHours() ); + } +} +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/Date/15.9.5.16.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.16.js new file mode 100644 index 0000000..2a02370 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.16.js @@ -0,0 +1,96 @@ +/* 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.9.5.16.js + ECMA Section: 15.9.5.16 + Description: Date.prototype.getMinutes + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return MinFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.16"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getMinutes()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getMinutes()", + NaN, + (new Date(NaN)).getMinutes() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getMinutes.length", + 0, + Date.prototype.getMinutes.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getMinutes()", + MinFromTime((LocalTime(t))), + (new Date(t)).getMinutes() ); + } +} +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/Date/15.9.5.17.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.17.js new file mode 100644 index 0000000..0afaa7b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.17.js @@ -0,0 +1,97 @@ +/* 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.9.5.17.js + ECMA Section: 15.9.5.17 + Description: Date.prototype.getUTCMinutes + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MinFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.17"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMinutes()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMinutes()", + NaN, + (new Date(NaN)).getUTCMinutes() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMinutes.length", + 0, + Date.prototype.getUTCMinutes.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMinutes()", + MinFromTime(t), + (new Date(t)).getUTCMinutes() ); + } +} +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/Date/15.9.5.18.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.18.js new file mode 100644 index 0000000..1537683 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.18.js @@ -0,0 +1,97 @@ +/* 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.9.5.18.js + ECMA Section: 15.9.5.18 + Description: Date.prototype.getSeconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.18"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getSeconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getSeconds()", + NaN, + (new Date(NaN)).getSeconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getSeconds.length", + 0, + Date.prototype.getSeconds.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getSeconds()", + SecFromTime(LocalTime(t)), + (new Date(t)).getSeconds() ); + } +} +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/Date/15.9.5.19.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.19.js new file mode 100644 index 0000000..91f2a0a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.19.js @@ -0,0 +1,97 @@ +/* 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.9.5.19.js + ECMA Section: 15.9.5.19 + Description: Date.prototype.getUTCSeconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.19"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCSeconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCSeconds()", + NaN, + (new Date(NaN)).getUTCSeconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCSeconds.length", + 0, + Date.prototype.getUTCSeconds.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCSeconds()", + SecFromTime(t), + (new Date(t)).getUTCSeconds() ); + } +} +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/Date/15.9.5.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2-1.js new file mode 100644 index 0000000..bb0fb02 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2-1.js @@ -0,0 +1,152 @@ +/* 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.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); + + var now = new Date(); + + // can't test the content of the string, but can verify that the string is + // parsable by Date.parse + + testcases[tc++] = new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); + + testcases[tc++] = new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); + // 1970 + + TZ_ADJUST = TZ_DIFF * msPerHour; + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ) + + // 1900 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ) + + // 2000 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ) + + // 29 Feb 2000 + + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", + UTC_29_FEB_2000, + Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", + UTC_29_FEB_2000-1000, + Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ) + + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", + UTC_29_FEB_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ) + // 2O05 + + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", + UTC_1_JAN_2005, + Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", + UTC_1_JAN_2005-1000, + Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", + UTC_1_JAN_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ) + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2-2-n.js new file mode 100644 index 0000000..8044dd8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2-2-n.js @@ -0,0 +1,77 @@ +/* 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.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + + This verifies that calling toString on an object that is not a string + generates a runtime error. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var OBJ = new MyObject( new Date(0) ); + + testcases[tc++] = new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.toString()", + "error", + OBJ.toString() ); + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; +} +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/Date/15.9.5.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2.js new file mode 100644 index 0000000..bb0fb02 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.2.js @@ -0,0 +1,152 @@ +/* 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.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); + + var now = new Date(); + + // can't test the content of the string, but can verify that the string is + // parsable by Date.parse + + testcases[tc++] = new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); + + testcases[tc++] = new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); + // 1970 + + TZ_ADJUST = TZ_DIFF * msPerHour; + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ) + + // 1900 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ) + + // 2000 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ) + + // 29 Feb 2000 + + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", + UTC_29_FEB_2000, + Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", + UTC_29_FEB_2000-1000, + Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ) + + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", + UTC_29_FEB_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ) + // 2O05 + + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", + UTC_1_JAN_2005, + Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", + UTC_1_JAN_2005-1000, + Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", + UTC_1_JAN_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ) + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.20.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.20.js new file mode 100644 index 0000000..3ef81f2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.20.js @@ -0,0 +1,97 @@ +/* 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.9.5.20.js + ECMA Section: 15.9.5.20 + Description: Date.prototype.getMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.20"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getMilliseconds()", + NaN, + (new Date(NaN)).getMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getMilliseconds.length", + 0, + Date.prototype.getMilliseconds.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getMilliseconds()", + msFromTime(LocalTime(t)), + (new Date(t)).getMilliseconds() ); + } +} +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/Date/15.9.5.21-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-1.js new file mode 100644 index 0000000..eb89ba4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-1.js @@ -0,0 +1,97 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); +/* + addTestCase( TIME_YEAR_0 ); + + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); +*/ + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-2.js new file mode 100644 index 0000000..5a70d47 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-2.js @@ -0,0 +1,95 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); +*/ + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-3.js new file mode 100644 index 0000000..bfd80c8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-3.js @@ -0,0 +1,78 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1970 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-4.js new file mode 100644 index 0000000..3f0e4e8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-4.js @@ -0,0 +1,78 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1900 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-5.js new file mode 100644 index 0000000..2ef6e21 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-5.js @@ -0,0 +1,78 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_2000 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-6.js new file mode 100644 index 0000000..3973472 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-6.js @@ -0,0 +1,79 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_FEB_29_2000 ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-7.js new file mode 100644 index 0000000..e50aa04 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-7.js @@ -0,0 +1,78 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.21-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-8.js new file mode 100644 index 0000000..b23dfc3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.21-8.js @@ -0,0 +1,86 @@ +/* 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.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +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/Date/15.9.5.22-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-1.js new file mode 100644 index 0000000..cd84a9b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-1.js @@ -0,0 +1,100 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + +// addTestCase( now ); + + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); + + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-2.js new file mode 100644 index 0000000..e516135 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-2.js @@ -0,0 +1,99 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-3.js new file mode 100644 index 0000000..371cbc2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-3.js @@ -0,0 +1,98 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1970 ); +/* + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-4.js new file mode 100644 index 0000000..1c63441 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-4.js @@ -0,0 +1,97 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1900 ); +/* + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-5.js new file mode 100644 index 0000000..3f20ea4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-5.js @@ -0,0 +1,96 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_2000 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-6.js new file mode 100644 index 0000000..0aee4a0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-6.js @@ -0,0 +1,95 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_FEB_29_2000 ); +/* + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-7.js new file mode 100644 index 0000000..2d6ecfc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-7.js @@ -0,0 +1,93 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.22-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-8.js new file mode 100644 index 0000000..f7d6520 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.22-8.js @@ -0,0 +1,90 @@ +/* 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.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +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/Date/15.9.5.23-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-1.js new file mode 100644 index 0000000..3a74450 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-1.js @@ -0,0 +1,157 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + var testcases = new Array(); + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( 0, 0 ); +/* + addTestCase( now, -2208988800000 ); + addTestCase( now, -86400000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-10.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-10.js new file mode 100644 index 0000000..406123b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-10.js @@ -0,0 +1,156 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + var testcases = new Array(); + + getTestCases(); + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, -2208988800000 ); +/* + addTestCase( now, -86400000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-11.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-11.js new file mode 100644 index 0000000..377edd5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-11.js @@ -0,0 +1,155 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, -86400000 ); +/* + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-12.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-12.js new file mode 100644 index 0000000..b0820c0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-12.js @@ -0,0 +1,153 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + var testcases = new Array(); + getTestCases(); + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, 946684800000 ); +/* + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-13.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-13.js new file mode 100644 index 0000000..058a7c7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-13.js @@ -0,0 +1,150 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, -2208988800000 ); +/* + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-14.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-14.js new file mode 100644 index 0000000..135e808 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-14.js @@ -0,0 +1,148 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-14"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, 946684800000 ); +/* + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-15.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-15.js new file mode 100644 index 0000000..0f4e587 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-15.js @@ -0,0 +1,144 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, 0 ); +/* + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-16.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-16.js new file mode 100644 index 0000000..7390eb5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-16.js @@ -0,0 +1,143 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, String( TIME_1900 ) ); +/* + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-17.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-17.js new file mode 100644 index 0000000..0ac866e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-17.js @@ -0,0 +1,142 @@ +/* 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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, String( TZ_DIFF* msPerHour ) ); +/* + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-18.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-18.js new file mode 100644 index 0000000..902f411 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-18.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.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, String( TIME_2000 ) ); +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +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/Date/15.9.5.23-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-2.js new file mode 100644 index 0000000..e471514 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-2.js @@ -0,0 +1,111 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + test_times = new Array( now, TIME_1970, TIME_1900, TIME_2000 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(now), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.23-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-3-n.js new file mode 100644 index 0000000..44fffdf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-3-n.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.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MYDATE = new MyDate(TIME_1970); + + testcases[tc++] = new TestCase( SECTION, + "MYDATE.setTime(TIME_2000)", + "error", + MYDATE.setTime(TIME_2000) ); + +function MyDate(value) { + this.value = value; + this.setTime = Date.prototype.setTime; + return this; +} +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/Date/15.9.5.23-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-4.js new file mode 100644 index 0000000..633bbf6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-4.js @@ -0,0 +1,122 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_YEAR_0), test_times[j] ); + } + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); + +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.23-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-5.js new file mode 100644 index 0000000..ab8d9a7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-5.js @@ -0,0 +1,122 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1970), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.23-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-6.js new file mode 100644 index 0000000..3f0c3f7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-6.js @@ -0,0 +1,122 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1900), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.23-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-7.js new file mode 100644 index 0000000..328642f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-7.js @@ -0,0 +1,122 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_2000), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.23-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-8.js new file mode 100644 index 0000000..4b9fbb3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-8.js @@ -0,0 +1,111 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_FEB_29_2000), test_times[j] ); + } + + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.23-9.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-9.js new file mode 100644 index 0000000..cbf8f18 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.23-9.js @@ -0,0 +1,112 @@ +/* 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.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_JAN_1_2005), test_times[j] ); + } + + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +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/Date/15.9.5.24-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-1.js new file mode 100644 index 0000000..4e7a4fb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, 0 ); +/* + addTestCase( 0, -86400000 ); + addTestCase( 0, -2208988800000 ); + addTestCase( 0, 946684800000 ); + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-2.js new file mode 100644 index 0000000..8995cf2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-2.js @@ -0,0 +1,150 @@ +/* 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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, -86400000 ); +/* + addTestCase( 0, -2208988800000 ); + addTestCase( 0, 946684800000 ); + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-3.js new file mode 100644 index 0000000..788fc80 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-3.js @@ -0,0 +1,149 @@ +/* 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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, -2208988800000 ); +/* + addTestCase( 0, 946684800000 ); + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-4.js new file mode 100644 index 0000000..b003de4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-4.js @@ -0,0 +1,148 @@ +/* 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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, 946684800000 ); +/* + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-5.js new file mode 100644 index 0000000..ccfadc0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-5.js @@ -0,0 +1,141 @@ +/* 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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, "0" ); +/* + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-6.js new file mode 100644 index 0000000..cd2d9d1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-6.js @@ -0,0 +1,140 @@ +/* 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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, "-2208988800000" ); +/* + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-7.js new file mode 100644 index 0000000..8e5846e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-7.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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + + addTestCase( 0, "-86400000" ); +/* + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-8.js new file mode 100644 index 0000000..956bc9d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.24-8.js @@ -0,0 +1,135 @@ +/* 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.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + addTestCase( 0, "946684800000" ); +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.25-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.25-1.js new file mode 100644 index 0000000..65cecdc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.25-1.js @@ -0,0 +1,190 @@ +/* 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.9.5.25-1.js + ECMA Section: 15.9.5.25 Date.prototype.setUTCMilliseconds(ms) + Description: + 1. Let t be this time value. + 2. Call ToNumber(ms). + 3. Compute MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), Result(2)). + 4. Compute MakeDate(Day(t), Result(3)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.25-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 0, "TDATE = new Date(0);(TDATE).setUTCMilliseconds(0);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,0)), + LocalDateFromTime(SetUTCMilliseconds(0,0)) ); + addNewTestCase( 28800000,999, + "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(28800000,999)), + LocalDateFromTime(SetUTCMilliseconds(28800000,999)) ); + addNewTestCase( 28800000,-28800000, + "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(-28800000);TDATE", + UTCDateFromTime(SetUTCMilliseconds(28800000,-28800000)), + LocalDateFromTime(SetUTCMilliseconds(28800000,-28800000)) ); + addNewTestCase( 946684800000,1234567, + "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(1234567);TDATE", + UTCDateFromTime(SetUTCMilliseconds(946684800000,1234567)), + LocalDateFromTime(SetUTCMilliseconds(946684800000,1234567)) ); + addNewTestCase( 946684800000, 123456789, + "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(946684800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(946684800000,123456789)) ); + + addNewTestCase( -2208988800000,123456789, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( -2208988800000,123456, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( -2208988800000,-123456, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( 0,-999, + "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +/* + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(0);TEST_DATE", UTCDateFromTime(0), LocalDateFromTime(0) ); +// addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(-2208988800000);TEST_DATE", UTCDateFromTime(-2208988800000), LocalDateFromTime(-2208988800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(-86400000);TEST_DATE", UTCDateFromTime(-86400000), LocalDateFromTime(-86400000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(946684800000);TEST_DATE", UTCDateFromTime(946684800000), LocalDateFromTime(946684800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(-69609600000);TEST_DATE", UTCDateFromTime(-69609600000), LocalDateFromTime(-69609600000) ); + + + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('0');TEST_DATE", UTCDateFromTime(0), LocalDateFromTime(0) ); +// addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-2208988800000');TEST_DATE", UTCDateFromTime(-2208988800000), LocalDateFromTime(-2208988800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-86400000');TEST_DATE", UTCDateFromTime(-86400000), LocalDateFromTime(-86400000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('946684800000');TEST_DATE", UTCDateFromTime(946684800000), LocalDateFromTime(946684800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-69609600000');TEST_DATE", UTCDateFromTime(-69609600000), LocalDateFromTime(-69609600000) ); +*/ +} +function addNewTestCase( initialTime, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date(initialTime); + DateCase.setUTCMilliseconds(ms); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetUTCMilliseconds( T, MS ) { + T = Number( T ); + TIME = MakeTime( HourFromTime(T), + MinFromTime(T), + SecFromTime(T), + MS ); + return( MakeDate( Day(T), TIME )); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.26-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.26-1.js new file mode 100644 index 0000000..58f70ff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.26-1.js @@ -0,0 +1,203 @@ +/* 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.9.5.26-1.js + ECMA Section: 15.9.5.26 Date.prototype.setSeconds(sec [,ms]) + Description: + + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), + Result(3)). + 5. Compute UTC(MakeDate(Day(t), Result(4))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.26-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setSeconds(sec [,ms] )"); + + var testcases = new Array(); + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 0, 0, + "TDATE = new Date(0);(TDATE).setSeconds(0,0);TDATE", + UTCDateFromTime(SetSeconds(0,0,0)), + LocalDateFromTime(SetSeconds(0,0,0)) ); + + addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,59,999)), + LocalDateFromTime(SetSeconds(28800000,59,999)) ); + + addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(999,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,999)), + LocalDateFromTime(SetSeconds(28800000,999,999)) ); + + addNewTestCase( 28800000,999, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,0)), + LocalDateFromTime(SetSeconds(28800000,999,0)) ); + + addNewTestCase( 28800000,-28800, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(-28800);TDATE", + UTCDateFromTime(SetSeconds(28800000,-28800)), + LocalDateFromTime(SetSeconds(28800000,-28800)) ); + + addNewTestCase( 946684800000,1234567,void 0, + "TDATE = new Date(946684800000);(TDATE).setSeconds(1234567);TDATE", + UTCDateFromTime(SetSeconds(946684800000,1234567)), + LocalDateFromTime(SetSeconds(946684800000,1234567)) ); + + addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetSeconds(-2208988800000,59,999)) ); + +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ +} +function addNewTestCase( startTime, sec, ms, DateString,UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms != void 0 ) { + DateCase.setSeconds( sec, ms ); + } else { + DateCase.setSeconds( sec ); + } + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetSeconds( t, s, m ) { + var MS = ( m == void 0 ) ? msFromTime(t) : Number( m ); + var TIME = LocalTime( t ); + var SEC = Number(s); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + var UTC_TIME = UTC(MakeDate(Day(TIME), RESULT4)); + return ( TimeClip(UTC_TIME) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.27-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.27-1.js new file mode 100644 index 0000000..38cd843 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.27-1.js @@ -0,0 +1,202 @@ +/* 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.9.5.27-1.js + ECMA Section: 15.9.5.27 Date.prototype.setUTCSeconds(sec [,ms]) + Description: + + If ms is not specified, this behaves as if ms were specified with the + value getUTCMilliseconds( ). + + 1. Let t be this time value. + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms) + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), Result(3)) + 5. Compute MakeDate(Day(t), Result(4)). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.27-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCSeconds(sec [,ms] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 0, 0, "TDATE = new Date(0);(TDATE).setUTCSeconds(0,0);TDATE", + UTCDateFromTime(SetUTCSeconds(0,0,0)), + LocalDateFromTime(SetUTCSeconds(0,0,0)) ); + + addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,59,999)), + LocalDateFromTime(SetUTCSeconds(28800000,59,999)) ); + + addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,999)), + LocalDateFromTime(SetUTCSeconds(28800000,999,999)) ); + + addNewTestCase( 28800000, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,0)), + LocalDateFromTime(SetUTCSeconds(28800000,999,0)) ); + + addNewTestCase( 28800000, -28800, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(-28800);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,-28800)), + LocalDateFromTime(SetUTCSeconds(28800000,-28800)) ); + + addNewTestCase( 946684800000, 1234567, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCSeconds(1234567);TDATE", + UTCDateFromTime(SetUTCSeconds(946684800000,1234567)), + LocalDateFromTime(SetUTCSeconds(946684800000,1234567)) ); + + addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetUTCSeconds(-2208988800000,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ +} +function addNewTestCase( startTime, sec, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms == void 0) { + DateCase.setSeconds( sec ); + } else { + DateCase.setSeconds( sec, ms ); + } + + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetUTCSeconds( t, s, m ) { + var TIME = t; + var SEC = Number(s); + var MS = ( m == void 0 ) ? msFromTime(TIME) : Number( m ); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT4)) ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.28-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.28-1.js new file mode 100644 index 0000000..8fd97d1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.28-1.js @@ -0,0 +1,216 @@ +/* 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.9.5.28-1.js + ECMA Section: 15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getSeconds ( ). + + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Day(t), Result(5))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.28-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE", + UTCDateFromTime(SetMinutes(0,0,0,0)), + LocalDateFromTime(SetMinutes(0,0,0,0)) ); + + addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59)), + LocalDateFromTime(SetMinutes(28800000,59,59)) ); + + addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59,999)), + LocalDateFromTime(SetMinutes(28800000,59,59,999)) ); + + addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,0)), + LocalDateFromTime(SetMinutes(28800000,59,0)) ); + + addNewTestCase( 28800000, -480, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE", + UTCDateFromTime(SetMinutes(28800000,-480)), + LocalDateFromTime(SetMinutes(28800000,-480)) ); + + addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE", + UTCDateFromTime(SetMinutes(946684800000,1234567)), + LocalDateFromTime(SetMinutes(946684800000,1234567)) ); + + addNewTestCase( -2208988800000,59, 59, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59)) ); + + addNewTestCase( -2208988800000, 59, 59, 999, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date( time ); + + if ( sec == void 0 ) { + DateCase.setMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setMinutes( min, sec ); + } else { + DateCase.setMinutes( min, sec, ms ); + } + } + + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetMinutes( t, min, sec, ms ) { + var TIME = LocalTime(t); + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.29-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.29-1.js new file mode 100644 index 0000000..0640a74 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.29-1.js @@ -0,0 +1,210 @@ +/* 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.9.5.29-1.js + ECMA Section: 15.9.5.29 Date.prototype.setUTCMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getUTCSeconds ( ). + + If ms is not specified, this behaves as if ms were specified with the value + getUTCMilliseconds( ). + + 1. Let t be this time value. + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Day(t), Result(5)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.29-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCMinutes( min [, sec, ms] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCMinutes(0);TDATE", + UTCDateFromTime(SetUTCMinutes(0,0,0,0)), + LocalDateFromTime(SetUTCMinutes(0,0,0,0)) ); + + addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59)) ); + + addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59,999)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59,999)) ); + + addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59)) ); + + addNewTestCase( 28800000, -480, 0, 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(-480);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,-480)), + LocalDateFromTime(SetUTCMinutes(28800000,-480)) ); + + addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCMinutes(1234567);TDATE", + UTCDateFromTime(SetUTCMinutes(946684800000,1234567)), + LocalDateFromTime(SetUTCMinutes(946684800000,1234567)) ); + + addNewTestCase( -2208988800000, 59, 999, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMinutes(59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(-2208988800000,59,999)), + LocalDateFromTime(SetUTCMinutes(-2208988800000,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { + var DateCase = new Date( time ); + + if ( sec == void 0 ) { + DateCase.setUTCMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCMinutes( min, sec ); + } else { + DateCase.setUTCMinutes( min, sec, ms ); + } + } + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCMinutes( t, min, sec, ms ) { + var TIME = t; + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME),RESULT5)) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.3-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.3-1-n.js new file mode 100644 index 0000000..109fc26 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.3-1-n.js @@ -0,0 +1,73 @@ +/* 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.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.3-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var OBJ = new MyObject( new Date(0) ); + + testcases[tc++] = new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()", + "error", + OBJ.valueOf() ); + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; +// The following line causes an infinte loop +// this.toString = new Function( "return this+\"\";"); + return this; +} +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/Date/15.9.5.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.3-2.js new file mode 100644 index 0000000..7698ac1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.3-2.js @@ -0,0 +1,107 @@ +/* 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.9.5.3-2.js + ECMA Section: 15.9.5.3-2 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var TZ_ADJUST = TZ_DIFF * msPerHour; + var now = (new Date()).valueOf(); + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_29_FEB_2000 ); + addTestCase( UTC_1_JAN_2005 ); + + test(); + +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+").valueOf()", + t, + (new Date(t)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+").valueOf()", + t+1, + (new Date(t+1)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+").valueOf()", + t-1, + (new Date(t-1)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").valueOf()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").valueOf()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).valueOf() ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; + this.toString = new Function( "return this+\"\";"); + return this; +} +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/Date/15.9.5.30-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.30-1.js new file mode 100644 index 0000000..6e6715f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.30-1.js @@ -0,0 +1,215 @@ +/* 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.9.5.30-1.js + ECMA Section: 15.9.5.30 Date.prototype.setHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the + value getMinutes( ). If sec is not specified, this behaves as if sec were + specified with the value getSeconds ( ). If ms is not specified, this + behaves as if ms were specified with the value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(hour). + 3. If min is not specified, compute MinFromTime(t); otherwise, call + ToNumber(min). + 4. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 5. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 6. Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7. Compute UTC(MakeDate(Day(t), Result(6))). + 8. Set the [[Value]] property of the this value to TimeClip(Result(7)). + 9. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.30-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setHours( hour [, min, sec, ms] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0,0,0,0,void 0, + "TDATE = new Date(0);(TDATE).setHours(0);TDATE" ); + + addNewTestCase( 28800000, 23, 59, 999,void 0, + "TDATE = new Date(28800000);(TDATE).setHours(23,59,999);TDATE" ); + + addNewTestCase( 28800000, 999, 999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999,999);TDATE" ); + + addNewTestCase( 28800000,999,0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999);TDATE" ); + + addNewTestCase( 28800000,-8, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(-8);TDATE" ); + + addNewTestCase( 946684800000,8760, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setHours(8760);TDATE" ); + + addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 999, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,999)" ); + + addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 1000, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,1000)" ); + + +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setHours(59,999);TDATE", + UTCDateFromTime(SetHours(-2208988800000,59,999)), + LocalDateFromTime(SetHours(-2208988800000,59,999)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, hours, min, sec, ms, DateString) { + var UTCDate = UTCDateFromTime( SetHours( time, hours, min, sec, ms )); + var LocalDate = LocalDateFromTime( SetHours( time, hours, min, sec, ms )); + + var DateCase = new Date( time ); + + if ( min == void 0 ) { + DateCase.setHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setHours( hours, min ); + } else { + if ( ms == void 0 ) { + DateCase.setHours( hours, min, sec ); + } else { + DateCase.setHours( hours, min, sec, ms ); + } + } + } + + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.day = WeekDay( t ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + + return (d); +} +function SetHours( t, hour, min, sec, ms ) { + var TIME = LocalTime(t); + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + var UTC_TIME = UTC( MakeDate(Day(TIME), RESULT6) ); + return ( TimeClip(UTC_TIME) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.31-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.31-1.js new file mode 100644 index 0000000..b6a2fee --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.31-1.js @@ -0,0 +1,212 @@ +/* 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.9.5.31-1.js + ECMA Section: 15.9.5.31 Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the value getUTCMinutes( ). + If sec is not specified, this behaves as if sec were specified with the value getUTCSeconds ( ). + If ms is not specified, this behaves as if ms were specified with the value getUTCMilliseconds( ). + + 1.Let t be this time value. + 2.Call ToNumber(hour). + 3.If min is not specified, compute MinFromTime(t); otherwise, call ToNumber(min). + 4.If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). + 5.If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). + 6.Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7.Compute MakeDate(Day(t), Result(6)). + 8.Set the [[Value]] property of the this value to TimeClip(Result(7)). + + 1.Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.31-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 0, void 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCHours(0);TDATE", + UTCDateFromTime(SetUTCHours(0,0,0,0)), + LocalDateFromTime(SetUTCHours(0,0,0,0)) ); + + addNewTestCase( 28800000, 23, 59, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(23,59,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,23,59,999)), + LocalDateFromTime(SetUTCHours(28800000,23,59,999)) ); + + addNewTestCase( 28800000,999,999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,999)), + LocalDateFromTime(SetUTCHours(28800000,999,999)) ); + + addNewTestCase( 28800000, 999, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,0)), + LocalDateFromTime(SetUTCHours(28800000,999,0)) ); + + addNewTestCase( 28800000, -8670, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(-8670);TDATE", + UTCDateFromTime(SetUTCHours(28800000,-8670)), + LocalDateFromTime(SetUTCHours(28800000,-8670)) ); + + addNewTestCase( 946684800000, 1234567, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCHours(1234567);TDATE", + UTCDateFromTime(SetUTCHours(946684800000,1234567)), + LocalDateFromTime(SetUTCHours(946684800000,1234567)) ); + + addNewTestCase( -2208988800000, 59, 999, void 0, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCHours(59,999);TDATE", + UTCDateFromTime(SetUTCHours(-2208988800000,59,999)), + LocalDateFromTime(SetUTCHours(-2208988800000,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, hours, min, sec, ms, DateString, UTCDate, LocalDate) { + + DateCase = new Date(time); + if ( min == void 0 ) { + DateCase.setUTCHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setUTCHours( hours, min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCHours( hours, min, sec ); + } else { + DateCase.setUTCHours( hours, min, sec, ms ); + } + } + } + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCHours( t, hour, min, sec, ms ) { + var TIME = t; + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT6)) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.32-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.32-1.js new file mode 100644 index 0000000..eded146 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.32-1.js @@ -0,0 +1,157 @@ +/* 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.9.5.32-1.js + ECMA Section: 15.9.5.32 Date.prototype.setDate(date) + Description: + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute UTC(MakeDate(Result(3), TimeWithinDay(t))). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.32-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setDate(date) "); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( 0, 1, + "TDATE = new Date(0);(TDATE).setDate(1);TDATE" ); + +/* + addNewTestCase( "TDATE = new Date(86400000);(TDATE).setDate(1);TDATE", + UTCDateFromTime(SetDate(86400000,1)), + LocalDateFromTime(SetDate(86400000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); +*/ +} +function addNewTestCase( t, d, DateString ) { + var DateCase = new Date( t ); + DateCase.setDate( d ); + + var UTCDate = UTCDateFromTime(SetDate(t, d)); + var LocalDate=LocalDateFromTime(SetDate(t,d)); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetDate( t, date ) { + var T = LocalTime( t ); + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + var UTC_DATE = UTC( MakeDate(RESULT3, TimeWithinDay(T)) ); + return ( TimeClip(UTC_DATE) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.33-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.33-1.js new file mode 100644 index 0000000..017d43e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.33-1.js @@ -0,0 +1,156 @@ +/* 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.9.5.33-1.js + ECMA Section: 15.9.5.33 Date.prototype.setUTCDate(date) + Description: + 1. Let t be this time value. + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute MakeDate(Result(3), TimeWithinDay(t)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.33-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCDate(date) "); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(31);TDATE", + UTCDateFromTime(SetUTCDate(0,31)), + LocalDateFromTime(SetUTCDate(0,31)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(0,1)), + LocalDateFromTime(SetUTCDate(0,1)) ); + + addNewTestCase( "TDATE = new Date(86400000);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(86400000,1)), + LocalDateFromTime(SetUTCDate(86400000,1)) ); +/* + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCDate( t, date ) { + var T = t; + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + return ( TimeClip(MakeDate(RESULT3, TimeWithinDay(t))) ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.34-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.34-1.js new file mode 100644 index 0000000..e042ab9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.34-1.js @@ -0,0 +1,220 @@ +/* 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.9.5.34-1.js + ECMA Section: 15.9.5.34 Date.prototype.setMonth(mon [, date ] ) + Description: + If date is not specified, this behaves as if date were specified with the + value getDate( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. If date is not specified, compute DateFromTime(t); otherwise, call ToNumber(date). + 4. Compute MakeDay(YearFromTime(t), Result(2), Result(3)). + 5. Compute UTC(MakeDate(Result(4), TimeWithinDay(t))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.34-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMonth(mon [, date ] )"); + + var now = (new Date()).valueOf(); + + getFunctionCases(); + getTestCases(); + 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 ); +} + +function getFunctionCases() { + // some tests for all functions + testcases[testcases.length] = new TestCase( + SECTION, + "Date.prototype.setMonth.length", + 2, + Date.prototype.setMonth.length ); + + testcases[testcases.length] = new TestCase( + SECTION, + "typeof Date.prototype.setMonth", + "function", + typeof Date.prototype.setMonth ); + + +/* + + testcases[testcases.length] = new TestCase( + SECTION, + "delete Date.prototype.setMonth", + false, + delete Date.prototype.setMonth ); +*/ + +} + + +function getTestCases() { + // regression test for http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112404 + d = new Date(0); + d.setMonth(1,1,1,1,1,1); + + addNewTestCase( + "TDATE = new Date(0); TDATE.setMonth(1,1,1,1,1,1); TDATE", + UTCDateFromTime(SetMonth(0,1,1)), + LocalDateFromTime(SetMonth(0,1,1)) ); + + + // whatever today is + + addNewTestCase( "TDATE = new Date(now); (TDATE).setMonth(11,31); TDATE", + UTCDateFromTime(SetMonth(now,11,31)), + LocalDateFromTime(SetMonth(now,11,31)) ); + + // 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setMonth(0,1);TDATE", + UTCDateFromTime(SetMonth(0,0,1)), + LocalDateFromTime(SetMonth(0,0,1)) ); + + addNewTestCase( "TDATE = new Date("+TIME_1900+"); "+ + "(TDATE).setMonth(11,31); TDATE", + UTCDateFromTime( SetMonth(TIME_1900,11,31) ), + LocalDateFromTime( SetMonth(TIME_1900,11,31) ) ); + + + + +/* + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11,23,59,999);TDATE", + UTCDateFromTime(SetMonth(28800000,11,23,59,999)), + LocalDateFromTime(SetMonth(28800000,11,23,59,999)) ); + + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(99,99);TDATE", + UTCDateFromTime(SetMonth(28800000,99,99)), + LocalDateFromTime(SetMonth(28800000,99,99)) ); + + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11);TDATE", + UTCDateFromTime(SetMonth(28800000,11,0)), + LocalDateFromTime(SetMonth(28800000,11,0)) ); + + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(-11);TDATE", + UTCDateFromTime(SetMonth(28800000,-11)), + LocalDateFromTime(SetMonth(28800000,-11)) ); + + // 1900 + +// addNewTestCase( "TDATE = new Date(); (TDATE).setMonth(11,31); TDATE;" +*/ + +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetMonth( t, mon, date ) { + var TIME = LocalTime(t); + var MONTH = Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(TIME) : Number( date ); + var DAY = MakeDay( YearFromTime(TIME), MONTH, DATE ); + return ( TimeClip (UTC(MakeDate( DAY, TimeWithinDay(TIME) ))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.35-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.35-1.js new file mode 100644 index 0000000..242c0d8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.35-1.js @@ -0,0 +1,143 @@ +/* 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.9.5.35-1.js + ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date]) + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.35-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) "); + + getTestCases(); + 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 ); +} + +function getTestCases() { + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE", + UTCDateFromTime(SetUTCMonth(0,0)), + LocalDateFromTime(SetUTCMonth(0,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE", + UTCDateFromTime(SetUTCMonth(0,11)), + LocalDateFromTime(SetUTCMonth(0,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE", + UTCDateFromTime(SetUTCMonth(0,3,4)), + LocalDateFromTime(SetUTCMonth(0,3,4)) ); + +} + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCMonth( t, month, date ) { + var T = t; + var MONTH = Number( month ); + var DATE = ( date == void 0) ? DateFromTime(T) : Number( date ); + + var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE ); + var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T)); + + return ( TimeClip(RESULT5) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-1.js new file mode 100644 index 0000000..f046829 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-1.js @@ -0,0 +1,245 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + + // 1969 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969);TDATE", + UTCDateFromTime(SetFullYear(0,1969)), + LocalDateFromTime(SetFullYear(0,1969)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11)), + LocalDateFromTime(SetFullYear(0,1969,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11,31)), + LocalDateFromTime(SetFullYear(0,1969,11,31)) ); +/* + // 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", + UTCDateFromTime(SetFullYear(0,1970)), + LocalDateFromTime(SetFullYear(0,1970)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0)), + LocalDateFromTime(SetFullYear(0,1970,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0,1)), + LocalDateFromTime(SetFullYear(0,1970,0,1)) ); + // 1971 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-2.js new file mode 100644 index 0000000..1e207ed --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-2.js @@ -0,0 +1,231 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + // 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", + UTCDateFromTime(SetFullYear(0,1970)), + LocalDateFromTime(SetFullYear(0,1970)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0)), + LocalDateFromTime(SetFullYear(0,1970,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0,1)), + LocalDateFromTime(SetFullYear(0,1970,0,1)) ); +/* + // 1971 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-3.js new file mode 100644 index 0000000..c1e9c81 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-3.js @@ -0,0 +1,218 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + // 1971 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + +/* + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-4.js new file mode 100644 index 0000000..4d7f08b0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-4.js @@ -0,0 +1,205 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + +/* + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-5.js new file mode 100644 index 0000000..41dc143 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-5.js @@ -0,0 +1,192 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + +/* + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-6.js new file mode 100644 index 0000000..8bed8d2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-6.js @@ -0,0 +1,179 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + +/* + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-7.js new file mode 100644 index 0000000..8520844 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.36-7.js @@ -0,0 +1,164 @@ +/* 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.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} +function getTestCases() { + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-1.js new file mode 100644 index 0000000..9eaf49d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-1.js @@ -0,0 +1,235 @@ +/* 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.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + + // Dates around 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1970);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1970)), + LocalDateFromTime(SetUTCFullYear(0,1970)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1971);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1971)), + LocalDateFromTime(SetUTCFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); +/* + // Dates around 2000 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2000)), + LocalDateFromTime(SetUTCFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2001)), + LocalDateFromTime(SetUTCFullYear(0,2001)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1999)), + LocalDateFromTime(SetUTCFullYear(0,1999)) ); + + // Dates around 29 February 2000 + + var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + + var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + + addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + + addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); + + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + + + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-2.js new file mode 100644 index 0000000..ffb8fda --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-2.js @@ -0,0 +1,209 @@ +/* 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.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + + // Dates around 2000 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2000)), + LocalDateFromTime(SetUTCFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2001)), + LocalDateFromTime(SetUTCFullYear(0,2001)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1999)), + LocalDateFromTime(SetUTCFullYear(0,1999)) ); +/* + // Dates around 29 February 2000 + + var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + + var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + + addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + + addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); + + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + + + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-3.js new file mode 100644 index 0000000..136ec89 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-3.js @@ -0,0 +1,195 @@ +/* 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.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + + // Dates around 29 February 2000 + + var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + + var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + + addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + + addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); +/* + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + + + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-4.js new file mode 100644 index 0000000..c7876d1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-4.js @@ -0,0 +1,177 @@ +/* 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.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + +/* + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-5.js new file mode 100644 index 0000000..cee31ed --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.37-5.js @@ -0,0 +1,160 @@ +/* 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.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + 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 ); +} + +function getTestCases() { + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.4-1.js new file mode 100644 index 0000000..81c3740 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.4-1.js @@ -0,0 +1,96 @@ +/* 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.9.5.4-1.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTime"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + var now = (new Date()).valueOf(); + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_29_FEB_2000 ); + addTestCase( UTC_1_JAN_2005 ); + + test(); + +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+").getTime()", + t, + (new Date(t)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+").getTime()", + t+1, + (new Date(t+1)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+").getTime()", + t-1, + (new Date(t-1)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").getTime()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").getTime()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).getTime() ); +} + +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/Date/15.9.5.4-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.4-2-n.js new file mode 100644 index 0000000..c90559a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.4-2-n.js @@ -0,0 +1,67 @@ +/* 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.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.9.5.4-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTime"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MYDATE = new MyDate( TIME_2000 ); + + testcases[tc++] = new TestCase( SECTION, + "MYDATE.getTime()", + "error", + MYDATE.getTime() ); + +function MyDate( value ) { + this.value = value; + this.getTime = Date.prototype.getTime; +} +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/Date/15.9.5.5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.5.js new file mode 100644 index 0000000..5660c4c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.5.js @@ -0,0 +1,123 @@ +/* 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.9.5.5.js + ECMA Section: 15.9.5.5 + Description: Date.prototype.getYear + + This function is specified here for backwards compatibility only. The + function getFullYear is much to be preferred for nearly all purposes, + because it avoids the "year 2000 problem." + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)) 1900. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getYear()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getYear()", + NaN, + (new Date(NaN)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getYear.length", + 0, + Date.prototype.getYear.length ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getYear()", + GetYear(YearFromTime(LocalTime(t))), + (new Date(t)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+1))), + (new Date(t+1)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-1))), + (new Date(t-1)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), + (new Date(t-TZ_ADJUST)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), + (new Date(t+TZ_ADJUST)).getYear() ); +} +function GetYear( year ) { +/* + if ( year >= 1900 && year < 2000 ) { + return year - 1900; + } else { + return year; + } +*/ + return year - 1900; +} +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/Date/15.9.5.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.6.js new file mode 100644 index 0000000..5a9cf38 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.6.js @@ -0,0 +1,114 @@ +/* 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.9.5.6.js + ECMA Section: 15.9.5.6 + Description: Date.prototype.getFullYear + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getFullYear()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getFullYear()", + NaN, + (new Date(NaN)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getFullYear.length", + 0, + Date.prototype.getFullYear.length ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getFullYear()", + YearFromTime(LocalTime(t)), + (new Date(t)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getFullYear()", + YearFromTime(LocalTime(t+1)), + (new Date(t+1)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getFullYear()", + YearFromTime(LocalTime(t-1)), + (new Date(t-1)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getFullYear() ); +} +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/Date/15.9.5.7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.7.js new file mode 100644 index 0000000..8a7f5c0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.7.js @@ -0,0 +1,114 @@ +/* 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.9.5.7.js + ECMA Section: 15.9.5.7 + Description: Date.prototype.getUTCFullYear + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return YearFromTime(t). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCFullYear()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCFullYear()", + NaN, + (new Date(NaN)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCFullYear.length", + 0, + Date.prototype.getUTCFullYear.length ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCFullYear()", + YearFromTime(t), + (new Date(t)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCFullYear()", + YearFromTime(t+1), + (new Date(t+1)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCFullYear()", + YearFromTime(t-1), + (new Date(t-1)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCFullYear() ); +} +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/Date/15.9.5.8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.8.js new file mode 100644 index 0000000..038eda9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.8.js @@ -0,0 +1,120 @@ +/* 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.9.5.8.js + ECMA Section: 15.9.5.8 + Description: Date.prototype.getMonth + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getMonth()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getMonth()", + NaN, + (new Date(NaN)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getMonth.length", + 0, + Date.prototype.getMonth.length ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + + t += TimeInMonth(m); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getMonth()", + MonthFromTime(LocalTime(t)), + (new Date(t)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getMonth()", + MonthFromTime(LocalTime(t+1)), + (new Date(t+1)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getMonth()", + MonthFromTime(LocalTime(t-1)), + (new Date(t-1)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getMonth() ); + + } +} +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/Date/15.9.5.9.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.9.js new file mode 100644 index 0000000..9fda4ea --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.9.js @@ -0,0 +1,120 @@ +/* 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.9.5.9.js + ECMA Section: 15.9.5.9 + Description: Date.prototype.getUTCMonth + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMonth()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMonth()", + NaN, + (new Date(NaN)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMonth.length", + 0, + Date.prototype.getUTCMonth.length ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + + t += TimeInMonth(m); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMonth()", + MonthFromTime(t), + (new Date(t)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCMonth()", + MonthFromTime(t+1), + (new Date(t+1)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCMonth()", + MonthFromTime(t-1), + (new Date(t-1)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCMonth() ); + + } +} +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/Date/15.9.5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.js new file mode 100644 index 0000000..d7bd303 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Date/15.9.5.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.9.5.js + ECMA Section: 15.9.5 Properties of the Date prototype object + Description: + + The Date prototype object is itself a Date object (its [[Class]] is + "Date") whose value is NaN. + + The value of the internal [[Prototype]] property of the Date prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Date + prototype object, the phrase "this Date object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Date". Also, the phrase "this time value" refers + to the number value for the time represented by this Date object, that is, + the value of the internal [[Value]] property of this Date object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Date Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + Date.prototype.getClass = Object.prototype.toString; + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getClass", + "[object Date]", + Date.prototype.getClass() ); + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.valueOf()", + NaN, + Date.prototype.valueOf() ); + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.__proto__ == Object.prototype", + true, + Date.prototype.__proto__ == Object.prototype ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js new file mode 100644 index 0000000..f827cc7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,107 @@ +/* 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: 10.1.3-1.js + ECMA Section: 10.1.3 + Description: + + For each formal parameter, as defined in the FormalParameterList, create + a property of the variable object whose name is the Identifier and whose + attributes are determined by the type of code. The values of the + parameters are supplied by the caller. If the caller supplies fewer + parameter values than there are formal parameters, the extra formal + parameters have value undefined. If two or more formal parameters share + the same name, hence the same property, the corresponding property is + given the value that was supplied for the last parameter with this name. + If the value of this last parameter was not supplied by the caller, + the value of the corresponding property is undefined. + + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104191 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Variable Instantiation: Formal Parameters"; + var BUGNUMBER="104191"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var myfun1 = new Function( "a", "a", "return a" ); + var myfun2 = new Function( "a", "b", "a", "return a" ); + + function myfun3(a, b, a) { + return a; + } + + // myfun1, myfun2, myfun3 tostring + + + testcases[tc++] = new TestCase( + SECTION, + String(myfun2) +"; myfun2(2,4,8)", + 8, + myfun2(2,4,8) ); + + testcases[tc++] = new TestCase( + SECTION, + "myfun2(2,4)", + void 0, + myfun2(2,4)); + + testcases[tc++] = new TestCase( + SECTION, + String(myfun3) +"; myfun3(2,4,8)", + 8, + myfun3(2,4,8) ); + + testcases[tc++] = new TestCase( + SECTION, + "myfun3(2,4)", + void 0, + myfun3(2,4) ); + + + + + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3.js new file mode 100644 index 0000000..be75451 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3.js @@ -0,0 +1,160 @@ +/* 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: 10.1.3.js + ECMA Section: 10.1.3.js Variable Instantiation + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "10.1.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Variable instantiation"; +var BUGNUMBER = "20256"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = getTestCases(); + +test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + // overriding a variable or function name with a function should succeed + array[item++] = + new TestCase(SECTION, + "function t() { return \"first\" };" + + "function t() { return \"second\" };t() ", + "second", + eval("function t() { return \"first\" };" + + "function t() { return \"second\" };t()")); + + array[item++] = + new TestCase(SECTION, + "var t; function t(){}; typeof(t)", + "function", + eval("var t; function t(){}; typeof(t)")); + + + // formal parameter tests + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( 4 );", + void 0, + eval("function t1(a,b) { return b; }; t1( 4 );") ); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(4);", + 4, + eval("function t1(a,b) { return a; }; t1(4)")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1();", + void 0, + eval("function t1(a,b) { return a; }; t1()")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(1,2,4);", + 1, + eval("function t1(a,b) { return a; }; t1(1,2,4)")); +/* + array[item++] = + new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );", + void 0, + eval("function t1(a,a) { return a; }; t1( 4 )")); + array[item++] = + new TestCase(SECTION, + "function t1(a,a) { return a; }; t1( 1,2 );", + 2, + eval("function t1(a,a) { return a; }; t1( 1,2 )")); +*/ + // variable declarations + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1( false, true );", + false, + eval("function t1(a,b) { return a; }; t1( false, true );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( false, true );", + true, + eval("function t1(a,b) { return b; }; t1( false, true );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4, 2 );", + 6, + eval("function t1(a,b) { return a+b; }; t1( 4, 2 );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4 );", + Number.NaN, + eval("function t1(a,b) { return a+b; }; t1( 4 );")); + + // overriding a function name with a variable should fail + array[item++] = + new TestCase(SECTION, + "function t() { return 'function' };" + + "var t = 'variable'; typeof(t)", + "string", + eval("function t() { return 'function' };" + + "var t = 'variable'; typeof(t)")); + + // function as a constructor + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { var a = b; return a; } t1(1,3);", + 3, + eval("function t1(a, b){ var a = b; return a;}; t1(1,3)")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a", + 3, + eval("function t2(a,b) { this.a = b; };" + + "x = new t2(1,3); x.a")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a", + 1, + eval("function t2(a,b) { this.a = a; };" + + "x = new t2(1,3); x.a")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; } " + + "x = new t2(1,3);x.a;", + 3, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.a;")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; }" + + "x = new t2(1,3);x.b;", + 1, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.b;") ); + + return (array); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js new file mode 100644 index 0000000..6390960 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js @@ -0,0 +1,100 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( " + INPUT +" )" ; + + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js new file mode 100644 index 0000000..6966acf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js @@ -0,0 +1,94 @@ +/* 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: 10.1.4-10.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-10"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + var VALUE = 12345; + var MYOBJECT = new Number( VALUE ); + + with ( MYOBJECT ) { + testcases[tc].actual = toString(); + testcases[tc].expect = String(VALUE); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "MYOBJECT.toString()" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js new file mode 100644 index 0000000..b42697a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js @@ -0,0 +1,102 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( "+INPUT +" )" ; + + with ( this ) { + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js new file mode 100644 index 0000000..54980af --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js @@ -0,0 +1,98 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-3"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js new file mode 100644 index 0000000..88f8241 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js @@ -0,0 +1,101 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js new file mode 100644 index 0000000..f03d120 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js @@ -0,0 +1,101 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = null; + } + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js new file mode 100644 index 0000000..def668a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js @@ -0,0 +1,83 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + getTestCases(); + test(); + +function getTestCases() { + testcases[0] = new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[0].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + ; + } + testcases[0].actual = eval( INPUT ); + testcases[0].expect = INPUT; + +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js new file mode 100644 index 0000000..7f900b5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js @@ -0,0 +1,100 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-7"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + delete( eval ); + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js new file mode 100644 index 0000000..288f0ed --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js @@ -0,0 +1,101 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = new Function ( "x", "return(Math.pow(Number(x),3))" ); + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,3); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should cube INPUT: " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js new file mode 100644 index 0000000..ec72ecd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js @@ -0,0 +1,98 @@ +/* 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: 10.1.4-9.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-9"; + var VERSION = "ECMA_2"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var RESULT = "hello"; + + with ( MYOBJECT ) { + NEW_PROPERTY = RESULT; + } + testcases[tc].actual = NEW_PROPERTY; + testcases[tc].expect = RESULT; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "NEW_PROPERTY = " ); + + return ( array ); +} +function MyObject( n ) { + this.__proto__ = Number.prototype; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js new file mode 100644 index 0000000..0cfb7c3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js @@ -0,0 +1,118 @@ +/* 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: 10.1.5-1.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + if ( Object == null ) { + testcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + testcases[0].reason += " Function == null"; + } + if ( String == null ) { + testcases[0].reason += " String == null"; + } + if ( Array == null ) { + testcases[0].reason += " Array == null"; + } + if ( Number == null ) { + testcases[0].reason += " Function == null"; + } + if ( Math == null ) { + testcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + testcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + testcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + testcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + testcases[0].reason += " parseInt == null"; + } + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + 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 ); + + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Global Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js new file mode 100644 index 0000000..a09c1ae --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js @@ -0,0 +1,101 @@ +/* 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: 10.1.5-2.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { testcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { testcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { testcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { testcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { testcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { testcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { testcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { testcases[0].reason += " parseInt == null"; }' ; + + eval( EVAL_STRING ); + +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + 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 ); + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Eval Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js new file mode 100644 index 0000000..7b0f85f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js @@ -0,0 +1,119 @@ +/* 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: 10.1.5-3.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-3"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + test(); + +function test() { + if ( Object == null ) { + testcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + testcases[0].reason += " Function == null"; + } + if ( String == null ) { + testcases[0].reason += " String == null"; + } + if ( Array == null ) { + testcases[0].reason += " Array == null"; + } + if ( Number == null ) { + testcases[0].reason += " Function == null"; + } + if ( Math == null ) { + testcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + testcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + testcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + testcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + testcases[0].reason += " parseInt == null"; + } + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Function Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js new file mode 100644 index 0000000..2954346 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js @@ -0,0 +1,94 @@ +/* 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: 10.1.5-4.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-4"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { testcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { testcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { testcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { testcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { testcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { testcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { testcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { testcases[0].reason += " parseInt == null"; }' ; + + var NEW_FUNCTION = new Function( EVAL_STRING ); + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + 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].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Anonymous Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.6.js new file mode 100644 index 0000000..8224cb2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.6.js @@ -0,0 +1,124 @@ +/* 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: 10.1.6 + ECMA Section: Activation Object + Description: + + If the function object being invoked has an arguments property, let x be + the value of that property; the activation object is also given an internal + property [[OldArguments]] whose initial value is x; otherwise, an arguments + property is created for the function object but the activation object is + not given an [[OldArguments]] property. Next, arguments object described + below (the same one stored in the arguments property of the activation + object) is used as the new value of the arguments property of the function + object. This new value is installed even if the arguments property already + exists and has the ReadOnly attribute (as it will for native Function + objects). (These actions are taken to provide compatibility with a form of + program syntax that is now discouraged: to access the arguments object for + function f within the body of f by using the expression f.arguments. + The recommended way to access the arguments object for function f within + the body of f is simply to refer to the variable arguments.) + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Activation Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var arguments = "FAILED!"; + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5)).length", + 6, + (new TestObject(0,1,2,3,4,5)).length ); + + for ( i = 0; i < 6; i++ ) { + + testcases[tc++] = new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5))["+i+"]", + i, + (new TestObject(0,1,2,3,4,5))[i]); + } + + + // The current object already has an arguments property. + + testcases[tc++] = new TestCase( SECTION, + "(new AnotherTestObject(1,2,3)).arguments", + ARG_STRING, + (new AnotherTestObject(1,2,3)).arguments ); + + // The function invoked with [[Call]] + + testcases[tc++] = new TestCase( SECTION, + "TestFunction(1,2,3)", + ARG_STRING, + TestFunction() + '' ); + + + test(); + + + +function Prototype() { + this.arguments = ARG_STRING; +} +function TestObject() { + this.__proto__ = new Prototype(); + return arguments; +} +function AnotherTestObject() { + this.__proto__ = new Prototype(); + return this; +} +function TestFunction() { + arguments = ARG_STRING; + return arguments; +} +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} + +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/ExecutionContexts/10.1.8-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js new file mode 100644 index 0000000..28b403f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js @@ -0,0 +1,132 @@ +/* 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: 10.1.8 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Arguments Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + + var LIMIT = 100; + + for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + + } + + var LENGTH = eval( "GetLength("+ args +")" ); + + testcases[tc++] = new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + + var ARGUMENTS = eval( "GetArguments( " +args+")" ); + + for ( var i = 0; i < 100; i++ ) { + testcases[tc++] = new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); + } + + test(); + +function TestFunction() { + var arg_proto = arguments.__proto__; +} +function GetCallee() { + var c = arguments.callee; + return c; +} +function GetArguments() { + var a = arguments; + return a; +} +function GetLength() { + var l = arguments.length; + return l; +} + +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} + +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/ExecutionContexts/10.1.8-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js new file mode 100644 index 0000000..b4ff578 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js @@ -0,0 +1,117 @@ +/* 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: 10.1.8-2 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Arguments Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +// Tests for anonymous functions + + var GetCallee = new Function( "var c = arguments.callee; return c" ); + var GetArguments = new Function( "var a = arguments; return a" ); + var GetLength = new Function( "var l = arguments.length; return l" ); + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + + var LIMIT = 100; + + for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + + } + + var LENGTH = eval( "GetLength("+ args +")" ); + + testcases[tc++] = new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + + var ARGUMENTS = eval( "GetArguments( " +args+")" ); + + for ( var i = 0; i < 100; i++ ) { + testcases[tc++] = new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); + } + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.1.js new file mode 100644 index 0000000..5e5737b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.1.js @@ -0,0 +1,82 @@ +/* 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: 10.2.1.js + ECMA Section: 10.2.1 Global Code + Description: + + The scope chain is created and initialized to contain the global object and + no others. + + Variable instantiation is performed using the global object as the variable + object and using empty property attributes. + + The this value is the global object. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Global Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var THIS = this; + + testcases[tc++] = new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; + } + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == void 0", + false, + eval("GLOBAL_PROPERTIES["+i+"] == void 0")); + } + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js new file mode 100644 index 0000000..db03ad6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js @@ -0,0 +1,119 @@ +/* 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: 10.2.2-1.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var THIS = eval("this"); + + testcases[tc++] = new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in THIS ) { + GLOBAL_PROPERTIES[i++] = p; + } + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]", + true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + + // this in eval statements is the same as this value of the calling context + + var RESULT = THIS == this; + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + RESULT ); + + var RESULT = THIS +''; + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + RESULT ); + + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval( "this == THIS" ) ); + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + eval( "this +''") ); + + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js new file mode 100644 index 0000000..c73feff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js @@ -0,0 +1,105 @@ +/* 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: 10.2.2-2.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // Test Objects + + var OBJECT = new MyObject( "hello" ); + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; + } + + with ( OBJECT ) { + var THIS = this; + testcases[tc++] = new TestCase( SECTION, "eval( 'this == THIS' )", true, eval("this == THIS") ); + testcases[tc++] = new TestCase( SECTION, "this in a with() block", GLOBAL, this+"" ); + testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').value", "hello", value ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').value)", "hello", eval("value") ); + testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').getClass()", "[object Object]", getClass() ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').getClass())", "[object Object]", eval("getClass()") ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').toString())", "hello", eval("toString()") ); + testcases[tc++] = new TestCase( SECTION, "eval('getClass') == Object.prototype.toString", true, eval("getClass") == Object.prototype.toString ); + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, GLOBAL_PROPERTIES[i] + + " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + + } + + 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 ); +} +function MyObject( value ) { + this.value = value; + this.getClass = Object.prototype.toString; + this.toString = new Function( "return this.value+''" ); + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js new file mode 100644 index 0000000..be1a00f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js @@ -0,0 +1,83 @@ +/* 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: 10.2.3-1.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new MyObject("hello") + + testcases[tc++] = new TestCase( SECTION, + "var o = new MyObject('hello'); o.THIS == x", + true, + o.THIS == o ); + + var o = MyFunction(); + + testcases[tc++] = new TestCase( SECTION, + "var o = MyFunction(); o == this", + true, + o == this ); + + 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 ); +} + +function MyFunction( value ) { + return this; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js new file mode 100644 index 0000000..084d72f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js @@ -0,0 +1,89 @@ +/* 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: 10.2.3-2.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function and Anonymous Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new MyObject("hello") + + testcases[tc++] = new TestCase( SECTION, + "MyFunction(\"PASSED!\")", + "PASSED!", + MyFunction("PASSED!") ); + + var o = MyFunction(); + + testcases[tc++] = new TestCase( SECTION, + "MyOtherFunction(true);", + false, + MyOtherFunction(true) ); + + 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 ); +} + +function MyFunction( value ) { + var x = value; + delete x; + return x; +} +function MyOtherFunction(value) { + var x = value; + return delete x; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.1.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.1.1.js new file mode 100644 index 0000000..5801961 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.1.1.js @@ -0,0 +1,135 @@ +/* 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: 11.1.1.js + ECMA Section: 11.1.1 The this keyword + Description: + + The this keyword evaluates to the this value of the execution context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.1.1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " The this keyword"); + + var testcases = new Array(); + var item = 0; + + var GLOBAL_OBJECT = this.toString(); + + // this in global code and eval(this) in global code should return the global object. + + testcases[item++] = new TestCase( SECTION, + "Global Code: this.toString()", + GLOBAL_OBJECT, + this.toString() ); + + testcases[item++] = new TestCase( SECTION, + "Global Code: eval('this.toString()')", + GLOBAL_OBJECT, + eval('this.toString()') ); + + // this in anonymous code called as a function should return the global object. + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return this.toString()'); MYFUNC()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return this.toString()'); MYFUNC()") ); + + // eval( this ) in anonymous code called as a function should return that function's activation object + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return (eval(\"this.toString()\")'); (MYFUNC()).toString()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return eval(\"this.toString()\")'); (MYFUNC()).toString()") ); + + // this and eval( this ) in anonymous code called as a constructor should return the object + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()") ); + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC().THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC()).THIS).toString()") ); + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); + + // this and eval(this) in function code called as a function should return the global object. + testcases[item++] = new TestCase( SECTION, + "Function Code: ReturnThis()", + GLOBAL_OBJECT, + ReturnThis() ); + + testcases[item++] = new TestCase( SECTION, + "Function Code: ReturnEvalThis()", + GLOBAL_OBJECT, + ReturnEvalThis() ); + + // this and eval(this) in function code called as a contructor should return the object. + testcases[item++] = new TestCase( SECTION, + "var MYOBJECT = new ReturnThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnThis(); MYOBJECT.toString()") ); + + testcases[item++] = new TestCase( SECTION, + "var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()") ); + + + + 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 ); +} +function ReturnThis() { + return this.toString(); +} +function ReturnEvalThis() { + return( eval("this.toString()") ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-1.js new file mode 100644 index 0000000..c5f6911 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-1.js @@ -0,0 +1,270 @@ +/* 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: 11.10-1.js + ECMA Section: 11.10-1 Binary Bitwise Operators: & + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.10-1"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Binary Bitwise Operators: &"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var shiftexp = 0; + var addexp = 0; + +// for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + for ( shiftpow = 0; shiftpow < 1; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + array[item++] = new TestCase( SECTION, + shiftexp + " & " + addexp, + And( shiftexp, addexp ), + shiftexp & addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-2.js new file mode 100644 index 0000000..fc2e10e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-2.js @@ -0,0 +1,269 @@ +/* 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: 11.10-2.js + ECMA Section: 11.10-2 Binary Bitwise Operators: | + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.10-2"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Binary Bitwise Operators: |"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var shiftexp = 0; + var addexp = 0; + + for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + array[item++] = new TestCase( SECTION, + shiftexp + " | " + addexp, + Or( shiftexp, addexp ), + shiftexp | addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-3.js new file mode 100644 index 0000000..0d55357 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.10-3.js @@ -0,0 +1,268 @@ +/* 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: 11.10-3.js + ECMA Section: 11.10-3 Binary Bitwise Operators: ^ + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.10-3"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Binary Bitwise Operators: ^"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var shiftexp = 0; + var addexp = 0; + + for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + array[item++] = new TestCase( SECTION, + shiftexp + " ^ " + addexp, + Xor( shiftexp, addexp ), + shiftexp ^ addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-1.js new file mode 100644 index 0000000..ae0a263 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-1.js @@ -0,0 +1,86 @@ +/* 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: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi + + calORExpression ? AssignmentExpression : AssignmentExpression + + Semantics + + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: + + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). + 10. Return Result(9). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.12"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Conditional operator( ? : )"); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + array[item++] = new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + + array[item++] = new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); + + 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/Expressions/11.12-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-2-n.js new file mode 100644 index 0000000..05e42dc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-2-n.js @@ -0,0 +1,71 @@ +/* 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: 11.12-2-n.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.12-2-n"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + + var testcases = new Array(); + + // the following expression should be an error in JS. + + testcases[tc] = new TestCase( SECTION, + "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR", + "error", + "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR" ); + + // get around parse time error by putting expression in an eval statement + + testcases[tc].actual = eval ( testcases[tc].actual ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-3.js new file mode 100644 index 0000000..eb79c16 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-3.js @@ -0,0 +1,71 @@ +/* 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: 11.12-3.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.12-3"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + + var testcases = new Array(); + + // the following expression should NOT be an error in JS. + + testcases[tc] = new TestCase( SECTION, + "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR", + "PASSED", + "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR" ); + + // get around potential parse time error by putting expression in an eval statement + + testcases[tc].actual = eval ( testcases[tc].actual ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-4.js new file mode 100644 index 0000000..017cf4b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.12-4.js @@ -0,0 +1,71 @@ +/* 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: 11.12-4.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.12-4"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + + var testcases = new Array(); + + // the following expression should NOT be an error in JS. + + testcases[tc] = new TestCase( SECTION, + "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1", + "PASSED", + "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1" ); + + // get around potential parse time error by putting expression in an eval statement + + testcases[tc].actual = eval ( testcases[tc].actual ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.1.js new file mode 100644 index 0000000..537ec28 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.1.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: 11.13.1.js + ECMA Section: 11.13.1 Simple assignment + Description: + + 11.13.1 Simple Assignment ( = ) + + The production AssignmentExpression : + LeftHandSideExpression = AssignmentExpression is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Evaluate AssignmentExpression. + 3. Call GetValue(Result(2)). + 4. Call PutValue(Result(1), Result(3)). + 5. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Simple Assignment ( = )"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "SOMEVAR = true", true, SOMEVAR = true ); + + + 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/Expressions/11.13.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-1.js new file mode 100644 index 0000000..721fb19 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-1.js @@ -0,0 +1,122 @@ +/* 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: 11.13.2-1.js + ECMA Section: 11.13.2 Compound Assignment: *= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: *="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // NaN cases + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 *= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 *= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2; VAR1") ); + + // number cases + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 *= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 *= VAR2") ); + + // special multiplication cases + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 *= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 *= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 *= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 *= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + + // string cases + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '255', VAR1 *= VAR2", 2550, eval("VAR1 = 10; VAR2 = '255', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2", 2550, eval("VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 *= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 *= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 *= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2", 225, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2") ); + + + 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/Expressions/11.13.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-2.js new file mode 100644 index 0000000..5838acf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-2.js @@ -0,0 +1,136 @@ +/* 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: 11.13.2-2js + ECMA Section: 11.13.2 Compound Assignment: /= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: /="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // NaN cases + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") ); + + // number cases + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", 25.5, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") ); + + // special division cases + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + + // string cases + array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", 100, eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", 100, eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") ); +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") ); + +*/ + 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/Expressions/11.13.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-3.js new file mode 100644 index 0000000..cf151db --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-3.js @@ -0,0 +1,149 @@ +/* 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: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment: %= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: +="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // If either operand is NaN, result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2; VAR1") ); + + // if the dividend is infinity or the divisor is zero or both, the result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + + // if the dividend is finite and the divisor is an infinity, the result equals the dividend. + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + + // if the dividend is a zero and the divisor is finite, the result is the same as the dividend + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + + // string cases + array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1", 0, eval("VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1") ); +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 %= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 %= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 %= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2") ); + +*/ + 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/Expressions/11.13.2-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-4.js new file mode 100644 index 0000000..edf79a7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-4.js @@ -0,0 +1,137 @@ +/* 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: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment:+= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: +="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // If either operand is NaN, result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2; VAR1") ); + + // the sum of two Infinities the same sign is the infinity of that sign + // the sum of two Infinities of opposite sign is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 += VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + + // the sum of an infinity and a finite value is equal to the infinite operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + + // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 += VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 += VAR2; VAR1") ); + + // the sum of a zero and a nonzero finite value is eqal to the nonzero operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = 0; VAR2 = 1; VAR2 += VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = -0; VAR2 = 1; VAR2 += VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = -0; VAR2 = -1; VAR2 += VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = 0; VAR2 = -1; VAR2 += VAR1; VAR2") ); + + // the sum of a zero and a nozero finite value is equal to the nonzero operand. + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1") ); + + // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 + array[item++] = new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1") ); + +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 += VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 += VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 += VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 += VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 += VAR2") ); + +*/ + 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/Expressions/11.13.2-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-5.js new file mode 100644 index 0000000..6923bef --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.2-5.js @@ -0,0 +1,137 @@ +/* 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: 11.13.2-5.js + ECMA Section: 11.13.2 Compound Assignment: -= + Description: + + *= /= %= -= -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-5"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: -="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // If either operand is NaN, result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2; VAR1") ); + + // the sum of two Infinities the same sign is the infinity of that sign + // the sum of two Infinities of opposite sign is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 -= VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + + // the sum of an infinity and a finite value is equal to the infinite operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + + // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 -= VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); + + // the sum of a zero and a nonzero finite value is eqal to the nonzero operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = 0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = -0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = -0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = 0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); + + // the sum of a zero and a nozero finite value is equal to the nonzero operand. + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); + + // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 + array[item++] = new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1") ); + +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 -= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 -= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 -= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2") ); + +*/ + 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/Expressions/11.13.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.js new file mode 100644 index 0000000..73b4d19 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.13.js @@ -0,0 +1,86 @@ +/* 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: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi + + calORExpression ? AssignmentExpression : AssignmentExpression + + Semantics + + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: + + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). + 10. Return Result(9). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.12"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Conditional operator( ? : )"); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + array[item++] = new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + + array[item++] = new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); + + 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/Expressions/11.14-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.14-1.js new file mode 100644 index 0000000..bd3e8f1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.14-1.js @@ -0,0 +1,73 @@ +/* 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: 11.14-1.js + ECMA Section: 11.14 Comma operator (,) + Description: + Expression : + + AssignmentExpression + Expression , AssignmentExpression + + Semantics + + The production Expression : Expression , AssignmentExpression is evaluated as follows: + + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Return Result(4). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.14-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Comma operator (,)"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true, false", false, eval("true, false") ); + array[item++] = new TestCase( SECTION, "VAR1=true, VAR2=false", false, eval("VAR1=true, VAR2=false") ); + array[item++] = new TestCase( SECTION, "VAR1=true, VAR2=false;VAR1", true, eval("VAR1=true, VAR2=false; VAR1") ); + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-1.js new file mode 100644 index 0000000..6144c9a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-1.js @@ -0,0 +1,268 @@ +/* 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: 11.2.1-1.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ <identifier-string> ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ <identifier-string> ] + where <identifier-string> is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // properties and functions of the global object + + PROPERTY[p++] = new Property( "this", "NaN", "number" ); + PROPERTY[p++] = new Property( "this", "Infinity", "number" ); + PROPERTY[p++] = new Property( "this", "eval", "function" ); + PROPERTY[p++] = new Property( "this", "parseInt", "function" ); + PROPERTY[p++] = new Property( "this", "parseFloat", "function" ); + PROPERTY[p++] = new Property( "this", "escape", "function" ); + PROPERTY[p++] = new Property( "this", "unescape", "function" ); + PROPERTY[p++] = new Property( "this", "isNaN", "function" ); + PROPERTY[p++] = new Property( "this", "isFinite", "function" ); + PROPERTY[p++] = new Property( "this", "Object", "function" ); + PROPERTY[p++] = new Property( "this", "Number", "function" ); + PROPERTY[p++] = new Property( "this", "Function", "function" ); + PROPERTY[p++] = new Property( "this", "Array", "function" ); + PROPERTY[p++] = new Property( "this", "String", "function" ); + PROPERTY[p++] = new Property( "this", "Boolean", "function" ); + PROPERTY[p++] = new Property( "this", "Date", "function" ); + PROPERTY[p++] = new Property( "this", "Math", "object" ); + + // properties and methods of Object objects + + PROPERTY[p++] = new Property( "Object", "prototype", "object" ); + PROPERTY[p++] = new Property( "Object", "toString", "function" ); + PROPERTY[p++] = new Property( "Object", "valueOf", "function" ); + PROPERTY[p++] = new Property( "Object", "constructor", "function" ); + + // properties of the Function object + + PROPERTY[p++] = new Property( "Function", "prototype", "function" ); + PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Function.prototype", "length", "number" ); + PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" ); + + Function.prototype.myProperty = "hi"; + + PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" ); + + // properties of the Array object + PROPERTY[p++] = new Property( "Array", "prototype", "object" ); + PROPERTY[p++] = new Property( "Array", "length", "number" ); + PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "join", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" ); + + // properties of the String object + PROPERTY[p++] = new Property( "String", "prototype", "object" ); + PROPERTY[p++] = new Property( "String", "fromCharCode", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "split", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "substring", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "length", "number" ); + + // properties of the Boolean object + PROPERTY[p++] = new Property( "Boolean", "prototype", "object" ); + PROPERTY[p++] = new Property( "Boolean", "constructor", "function" ); + PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" ); + PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" ); + + // properties of the Number object + + PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" ); + PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" ); + PROPERTY[p++] = new Property( "Number", "NaN", "number" ); + PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" ); + PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" ); + PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" ); + + // properties of the Math Object. + PROPERTY[p++] = new Property( "Math", "E", "number" ); + PROPERTY[p++] = new Property( "Math", "LN10", "number" ); + PROPERTY[p++] = new Property( "Math", "LN2", "number" ); + PROPERTY[p++] = new Property( "Math", "LOG2E", "number" ); + PROPERTY[p++] = new Property( "Math", "LOG10E", "number" ); + PROPERTY[p++] = new Property( "Math", "PI", "number" ); + PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" ); + PROPERTY[p++] = new Property( "Math", "SQRT2", "number" ); + PROPERTY[p++] = new Property( "Math", "abs", "function" ); + PROPERTY[p++] = new Property( "Math", "acos", "function" ); + PROPERTY[p++] = new Property( "Math", "asin", "function" ); + PROPERTY[p++] = new Property( "Math", "atan", "function" ); + PROPERTY[p++] = new Property( "Math", "atan2", "function" ); + PROPERTY[p++] = new Property( "Math", "ceil", "function" ); + PROPERTY[p++] = new Property( "Math", "cos", "function" ); + PROPERTY[p++] = new Property( "Math", "exp", "function" ); + PROPERTY[p++] = new Property( "Math", "floor", "function" ); + PROPERTY[p++] = new Property( "Math", "log", "function" ); + PROPERTY[p++] = new Property( "Math", "max", "function" ); + PROPERTY[p++] = new Property( "Math", "min", "function" ); + PROPERTY[p++] = new Property( "Math", "pow", "function" ); + PROPERTY[p++] = new Property( "Math", "random", "function" ); + PROPERTY[p++] = new Property( "Math", "round", "function" ); + PROPERTY[p++] = new Property( "Math", "sin", "function" ); + PROPERTY[p++] = new Property( "Math", "sqrt", "function" ); + PROPERTY[p++] = new Property( "Math", "tan", "function" ); + + // properties of the Date object + PROPERTY[p++] = new Property( "Date", "parse", "function" ); + PROPERTY[p++] = new Property( "Date", "prototype", "object" ); + PROPERTY[p++] = new Property( "Date", "UTC", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name ); + + testcases[tc++] = new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name, + PROPERTY[i].type, + RESULT ); + + RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']"); + + testcases[tc++] = new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']", + PROPERTY[i].type, + RESULT ); + } + + 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 ); +} +function MyObject( arg0, arg1, arg2, arg3, arg4 ) { + this.name = arg0; +} +function Property( object, name, type ) { + this.object = object; + this.name = name; + this.type = type; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-2.js new file mode 100644 index 0000000..fa3056b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-2.js @@ -0,0 +1,124 @@ +/* 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: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ <identifier-string> ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ <identifier-string> ] + where <identifier-string> is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( "\"hi\"", "hi", "hi", NaN ); + PROPERTY[p++] = new Property( NaN, NaN, "NaN", NaN ); +// PROPERTY[p++] = new Property( 3, 3, "3", 3 ); + PROPERTY[p++] = new Property( true, true, "true", 1 ); + PROPERTY[p++] = new Property( false, false, "false", 0 ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + + } + + 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 ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-3-n.js new file mode 100644 index 0000000..f84bb28 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-3-n.js @@ -0,0 +1,120 @@ +/* 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: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ <identifier-string> ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ <identifier-string> ] + where <identifier-string> is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( "undefined", void 0, "undefined", NaN ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + + } + + 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 ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-4-n.js new file mode 100644 index 0000000..0127253 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-4-n.js @@ -0,0 +1,120 @@ +/* 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: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ <identifier-string> ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ <identifier-string> ] + where <identifier-string> is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( "null", null, "null", 0 ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + + } + + 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 ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-5.js new file mode 100644 index 0000000..0cb19c9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.1-5.js @@ -0,0 +1,124 @@ +/* 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: 11.2.1-5.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ <identifier-string> ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ <identifier-string> ] + where <identifier-string> is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( new String("hi"), "hi", "hi", NaN ); + PROPERTY[p++] = new Property( new Number(NaN), NaN, "NaN", NaN ); + PROPERTY[p++] = new Property( new Number(3), 3, "3", 3 ); + PROPERTY[p++] = new Property( new Boolean(true), true, "true", 1 ); + PROPERTY[p++] = new Property( new Boolean(false), false, "false", 0 ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( "PROPERTY[i].object.valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( "PROPERTY[i].object.toString()" ) ); + + } + + 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 ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-1-n.js new file mode 100644 index 0000000..db73cad --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-1-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-1-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var OBJECT = new Object(); + + testcases[tc++] = new TestCase( SECTION, + "OBJECT = new Object; var o = new OBJECT()", + "error", + o = new OBJECT() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-1.js new file mode 100644 index 0000000..48c2e6a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-1.js @@ -0,0 +1,99 @@ +/* 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: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "(new TestFunction(0,1,2,3,4,5)).length", + 6, + (new TestFunction(0,1,2,3,4,5)).length ); + + + + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-10-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-10-n.js new file mode 100644 index 0000000..619554d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-10-n.js @@ -0,0 +1,96 @@ +/* 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: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-9-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "var m = new Math()", + "error", + m = new Math() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-11.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-11.js new file mode 100644 index 0000000..a6f7364 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-11.js @@ -0,0 +1,99 @@ +/* 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: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-9-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var FUNCTION = new Function(); + + testcases[tc++] = new TestCase( SECTION, + "var FUNCTION = new Function(); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") ); + + testcases[tc++] = new TestCase( SECTION, + "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-2-n.js new file mode 100644 index 0000000..4e74cd4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-2-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-2.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-2-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var UNDEFINED = void 0; + + testcases[tc++] = new TestCase( SECTION, + "UNDEFINED = void 0; var o = new UNDEFINED()", + "error", + o = new UNDEFINED() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-3-n.js new file mode 100644 index 0000000..2c6b509 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-3-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-3-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var NULL = null; + + testcases[tc++] = new TestCase( SECTION, + "NULL = null; var o = new NULL()", + "error", + o = new NULL() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-4-n.js new file mode 100644 index 0000000..a9e5f4a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-4-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-4-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var STRING = ""; + + testcases[tc++] = new TestCase( SECTION, + "STRING = '', var s = new STRING()", + "error", + s = new STRING() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-5-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-5-n.js new file mode 100644 index 0000000..304f1d3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-5-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-5-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var NUMBER = 0; + + testcases[tc++] = new TestCase( SECTION, + "NUMBER=0, var n = new NUMBER()", + "error", + n = new NUMBER() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-6-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-6-n.js new file mode 100644 index 0000000..fd24e4f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-6-n.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: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.2-6-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var BOOLEAN = true; + + testcases[tc++] = new TestCase( SECTION, + "BOOLEAN = true; var b = new BOOLEAN()", + "error", + b = new BOOLEAN() ); + test(); + +function TestFunction() { + return arguments; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-7-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-7-n.js new file mode 100644 index 0000000..4a54726 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-7-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-6-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var STRING = new String("hi"); + + testcases[tc++] = new TestCase( SECTION, + "var STRING = new String('hi'); var s = new STRING()", + "error", + s = new STRING() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-8-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-8-n.js new file mode 100644 index 0000000..eb58ff5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-8-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-8-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var NUMBER = new Number(1); + + testcases[tc++] = new TestCase( SECTION, + "var NUMBER = new Number(1); var n = new NUMBER()", + "error", + n = new NUMBER() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.2-9-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-9-n.js new file mode 100644 index 0000000..56199cf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.2-9-n.js @@ -0,0 +1,98 @@ +/* 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: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-9-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var BOOLEAN = new Boolean(); + + testcases[tc++] = new TestCase( SECTION, + "var BOOLEAN = new Boolean(); var b = new BOOLEAN()", + "error", + b = new BOOLEAN() ); + test(); + +function TestFunction() { + return arguments; +} +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/Expressions/11.2.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-1.js new file mode 100644 index 0000000..7653900 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-1.js @@ -0,0 +1,121 @@ +/* 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: 11.2.3-1.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +/* this.eval() is no longer legal syntax. + // MemberExpression : this + + testcases[tc++] = new TestCase( SECTION, + "this.eval()", + void 0, + this.eval() ); + + testcases[tc++] = new TestCase( SECTION, + "this.eval('NaN')", + NaN, + this.eval("NaN") ); +*/ + // MemberExpression: Identifier + + var OBJECT = true; + + testcases[tc++] = new TestCase( SECTION, + "OBJECT.toString()", + "true", + OBJECT.toString() ); + + // MemberExpression[ Expression] + + testcases[tc++] = new TestCase( SECTION, + "(new Array())['length'].valueOf()", + 0, + (new Array())["length"].valueOf() ); + + // MemberExpression . Identifier + testcases[tc++] = new TestCase( SECTION, + "(new Array()).length.valueOf()", + 0, + (new Array()).length.valueOf() ); + // new MemberExpression Arguments + + testcases[tc++] = new TestCase( SECTION, + "(new Array(20))['length'].valueOf()", + 20, + (new Array(20))["length"].valueOf() ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-2-n.js new file mode 100644 index 0000000..e5ba65c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-2-n.js @@ -0,0 +1,90 @@ +/* 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: 11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-2-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "3.valueOf()", + 3, + 3.valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(3).valueOf()", + 3, + (3).valueOf() ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-3-n.js new file mode 100644 index 0000000..da58907 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-3-n.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: 11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-3-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "(void 0).valueOf()", "error", (void 0).valueOf() ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-4-n.js new file mode 100644 index 0000000..eed49b2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-4-n.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: 11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-4-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "null.valueOf()", "error", null.valueOf() ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-5.js new file mode 100644 index 0000000..77a0f6c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.2.3-5.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: 11.2.3-5-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1. Evaluate MemberExpression. + 2. Evaluate Arguments, producing an internal list of argument values + (section 0). + 3. Call GetValue(Result(1)). + 4. If Type(Result(3)) is not Object, generate a runtime error. + 5. If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6. If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7. If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8. Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9. Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "true.valueOf()", true, true.valueOf() ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.3.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.3.1.js new file mode 100644 index 0000000..0e1e8aa --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.3.1.js @@ -0,0 +1,154 @@ +/* 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: 11.3.1.js + ECMA Section: 11.3.1 Postfix increment operator + Description: + The production MemberExpression : MemberExpression ++ is evaluated as + follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.3.1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Postfix increment operator"); + + testcases = getTestCases(); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special numbers + array[item++] = new TestCase( SECTION, "var MYVAR; MYVAR++", NaN, eval("var MYVAR; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; MYVAR++", NaN, eval("var MYVAR=void 0; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; MYVAR++", 0, eval("var MYVAR=null; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; MYVAR++", 1, eval("var MYVAR=true; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; MYVAR++", 0, eval("var MYVAR=false; MYVAR++") ); + + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++;MYVAR") ); + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++", 0, eval("var MYVAR=0;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++", 0.2345, eval("var MYVAR=0.2345;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++", -0.2345, eval("var MYVAR=-0.2345;MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++;MYVAR", 1.2345, eval("var MYVAR=0.2345;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++;MYVAR", 0.7655, eval("var MYVAR=-0.2345;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR++;MYVAR", 2, eval("var MYVAR=true;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR++;MYVAR", 1, eval("var MYVAR=false;MYVAR++;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++;MYVAR", 2, eval("var MYVAR=new Boolean(true);MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++;MYVAR", 1, eval("var MYVAR=new Boolean(false);MYVAR++;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR++", Number.NaN, eval("var MYVAR='string';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR++", 12345, eval("var MYVAR='12345';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR++", -12345, eval("var MYVAR='-12345';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';MYVAR++", 15, eval("var MYVAR='0Xf';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR++", 77, eval("var MYVAR='077';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; MYVAR++", 0, eval("var MYVAR='';MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR++;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR++;MYVAR", 12346, eval("var MYVAR='12345';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR++;MYVAR", -12344, eval("var MYVAR='-12345';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';MYVAR++;MYVAR", 16, eval("var MYVAR='0xf';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR++;MYVAR", 78, eval("var MYVAR='077';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';MYVAR++;MYVAR", 1, eval("var MYVAR='';MYVAR++;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++", Number.NaN, eval("var MYVAR=new String('string');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++", 12345, eval("var MYVAR=new String('12345');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++", -12345, eval("var MYVAR=new String('-12345');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR++", 15, eval("var MYVAR=new String('0Xf');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++", 77, eval("var MYVAR=new String('077');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); MYVAR++", 0, eval("var MYVAR=new String('');MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++;MYVAR", 12346, eval("var MYVAR=new String('12345');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++;MYVAR", -12344, eval("var MYVAR=new String('-12345');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR++;MYVAR", 16, eval("var MYVAR=new String('0xf');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++;MYVAR", 78, eval("var MYVAR=new String('077');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');MYVAR++;MYVAR", 1, eval("var MYVAR=new String('');MYVAR++;MYVAR") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.3.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.3.2.js new file mode 100644 index 0000000..1042f85 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.3.2.js @@ -0,0 +1,154 @@ +/* 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: 11.3.2.js + ECMA Section: 11.3.2 Postfix decrement operator + Description: + + 11.3.2 Postfix decrement operator + + The production MemberExpression : MemberExpression -- is evaluated as follows: + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Subtract the value 1 from Result(3), using the same rules as for the - + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.3.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Postfix decrement operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special numbers + array[item++] = new TestCase( SECTION, "var MYVAR; MYVAR--", NaN, eval("var MYVAR; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; MYVAR--", NaN, eval("var MYVAR=void 0; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; MYVAR--", 0, eval("var MYVAR=null; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; MYVAR--", 1, eval("var MYVAR=true; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; MYVAR--", 0, eval("var MYVAR=false; MYVAR--") ); + + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--;MYVAR") ); + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--", 0, eval("var MYVAR=0;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--", 0.2345, eval("var MYVAR=0.2345;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--", -0.2345, eval("var MYVAR=-0.2345;MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--;MYVAR", -0.7655, eval("var MYVAR=0.2345;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--;MYVAR", -1.2345, eval("var MYVAR=-0.2345;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR--;MYVAR", 0, eval("var MYVAR=true;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR--;MYVAR", -1, eval("var MYVAR=false;MYVAR--;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--;MYVAR", 0, eval("var MYVAR=new Boolean(true);MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--;MYVAR", -1, eval("var MYVAR=new Boolean(false);MYVAR--;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR--", Number.NaN, eval("var MYVAR='string';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR--", 12345, eval("var MYVAR='12345';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR--", -12345, eval("var MYVAR='-12345';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';MYVAR--", 15, eval("var MYVAR='0Xf';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR--", 77, eval("var MYVAR='077';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; MYVAR--", 0, eval("var MYVAR='';MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR--;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR--;MYVAR", 12344, eval("var MYVAR='12345';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR--;MYVAR", -12346, eval("var MYVAR='-12345';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';MYVAR--;MYVAR", 14, eval("var MYVAR='0xf';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR--;MYVAR", 76, eval("var MYVAR='077';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';MYVAR--;MYVAR", -1, eval("var MYVAR='';MYVAR--;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--", Number.NaN, eval("var MYVAR=new String('string');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--", 12345, eval("var MYVAR=new String('12345');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--", -12345, eval("var MYVAR=new String('-12345');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR--", 15, eval("var MYVAR=new String('0Xf');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--", 77, eval("var MYVAR=new String('077');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); MYVAR--", 0, eval("var MYVAR=new String('');MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--;MYVAR", 12344, eval("var MYVAR=new String('12345');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--;MYVAR", -12346, eval("var MYVAR=new String('-12345');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR--;MYVAR", 14, eval("var MYVAR=new String('0xf');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--;MYVAR", 76, eval("var MYVAR=new String('077');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');MYVAR--;MYVAR", -1, eval("var MYVAR=new String('');MYVAR--;MYVAR") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.1.js new file mode 100644 index 0000000..766b786 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.1.js @@ -0,0 +1,95 @@ +/* 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: 11.4.1.js + ECMA Section: 11.4.1 the Delete Operator + Description: returns true if the property could be deleted + returns false if it could not be deleted + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + + var SECTION = "11.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The delete operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") ); +// array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") ); + array[item++] = new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") ); + +// array[item++] = new TestCase( SECTION, "delete(x=new Date())", true, delete(x=new Date()) ); +// array[item++] = new TestCase( SECTION, "delete('string primitive')", true, delete("string primitive") ); +// array[item++] = new TestCase( SECTION, "delete(new String( 'string object' ) )", true, delete(new String("string object")) ); +// array[item++] = new TestCase( SECTION, "delete(new Number(12345) )", true, delete(new Number(12345)) ); + array[item++] = new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) ); +// array[item++] = new TestCase( SECTION, "delete(null)", true, delete(null) ); +// array[item++] = new TestCase( SECTION, "delete(void(0))", true, delete(void(0)) ); + + // variables declared with the var statement are not deletable. + + var abc; + array[item++] = new TestCase( SECTION, "var abc; delete(abc)", false, delete abc ); + + array[item++] = new TestCase( SECTION, + "var OB = new MyObject(); for ( p in OB ) { delete p }", + true, + eval("var OB = new MyObject(); for ( p in OB ) { delete p }") ); + 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() { + this.prop1 = true; + this.prop2 = false; + this.prop3 = null + this.prop4 = void 0; + this.prop5 = "hi"; + this.prop6 = 42; + this.prop7 = new Date(); + this.prop8 = Math.PI; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.2.js new file mode 100644 index 0000000..c889ec6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.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: 11.4.2.js + ECMA Section: 11.4.2 the Void Operator + Description: always returns undefined (?) + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "11.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The void operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "void(new String('string object'))", void 0, void(new String( 'string object' )) ); + array[item++] = new TestCase( SECTION, "void('string primitive')", void 0, void("string primitive") ); + array[item++] = new TestCase( SECTION, "void(Number.NaN)", void 0, void(Number.NaN) ); + array[item++] = new TestCase( SECTION, "void(Number.POSITIVE_INFINITY)", void 0, void(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "void(1)", void 0, void(1) ); + array[item++] = new TestCase( SECTION, "void(0)", void 0, void(0) ); + array[item++] = new TestCase( SECTION, "void(-1)", void 0, void(-1) ); + array[item++] = new TestCase( SECTION, "void(Number.NEGATIVE_INFINITY)", void 0, void(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "void(Math.PI)", void 0, void(Math.PI) ); + array[item++] = new TestCase( SECTION, "void(true)", void 0, void(true) ); + array[item++] = new TestCase( SECTION, "void(false)", void 0, void(false) ); + array[item++] = new TestCase( SECTION, "void(null)", void 0, void(null) ); + array[item++] = new TestCase( SECTION, "void new String('string object')", void 0, void new String( 'string object' ) ); + array[item++] = new TestCase( SECTION, "void 'string primitive'", void 0, void "string primitive" ); + array[item++] = new TestCase( SECTION, "void Number.NaN", void 0, void Number.NaN ); + array[item++] = new TestCase( SECTION, "void Number.POSITIVE_INFINITY", void 0, void Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "void 1", void 0, void 1 ); + array[item++] = new TestCase( SECTION, "void 0", void 0, void 0 ); + array[item++] = new TestCase( SECTION, "void -1", void 0, void -1 ); + array[item++] = new TestCase( SECTION, "void Number.NEGATIVE_INFINITY", void 0, void Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "void Math.PI", void 0, void Math.PI ); + array[item++] = new TestCase( SECTION, "void true", void 0, void true ); + array[item++] = new TestCase( SECTION, "void false", void 0, void false ); + array[item++] = new TestCase( SECTION, "void null", void 0, void null ); + +// array[item++] = new TestCase( SECTION, "void()", void 0, void() ); + + return ( array ); +} + +function test() { + for ( i = 0; i < testcases.length; i++ ) { + testcases[i].passed = writeTestCaseResult( + testcases[i].expect, + testcases[i].actual, + testcases[i].description +" = "+ testcases[i].actual ); + testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.3.js new file mode 100644 index 0000000..eccfa0d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.3.js @@ -0,0 +1,109 @@ +/* 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: typeof_1.js + ECMA Section: 11.4.3 typeof operator + Description: typeof evaluates unary expressions: + undefined "undefined" + null "object" + Boolean "boolean" + Number "number" + String "string" + Object "object" [native, doesn't implement Call] + Object "function" [native, implements [Call]] + Object implementation dependent + [not sure how to test this] + Author: christine@netscape.com + Date: june 30, 1997 + +*/ + + var SECTION = "11.4.3"; + + var VERSION = "ECMA_1"; + startTest(); + var TITLE = " The typeof operator"; + + var testcases = new Array(); + + + testcases[testcases.length] = new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(null)", "object", typeof(null) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(0)", "number", typeof(0) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(1)", "number", typeof(1) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof('0')", "string", typeof("0") ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) ); + + // Math does not implement [[Construct]] or [[Call]] so its type is object. + + testcases[testcases.length] = new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) ); + + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) ); + + testcases[testcases.length] = new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") ); + testcases[testcases.length] = new TestCase( SECTION, "typeof('')", "string", typeof("") ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(test)", "function", typeof( test ) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) ); + + + writeHeaderToLog( SECTION + " "+ TITLE); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.4.js new file mode 100644 index 0000000..7a7a547 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.4.js @@ -0,0 +1,156 @@ +/* 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: 11.4.4.js + ECMA Section: 11.4.4 Prefix increment operator + Description: + The production UnaryExpression : ++ UnaryExpression is evaluated as + follows: + + 1. Evaluate UnaryExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 11.6.3). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(4). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.4.4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Prefix increment operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special case: var is not defined + + array[item++] = new TestCase( SECTION, "var MYVAR; ++MYVAR", NaN, eval("var MYVAR; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; ++MYVAR", NaN, eval("var MYVAR=void 0; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; ++MYVAR", 1, eval("var MYVAR=null; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; ++MYVAR", 2, eval("var MYVAR=true; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; ++MYVAR", 1, eval("var MYVAR=false; ++MYVAR") ); + + // special numbers + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR;MYVAR") ); + + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR", 1, eval("var MYVAR=0;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR;MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR;MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;++MYVAR;MYVAR", 2, eval("var MYVAR=true;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;++MYVAR;MYVAR", 1, eval("var MYVAR=false;++MYVAR;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR;MYVAR", 2, eval("var MYVAR=new Boolean(true);++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR;MYVAR", 1, eval("var MYVAR=new Boolean(false);++MYVAR;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';++MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';++MYVAR", 12346, eval("var MYVAR='12345';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';++MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';++MYVAR", 16, eval("var MYVAR='0Xf';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';++MYVAR", 78, eval("var MYVAR='077';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; ++MYVAR", 1, eval("var MYVAR='';++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';++MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';++MYVAR;MYVAR", 12346, eval("var MYVAR='12345';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';++MYVAR;MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';++MYVAR;MYVAR", 16, eval("var MYVAR='0xf';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';++MYVAR;MYVAR", 78, eval("var MYVAR='077';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';++MYVAR;MYVAR", 1, eval("var MYVAR='';++MYVAR;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');++MYVAR", 16, eval("var MYVAR=new String('0Xf');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); ++MYVAR", 1, eval("var MYVAR=new String('');++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR;MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR;MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');++MYVAR;MYVAR", 16, eval("var MYVAR=new String('0xf');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR;MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');++MYVAR;MYVAR", 1, eval("var MYVAR=new String('');++MYVAR;MYVAR") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.5.js new file mode 100644 index 0000000..d82ac60 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.5.js @@ -0,0 +1,154 @@ +/* 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: 11.4.5.js + ECMA Section: 11.4.5 Prefix decrement operator + Description: + + The production UnaryExpression : -- UnaryExpression is evaluated as follows: + + 1.Evaluate UnaryExpression. + 2.Call GetValue(Result(1)). + 3.Call ToNumber(Result(2)). + 4.Subtract the value 1 from Result(3), using the same rules as for the - operator (section 11.6.3). + 5.Call PutValue(Result(1), Result(4)). + + 1.Return Result(4). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.4.5"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Prefix decrement operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // + array[item++] = new TestCase( SECTION, "var MYVAR; --MYVAR", NaN, eval("var MYVAR; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; --MYVAR", NaN, eval("var MYVAR=void 0; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; --MYVAR", -1, eval("var MYVAR=null; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; --MYVAR", 0, eval("var MYVAR=true; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; --MYVAR", -1, eval("var MYVAR=false; --MYVAR") ); + + // special numbers + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR;MYVAR") ); + + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR", -1, eval("var MYVAR=0;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR;MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR;MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;--MYVAR;MYVAR", 0, eval("var MYVAR=true;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;--MYVAR;MYVAR", -1, eval("var MYVAR=false;--MYVAR;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR;MYVAR", 0, eval("var MYVAR=new Boolean(true);--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR;MYVAR", -1, eval("var MYVAR=new Boolean(false);--MYVAR;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';--MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';--MYVAR", 12344, eval("var MYVAR='12345';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';--MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';--MYVAR", 14, eval("var MYVAR='0Xf';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';--MYVAR", 76, eval("var MYVAR='077';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; --MYVAR", -1, eval("var MYVAR='';--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';--MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';--MYVAR;MYVAR", 12344, eval("var MYVAR='12345';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';--MYVAR;MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';--MYVAR;MYVAR", 14, eval("var MYVAR='0xf';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';--MYVAR;MYVAR", 76, eval("var MYVAR='077';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';--MYVAR;MYVAR", -1, eval("var MYVAR='';--MYVAR;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');--MYVAR", 14, eval("var MYVAR=new String('0Xf');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); --MYVAR", -1, eval("var MYVAR=new String('');--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR;MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR;MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');--MYVAR;MYVAR", 14, eval("var MYVAR=new String('0xf');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR;MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');--MYVAR;MYVAR", -1, eval("var MYVAR=new String('');--MYVAR;MYVAR") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.6.js new file mode 100644 index 0000000..31d9551 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.6.js @@ -0,0 +1,299 @@ +/* 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: 11.4.6.js + ECMA Section: 11.4.6 Unary + Operator + Description: convert operand to Number type + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "11.4.6"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + var BUGNUMBER="77391"; + + writeHeaderToLog( SECTION + " Unary + operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "+('')", 0, +("") ); + array[item++] = new TestCase( SECTION, "+(' ')", 0, +(" ") ); + array[item++] = new TestCase( SECTION, "+(\\t)", 0, +("\t") ); + array[item++] = new TestCase( SECTION, "+(\\n)", 0, +("\n") ); + array[item++] = new TestCase( SECTION, "+(\\r)", 0, +("\r") ); + array[item++] = new TestCase( SECTION, "+(\\f)", 0, +("\f") ); + + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x0009)", 0, +(String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x0020)", 0, +(String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000C)", 0, +(String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000B)", 0, +(String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000D)", 0, +(String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000A)", 0, +(String.fromCharCode(0x000A)) ); + + // a StringNumericLiteral may be preceeded or followed by whitespace and/or + // line terminators + + array[item++] = new TestCase( SECTION, "+( ' ' + 999 )", 999, +( ' '+999) ); + array[item++] = new TestCase( SECTION, "+( '\\n' + 999 )", 999, +( '\n' +999) ); + array[item++] = new TestCase( SECTION, "+( '\\r' + 999 )", 999, +( '\r' +999) ); + array[item++] = new TestCase( SECTION, "+( '\\t' + 999 )", 999, +( '\t' +999) ); + array[item++] = new TestCase( SECTION, "+( '\\f' + 999 )", 999, +( '\f' +999) ); + + array[item++] = new TestCase( SECTION, "+( 999 + ' ' )", 999, +( 999+' ') ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\n' )", 999, +( 999+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\r' )", 999, +( 999+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\t' )", 999, +( 999+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\f' )", 999, +( 999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( '\\n' + 999 + '\\n' )", 999, +( '\n' +999+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( '\\r' + 999 + '\\r' )", 999, +( '\r' +999+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( '\\t' + 999 + '\\t' )", 999, +( '\t' +999+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( '\\f' + 999 + '\\f' )", 999, +( '\f' +999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( ' ' + '999' )", 999, +( ' '+'999') ); + array[item++] = new TestCase( SECTION, "+( '\\n' + '999' )", 999, +( '\n' +'999') ); + array[item++] = new TestCase( SECTION, "+( '\\r' + '999' )", 999, +( '\r' +'999') ); + array[item++] = new TestCase( SECTION, "+( '\\t' + '999' )", 999, +( '\t' +'999') ); + array[item++] = new TestCase( SECTION, "+( '\\f' + '999' )", 999, +( '\f' +'999') ); + + array[item++] = new TestCase( SECTION, "+( '999' + ' ' )", 999, +( '999'+' ') ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\n' )", 999, +( '999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\r' )", 999, +( '999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\t' )", 999, +( '999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\f' )", 999, +( '999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( '\\n' + '999' + '\\n' )", 999, +( '\n' +'999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( '\\r' + '999' + '\\r' )", 999, +( '\r' +'999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( '\\t' + '999' + '\\t' )", 999, +( '\t' +'999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( '\\f' + '999' + '\\f' )", 999, +( '\f' +'999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' )", 99, +( String.fromCharCode(0x0009) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' )", 99, +( String.fromCharCode(0x0020) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' )", 99, +( String.fromCharCode(0x000C) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' )", 99, +( String.fromCharCode(0x000B) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' )", 99, +( String.fromCharCode(0x000D) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' )", 99, +( String.fromCharCode(0x000A) + '99' ) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0009)", 99, +( '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0020)", 99, +( '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000C)", 99, +( '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000D)", 99, +( '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000B)", 99, +( '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000A)", 99, +( '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 )", 99, +( String.fromCharCode(0x0009) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 )", 99, +( String.fromCharCode(0x0020) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 )", 99, +( String.fromCharCode(0x000C) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 )", 99, +( String.fromCharCode(0x000B) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 )", 99, +( String.fromCharCode(0x000D) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 )", 99, +( String.fromCharCode(0x000A) + 99 ) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0009)", 99, +( 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0020)", 99, +( 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000C)", 99, +( 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000D)", 99, +( 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000B)", 99, +( 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000A)", 99, +( 99 + String.fromCharCode(0x000A)) ); + + + // StrNumericLiteral:::StrDecimalLiteral:::Infinity + + array[item++] = new TestCase( SECTION, "+('Infinity')", Math.pow(10,10000), +("Infinity") ); + array[item++] = new TestCase( SECTION, "+('-Infinity')", -Math.pow(10,10000), +("-Infinity") ); + array[item++] = new TestCase( SECTION, "+('+Infinity')", Math.pow(10,10000), +("+Infinity") ); + + // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + + array[item++] = new TestCase( SECTION, "+('0')", 0, +("0") ); + array[item++] = new TestCase( SECTION, "+('-0')", -0, +("-0") ); + array[item++] = new TestCase( SECTION, "+('+0')", 0, +("+0") ); + + array[item++] = new TestCase( SECTION, "+('1')", 1, +("1") ); + array[item++] = new TestCase( SECTION, "+('-1')", -1, +("-1") ); + array[item++] = new TestCase( SECTION, "+('+1')", 1, +("+1") ); + + array[item++] = new TestCase( SECTION, "+('2')", 2, +("2") ); + array[item++] = new TestCase( SECTION, "+('-2')", -2, +("-2") ); + array[item++] = new TestCase( SECTION, "+('+2')", 2, +("+2") ); + + array[item++] = new TestCase( SECTION, "+('3')", 3, +("3") ); + array[item++] = new TestCase( SECTION, "+('-3')", -3, +("-3") ); + array[item++] = new TestCase( SECTION, "+('+3')", 3, +("+3") ); + + array[item++] = new TestCase( SECTION, "+('4')", 4, +("4") ); + array[item++] = new TestCase( SECTION, "+('-4')", -4, +("-4") ); + array[item++] = new TestCase( SECTION, "+('+4')", 4, +("+4") ); + + array[item++] = new TestCase( SECTION, "+('5')", 5, +("5") ); + array[item++] = new TestCase( SECTION, "+('-5')", -5, +("-5") ); + array[item++] = new TestCase( SECTION, "+('+5')", 5, +("+5") ); + + array[item++] = new TestCase( SECTION, "+('6')", 6, +("6") ); + array[item++] = new TestCase( SECTION, "+('-6')", -6, +("-6") ); + array[item++] = new TestCase( SECTION, "+('+6')", 6, +("+6") ); + + array[item++] = new TestCase( SECTION, "+('7')", 7, +("7") ); + array[item++] = new TestCase( SECTION, "+('-7')", -7, +("-7") ); + array[item++] = new TestCase( SECTION, "+('+7')", 7, +("+7") ); + + array[item++] = new TestCase( SECTION, "+('8')", 8, +("8") ); + array[item++] = new TestCase( SECTION, "+('-8')", -8, +("-8") ); + array[item++] = new TestCase( SECTION, "+('+8')", 8, +("+8") ); + + array[item++] = new TestCase( SECTION, "+('9')", 9, +("9") ); + array[item++] = new TestCase( SECTION, "+('-9')", -9, +("-9") ); + array[item++] = new TestCase( SECTION, "+('+9')", 9, +("+9") ); + + array[item++] = new TestCase( SECTION, "+('3.14159')", 3.14159, +("3.14159") ); + array[item++] = new TestCase( SECTION, "+('-3.14159')", -3.14159, +("-3.14159") ); + array[item++] = new TestCase( SECTION, "+('+3.14159')", 3.14159, +("+3.14159") ); + + array[item++] = new TestCase( SECTION, "+('3.')", 3, +("3.") ); + array[item++] = new TestCase( SECTION, "+('-3.')", -3, +("-3.") ); + array[item++] = new TestCase( SECTION, "+('+3.')", 3, +("+3.") ); + + array[item++] = new TestCase( SECTION, "+('3.e1')", 30, +("3.e1") ); + array[item++] = new TestCase( SECTION, "+('-3.e1')", -30, +("-3.e1") ); + array[item++] = new TestCase( SECTION, "+('+3.e1')", 30, +("+3.e1") ); + + array[item++] = new TestCase( SECTION, "+('3.e+1')", 30, +("3.e+1") ); + array[item++] = new TestCase( SECTION, "+('-3.e+1')", -30, +("-3.e+1") ); + array[item++] = new TestCase( SECTION, "+('+3.e+1')", 30, +("+3.e+1") ); + + array[item++] = new TestCase( SECTION, "+('3.e-1')", .30, +("3.e-1") ); + array[item++] = new TestCase( SECTION, "+('-3.e-1')", -.30, +("-3.e-1") ); + array[item++] = new TestCase( SECTION, "+('+3.e-1')", .30, +("+3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "+('.00001')", 0.00001, +(".00001") ); + array[item++] = new TestCase( SECTION, "+('+.00001')", 0.00001, +("+.00001") ); + array[item++] = new TestCase( SECTION, "+('-0.0001')", -0.00001, +("-.00001") ); + + array[item++] = new TestCase( SECTION, "+('.01e2')", 1, +(".01e2") ); + array[item++] = new TestCase( SECTION, "+('+.01e2')", 1, +("+.01e2") ); + array[item++] = new TestCase( SECTION, "+('-.01e2')", -1, +("-.01e2") ); + + array[item++] = new TestCase( SECTION, "+('.01e+2')", 1, +(".01e+2") ); + array[item++] = new TestCase( SECTION, "+('+.01e+2')", 1, +("+.01e+2") ); + array[item++] = new TestCase( SECTION, "+('-.01e+2')", -1, +("-.01e+2") ); + + array[item++] = new TestCase( SECTION, "+('.01e-2')", 0.0001, +(".01e-2") ); + array[item++] = new TestCase( SECTION, "+('+.01e-2')", 0.0001, +("+.01e-2") ); + array[item++] = new TestCase( SECTION, "+('-.01e-2')", -0.0001, +("-.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "+('1234e5')", 123400000, +("1234e5") ); + array[item++] = new TestCase( SECTION, "+('+1234e5')", 123400000, +("+1234e5") ); + array[item++] = new TestCase( SECTION, "+('-1234e5')", -123400000, +("-1234e5") ); + + array[item++] = new TestCase( SECTION, "+('1234e+5')", 123400000, +("1234e+5") ); + array[item++] = new TestCase( SECTION, "+('+1234e+5')", 123400000, +("+1234e+5") ); + array[item++] = new TestCase( SECTION, "+('-1234e+5')", -123400000, +("-1234e+5") ); + + array[item++] = new TestCase( SECTION, "+('1234e-5')", 0.01234, +("1234e-5") ); + array[item++] = new TestCase( SECTION, "+('+1234e-5')", 0.01234, +("+1234e-5") ); + array[item++] = new TestCase( SECTION, "+('-1234e-5')", -0.01234, +("-1234e-5") ); + + // StrNumericLiteral::: HexIntegerLiteral + + array[item++] = new TestCase( SECTION, "+('0x0')", 0, +("0x0")); + array[item++] = new TestCase( SECTION, "+('0x1')", 1, +("0x1")); + array[item++] = new TestCase( SECTION, "+('0x2')", 2, +("0x2")); + array[item++] = new TestCase( SECTION, "+('0x3')", 3, +("0x3")); + array[item++] = new TestCase( SECTION, "+('0x4')", 4, +("0x4")); + array[item++] = new TestCase( SECTION, "+('0x5')", 5, +("0x5")); + array[item++] = new TestCase( SECTION, "+('0x6')", 6, +("0x6")); + array[item++] = new TestCase( SECTION, "+('0x7')", 7, +("0x7")); + array[item++] = new TestCase( SECTION, "+('0x8')", 8, +("0x8")); + array[item++] = new TestCase( SECTION, "+('0x9')", 9, +("0x9")); + array[item++] = new TestCase( SECTION, "+('0xa')", 10, +("0xa")); + array[item++] = new TestCase( SECTION, "+('0xb')", 11, +("0xb")); + array[item++] = new TestCase( SECTION, "+('0xc')", 12, +("0xc")); + array[item++] = new TestCase( SECTION, "+('0xd')", 13, +("0xd")); + array[item++] = new TestCase( SECTION, "+('0xe')", 14, +("0xe")); + array[item++] = new TestCase( SECTION, "+('0xf')", 15, +("0xf")); + array[item++] = new TestCase( SECTION, "+('0xA')", 10, +("0xA")); + array[item++] = new TestCase( SECTION, "+('0xB')", 11, +("0xB")); + array[item++] = new TestCase( SECTION, "+('0xC')", 12, +("0xC")); + array[item++] = new TestCase( SECTION, "+('0xD')", 13, +("0xD")); + array[item++] = new TestCase( SECTION, "+('0xE')", 14, +("0xE")); + array[item++] = new TestCase( SECTION, "+('0xF')", 15, +("0xF")); + + array[item++] = new TestCase( SECTION, "+('0X0')", 0, +("0X0")); + array[item++] = new TestCase( SECTION, "+('0X1')", 1, +("0X1")); + array[item++] = new TestCase( SECTION, "+('0X2')", 2, +("0X2")); + array[item++] = new TestCase( SECTION, "+('0X3')", 3, +("0X3")); + array[item++] = new TestCase( SECTION, "+('0X4')", 4, +("0X4")); + array[item++] = new TestCase( SECTION, "+('0X5')", 5, +("0X5")); + array[item++] = new TestCase( SECTION, "+('0X6')", 6, +("0X6")); + array[item++] = new TestCase( SECTION, "+('0X7')", 7, +("0X7")); + array[item++] = new TestCase( SECTION, "+('0X8')", 8, +("0X8")); + array[item++] = new TestCase( SECTION, "+('0X9')", 9, +("0X9")); + array[item++] = new TestCase( SECTION, "+('0Xa')", 10, +("0Xa")); + array[item++] = new TestCase( SECTION, "+('0Xb')", 11, +("0Xb")); + array[item++] = new TestCase( SECTION, "+('0Xc')", 12, +("0Xc")); + array[item++] = new TestCase( SECTION, "+('0Xd')", 13, +("0Xd")); + array[item++] = new TestCase( SECTION, "+('0Xe')", 14, +("0Xe")); + array[item++] = new TestCase( SECTION, "+('0Xf')", 15, +("0Xf")); + array[item++] = new TestCase( SECTION, "+('0XA')", 10, +("0XA")); + array[item++] = new TestCase( SECTION, "+('0XB')", 11, +("0XB")); + array[item++] = new TestCase( SECTION, "+('0XC')", 12, +("0XC")); + array[item++] = new TestCase( SECTION, "+('0XD')", 13, +("0XD")); + array[item++] = new TestCase( SECTION, "+('0XE')", 14, +("0XE")); + array[item++] = new TestCase( SECTION, "+('0XF')", 15, +("0XF")); + + return array; + +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.8.js new file mode 100644 index 0000000..491167f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.8.js @@ -0,0 +1,215 @@ +/* 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: 11.4.8.js + ECMA Section: 11.4.8 Bitwise NOT Operator + Description: flip bits up to 32 bits + no special cases + Author: christine@netscape.com + Date: 7 july 1997 + + Data File Fields: + VALUE value passed as an argument to the ~ operator + E_RESULT expected return value of ~ VALUE; + + Static variables: + none + +*/ + + var SECTION = "11.4.8"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Bitwise Not operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( var i = 0; i < 35; i++ ) { + var p = Math.pow(2,i); + + array[item++] = new TestCase( SECTION, "~"+p, Not(p), ~p ); + + } + for ( i = 0; i < 35; i++ ) { + var p = -Math.pow(2,i); + + array[item++] = new TestCase( SECTION, "~"+p, Not(p), ~p ); + + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function Not( n ) { + n = ToInt32(n); + n = ToInt32BitString(n); + + r = "" + + for( var l = 0; l < n.length; l++ ) { + r += ( n.charAt(l) == "0" ) ? "1" : "0"; + } + + n = ToInt32Decimal(r); + + return n; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.9.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.9.js new file mode 100644 index 0000000..90ef06d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.4.9.js @@ -0,0 +1,90 @@ +/* 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: 11.4.9.js + ECMA Section: 11.4.9 Logical NOT Operator (!) + Description: if the ToBoolean( VALUE ) result is true, return + true. else return false. + Author: christine@netscape.com + Date: 7 july 1997 + + Static variables: + none +*/ + var SECTION = "11.4.9"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Logical NOT operator (!)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + +// version("130") + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "!(null)", true, !(null) ); + testcases[tc++] = new TestCase( SECTION, "!(var x)", true, !(eval("var x")) ); + testcases[tc++] = new TestCase( SECTION, "!(void 0)", true, !(void 0) ); + + testcases[tc++] = new TestCase( SECTION, "!(false)", true, !(false) ); + testcases[tc++] = new TestCase( SECTION, "!(true)", false, !(true) ); + testcases[tc++] = new TestCase( SECTION, "!()", true, !(eval()) ); + testcases[tc++] = new TestCase( SECTION, "!(0)", true, !(0) ); + testcases[tc++] = new TestCase( SECTION, "!(-0)", true, !(-0) ); + testcases[tc++] = new TestCase( SECTION, "!(NaN)", true, !(Number.NaN) ); + testcases[tc++] = new TestCase( SECTION, "!(Infinity)", false, !(Number.POSITIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "!(-Infinity)", false, !(Number.NEGATIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "!(Math.PI)", false, !(Math.PI) ); + testcases[tc++] = new TestCase( SECTION, "!(1)", false, !(1) ); + testcases[tc++] = new TestCase( SECTION, "!(-1)", false, !(-1) ); + testcases[tc++] = new TestCase( SECTION, "!('')", true, !("") ); + testcases[tc++] = new TestCase( SECTION, "!('\t')", false, !("\t") ); + testcases[tc++] = new TestCase( SECTION, "!('0')", false, !("0") ); + testcases[tc++] = new TestCase( SECTION, "!('string')", false, !("string") ); + testcases[tc++] = new TestCase( SECTION, "!(new String(''))", false, !(new String("")) ); + testcases[tc++] = new TestCase( SECTION, "!(new String('string'))", false, !(new String("string")) ); + testcases[tc++] = new TestCase( SECTION, "!(new String())", false, !(new String()) ); + testcases[tc++] = new TestCase( SECTION, "!(new Boolean(true))", false, !(new Boolean(true)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Boolean(false))", false, !(new Boolean(false)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Array())", false, !(new Array()) ); + testcases[tc++] = new TestCase( SECTION, "!(new Array(1,2,3)", false, !(new Array(1,2,3)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number())", false, !(new Number()) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number(0))", false, !(new Number(0)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number(NaN))", false, !(new Number(Number.NaN)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number(Infinity))", false, !(new Number(Number.POSITIVE_INFINITY)) ); + + 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(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.1.js new file mode 100644 index 0000000..67c0a8a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.1.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: 11.5.1.js + ECMA Section: 11.5.1 Applying the * operator + Description: + + 11.5.1 Applying the * operator + + The * operator performs multiplication, producing the product of its + operands. Multiplication is commutative. Multiplication is not always + associative in ECMAScript, because of finite precision. + + The result of a floating-point multiplication is governed by the rules + of IEEE 754 double-precision arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, + negative if the operands have different signs. + Multiplication of an infinity by a zero results in NaN. + Multiplication of an infinity by an infinity results in an infinity. + The sign is determined by the rule already stated above. + Multiplication of an infinity by a finite non-zero value results in a + signed infinity. The sign is determined by the rule already stated above. + In the remaining cases, where neither an infinity or NaN is involved, the + product is computed and rounded to the nearest representable value using IEEE + 754 round-to-nearest mode. If the magnitude is too large to represent, + the result is then an infinity of appropriate sign. If the magnitude is + oo small to represent, the result is then a zero + of appropriate sign. The ECMAScript language requires support of gradual + underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Applying the * operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); + array[item++] = new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); + array[item++] = new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); + + array[item++] = new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); + array[item++] = new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); + array[item++] = new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); + array[item++] = new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); + array[item++] = new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); + array[item++] = new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.2.js new file mode 100644 index 0000000..c681a35 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.2.js @@ -0,0 +1,154 @@ +/* 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: 11.5.2.js + ECMA Section: 11.5.2 Applying the / operator + Description: + + The / operator performs division, producing the quotient of its operands. + The left operand is the dividend and the right operand is the divisor. + ECMAScript does not perform integer division. The operands and result of all + division operations are double-precision floating-point numbers. + The result of division is determined by the specification of IEEE 754 arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, negative if the operands have different + signs. + Division of an infinity by an infinity results in NaN. + Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated above. + Division of an infinity by a non-zero finite value results in a signed infinity. The sign is determined by the rule + already stated above. + Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated above. + Division of a zero by a zero results in NaN; division of zero by any other finite value results in zero, with the sign + determined by the rule already stated above. + Division of a non-zero finite value by a zero results in a signed infinity. The sign is determined by the rule + already stated above. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the quotient is computed and + rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too + large to represent, we say the operation overflows; the result is then an infinity of appropriate sign. If the + magnitude is too small to represent, we say the operation underflows and the result is a zero of the appropriate + sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + var BUGNUMBER="111202"; + + writeHeaderToLog( SECTION + " Applying the / operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // if either operand is NaN, the result is NaN. + + array[item++] = new TestCase( SECTION, "Number.NaN / Number.NaN", Number.NaN, Number.NaN / Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN / 1", Number.NaN, Number.NaN / 1 ); + array[item++] = new TestCase( SECTION, "1 / Number.NaN", Number.NaN, 1 / Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NaN", Number.NaN, Number.POSITIVE_INFINITY / Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY / Number.NaN ); + + // Division of an infinity by an infinity results in NaN. + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY ); + + // Division of an infinity by a zero results in an infinity. + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / 0", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 0", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -0", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -0", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -0 ); + + // Division of an infinity by a non-zero finite value results in a signed infinity. + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 1 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -1 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -Number.MAX_VALUE ); + + // Division of a finite value by an infinity results in zero. + + array[item++] = new TestCase( SECTION, "1 / Number.NEGATIVE_INFINITY", -0, 1 / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "1 / Number.POSITIVE_INFINITY", 0, 1 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 / Number.POSITIVE_INFINITY", -0, -1 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 / Number.NEGATIVE_INFINITY", 0, -1 / Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE / Number.NEGATIVE_INFINITY", -0, Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE / Number.POSITIVE_INFINITY", 0, Number.MAX_VALUE / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE / Number.POSITIVE_INFINITY", -0, -Number.MAX_VALUE / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY", 0, -Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); + + // Division of a zero by a zero results in NaN + + array[item++] = new TestCase( SECTION, "0 / -0", Number.NaN, 0 / -0 ); + array[item++] = new TestCase( SECTION, "-0 / 0", Number.NaN, -0 / 0 ); + array[item++] = new TestCase( SECTION, "-0 / -0", Number.NaN, -0 / -0 ); + array[item++] = new TestCase( SECTION, "0 / 0", Number.NaN, 0 / 0 ); + + // division of zero by any other finite value results in zero + + array[item++] = new TestCase( SECTION, "0 / 1", 0, 0 / 1 ); + array[item++] = new TestCase( SECTION, "0 / -1", -0, 0 / -1 ); + array[item++] = new TestCase( SECTION, "-0 / 1", -0, -0 / 1 ); + array[item++] = new TestCase( SECTION, "-0 / -1", 0, -0 / -1 ); + + // Division of a non-zero finite value by a zero results in a signed infinity. + + array[item++] = new TestCase( SECTION, "1 / 0", Number.POSITIVE_INFINITY, 1/0 ); + array[item++] = new TestCase( SECTION, "1 / -0", Number.NEGATIVE_INFINITY, 1/-0 ); + array[item++] = new TestCase( SECTION, "-1 / 0", Number.NEGATIVE_INFINITY, -1/0 ); + array[item++] = new TestCase( SECTION, "-1 / -0", Number.POSITIVE_INFINITY, -1/-0 ); + + array[item++] = new TestCase( SECTION, "0 / Number.POSITIVE_INFINITY", 0, 0 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "0 / Number.NEGATIVE_INFINITY", -0, 0 / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 / Number.POSITIVE_INFINITY", -0, -0 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 / Number.NEGATIVE_INFINITY", 0, -0 / Number.NEGATIVE_INFINITY ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.3.js new file mode 100644 index 0000000..8b9722c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.5.3.js @@ -0,0 +1,160 @@ +/* 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: 11.5.3.js + ECMA Section: 11.5.3 Applying the % operator + Description: + + The binary % operator is said to yield the remainder of its operands from + an implied division; the left operand is the dividend and the right operand + is the divisor. In C and C++, the remainder operator accepts only integral + operands, but in ECMAScript, it also accepts floating-point operands. + + The result of a floating-point remainder operation as computed by the % + operator is not the same as the "remainder" operation defined by IEEE 754. + The IEEE 754 "remainder" operation computes the remainder from a rounding + division, not a truncating division, and so its behavior is not analogous + to that of the usual integer remainder operator. Instead the ECMAScript + language defines % on floating-point operations to behave in a manner + analogous to that of the Java integer remainder operator; this may be + compared with the C library function fmod. + + The result of a ECMAScript floating-point remainder operation is determined by the rules of IEEE arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result equals the sign of the dividend. + If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + If the dividend is finite and the divisor is an infinity, the result equals the dividend. + If the dividend is a zero and the divisor is finite, the result is the same as the dividend. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r + from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that + is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as + possible without exceeding the magnitude of the true mathematical quotient of n and d. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.5.3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + var BUGNUMBER="111202"; + + writeHeaderToLog( SECTION + " Applying the % operator"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // if either operand is NaN, the result is NaN. + + array[item++] = new TestCase( SECTION, "Number.NaN % Number.NaN", Number.NaN, Number.NaN % Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN % 1", Number.NaN, Number.NaN % 1 ); + array[item++] = new TestCase( SECTION, "1 % Number.NaN", Number.NaN, 1 % Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NaN", Number.NaN, Number.POSITIVE_INFINITY % Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY % Number.NaN ); + + // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + // dividend is an infinity + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % 0", Number.NaN, Number.POSITIVE_INFINITY % 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 0", Number.NaN, Number.NEGATIVE_INFINITY % 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -0", Number.NaN, Number.POSITIVE_INFINITY % -0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -0", Number.NaN, Number.NEGATIVE_INFINITY % -0 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 1 ", Number.NaN, Number.NEGATIVE_INFINITY % 1 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -1 ", Number.NaN, Number.NEGATIVE_INFINITY % -1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % 1 ", Number.NaN, Number.POSITIVE_INFINITY % 1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -1 ", Number.NaN, Number.POSITIVE_INFINITY % -1 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % -Number.MAX_VALUE ); + + // divisor is 0 + array[item++] = new TestCase( SECTION, "0 % -0", Number.NaN, 0 % -0 ); + array[item++] = new TestCase( SECTION, "-0 % 0", Number.NaN, -0 % 0 ); + array[item++] = new TestCase( SECTION, "-0 % -0", Number.NaN, -0 % -0 ); + array[item++] = new TestCase( SECTION, "0 % 0", Number.NaN, 0 % 0 ); + + array[item++] = new TestCase( SECTION, "1 % 0", Number.NaN, 1%0 ); + array[item++] = new TestCase( SECTION, "1 % -0", Number.NaN, 1%-0 ); + array[item++] = new TestCase( SECTION, "-1 % 0", Number.NaN, -1%0 ); + array[item++] = new TestCase( SECTION, "-1 % -0", Number.NaN, -1%-0 ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % 0", Number.NaN, Number.MAX_VALUE%0 ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % -0", Number.NaN, Number.MAX_VALUE%-0 ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % 0", Number.NaN, -Number.MAX_VALUE%0 ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % -0", Number.NaN, -Number.MAX_VALUE%-0 ); + + // If the dividend is finite and the divisor is an infinity, the result equals the dividend. + + array[item++] = new TestCase( SECTION, "1 % Number.NEGATIVE_INFINITY", 1, 1 % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "1 % Number.POSITIVE_INFINITY", 1, 1 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 % Number.POSITIVE_INFINITY", -1, -1 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 % Number.NEGATIVE_INFINITY", -1, -1 % Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % Number.NEGATIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % Number.POSITIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % Number.POSITIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % Number.NEGATIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 % Number.POSITIVE_INFINITY", 0, 0 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "0 % Number.NEGATIVE_INFINITY", 0, 0 % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 % Number.POSITIVE_INFINITY", -0, -0 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 % Number.NEGATIVE_INFINITY", -0, -0 % Number.NEGATIVE_INFINITY ); + + // If the dividend is a zero and the divisor is finite, the result is the same as the dividend. + + array[item++] = new TestCase( SECTION, "0 % 1", 0, 0 % 1 ); + array[item++] = new TestCase( SECTION, "0 % -1", -0, 0 % -1 ); + array[item++] = new TestCase( SECTION, "-0 % 1", -0, -0 % 1 ); + array[item++] = new TestCase( SECTION, "-0 % -1", 0, -0 % -1 ); + +// In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r +// from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that +// is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as +// possible without exceeding the magnitude of the true mathematical quotient of n and d. + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-1.js new file mode 100644 index 0000000..58e5edc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-1.js @@ -0,0 +1,211 @@ +/* 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: 11.6.1-1.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does not cover cases where the Additive or Mulplicative expression + ToPrimitive is string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.1-1"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The Addition operator ( + )"); + 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 ); +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "truefalse", + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); + + // tests for number primitive, number object, Object object, a "MyObject" whose value is + // a number primitive and a number object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); + + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "100-1", + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1", + "truetrue", + eval("var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1") ); + + return ( array ); +} + + +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} + +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} + +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} + +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-2.js new file mode 100644 index 0000000..400ec71 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-2.js @@ -0,0 +1,203 @@ +/* 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: 11.6.1-2.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + ToPrimitive is a string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.1-2"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The Addition operator ( + )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); + + // tests for number primitive, number object, Object object, a "MyObject" whose value is + // a number primitive and a number object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); + return ( array ); +} +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-3.js new file mode 100644 index 0000000..a5fdc88 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.1-3.js @@ -0,0 +1,181 @@ +/* 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: 11.6.1-3.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + is a Date. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The Addition operator ( + )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + var DATE1 = new Date(); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + DATE1", + DATE1.toString() + DATE1.toString(), + DATE1 + DATE1 ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + 0", + DATE1.toString() + 0, + DATE1 + 0 ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Number(0)", + DATE1.toString() + 0, + DATE1 + new Number(0) ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + true", + DATE1.toString() + "true", + DATE1 + true ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); + + var MYOB1 = new MyObject( DATE1 ); + var MYOB2 = new MyValuelessObject( DATE1 ); + var MYOB3 = new MyProtolessObject( DATE1 ); + var MYOB4 = new MyProtoValuelessObject( DATE1 ); + + array[item++] = new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + new Number(1)", + "[object Object]1", + MYOB1 + new Number(1) ); + + array[item++] = new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + 1", + "[object Object]1", + MYOB1 + 1 ); + + array[item++] = new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + 'string'", + DATE1.toString() + "string", + MYOB2 + 'string' ); + + array[item++] = new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + new String('string')", + DATE1.toString() + "string", + MYOB2 + new String('string') ); +/* + array[item++] = new TestCase( SECTION, + "MYOB3 = new MyProtolessObject(DATE1); MYOB3 + new Boolean(true)", + DATE1.toString() + "true", + MYOB3 + new Boolean(true) ); +*/ + array[item++] = new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + true", + "[object Object]true", + MYOB1 + true ); + + return ( array ); +} +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.2-1.js new file mode 100644 index 0000000..3c1bd91 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.2-1.js @@ -0,0 +1,199 @@ +/* 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: 11.6.2-1.js + ECMA Section: 11.6.2 The Subtraction operator ( - ) + Description: + + The production AdditiveExpression : AdditiveExpression - + MultiplicativeExpression is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToNumber(Result(2)). + 6. Call ToNumber(Result(4)). + 7. Apply the subtraction operation to Result(5) and Result(6). See the + discussion below (11.6.3). + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The subtraction operator ( - )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") ); + + // tests for number primitive, number object, Object object, a "MyObject" whose value is + // a number primitive and a number object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") ); +/* + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") ); +*/ + // same thing with string! + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1'); EXP_1 - EXP_2", + 254, + eval("var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1')); EXP_1 - EXP_2") ); + + return ( array ); +} +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} +function MyOtherObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.toString = new Function ( "return this.value + ''" ); + this.value = value; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.3.js new file mode 100644 index 0000000..91af1b7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.6.3.js @@ -0,0 +1,116 @@ +/* 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: 11.6.3.js + ECMA Section: 11.6.3 Applying the additive operators + (+, -) to numbers + Description: + The + operator performs addition when applied to two operands of numeric + type, producing the sum of the operands. The - operator performs + subtraction, producing the difference of two numeric operands. + + Addition is a commutative operation, but not always associative. + + The result of an addition is determined using the rules of IEEE 754 + double-precision arithmetic: + + If either operand is NaN, the result is NaN. + The sum of two infinities of opposite sign is NaN. + The sum of two infinities of the same sign is the infinity of that sign. + The sum of an infinity and a finite value is equal to the infinite operand. + The sum of two negative zeros is 0. The sum of two positive zeros, or of + two zeros of opposite sign, is +0. + The sum of a zero and a nonzero finite value is equal to the nonzero + operand. + The sum of two nonzero finite values of the same magnitude and opposite + sign is +0. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is + involved, and the operands have the same sign or have different + magnitudes, the sum is computed and rounded to the nearest + representable value using IEEE 754 round-to-nearest mode. If the + magnitude is too large to represent, the operation overflows and + the result is then an infinity of appropriate sign. The ECMAScript + language requires support of gradual underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Applying the additive operators (+,-) to numbers"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.NaN + 1", Number.NaN, Number.NaN + 1 ); + array[item++] = new TestCase( SECTION, "1 + Number.NaN", Number.NaN, 1 + Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.NaN - 1", Number.NaN, Number.NaN - 1 ); + array[item++] = new TestCase( SECTION, "1 - Number.NaN", Number.NaN, 1 - Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "-0 + -0", -0, -0 + -0 ); + array[item++] = new TestCase( SECTION, "-0 - 0", -0, -0 - 0 ); + + array[item++] = new TestCase( SECTION, "0 + 0", 0, 0 + 0 ); + array[item++] = new TestCase( SECTION, "0 + -0", 0, 0 + -0 ); + array[item++] = new TestCase( SECTION, "0 - -0", 0, 0 - -0 ); + array[item++] = new TestCase( SECTION, "0 - 0", 0, 0 - 0 ); + array[item++] = new TestCase( SECTION, "-0 - -0", 0, -0 - -0 ); + array[item++] = new TestCase( SECTION, "-0 + 0", 0, -0 + 0 ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE - Number.MAX_VALUE", 0, Number.MAX_VALUE - Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "1/Number.MAX_VALUE - 1/Number.MAX_VALUE", 0, 1/Number.MAX_VALUE - 1/Number.MAX_VALUE ); + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE - Number.MIN_VALUE", 0, Number.MIN_VALUE - Number.MIN_VALUE ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.1.js new file mode 100644 index 0000000..23e2ab5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.1.js @@ -0,0 +1,229 @@ +/* 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: 11.7.1.js + ECMA Section: 11.7.1 The Left Shift Operator ( << ) + Description: + Performs a bitwise left shift operation on the left argument by the amount + specified by the right argument. + + The production ShiftExpression : ShiftExpression << AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Left shift Result(5) by Result(7) bits. The result is a signed 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.7.1"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The left shift operator ( << )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( power = 0; power < 33; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp < 33; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " << " + addexp, + LeftShift( shiftexp, addexp ), + shiftexp << addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function LeftShift( s, a ) { + var shift = ToInt32( s ); + var add = ToUint32( a ); + add = Mask( add, 5 ); + var exp = LShift( shift, add ); + + return ( exp ); +} +function LShift( s, a ) { + s = ToInt32BitString( s ); + + for ( var z = 0; z < a; z++ ) { + s += "0"; + } + + s = s.substring( a, s.length); + + return ToInt32(ToInt32Decimal(s)); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.2.js new file mode 100644 index 0000000..b2761cf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.2.js @@ -0,0 +1,246 @@ +/* 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: 11.7.2.js + ECMA Section: 11.7.2 The signed right shift operator ( >> ) + Description: + Performs a sign-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. + + The production ShiftExpression : ShiftExpression >> AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform sign-extending right shift of Result(5) by Result(7) bits. The + most significant bit is propagated. The result is a signed 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.7.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The signed right shift operator ( >> )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var power = 0; + var addexp = 0; + + for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); + } + } + + for ( power = 0; power <= 32; power++ ) { + shiftexp = -Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); + } + } + + return ( array ); +} + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function SignedRightShift( s, a ) { + s = ToInt32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( SignedRShift( s, a ) ); +} +function SignedRShift( s, a ) { + s = ToInt32BitString( s ); + + var firstbit = s.substring(0,1); + + s = s.substring( 1, s.length ); + + for ( var z = 0; z < a; z++ ) { + s = firstbit + s; + } + + s = s.substring( 0, s.length - a); + + s = firstbit +s; + + + return ToInt32(ToInt32Decimal(s)); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.3.js new file mode 100644 index 0000000..9c963e1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.7.3.js @@ -0,0 +1,230 @@ +/* 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: 11.7.3.js + ECMA Section: 11.7.3 The unsigned right shift operator ( >>> ) + Description: + 11.7.3 The unsigned right shift operator ( >>> ) + Performs a zero-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. + + The production ShiftExpression : ShiftExpression >>> AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToUint32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform zero-filling right shift of Result(5) by Result(7) bits. + Vacated bits are filled with zero. The result is an unsigned 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.7.3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The unsigned right shift operator ( >>> )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + var addexp = 0; + var power = 0; + + for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " >>> " + addexp, + UnsignedRightShift( shiftexp, addexp ), + shiftexp >>> addexp ); + } + } + + return ( array ); +} + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 32; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function RShift( s, a ) { + s = ToUint32BitString( s ); + for ( z = 0; z < a; z++ ) { + s = "0" + s; + } + s = s.substring( 0, s.length - a ); + + return ToUint32Decimal(s); +} +function UnsignedRightShift( s, a ) { + s = ToUint32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( RShift( s, a ) ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.1.js new file mode 100644 index 0000000..db2c701 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.1.js @@ -0,0 +1,121 @@ +/* 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: 11.8.1.js + ECMA Section: 11.8.1 The less-than operator ( < ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The less-than operator ( < )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true < false", false, true < false ); + array[item++] = new TestCase( SECTION, "false < true", true, false < true ); + array[item++] = new TestCase( SECTION, "false < false", false, false < false ); + array[item++] = new TestCase( SECTION, "true < true", false, true < true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) < new Boolean(true)", false, new Boolean(true) < new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) < new Boolean(false)", false, new Boolean(true) < new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) < new Boolean(true)", true, new Boolean(false) < new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) < new Boolean(false)", false, new Boolean(false) < new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) < new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(true)", true, new MyValueObject(false) < new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) < new MyValueObject(true)", false, new MyValueObject(true) < new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(false)", false, new MyValueObject(false) < new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(true)", true, new MyStringObject(false) < new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) < new MyStringObject(true)", false, new MyStringObject(true) < new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(false)", false, new MyStringObject(false) < new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN < Number.NaN", false, Number.NaN < Number.NaN ); + array[item++] = new TestCase( SECTION, "0 < Number.NaN", false, 0 < Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN < 0", false, Number.NaN < 0 ); + + array[item++] = new TestCase( SECTION, "0 < -0", false, 0 < -0 ); + array[item++] = new TestCase( SECTION, "-0 < 0", false, -0 < 0 ); + + array[item++] = new TestCase( SECTION, "Infinity < 0", false, Number.POSITIVE_INFINITY < 0 ); + array[item++] = new TestCase( SECTION, "Infinity < Number.MAX_VALUE", false, Number.POSITIVE_INFINITY < Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity < Infinity", false, Number.POSITIVE_INFINITY < Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 < Infinity", true, 0 < Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE < Infinity", true, Number.MAX_VALUE < Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 < -Infinity", false, 0 < Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE < -Infinity", false, Number.MAX_VALUE < Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity < -Infinity", false, Number.NEGATIVE_INFINITY < Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity < 0", true, Number.NEGATIVE_INFINITY < 0 ); + array[item++] = new TestCase( SECTION, "-Infinity < -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY < -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity < Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY < Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' < 'string'", false, 'string' < 'string' ); + array[item++] = new TestCase( SECTION, "'astring' < 'string'", true, 'astring' < 'string' ); + array[item++] = new TestCase( SECTION, "'strings' < 'stringy'", true, 'strings' < 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' < 'stringier'", false, 'strings' < 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' < 'astring'", false, 'string' < 'astring' ); + array[item++] = new TestCase( SECTION, "'string' < 'strings'", true, 'string' < 'strings' ); + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.2.js new file mode 100644 index 0000000..962c33e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.2.js @@ -0,0 +1,122 @@ +/* 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: 11.8.2.js + ECMA Section: 11.8.2 The greater-than operator ( > ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The greater-than operator ( > )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true > false", true, true > false ); + array[item++] = new TestCase( SECTION, "false > true", false, false > true ); + array[item++] = new TestCase( SECTION, "false > false", false, false > false ); + array[item++] = new TestCase( SECTION, "true > true", false, true > true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) > new Boolean(true)", false, new Boolean(true) > new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) > new Boolean(false)", true, new Boolean(true) > new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) > new Boolean(true)", false, new Boolean(false) > new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) > new Boolean(false)", false, new Boolean(false) > new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) > new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(true)", false, new MyValueObject(false) > new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) > new MyValueObject(true)", false, new MyValueObject(true) > new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(false)", false, new MyValueObject(false) > new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(true)", false, new MyStringObject(false) > new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) > new MyStringObject(true)", false, new MyStringObject(true) > new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(false)", false, new MyStringObject(false) > new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN > Number.NaN", false, Number.NaN > Number.NaN ); + array[item++] = new TestCase( SECTION, "0 > Number.NaN", false, 0 > Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN > 0", false, Number.NaN > 0 ); + + array[item++] = new TestCase( SECTION, "0 > -0", false, 0 > -0 ); + array[item++] = new TestCase( SECTION, "-0 > 0", false, -0 > 0 ); + + array[item++] = new TestCase( SECTION, "Infinity > 0", true, Number.POSITIVE_INFINITY > 0 ); + array[item++] = new TestCase( SECTION, "Infinity > Number.MAX_VALUE", true, Number.POSITIVE_INFINITY > Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity > Infinity", false, Number.POSITIVE_INFINITY > Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 > Infinity", false, 0 > Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE > Infinity", false, Number.MAX_VALUE > Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 > -Infinity", true, 0 > Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE > -Infinity", true, Number.MAX_VALUE > Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity > -Infinity", false, Number.NEGATIVE_INFINITY > Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity > 0", false, Number.NEGATIVE_INFINITY > 0 ); + array[item++] = new TestCase( SECTION, "-Infinity > -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY > -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity > Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY > Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); + array[item++] = new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); + array[item++] = new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); + + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.3.js new file mode 100644 index 0000000..5da73d6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.3.js @@ -0,0 +1,120 @@ +/* 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: 11.8.3.js + ECMA Section: 11.8.3 The less-than-or-equal operator ( <= ) + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true <= false", false, true <= false ); + array[item++] = new TestCase( SECTION, "false <= true", true, false <= true ); + array[item++] = new TestCase( SECTION, "false <= false", true, false <= false ); + array[item++] = new TestCase( SECTION, "true <= true", true, true <= true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(true)", true, new Boolean(true) <= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(false)", false, new Boolean(true) <= new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(true)", true, new Boolean(false) <= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(false)", true, new Boolean(false) <= new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(true)", true, new MyValueObject(false) <= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) <= new MyValueObject(true)", true, new MyValueObject(true) <= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(false)", true, new MyValueObject(false) <= new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(true)", true, new MyStringObject(false) <= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) <= new MyStringObject(true)", true, new MyStringObject(true) <= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(false)", true, new MyStringObject(false) <= new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN <= Number.NaN", false, Number.NaN <= Number.NaN ); + array[item++] = new TestCase( SECTION, "0 <= Number.NaN", false, 0 <= Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN <= 0", false, Number.NaN <= 0 ); + + array[item++] = new TestCase( SECTION, "0 <= -0", true, 0 <= -0 ); + array[item++] = new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 ); + + array[item++] = new TestCase( SECTION, "Infinity <= 0", false, Number.POSITIVE_INFINITY <= 0 ); + array[item++] = new TestCase( SECTION, "Infinity <= Number.MAX_VALUE", false, Number.POSITIVE_INFINITY <= Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity <= Infinity", true, Number.POSITIVE_INFINITY <= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 <= Infinity", true, 0 <= Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= Infinity", true, Number.MAX_VALUE <= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 <= -Infinity", false, 0 <= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= -Infinity", false, Number.MAX_VALUE <= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity <= -Infinity", true, Number.NEGATIVE_INFINITY <= Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity <= 0", true, Number.NEGATIVE_INFINITY <= 0 ); + array[item++] = new TestCase( SECTION, "-Infinity <= -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity <= Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY <= Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' <= 'string'", true, 'string' <= 'string' ); + array[item++] = new TestCase( SECTION, "'astring' <= 'string'", true, 'astring' <= 'string' ); + array[item++] = new TestCase( SECTION, "'strings' <= 'stringy'", true, 'strings' <= 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' <= 'stringier'", false, 'strings' <= 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' <= 'astring'", false, 'string' <= 'astring' ); + array[item++] = new TestCase( SECTION, "'string' <= 'strings'", true, 'string' <= 'strings' ); + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.4.js new file mode 100644 index 0000000..7e25b05 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.8.4.js @@ -0,0 +1,122 @@ +/* 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: 11.8.4.js + ECMA Section: 11.8.4 The greater-than-or-equal operator ( >= ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The greater-than-or-equal operator ( >= )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true >= false", true, true >= false ); + array[item++] = new TestCase( SECTION, "false >= true", false, false >= true ); + array[item++] = new TestCase( SECTION, "false >= false", true, false >= false ); + array[item++] = new TestCase( SECTION, "true >= true", true, true >= true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) >= new Boolean(true)", true, new Boolean(true) >= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) >= new Boolean(false)", true, new Boolean(true) >= new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) >= new Boolean(true)", false, new Boolean(false) >= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) >= new Boolean(false)", true, new Boolean(false) >= new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) >= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(true)", false, new MyValueObject(false) >= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) >= new MyValueObject(true)", true, new MyValueObject(true) >= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(false)", true, new MyValueObject(false) >= new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(true)", false, new MyStringObject(false) >= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) >= new MyStringObject(true)", true, new MyStringObject(true) >= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(false)", true, new MyStringObject(false) >= new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN >= Number.NaN", false, Number.NaN >= Number.NaN ); + array[item++] = new TestCase( SECTION, "0 >= Number.NaN", false, 0 >= Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN >= 0", false, Number.NaN >= 0 ); + + array[item++] = new TestCase( SECTION, "0 >= -0", true, 0 >= -0 ); + array[item++] = new TestCase( SECTION, "-0 >= 0", true, -0 >= 0 ); + + array[item++] = new TestCase( SECTION, "Infinity >= 0", true, Number.POSITIVE_INFINITY >= 0 ); + array[item++] = new TestCase( SECTION, "Infinity >= Number.MAX_VALUE", true, Number.POSITIVE_INFINITY >= Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity >= Infinity", true, Number.POSITIVE_INFINITY >= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 >= Infinity", false, 0 >= Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE >= Infinity", false, Number.MAX_VALUE >= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 >= -Infinity", true, 0 >= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE >= -Infinity", true, Number.MAX_VALUE >= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity >= -Infinity", true, Number.NEGATIVE_INFINITY >= Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity >= 0", false, Number.NEGATIVE_INFINITY >= 0 ); + array[item++] = new TestCase( SECTION, "-Infinity >= -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY >= -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity >= Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY >= Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); + array[item++] = new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); + array[item++] = new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); + + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.1.js new file mode 100644 index 0000000..b64df9a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.1.js @@ -0,0 +1,162 @@ +/* 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: 11.9.1.js + ECMA Section: 11.9.1 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.9.1"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="77391"; + + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The equals operator ( == )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // type x and type y are the same. if type x is undefined or null, return true + + array[item++] = new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); + array[item++] = new TestCase( SECTION, "null == null", true, null == null ); + + // if x is NaN, return false. if y is NaN, return false. + + array[item++] = new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); + array[item++] = new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + + // if x is the same number value as y, return true. + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + + // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + + array[item++] = new TestCase( SECTION, "0 == 0", true, 0 == 0 ); + array[item++] = new TestCase( SECTION, "0 == -0", true, 0 == -0 ); + array[item++] = new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); + array[item++] = new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + + // return false. + + array[item++] = new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); + array[item++] = new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + + // type x and type y are the same type, but not numbers. + + + // x and y are strings. return true if x and y are exactly the same sequence of characters. + // otherwise, return false. + + array[item++] = new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); + + // x and y are booleans. return true if both are true or both are false. + + array[item++] = new TestCase( SECTION, "true == true", true, true == true ); + array[item++] = new TestCase( SECTION, "false == false", true, false == false ); + array[item++] = new TestCase( SECTION, "true == false", false, true == false ); + array[item++] = new TestCase( SECTION, "false == true", false, false == true ); + + // return true if x and y refer to the same object. otherwise return false. + + array[item++] = new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + + array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + // if x is null and y is undefined, return true. if x is undefined and y is null return true. + + array[item++] = new TestCase( SECTION, "null == void 0", true, null == void 0 ); + array[item++] = new TestCase( SECTION, "void 0 == null", true, void 0 == null ); + + // if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). + + array[item++] = new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); + array[item++] = new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); + array[item++] = new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); + array[item++] = new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); + + + array[item++] = new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); + array[item++] = new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); + + array[item++] = new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); + array[item++] = new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); + + return ( array ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.2.js new file mode 100644 index 0000000..9eb4bfc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.2.js @@ -0,0 +1,161 @@ +/* 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: 11.9.2.js + ECMA Section: 11.9.2 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.9.2"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="77391"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The equals operator ( == )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // type x and type y are the same. if type x is undefined or null, return true + + array[item++] = new TestCase( SECTION, "void 0 == void 0", false, void 0 != void 0 ); + array[item++] = new TestCase( SECTION, "null == null", false, null != null ); + + // if x is NaN, return false. if y is NaN, return false. + + array[item++] = new TestCase( SECTION, "NaN != NaN", true, Number.NaN != Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN != 0", true, Number.NaN != 0 ); + array[item++] = new TestCase( SECTION, "0 != NaN", true, 0 != Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN != Infinity", true, Number.NaN != Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Infinity != NaN", true, Number.POSITIVE_INFINITY != Number.NaN ); + + // if x is the same number value as y, return true. + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE != Number.MAX_VALUE", false, Number.MAX_VALUE != Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE != Number.MIN_VALUE", false, Number.MIN_VALUE != Number.MIN_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY", false, Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY", false, Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY ); + + // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + + array[item++] = new TestCase( SECTION, "0 != 0", false, 0 != 0 ); + array[item++] = new TestCase( SECTION, "0 != -0", false, 0 != -0 ); + array[item++] = new TestCase( SECTION, "-0 != 0", false, -0 != 0 ); + array[item++] = new TestCase( SECTION, "-0 != -0", false, -0 != -0 ); + + // return false. + + array[item++] = new TestCase( SECTION, "0.9 != 1", true, 0.9 != 1 ); + array[item++] = new TestCase( SECTION, "0.999999 != 1", true, 0.999999 != 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999 != 1", true, 0.9999999999 != 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999999 != 1", true, 0.9999999999999 != 1 ); + + // type x and type y are the same type, but not numbers. + + + // x and y are strings. return true if x and y are exactly the same sequence of characters. + // otherwise, return false. + + array[item++] = new TestCase( SECTION, "'hello' != 'hello'", false, "hello" != "hello" ); + + // x and y are booleans. return true if both are true or both are false. + + array[item++] = new TestCase( SECTION, "true != true", false, true != true ); + array[item++] = new TestCase( SECTION, "false != false", false, false != false ); + array[item++] = new TestCase( SECTION, "true != false", true, true != false ); + array[item++] = new TestCase( SECTION, "false != true", true, false != true ); + + // return true if x and y refer to the same object. otherwise return false. + + array[item++] = new TestCase( SECTION, "new MyObject(true) != new MyObject(true)", true, new MyObject(true) != new MyObject(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); + + + array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z != y", false, eval("x = new MyObject(true); y = x; z = x; z != y") ); + array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z != y", false, eval("x = new MyObject(false); y = x; z = x; z != y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z != y", false, eval("x = new Boolean(true); y = x; z = x; z != y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z != y", false, eval("x = new Boolean(false); y = x; z = x; z != y") ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); + + // if x is null and y is undefined, return true. if x is undefined and y is null return true. + + array[item++] = new TestCase( SECTION, "null != void 0", false, null != void 0 ); + array[item++] = new TestCase( SECTION, "void 0 != null", false, void 0 != null ); + + // if type(x) is Number and type(y) is string, return the result of the comparison x != ToNumber(y). + + array[item++] = new TestCase( SECTION, "1 != '1'", false, 1 != '1' ); + array[item++] = new TestCase( SECTION, "255 != '0xff'", false, 255 != '0xff' ); + array[item++] = new TestCase( SECTION, "0 != '\r'", false, 0 != "\r" ); + array[item++] = new TestCase( SECTION, "1e19 != '1e19'", false, 1e19 != "1e19" ); + + + array[item++] = new TestCase( SECTION, "new Boolean(true) != true", false, true != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new MyObject(true) != true", false, true != new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "new Boolean(false) != false", false, new Boolean(false) != false ); + array[item++] = new TestCase( SECTION, "new MyObject(false) != false", false, new MyObject(false) != false ); + + array[item++] = new TestCase( SECTION, "true != new Boolean(true)", false, true != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "true != new MyObject(true)", false, true != new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "false != new Boolean(false)", false, false != new Boolean(false) ); + array[item++] = new TestCase( SECTION, "false != new MyObject(false)", false, false != new MyObject(false) ); + + return ( array ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.3.js new file mode 100644 index 0000000..134060b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Expressions/11.9.3.js @@ -0,0 +1,161 @@ +/* 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: 11.9.3.js + ECMA Section: 11.9.3 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.9.3"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="77391"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The equals operator ( == )"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // type x and type y are the same. if type x is undefined or null, return true + + array[item++] = new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); + array[item++] = new TestCase( SECTION, "null == null", true, null == null ); + + // if x is NaN, return false. if y is NaN, return false. + + array[item++] = new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); + array[item++] = new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + + // if x is the same number value as y, return true. + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + + // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + + array[item++] = new TestCase( SECTION, "0 == 0", true, 0 == 0 ); + array[item++] = new TestCase( SECTION, "0 == -0", true, 0 == -0 ); + array[item++] = new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); + array[item++] = new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + + // return false. + + array[item++] = new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); + array[item++] = new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + + // type x and type y are the same type, but not numbers. + + + // x and y are strings. return true if x and y are exactly the same sequence of characters. + // otherwise, return false. + + array[item++] = new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); + + // x and y are booleans. return true if both are true or both are false. + + array[item++] = new TestCase( SECTION, "true == true", true, true == true ); + array[item++] = new TestCase( SECTION, "false == false", true, false == false ); + array[item++] = new TestCase( SECTION, "true == false", false, true == false ); + array[item++] = new TestCase( SECTION, "false == true", false, false == true ); + + // return true if x and y refer to the same object. otherwise return false. + + array[item++] = new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + + array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + // if x is null and y is undefined, return true. if x is undefined and y is null return true. + + array[item++] = new TestCase( SECTION, "null == void 0", true, null == void 0 ); + array[item++] = new TestCase( SECTION, "void 0 == null", true, void 0 == null ); + + // if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). + + array[item++] = new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); + array[item++] = new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); + array[item++] = new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); + array[item++] = new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); + + + array[item++] = new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); + array[item++] = new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); + + array[item++] = new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); + array[item++] = new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); + + return ( array ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js new file mode 100644 index 0000000..c20dd37 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js @@ -0,0 +1,90 @@ +/* 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.3.1.1.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, body + (where n might be 0, that is, there are no "p" arguments, and where body might + also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor had + been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.1.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc = Function(); + myfunc.toString = Object.prototype.toString; + +// not going to test toString here since it is implementation dependent. +// array[item++] = new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + + myfunc.toString = Object.prototype.toString; + array[item++] = new TestCase( SECTION, + "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length ); + array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() ); + array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() ); + array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype ); + array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length ); + array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor ); + array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + 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/FunctionObjects/15.3.1.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-2.js new file mode 100644 index 0000000..ce6994e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-2.js @@ -0,0 +1,118 @@ +/* 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.3.1.1-2.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + Function(p1, p2, ..., pn, body ) + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, + body (where n might be 0, that is, there are no "p" arguments, and where body + might also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor + had been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.1.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc1 = Function("a","b","c", "return a+b+c" ); + var myfunc2 = Function("a, b, c", "return a+b+c" ); + var myfunc3 = Function("a,b", "c", "return a+b+c" ); + + myfunc1.toString = Object.prototype.toString; + myfunc2.toString = Object.prototype.toString; + myfunc3.toString = Object.prototype.toString; + + array[item++] = new TestCase( SECTION, "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); + array[item++] = new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); + array[item++] = new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); + array[item++] = new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); + array[item++] = new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); + array[item++] = new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); + array[item++] = new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + + 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/FunctionObjects/15.3.1.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-3.js new file mode 100644 index 0000000..459a6bf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.1.1-3.js @@ -0,0 +1,96 @@ +/* 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.3.1.1-3.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.1.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + + var testcases = new Array(); + + var args = ""; + + for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } + } + + var s = ""; + + for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } + } + + MyFunc = Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); + MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + var MY_OB = eval( "MyFunc("+ s +")" ); + + testcases[testcases.length] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); + testcases[testcases.length] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB ); + testcases[testcases.length] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + + testcases[testcases.length] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + + testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); + testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); + testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js new file mode 100644 index 0000000..ec1b86b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js @@ -0,0 +1,94 @@ +/* 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.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc = new Function(); + +// not going to test toString here since it is implementation dependent. +// array[item++] = new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + + myfunc.toString = Object.prototype.toString; + + array[item++] = new TestCase( SECTION, "myfunc = new Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length ); + array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments ); + + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() ); + array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + + array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype ); + array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length ); + array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor ); + array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + + 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/FunctionObjects/15.3.2.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-2.js new file mode 100644 index 0000000..b8f403c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-2.js @@ -0,0 +1,111 @@ +/* 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.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc1 = new Function("a","b","c", "return a+b+c" ); + var myfunc2 = new Function("a, b, c", "return a+b+c" ); + var myfunc3 = new Function("a,b", "c", "return a+b+c" ); + + myfunc1.toString = Object.prototype.toString; + myfunc2.toString = Object.prototype.toString; + myfunc3.toString = Object.prototype.toString; + + array[item++] = new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); + array[item++] = new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); + array[item++] = new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); + array[item++] = new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); + array[item++] = new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); + array[item++] = new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); + array[item++] = new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + + 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/FunctionObjects/15.3.2.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-3.js new file mode 100644 index 0000000..76c5e2f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.2.1-3.js @@ -0,0 +1,96 @@ +/* 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.3.2.1-3.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.2.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var args = ""; + + for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } + } + + var s = ""; + + for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } + } + + MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); + MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + array[item++] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); + array[item++] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + + array[item++] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + + 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/FunctionObjects/15.3.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-1.js new file mode 100644 index 0000000..4442e27 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-1.js @@ -0,0 +1,62 @@ +/* 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.3.3.1-1.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the value of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-1"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + testcases[tc++] = new TestCase( SECTION, "Function.prototype == Function.proto", true, Function.__proto__ == Function.prototype ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-2.js new file mode 100644 index 0000000..e39abbf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.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.3.3.1-2.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontEnum property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.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 (prop in Function ) str += prop; str;", + "", + eval("var str='';for (prop in Function) str += prop; str;") + ); + 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/FunctionObjects/15.3.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-3.js new file mode 100644 index 0000000..b95752c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-3.js @@ -0,0 +1,79 @@ +/* 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.3.3.1-3.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontDelete property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var FUN_PROTO = Function.prototype; + + array[item++] = new TestCase( SECTION, + "delete Function.prototype", + false, + delete Function.prototype + ); + + array[item++] = new TestCase( SECTION, + "delete Function.prototype; Function.prototype", + FUN_PROTO, + eval("delete Function.prototype; Function.prototype") + ); + 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/FunctionObjects/15.3.3.1-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.1-4.js new file mode 100644 index 0000000..5b4e811 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.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.3.3.1-4.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the ReadOnly property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "Function.prototype = null; Function.prototype", + Function.prototype, + eval("Function.prototype = null; Function.prototype") + ); + 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/FunctionObjects/15.3.3.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.2.js new file mode 100644 index 0000000..821f93e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.3.2.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.3.3.2.js + ECMA Section: 15.3.3.2 Properties of the Function Constructor + Function.length + + Description: The length property is 1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.3.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Function.length", 1, Function.length ); + 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/FunctionObjects/15.3.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.4-1.js new file mode 100644 index 0000000..d919d41 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.4-1.js @@ -0,0 +1,80 @@ +/* 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.3.4-1.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Function Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); + array[item++] = new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); + array[item++] = new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + 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/FunctionObjects/15.3.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.4.1.js new file mode 100644 index 0000000..ce75a14 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.4.1.js @@ -0,0 +1,62 @@ +/* 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.3.4.1.js + ECMA Section: 15.3.4.1 Function.prototype.constructor + + Description: The initial value of Function.prototype.constructor + is the built-in Function constructor. + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Function.prototype.constructor", Function, Function.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/FunctionObjects/15.3.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.4.js new file mode 100644 index 0000000..df519d2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.4.js @@ -0,0 +1,79 @@ +/* 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.3.4.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Function Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); + array[item++] = new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); + array[item++] = new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + 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/FunctionObjects/15.3.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5-1.js new file mode 100644 index 0000000..1e63370 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5-1.js @@ -0,0 +1,118 @@ +/* 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.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of Function Instances"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var args = ""; + + for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } + } + + var s = ""; + + for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } + } + + MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); + MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + + array[item++] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); + array[item++] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + array[item++] = new TestCase( SECTION, "MyFunc.prototype.toString()", "[object Object]", MyFunc.prototype.toString() ); + array[item++] = new TestCase( SECTION, "typeof MyFunc.prototype", "object", typeof MyFunc.prototype ); + + + array[item++] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + + 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/FunctionObjects/15.3.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5-2.js new file mode 100644 index 0000000..fe24e32 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5-2.js @@ -0,0 +1,92 @@ +/* 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.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of Function Instances"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MyObject = new Function( 'a', 'b', 'c', 'this.a = a; this.b = b; this.c = c; this.value = a+b+c; this.valueOf = new Function( "return this.value" )' ); + + array[item++] = new TestCase( SECTION, "MyObject.length", 3, MyObject.length ); + array[item++] = new TestCase( SECTION, "typeof MyObject.prototype", "object", typeof MyObject.prototype ); + array[item++] = new TestCase( SECTION, "typeof MyObject.prototype.constructor", "function", typeof MyObject.prototype.constructor ); + array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + + 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/FunctionObjects/15.3.5.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5.1.js new file mode 100644 index 0000000..3da3b0e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5.1.js @@ -0,0 +1,80 @@ +/* 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.3.5.1.js + ECMA Section: Function.length + Description: + + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. + + this test needs a 1.2 version check. + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.3.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.length"; + var BUGNUMBER="104204"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var f = new Function( "a","b", "c", "return f.length"); + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); + + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); + + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5.3.js new file mode 100644 index 0000000..eaf6dbe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/FunctionObjects/15.3.5.3.js @@ -0,0 +1,75 @@ +/* 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.3.5.3.js + ECMA Section: Function.arguments + Description: + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the + function has been called but has not yet returned). When a non-internal + Function object (15.3.2.1) is invoked, its arguments property is + "dynamically bound" to a newly created object that contains the arguments + on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility + with existing old code. + + See sections 10.1.6 and 10.1.8 for more extensive tests. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.3.5.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.arguments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array =new Array(); + var item = 0; + + var MYFUNCTION = new Function( "return this.arguments" ); + + + array[item++] = new TestCase( SECTION, "var MYFUNCTION = new Function( 'return this.arguments' ); MYFUNCTION.arguments", null, MYFUNCTION.arguments ); + + 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/GlobalObject/15.1-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1-1-n.js new file mode 100644 index 0000000..906b0b4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1-1-n.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.1-1-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.1-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Global Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( SECTION, + "var MY_GLOBAL = new this()", + "error", + "var MY_GLOBAL = new this()" ); + + test(); + +function test() { + 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/GlobalObject/15.1-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1-2-n.js new file mode 100644 index 0000000..327c685 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1-2-n.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.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Call]] property; it is not possible + to invoke the global object as a function. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.1-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Global Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( SECTION, + "var MY_GLOBAL = this()", + "error", + "var MY_GLOBAL = this()" ); + test(); + +function test() { + 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/GlobalObject/15.1.1.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.1.1.js new file mode 100644 index 0000000..4310a51 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.1.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.1.1.1.js + ECMA Section: 15.1.1.1 NaN + + Description: The initial value of NaN is NaN. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.1.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[array.length] = new TestCase( SECTION, "NaN", Number.NaN, NaN ); + array[array.length] = new TestCase( SECTION, "this.NaN", Number.NaN, this.NaN ); + array[array.length] = new TestCase( SECTION, "typeof NaN", "number", typeof NaN ); + + 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/GlobalObject/15.1.1.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.1.2.js new file mode 100644 index 0000000..35324d6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.1.2.js @@ -0,0 +1,66 @@ +/* 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.1.1.2.js + ECMA Section: 15.1.1.2 Infinity + + Description: The initial value of Infinity is +Infinity. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.1.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Infinity"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Infinity", Number.POSITIVE_INFINITY, Infinity ); + array[item++] = new TestCase( SECTION, "this.Infinity", Number.POSITIVE_INFINITY, this.Infinity ); + array[item++] = new TestCase( SECTION, "typeof Infinity", "number", typeof Infinity ); + + 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/GlobalObject/15.1.2.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js new file mode 100644 index 0000000..d4f38a7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js @@ -0,0 +1,91 @@ +/* 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.1.2.1-1.js + ECMA Section: 15.1.2.1 eval(x) + + if x is not a string object, return x. + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.1.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "eval(x)"; + + var BUGNUMBER = "111199"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "eval.length", 1, eval.length ); + array[item++] = new TestCase( SECTION, "delete eval.length", false, delete eval.length ); + array[item++] = new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") ); + array[item++] = new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") ); +// array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); + + // test cases where argument is not a string. should return the argument. + + array[item++] = new TestCase( SECTION, "eval()", void 0, eval() ); + array[item++] = new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) ); + array[item++] = new TestCase( SECTION, "eval(null)", null, eval( null ) ); + array[item++] = new TestCase( SECTION, "eval(true)", true, eval( true ) ); + array[item++] = new TestCase( SECTION, "eval(false)", false, eval( false ) ); + + array[item++] = new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) ); + + array[item++] = new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) ); + array[item++] = new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) ); + array[item++] = new TestCase( SECTION, "eval(1)", 1, eval(1) ); + array[item++] = new TestCase( SECTION, "eval(0)", 0, eval(0) ); + array[item++] = new TestCase( SECTION, "eval(-1)", -1, eval(-1) ); + array[item++] = new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) ); + array[item++] = new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) ); + array[item++] = new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) ); + + 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/GlobalObject/15.1.2.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js new file mode 100644 index 0000000..203cd4d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js @@ -0,0 +1,66 @@ +/* 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.1.2.1-2.js + ECMA Section: 15.1.2.1 eval(x) + + Parse x as an ECMAScript Program. If the parse fails, + generate a runtime error. Evaluate the program. If + result is "Normal completion after value V", return + the value V. Else, return undefined. + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.1.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "eval(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[0] = new TestCase( SECTION, + "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x", + "0/1/1970", + eval( "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x" ) + ); + 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/GlobalObject/15.1.2.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js new file mode 100644 index 0000000..422109d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js @@ -0,0 +1,291 @@ +/* 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.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) + + Description: + + The parseInt function produces an integer value dictated by intepretation + of the contents of the string argument according to the specified radix. + + When the parseInt function is called, the following steps are taken: + + 1. Call ToString(string). + 2. Compute a substring of Result(1) consisting of the leftmost character + that is not a StrWhiteSpaceChar and all characters to the right of + that character. (In other words, remove leading whitespace.) + 3. Let sign be 1. + 4. If Result(2) is not empty and the first character of Result(2) is a + minus sign -, let sign be -1. + 5. If Result(2) is not empty and the first character of Result(2) is a + plus sign + or a minus sign -, then Result(5) is the substring of + Result(2) produced by removing the first character; otherwise, Result(5) + is Result(2). + 6. If the radix argument is not supplied, go to step 12. + 7. Call ToInt32(radix). + 8. If Result(7) is zero, go to step 12; otherwise, if Result(7) < 2 or + Result(7) > 36, return NaN. + 9. Let R be Result(7). + 10. If R = 16 and the length of Result(5) is at least 2 and the first two + characters of Result(5) are either "0x" or "0X", let S be the substring + of Result(5) consisting of all but the first two characters; otherwise, + let S be Result(5). + 11. Go to step 22. + 12. If Result(5) is empty or the first character of Result(5) is not 0, + go to step 20. + 13. If the length of Result(5) is at least 2 and the second character of + Result(5) is x or X, go to step 17. + 14. Let R be 8. + 15. Let S be Result(5). + 16. Go to step 22. + 17. Let R be 16. + 18. Let S be the substring of Result(5) consisting of all but the first + two characters. + 19. Go to step 22. + 20. Let R be 10. + 21. Let S be Result(5). + 22. If S contains any character that is not a radix-R digit, then let Z be + the substring of S consisting of all characters to the left of the + leftmost such character; otherwise, let Z be S. + 23. If Z is empty, return NaN. + 24. Compute the mathematical integer value that is represented by Z in + radix-R notation. (But if R is 10 and Z contains more than 20 + significant digits, every digit after the 20th may be replaced by a 0 + digit, at the option of the implementation; and if R is not 2, 4, 8, + 10, 16, or 32, then Result(24) may be an implementation-dependent + approximation to the mathematical integer value that is represented + by Z in radix-R notation.) + 25. Compute the number value for Result(24). + 26. Return sign Result(25). + + Note that parseInt may interpret only a leading portion of the string as + an integer value; it ignores any characters that cannot be interpreted as + part of the notation of an integer, and no indication is given that any + such characters were ignored. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "parseInt(string, radix)"; + var BUGNUMBER="111199"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var HEX_STRING = "0x0"; + var HEX_VALUE = 0; + + array[item++] = new TestCase( SECTION, "parseInt.length", 2, parseInt.length ); + array[item++] = new TestCase( SECTION, "parseInt.length = 0; parseInt.length", 2, eval("parseInt.length = 0; parseInt.length") ); + array[item++] = new TestCase( SECTION, "var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "", eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") ); + array[item++] = new TestCase( SECTION, "delete parseInt.length", false, delete parseInt.length ); + array[item++] = new TestCase( SECTION, "delete parseInt.length; parseInt.length", 2, eval("delete parseInt.length; parseInt.length") ); + array[item++] = new TestCase( SECTION, "parseInt.length = null; parseInt.length", 2, eval("parseInt.length = null; parseInt.length") ); + + array[item++] = new TestCase( SECTION, "parseInt()", NaN, parseInt() ); + array[item++] = new TestCase( SECTION, "parseInt('')", NaN, parseInt("") ); + array[item++] = new TestCase( SECTION, "parseInt('','')", NaN, parseInt("","") ); + array[item++] = new TestCase( SECTION, + "parseInt(\" 0xabcdef ", + 11259375, + parseInt( " 0xabcdef " )); + + array[item++] = new TestCase( SECTION, + "parseInt(\" 0XABCDEF ", + 11259375, + parseInt( " 0XABCDEF " ) ); + + array[item++] = new TestCase( SECTION, + "parseInt( 0xabcdef )", + 11259375, + parseInt( "0xabcdef") ); + + array[item++] = new TestCase( SECTION, + "parseInt( 0XABCDEF )", + 11259375, + parseInt( "0XABCDEF") ); + + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",null)", HEX_VALUE, parseInt(HEX_STRING,null) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+", void 0)", HEX_VALUE, parseInt(HEX_STRING, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + + // a few tests with spaces + + for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; + POWER < 15; + POWER++, HEX_STRING = HEX_STRING +"f", space += " ") + { + array[item++] = new TestCase( SECTION, "parseInt("+space+HEX_STRING+space+", void 0)", HEX_VALUE, parseInt(space+HEX_STRING+space, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + + // a few tests with negative numbers + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + + // we should stop parsing when we get to a value that is not a numeric literal for the type we expect + + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"g",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"G",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "-0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + + // let us do some octal tests. numbers that start with 0 and do not provid a radix should + // default to using "0" as a radix. + + var OCT_STRING = "0"; + var OCT_VALUE = 0; + + for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE += Math.pow(8,POWER)*7; + } + + for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE -= Math.pow(8,POWER)*7; + } + + // should get the same results as above if we provid the radix of 8 (or 010) + + for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) ); + OCT_VALUE += Math.pow(8,POWER)*7; + } + for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; + } + + // we shall stop parsing digits when we get one that isn't a numeric literal of the type we think + // it should be. + for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) ); + OCT_VALUE += Math.pow(8,POWER)*7; + } + for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; + } + + array[item++] = new TestCase( SECTION, "parseInt( '0x' )", NaN, parseInt("0x") ); + array[item++] = new TestCase( SECTION, "parseInt( '0X' )", NaN, parseInt("0X") ); + + array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222' )", 11111111112222222222, parseInt("11111111112222222222") ); + array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223' )", 111111111122222222220, parseInt("111111111122222222223") ); + array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222',10 )", 11111111112222222222, parseInt("11111111112222222222",10) ); + array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223',10 )", 111111111122222222220, parseInt("111111111122222222223",10) ); + + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', -1 )", Number.NaN, parseInt("01234567890",-1) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 0 )", Number.NaN, parseInt("01234567890",1) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 1 )", Number.NaN, parseInt("01234567890",1) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 2 )", 1, parseInt("01234567890",2) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 3 )", 5, parseInt("01234567890",3) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 4 )", 27, parseInt("01234567890",4) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 5 )", 194, parseInt("01234567890",5) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 6 )", 1865, parseInt("01234567890",6) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 7 )", 22875, parseInt("01234567890",7) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 8 )", 342391, parseInt("01234567890",8) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 9 )", 6053444, parseInt("01234567890",9) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 10 )", 1234567890, parseInt("01234567890",10) ); + + // need more test cases with hex radix + + array[item++] = new TestCase( SECTION, "parseInt( '1234567890', '0xa')", 1234567890, parseInt("1234567890","0xa") ); + + array[item++] = new TestCase( SECTION, "parseInt( '012345', 11 )", 17715, parseInt("012345",11) ); + + array[item++] = new TestCase( SECTION, "parseInt( '012345', 35 )", 1590195, parseInt("012345",35) ); + array[item++] = new TestCase( SECTION, "parseInt( '012345', 36 )", 1776965, parseInt("012345",36) ); + array[item++] = new TestCase( SECTION, "parseInt( '012345', 37 )", Number.NaN, parseInt("012345",37) ); + + 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/GlobalObject/15.1.2.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js new file mode 100644 index 0000000..27d31be --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js @@ -0,0 +1,232 @@ +/* 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.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) + + Description: parseInt test cases written by waldemar, and documented in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.2-2"; +var VERSION = "ECMA_1"; + startTest(); +var TITLE = "parseInt(string, radix)"; +var BUGNUMBER="123874"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = new Array(); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111101",2)); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', + 9027215253084864, + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', + 18054430506169720, + parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', + 18054430506169728, + parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("yz",35)', + 34, + parseInt("yz",35) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("yz",36)', + 1259, + parseInt("yz",36) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("yz",37)', + NaN, + parseInt("yz",37) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("+77")', + 77, + parseInt("+77") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("-77",9)', + -70, + parseInt("-77",9) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("\u20001234\u2000")', + 1234, + parseInt("\u20001234\u2000") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("123456789012345678")', + 123456789012345680, + parseInt("123456789012345678") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("9",8)', + NaN, + parseInt("9",8) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("1e2")', + 1, + parseInt("1e2") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("1.9999999999999999999")', + 1, + parseInt("1.9999999999999999999") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x10")', + 16, + parseInt("0x10") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x10",10)', + 0, + parseInt("0x10",10)); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0022")', + 18, + parseInt("0022")); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0022",10)', + 22, + parseInt("0022",10) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x1000000000000080")', + 1152921504606847000, + parseInt("0x1000000000000080") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x1000000000000081")', + 1152921504606847200, + parseInt("0x1000000000000081") ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + +s += "0000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; +s += "0000000000000000000000000000000000001"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); + + +s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +s += "0000000000000000000000000000000000000" + + +testcases[tc++] = new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); + +s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; +s += "0000000000000000000000000000000000001"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s + "; -s", + -1.7976931348623157e+308, + -s ); + +s += "0" + +testcases[tc++] = new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt(s)', + Infinity, + parseInt(s) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt(s,32)', + 0, + parseInt(s,32) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt(s,36)', + Infinity, + parseInt(s,36)); + +test(); + +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/GlobalObject/15.1.2.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js new file mode 100644 index 0000000..0efec6b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js @@ -0,0 +1,444 @@ +/* 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.1.2.3.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) + + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. + + When the parseFloat function is called, the following + steps are taken: + + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). + + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. + + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.1.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "parseFloat(string)"; + var BUGNUMBER= "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length ); + + array[item++] = new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") ); + array[item++] = new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length ); + array[item++] = new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() ); + array[item++] = new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') ); + + array[item++] = new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') ); + array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); + array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); + array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') ); + + array[item++] = new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) ); + + + array[item++] = new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') ); + + array[item++] = new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) ); + + array[item++] = new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") ); + array[item++] = new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") ); + array[item++] = new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") ); + + array[item++] = new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") ); + + array[item++] = new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") ); + + array[item++] = new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") ); + array[item++] = new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") ); + array[item++] = new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") ); + + array[item++] = new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") ); + array[item++] = new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") ); + array[item++] = new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") ); + + array[item++] = new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") ); + array[item++] = new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") ); + array[item++] = new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") ); + + array[item++] = new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") ); + array[item++] = new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") ); + array[item++] = new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") ); + + array[item++] = new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") ); + array[item++] = new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") ); + array[item++] = new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") ); + array[item++] = new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") ); + + array[item++] = new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") ); + + array[item++] = new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") ); + + array[item++] = new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") ); + + + array[item++] = new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) ); + array[item++] = new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) ); + + array[item++] = new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) ); + + array[item++] = new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) ); + array[item++] = new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) ); + + array[item++] = new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) ); + + array[item++] = new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) ); + array[item++] = new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) ); + + array[item++] = new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) ); + array[item++] = new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) ); + + array[item++] = new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) ); + array[item++] = new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) ); + + array[item++] = new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) ); + array[item++] = new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) ); + + + array[item++] = new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) ); + array[item++] = new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) ); + + array[item++] = new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) ); + + array[item++] = new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) ); + + array[item++] = new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) ); + + array[item++] = new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) ); + + array[item++] = new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) ); + + // hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral) + + array[item++] = new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0")); + array[item++] = new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1")); + array[item++] = new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2")); + array[item++] = new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3")); + array[item++] = new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4")); + array[item++] = new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5")); + array[item++] = new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6")); + array[item++] = new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7")); + array[item++] = new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8")); + array[item++] = new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9")); + array[item++] = new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa")); + array[item++] = new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb")); + array[item++] = new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc")); + array[item++] = new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd")); + array[item++] = new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe")); + array[item++] = new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf")); + array[item++] = new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA")); + array[item++] = new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB")); + array[item++] = new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC")); + array[item++] = new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD")); + array[item++] = new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE")); + array[item++] = new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF")); + + array[item++] = new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0")); + array[item++] = new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1")); + array[item++] = new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2")); + array[item++] = new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3")); + array[item++] = new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4")); + array[item++] = new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5")); + array[item++] = new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6")); + array[item++] = new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7")); + array[item++] = new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8")); + array[item++] = new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf")); + array[item++] = new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA")); + array[item++] = new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB")); + array[item++] = new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC")); + array[item++] = new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD")); + array[item++] = new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE")); + array[item++] = new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF ")); + + // hex literals should still succeed + + array[item++] = new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0)); + array[item++] = new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1)); + array[item++] = new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2)); + array[item++] = new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3)); + array[item++] = new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4)); + array[item++] = new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5)); + array[item++] = new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6)); + array[item++] = new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7)); + array[item++] = new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8)); + array[item++] = new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9)); + array[item++] = new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa)); + array[item++] = new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb)); + array[item++] = new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc)); + array[item++] = new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd)); + array[item++] = new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe)); + array[item++] = new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf)); + array[item++] = new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA)); + array[item++] = new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB)); + array[item++] = new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC)); + array[item++] = new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD)); + array[item++] = new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE)); + array[item++] = new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF)); + + array[item++] = new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0)); + array[item++] = new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1)); + array[item++] = new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2)); + array[item++] = new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3)); + array[item++] = new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4)); + array[item++] = new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5)); + array[item++] = new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6)); + array[item++] = new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7)); + array[item++] = new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8)); + array[item++] = new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf)); + array[item++] = new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA)); + array[item++] = new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB)); + array[item++] = new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC)); + array[item++] = new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD)); + array[item++] = new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); + array[item++] = new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); + + + // A StringNumericLiteral may not use octal notation + + array[item++] = new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); + array[item++] = new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); + array[item++] = new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); + array[item++] = new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); + array[item++] = new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); + array[item++] = new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); + array[item++] = new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); + array[item++] = new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); + array[item++] = new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); + array[item++] = new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); + array[item++] = new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); + + // an octal numeric literal should be treated as an octal + + array[item++] = new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); + array[item++] = new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); + array[item++] = new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); + array[item++] = new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); + array[item++] = new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); + array[item++] = new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); + array[item++] = new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); + array[item++] = new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); + array[item++] = new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); + array[item++] = new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); + array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + + // make sure it's reflexive + array[item++] = new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2)); + + array[item++] = new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+'')); + + 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/GlobalObject/15.1.2.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js new file mode 100644 index 0000000..c3905c0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js @@ -0,0 +1,295 @@ +/* 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.1.2.3-2.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) + + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. + + When the parseFloat function is called, the following + steps are taken: + + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). + + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. + + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.3-2"; + var VERSION = "ECMA_1"; + startTest(); + + var BUGNUMBER = "77391"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " parseFloat(string)"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); + array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); + array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Number.POSITIVE_INFINITY, parseFloat("Infinity") ); +// array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Number.POSITIVE_INFINITY, parseFloat(Infinity) ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 0')", 0, parseFloat(" 0") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -0')", -0, parseFloat(" -0") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +0')", 0, parseFloat(" +0") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1')", 1, parseFloat(" 1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1')", -1, parseFloat(" -1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1')", 1, parseFloat(" +1") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 2')", 2, parseFloat(" 2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -2')", -2, parseFloat(" -2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +2')", 2, parseFloat(" +2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3')", 3, parseFloat(" 3") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3')", -3, parseFloat(" -3") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3')", 3, parseFloat(" +3") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 4')", 4, parseFloat(" 4") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -4')", -4, parseFloat(" -4") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +4')", 4, parseFloat(" +4") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 5')", 5, parseFloat(" 5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -5')", -5, parseFloat(" -5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +5')", 5, parseFloat(" +5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 6')", 6, parseFloat(" 6") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -6')", -6, parseFloat(" -6") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +6')", 6, parseFloat(" +6") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 7')", 7, parseFloat(" 7") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -7')", -7, parseFloat(" -7") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +7')", 7, parseFloat(" +7") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 8')", 8, parseFloat(" 8") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -8')", -8, parseFloat(" -8") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +8')", 8, parseFloat(" +8") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 9')", 9, parseFloat(" 9") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -9')", -9, parseFloat(" -9") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +9')", 9, parseFloat(" +9") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.14159')", 3.14159, parseFloat(" 3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.14159')", -3.14159, parseFloat(" -3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.14159')", 3.14159, parseFloat(" +3.14159") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.')", 3, parseFloat(" 3.") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.')", -3, parseFloat(" -3.") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.')", 3, parseFloat(" +3.") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.e1')", 30, parseFloat(" 3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.e1')", -30, parseFloat(" -3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.e1')", 30, parseFloat(" +3.e1") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.e+1')", 30, parseFloat(" 3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.e+1')", -30, parseFloat(" -3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.e+1')", 30, parseFloat(" +3.e+1") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.e-1')", .30, parseFloat(" 3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.e-1')", -.30, parseFloat(" -3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.e-1')", .30, parseFloat(" +3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(' .00001')", 0.00001, parseFloat(" .00001") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.00001')", 0.00001, parseFloat(" +.00001") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -0.0001')", -0.00001, parseFloat(" -.00001") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01e2')", 1, parseFloat(" .01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01e2')", 1, parseFloat(" +.01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01e2')", -1, parseFloat(" -.01e2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01e+2')", 1, parseFloat(" .01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01e+2')", 1, parseFloat(" +.01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01e+2')", -1, parseFloat(" -.01e+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01e-2')", 0.0001, parseFloat(" .01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01e-2')", 0.0001, parseFloat(" +.01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01e-2')", -0.0001, parseFloat(" -.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234e5')", 123400000, parseFloat(" 1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234e5')", 123400000, parseFloat(" +1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234e5')", -123400000, parseFloat(" -1234e5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234e+5')", 123400000, parseFloat(" 1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234e+5')", 123400000, parseFloat(" +1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234e+5')", -123400000, parseFloat(" -1234e+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234e-5')", 0.01234, parseFloat(" 1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234e-5')", 0.01234, parseFloat(" +1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234e-5')", -0.01234, parseFloat(" -1234e-5") ); + + + array[item++] = new TestCase( SECTION, "parseFloat(' .01E2')", 1, parseFloat(" .01E2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01E2')", 1, parseFloat(" +.01E2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01E2')", -1, parseFloat(" -.01E2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01E+2')", 1, parseFloat(" .01E+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01E+2')", 1, parseFloat(" +.01E+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01E+2')", -1, parseFloat(" -.01E+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01E-2')", 0.0001, parseFloat(" .01E-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01E-2')", 0.0001, parseFloat(" +.01E-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01E-2')", -0.0001, parseFloat(" -.01E-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + array[item++] = new TestCase( SECTION, "parseFloat(' 1234E5')", 123400000, parseFloat(" 1234E5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234E5')", 123400000, parseFloat(" +1234E5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234E5')", -123400000, parseFloat(" -1234E5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234E+5')", 123400000, parseFloat(" 1234E+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234E+5')", 123400000, parseFloat(" +1234E+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234E+5')", -123400000, parseFloat(" -1234E+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234E-5')", 0.01234, parseFloat(" 1234E-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234E-5')", 0.01234, parseFloat(" +1234E-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234E-5')", -0.01234, parseFloat(" -1234E-5") ); + + + // hex cases should all return NaN + + array[item++] = new TestCase( SECTION, "parseFloat(' 0x0')", 0, parseFloat(" 0x0")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x1')", 0, parseFloat(" 0x1")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x2')", 0, parseFloat(" 0x2")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x3')", 0, parseFloat(" 0x3")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x4')", 0, parseFloat(" 0x4")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x5')", 0, parseFloat(" 0x5")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x6')", 0, parseFloat(" 0x6")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x7')", 0, parseFloat(" 0x7")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x8')", 0, parseFloat(" 0x8")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x9')", 0, parseFloat(" 0x9")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xa')", 0, parseFloat(" 0xa")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xb')", 0, parseFloat(" 0xb")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xc')", 0, parseFloat(" 0xc")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xd')", 0, parseFloat(" 0xd")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xe')", 0, parseFloat(" 0xe")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xf')", 0, parseFloat(" 0xf")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xA')", 0, parseFloat(" 0xA")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xB')", 0, parseFloat(" 0xB")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xC')", 0, parseFloat(" 0xC")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xD')", 0, parseFloat(" 0xD")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xE')", 0, parseFloat(" 0xE")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xF')", 0, parseFloat(" 0xF")); + + array[item++] = new TestCase( SECTION, "parseFloat(' 0X0')", 0, parseFloat(" 0X0")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X1')", 0, parseFloat(" 0X1")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X2')", 0, parseFloat(" 0X2")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X3')", 0, parseFloat(" 0X3")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X4')", 0, parseFloat(" 0X4")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X5')", 0, parseFloat(" 0X5")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X6')", 0, parseFloat(" 0X6")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X7')", 0, parseFloat(" 0X7")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X8')", 0, parseFloat(" 0X8")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X9')", 0, parseFloat(" 0X9")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xa')", 0, parseFloat(" 0Xa")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xb')", 0, parseFloat(" 0Xb")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xc')", 0, parseFloat(" 0Xc")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xd')", 0, parseFloat(" 0Xd")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xe')", 0, parseFloat(" 0Xe")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xf')", 0, parseFloat(" 0Xf")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XA')", 0, parseFloat(" 0XA")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XB')", 0, parseFloat(" 0XB")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XC')", 0, parseFloat(" 0XC")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFloat(" 0XD")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF")); + + // A StringNumericLiteral may not use octal notation + + array[item++] = new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00")); + array[item++] = new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01")); + array[item++] = new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02")); + array[item++] = new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03")); + array[item++] = new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04")); + array[item++] = new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05")); + array[item++] = new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06")); + array[item++] = new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07")); + array[item++] = new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010")); + array[item++] = new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); + array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + + // make sure it' s reflexive + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LN2+' ')", Math.LN2, parseFloat( ' ' +Math.LN2+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LN10+' ')", Math.LN10, parseFloat( ' ' +Math.LN10+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LOG2E+' ')", Math.LOG2E, parseFloat( ' ' +Math.LOG2E+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LOG10E+' ')", Math.LOG10E, parseFloat( ' ' +Math.LOG10E+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT2+' ')", Math.SQRT2, parseFloat( ' ' +Math.SQRT2+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT1_2+' ')", Math.SQRT1_2, parseFloat( ' ' +Math.SQRT1_2+' ')); + + + 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/GlobalObject/15.1.2.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.4.js new file mode 100644 index 0000000..386f3a6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.4.js @@ -0,0 +1,206 @@ +/* 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.1.2.4.js + ECMA Section: 15.1.2.4 Function properties of the global object + escape( string ) + + Description: + The escape function computes a new version of a string value in which + certain characters have been replaced by a hexadecimal escape sequence. + The result thus contains no special characters that might have special + meaning within a URL. + + For characters whose Unicode encoding is 0xFF or less, a two-digit + escape sequence of the form %xx is used in accordance with RFC1738. + For characters whose Unicode encoding is greater than 0xFF, a four- + digit escape sequence of the form %uxxxx is used. + + When the escape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Get the character at position k within Result(1). + 7. If Result(6) is one of the 69 nonblank ASCII characters + ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz + 0123456789 @*_+-./, go to step 14. + 8. Compute the 16-bit unsigned integer that is the Unicode character + encoding of Result(6). + 9. If Result(8), is less than 256, go to step 12. + 10. Let S be a string containing six characters "%uwxyz" where wxyz are + four hexadecimal digits encoding the value of Result(8). + 11. Go to step 15. + 12. Let S be a string containing three characters "%xy" where xy are two + hexadecimal digits encoding the value of Result(8). + 13. Go to step 15. + 14. Let S be a string containing the single character Result(6). + 15. Let R be a new string value computed by concatenating the previous value + of R and S. + 16. Increase k by 1. + 17. Go to step 5. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "escape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "escape.length", 1, escape.length ); + array[item++] = new TestCase( SECTION, "escape.length = null; escape.length", 1, eval("escape.length = null; escape.length") ); + array[item++] = new TestCase( SECTION, "delete escape.length", false, delete escape.length ); + array[item++] = new TestCase( SECTION, "delete escape.length; escape.length", 1, eval("delete escape.length; escape.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS", "", eval("var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "escape()", "undefined", escape() ); + array[item++] = new TestCase( SECTION, "escape('')", "", escape('') ); + array[item++] = new TestCase( SECTION, "escape( null )", "null", escape(null) ); + array[item++] = new TestCase( SECTION, "escape( void 0 )", "undefined", escape(void 0) ); + array[item++] = new TestCase( SECTION, "escape( true )", "true", escape( true ) ); + array[item++] = new TestCase( SECTION, "escape( false )", "false", escape( false ) ); + + array[item++] = new TestCase( SECTION, "escape( new Boolean(true) )", "true", escape(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "escape( new Boolean(false) )", "false", escape(new Boolean(false)) ); + + array[item++] = new TestCase( SECTION, "escape( Number.NaN )", "NaN", escape(Number.NaN) ); + array[item++] = new TestCase( SECTION, "escape( -0 )", "0", escape( -0 ) ); + array[item++] = new TestCase( SECTION, "escape( 'Infinity' )", "Infinity", escape( "Infinity" ) ); + array[item++] = new TestCase( SECTION, "escape( Number.POSITIVE_INFINITY )", "Infinity", escape( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "escape( Number.NEGATIVE_INFINITY )", "-Infinity", escape( Number.NEGATIVE_INFINITY ) ); + + var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; + + array[item++] = new TestCase( SECTION, "escape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, escape( ASCII_TEST_STRING ) ); + + // ASCII value less than + + for ( var CHARCODE = 0; CHARCODE < 32; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + for ( var CHARCODE = 128; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + + for ( var CHARCODE = 256; CHARCODE < 1024; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + for ( var CHARCODE = 65500; CHARCODE < 65536; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + + return ( array ); +} + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +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/GlobalObject/15.1.2.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js new file mode 100644 index 0000000..da1a6f9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js @@ -0,0 +1,207 @@ +/* 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.1.2.5-1.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + var SECTION = "15.1.2.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "unescape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "unescape.length", 1, unescape.length ); + array[item++] = new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") ); + array[item++] = new TestCase( SECTION, "delete unescape.length", false, delete unescape.length ); + array[item++] = new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "unescape()", "undefined", unescape() ); + array[item++] = new TestCase( SECTION, "unescape('')", "", unescape('') ); + array[item++] = new TestCase( SECTION, "unescape( null )", "null", unescape(null) ); + array[item++] = new TestCase( SECTION, "unescape( void 0 )", "undefined", unescape(void 0) ); + array[item++] = new TestCase( SECTION, "unescape( true )", "true", unescape( true ) ); + array[item++] = new TestCase( SECTION, "unescape( false )", "false", unescape( false ) ); + + array[item++] = new TestCase( SECTION, "unescape( new Boolean(true) )", "true", unescape(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "unescape( new Boolean(false) )", "false", unescape(new Boolean(false)) ); + + array[item++] = new TestCase( SECTION, "unescape( Number.NaN )", "NaN", unescape(Number.NaN) ); + array[item++] = new TestCase( SECTION, "unescape( -0 )", "0", unescape( -0 ) ); + array[item++] = new TestCase( SECTION, "unescape( 'Infinity' )", "Infinity", unescape( "Infinity" ) ); + array[item++] = new TestCase( SECTION, "unescape( Number.POSITIVE_INFINITY )", "Infinity", unescape( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "unescape( Number.NEGATIVE_INFINITY )", "-Infinity", unescape( Number.NEGATIVE_INFINITY ) ); + + var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; + + array[item++] = new TestCase( SECTION, "unescape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, unescape( ASCII_TEST_STRING ) ); + + // escaped chars with ascii values less than 256 + + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "unescape( %"+ ToHexString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%" + ToHexString(CHARCODE) ) ); + } + + // unicode chars represented by two hex digits + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ ToHexString(CHARCODE)+" )", + "%u"+ToHexString(CHARCODE), + unescape( "%u" + ToHexString(CHARCODE) ) ); + } +/* + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } + for ( var CHARCODE = 256; CHARCODE < 65536; CHARCODE+= 333 ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } +*/ + return ( array ); +} + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +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/GlobalObject/15.1.2.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js new file mode 100644 index 0000000..d8fc253 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js @@ -0,0 +1,184 @@ +/* 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.1.2.5-2.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + Description: + + This tests the cases where there are fewer than 4 characters following "%u", + or fewer than 2 characters following "%" or "%u". + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + var SECTION = "15.1.2.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "unescape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // since there is only one character following "%", no conversion should occur. + + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE += 16 ) { + array[item++] = new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1) ) ); + } + + // since there is only one character following "%u", no conversion should occur. + + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE +=16 ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%u"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1) ) ); + } + + + // three char unicode string. no conversion should occur + + for ( var CHARCODE = 1024; CHARCODE < 65536; CHARCODE+= 1234 ) { + array[item++] = new TestCase + ( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3)+ " )", + + "%u"+(ToUnicodeString(CHARCODE)).substring(0,3), + unescape( "%u"+(ToUnicodeString(CHARCODE)).substring(0,3) ) + ); + } + + return ( array ); +} + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +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/GlobalObject/15.1.2.5-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js new file mode 100644 index 0000000..9fa83f3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js @@ -0,0 +1,207 @@ +/* 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.1.2.5-3.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + This tests the cases where one of the four characters following "%u" is + not a hexidecimal character, or one of the two characters following "%" + or "%u" is not a hexidecimal character. + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + + var SECTION = "15.1.2.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "unescape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + array[item++] = new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); + } + for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + array[item++] = new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%u"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); + } + + for ( var CHARCODE = 0, NONHEXCHARCODE = 0 ; CHARCODE < 65536; CHARCODE+= 54321, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + array[item++] = new TestCase( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + + String.fromCharCode(eval("0x"+ (ToUnicodeString(CHARCODE)).substring(0,2))) + + (ToUnicodeString(CHARCODE)).substring(2,3) + + String.fromCharCode( NONHEXCHARCODE ), + + unescape( "%" + (ToUnicodeString(CHARCODE)).substring(0,3)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); + } + + return ( array ); +} +function getNextNonHexCharCode( n ) { + for ( ; n < Math.pow(2,16); n++ ) { + if ( ( n == 43 || n == 45 || n == 46 || n == 47 || + (n >= 71 && n <= 90) || (n >= 103 && n <= 122) || + n == 64 || n == 95 ) ) { + break; + } else { + n = ( n > 122 ) ? 0 : n; + } + } + return n; +} +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +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/GlobalObject/15.1.2.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.6.js new file mode 100644 index 0000000..053dab4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.6.js @@ -0,0 +1,127 @@ +/* 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.1.2.6.js + ECMA Section: 15.1.2.6 isNaN( x ) + + Description: Applies ToNumber to its argument, then returns true if + the result isNaN and otherwise returns false. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "isNaN( x )"; + + var BUGNUMBER = "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "isNaN.length", 1, isNaN.length ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") ); + array[item++] = new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") ); + array[item++] = new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length ); + array[item++] = new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") ); + +// array[item++] = new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ ); + + array[item++] = new TestCase( SECTION, "isNaN()", true, isNaN() ); + array[item++] = new TestCase( SECTION, "isNaN( null )", false, isNaN(null) ); + array[item++] = new TestCase( SECTION, "isNaN( void 0 )", true, isNaN(void 0) ); + array[item++] = new TestCase( SECTION, "isNaN( true )", false, isNaN(true) ); + array[item++] = new TestCase( SECTION, "isNaN( false)", false, isNaN(false) ); + array[item++] = new TestCase( SECTION, "isNaN( ' ' )", false, isNaN( " " ) ); + + array[item++] = new TestCase( SECTION, "isNaN( 0 )", false, isNaN(0) ); + array[item++] = new TestCase( SECTION, "isNaN( 1 )", false, isNaN(1) ); + array[item++] = new TestCase( SECTION, "isNaN( 2 )", false, isNaN(2) ); + array[item++] = new TestCase( SECTION, "isNaN( 3 )", false, isNaN(3) ); + array[item++] = new TestCase( SECTION, "isNaN( 4 )", false, isNaN(4) ); + array[item++] = new TestCase( SECTION, "isNaN( 5 )", false, isNaN(5) ); + array[item++] = new TestCase( SECTION, "isNaN( 6 )", false, isNaN(6) ); + array[item++] = new TestCase( SECTION, "isNaN( 7 )", false, isNaN(7) ); + array[item++] = new TestCase( SECTION, "isNaN( 8 )", false, isNaN(8) ); + array[item++] = new TestCase( SECTION, "isNaN( 9 )", false, isNaN(9) ); + + array[item++] = new TestCase( SECTION, "isNaN( '0' )", false, isNaN('0') ); + array[item++] = new TestCase( SECTION, "isNaN( '1' )", false, isNaN('1') ); + array[item++] = new TestCase( SECTION, "isNaN( '2' )", false, isNaN('2') ); + array[item++] = new TestCase( SECTION, "isNaN( '3' )", false, isNaN('3') ); + array[item++] = new TestCase( SECTION, "isNaN( '4' )", false, isNaN('4') ); + array[item++] = new TestCase( SECTION, "isNaN( '5' )", false, isNaN('5') ); + array[item++] = new TestCase( SECTION, "isNaN( '6' )", false, isNaN('6') ); + array[item++] = new TestCase( SECTION, "isNaN( '7' )", false, isNaN('7') ); + array[item++] = new TestCase( SECTION, "isNaN( '8' )", false, isNaN('8') ); + array[item++] = new TestCase( SECTION, "isNaN( '9' )", false, isNaN('9') ); + + + array[item++] = new TestCase( SECTION, "isNaN( 0x0a )", false, isNaN( 0x0a ) ); + array[item++] = new TestCase( SECTION, "isNaN( 0xaa )", false, isNaN( 0xaa ) ); + array[item++] = new TestCase( SECTION, "isNaN( 0x0A )", false, isNaN( 0x0A ) ); + array[item++] = new TestCase( SECTION, "isNaN( 0xAA )", false, isNaN( 0xAA ) ); + + array[item++] = new TestCase( SECTION, "isNaN( '0x0a' )", false, isNaN( "0x0a" ) ); + array[item++] = new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) ); + array[item++] = new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) ); + array[item++] = new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) ); + + array[item++] = new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) ); + array[item++] = new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) ); + + + array[item++] = new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.NEGATIVE_INFINITY )", false, isNaN(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.MAX_VALUE )", false, isNaN(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.MIN_VALUE )", false, isNaN(Number.MIN_VALUE) ); + + array[item++] = new TestCase( SECTION, "isNaN( NaN )", true, isNaN(NaN) ); + array[item++] = new TestCase( SECTION, "isNaN( Infinity )", false, isNaN(Infinity) ); + + array[item++] = new TestCase( SECTION, "isNaN( 'Infinity' )", false, isNaN("Infinity") ); + array[item++] = new TestCase( SECTION, "isNaN( '-Infinity' )", false, isNaN("-Infinity") ); + + 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/GlobalObject/15.1.2.7.js b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.7.js new file mode 100644 index 0000000..df384fa --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/GlobalObject/15.1.2.7.js @@ -0,0 +1,131 @@ +/* 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.1.2.7.js + ECMA Section: 15.1.2.7 isFinite(number) + + Description: Applies ToNumber to its argument, then returns false if + the result is NaN, Infinity, or -Infinity, and otherwise + returns true. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "isFinite( x )"; + + var BUGNUMBER= "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "isFinite.length", 1, isFinite.length ); + array[item++] = new TestCase( SECTION, "isFinite.length = null; isFinite.length", 1, eval("isFinite.length=null; isFinite.length") ); + array[item++] = new TestCase( SECTION, "delete isFinite.length", false, delete isFinite.length ); + array[item++] = new TestCase( SECTION, "delete isFinite.length; isFinite.length", 1, eval("delete isFinite.length; isFinite.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( p in isFinite ) { MYPROPS += p }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "isFinite()", false, isFinite() ); + array[item++] = new TestCase( SECTION, "isFinite( null )", true, isFinite(null) ); + array[item++] = new TestCase( SECTION, "isFinite( void 0 )", false, isFinite(void 0) ); + array[item++] = new TestCase( SECTION, "isFinite( false )", true, isFinite(false) ); + array[item++] = new TestCase( SECTION, "isFinite( true)", true, isFinite(true) ); + array[item++] = new TestCase( SECTION, "isFinite( ' ' )", true, isFinite( " " ) ); + + array[item++] = new TestCase( SECTION, "isFinite( new Boolean(true) )", true, isFinite(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "isFinite( new Boolean(false) )", true, isFinite(new Boolean(false)) ); + + array[item++] = new TestCase( SECTION, "isFinite( 0 )", true, isFinite(0) ); + array[item++] = new TestCase( SECTION, "isFinite( 1 )", true, isFinite(1) ); + array[item++] = new TestCase( SECTION, "isFinite( 2 )", true, isFinite(2) ); + array[item++] = new TestCase( SECTION, "isFinite( 3 )", true, isFinite(3) ); + array[item++] = new TestCase( SECTION, "isFinite( 4 )", true, isFinite(4) ); + array[item++] = new TestCase( SECTION, "isFinite( 5 )", true, isFinite(5) ); + array[item++] = new TestCase( SECTION, "isFinite( 6 )", true, isFinite(6) ); + array[item++] = new TestCase( SECTION, "isFinite( 7 )", true, isFinite(7) ); + array[item++] = new TestCase( SECTION, "isFinite( 8 )", true, isFinite(8) ); + array[item++] = new TestCase( SECTION, "isFinite( 9 )", true, isFinite(9) ); + + array[item++] = new TestCase( SECTION, "isFinite( '0' )", true, isFinite('0') ); + array[item++] = new TestCase( SECTION, "isFinite( '1' )", true, isFinite('1') ); + array[item++] = new TestCase( SECTION, "isFinite( '2' )", true, isFinite('2') ); + array[item++] = new TestCase( SECTION, "isFinite( '3' )", true, isFinite('3') ); + array[item++] = new TestCase( SECTION, "isFinite( '4' )", true, isFinite('4') ); + array[item++] = new TestCase( SECTION, "isFinite( '5' )", true, isFinite('5') ); + array[item++] = new TestCase( SECTION, "isFinite( '6' )", true, isFinite('6') ); + array[item++] = new TestCase( SECTION, "isFinite( '7' )", true, isFinite('7') ); + array[item++] = new TestCase( SECTION, "isFinite( '8' )", true, isFinite('8') ); + array[item++] = new TestCase( SECTION, "isFinite( '9' )", true, isFinite('9') ); + + array[item++] = new TestCase( SECTION, "isFinite( 0x0a )", true, isFinite( 0x0a ) ); + array[item++] = new TestCase( SECTION, "isFinite( 0xaa )", true, isFinite( 0xaa ) ); + array[item++] = new TestCase( SECTION, "isFinite( 0x0A )", true, isFinite( 0x0A ) ); + array[item++] = new TestCase( SECTION, "isFinite( 0xAA )", true, isFinite( 0xAA ) ); + + array[item++] = new TestCase( SECTION, "isFinite( '0x0a' )", true, isFinite( "0x0a" ) ); + array[item++] = new TestCase( SECTION, "isFinite( '0xaa' )", true, isFinite( "0xaa" ) ); + array[item++] = new TestCase( SECTION, "isFinite( '0x0A' )", true, isFinite( "0x0A" ) ); + array[item++] = new TestCase( SECTION, "isFinite( '0xAA' )", true, isFinite( "0xAA" ) ); + + array[item++] = new TestCase( SECTION, "isFinite( 077 )", true, isFinite( 077 ) ); + array[item++] = new TestCase( SECTION, "isFinite( '077' )", true, isFinite( "077" ) ); + + array[item++] = new TestCase( SECTION, "isFinite( new String('Infinity') )", false, isFinite(new String("Infinity")) ); + array[item++] = new TestCase( SECTION, "isFinite( new String('-Infinity') )", false, isFinite(new String("-Infinity")) ); + + array[item++] = new TestCase( SECTION, "isFinite( 'Infinity' )", false, isFinite("Infinity") ); + array[item++] = new TestCase( SECTION, "isFinite( '-Infinity' )", false, isFinite("-Infinity") ); + array[item++] = new TestCase( SECTION, "isFinite( Number.POSITIVE_INFINITY )", false, isFinite(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isFinite( Number.NEGATIVE_INFINITY )", false, isFinite(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isFinite( Number.NaN )", false, isFinite(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "isFinite( Infinity )", false, isFinite(Infinity) ); + array[item++] = new TestCase( SECTION, "isFinite( -Infinity )", false, isFinite(-Infinity) ); + array[item++] = new TestCase( SECTION, "isFinite( NaN )", false, isFinite(NaN) ); + + + array[item++] = new TestCase( SECTION, "isFinite( Number.MAX_VALUE )", true, isFinite(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "isFinite( Number.MIN_VALUE )", true, isFinite(Number.MIN_VALUE) ); + + 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/LexicalConventions/7.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-1.js new file mode 100644 index 0000000..d801063 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-1.js @@ -0,0 +1,86 @@ +/* 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: 7.1-1.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab <TAB> \t + \u000B veritical tab <VT> \v + \U000C form feed <FF> \f + \u0020 space <SP> " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "7.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "White Space"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + // whitespace between var keyword and identifier + + array[item++] = new TestCase( SECTION, 'var'+'\t'+'MYVAR1=10;MYVAR1', 10, eval('var'+'\t'+'MYVAR1=10;MYVAR1') ); + array[item++] = new TestCase( SECTION, 'var'+'\f'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\f'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, 'var'+'\v'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\v'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, 'var'+'\ '+'MYVAR2=10;MYVAR2', 10, eval('var'+'\ '+'MYVAR2=10;MYVAR2') ); + + // use whitespace between tokens object name, dot operator, and object property + + array[item++] = new TestCase( SECTION, + "var a = new Array(12345); a\t\v\f .\\u0009\\000B\\u000C\\u0020length", + 12345, + eval("var a = new Array(12345); a\t\v\f .\u0009\u0020\u000C\u000Blength") ); + + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-2.js new file mode 100644 index 0000000..04da3c9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-2.js @@ -0,0 +1,74 @@ +/* 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: 7.1-2.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab <TAB> \t + \u000B veritical tab <VT> ?? + \U000C form feed <FF> \f + \u0020 space <SP> " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "7.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "White Space"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-3.js new file mode 100644 index 0000000..c9c6ae1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.1-3.js @@ -0,0 +1,92 @@ +/* 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: 7.1-3.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab <TAB> \t + \u000B veritical tab <VT> ?? + \U000C form feed <FF> \f + \u0020 space <SP> " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "7.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "White Space"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); + + // +<white space>+ should be interpreted as the unary + operator twice, not as a post or prefix increment operator + + array[item++] = new TestCase( SECTION, + "var VAR = 12345; + + VAR", + 12345, + eval("var VAR = 12345; + + VAR") ); + + array[item++] = new TestCase( SECTION, + "var VAR = 12345;VAR+ + VAR", + 24690, + eval("var VAR = 12345;VAR+ +VAR") ); + array[item++] = new TestCase( SECTION, + "var VAR = 12345;VAR - - VAR", + 24690, + eval("var VAR = 12345;VAR- -VAR") ); + + + 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/LexicalConventions/7.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-1.js new file mode 100644 index 0000000..4936984 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-1.js @@ -0,0 +1,75 @@ +/* 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: 7.2-1.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var a\nb = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\nb = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); + array[item++] = new TestCase( SECTION, "var a\rb = 5; ab=10;ab;", 10, eval("var a\rb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\rb = 5; ab=10;b;", 5, eval("var a\rb = 5; ab=10;b") ); + array[item++] = new TestCase( SECTION, "var a\r\nb = 5; ab=10;ab;", 10, eval("var a\r\nb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\r\nb = 5; ab=10;b;", 5, eval("var a\r\nb = 5; ab=10;b") ); + + 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/LexicalConventions/7.2-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-2-n.js new file mode 100644 index 0000000..268fc56 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-2-n.js @@ -0,0 +1,80 @@ +/* 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: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + // this is line 29 + a = "\r\r\r\nb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[0].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + stopTest(); + + return ( testcases ); +} + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "<cr>a", "error", ""); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-3-n.js new file mode 100644 index 0000000..ff3753d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-3-n.js @@ -0,0 +1,83 @@ +/* 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: 7.2-3.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + + // this is line 27 + + a = "\r\nb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[0].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + stopTest(); + return ( testcases ); +} + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "<cr>a", "error", ""); + + return ( array ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-4-n.js new file mode 100644 index 0000000..0f98b9b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-4-n.js @@ -0,0 +1,82 @@ +/* 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: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + // this is line 33 + + a = "\nb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[0].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + stopTest(); + + return ( testcases ); +} + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "a = \\nb", "error", ""); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-5-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-5-n.js new file mode 100644 index 0000000..b226a98 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-5-n.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: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function test() { + // this is line 27 + + a = "\rb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + passed = false; + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "<cr>a", "error", ""); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-6.js new file mode 100644 index 0000000..70cff7e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.2-6.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: 7.2-6.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var a\u000Ab = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\u000Db = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); + 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/LexicalConventions/7.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-1.js new file mode 100644 index 0000000..ff94a3c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-1.js @@ -0,0 +1,79 @@ +/* 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: 7.3-1.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item] = new TestCase( SECTION, + "a comment with a line terminator string, and text following", + "pass", + "pass"); + + // "\u000A" array[item].actual = "fail"; + + item++; + + array[item] = new TestCase( SECTION, + "// test \\n array[item].actual = \"pass\"", + "pass", + "" ); + + var x = "// test \n array[item].actual = 'pass'" + + array[0].actual = eval(x); + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-10.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-10.js new file mode 100644 index 0000000..ed4a5b3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-10.js @@ -0,0 +1,67 @@ +/* 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: 7.3-10.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + /*//*/testcases[tc].actual="pass"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-11.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-11.js new file mode 100644 index 0000000..8b6773a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-11.js @@ -0,0 +1,66 @@ +/* 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: 7.3-11.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); + return ( array ); +} +function test() { + + ////testcases[tc].actual="fail"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-12.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-12.js new file mode 100644 index 0000000..fede098 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-12.js @@ -0,0 +1,66 @@ +/* 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: 7.3-12.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); + return ( array ); +} +function test() { + + /*testcases[tc].actual="fail";**/ + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-13-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-13-n.js new file mode 100644 index 0000000..92394e6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-13-n.js @@ -0,0 +1,66 @@ +/* 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: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-13-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "nested comment", + "error", + "pass"); + return ( array ); +} +function test() { + + /*/*testcases[tc].actual="fail";*/*/ + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-2.js new file mode 100644 index 0000000..8eca512 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-2.js @@ -0,0 +1,67 @@ +/* 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: 7.3-2.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); + return ( array ); +} +function test() { + + // "\u000D" testcases[tc].actual = "fail"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-3.js new file mode 100644 index 0000000..1bcd561 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-3.js @@ -0,0 +1,67 @@ +/* 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: 7.3-3.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "source text directly following a single-line comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + // a comment string + testcases[tc].actual = "pass"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-4.js new file mode 100644 index 0000000..7ac82c7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-4.js @@ -0,0 +1,67 @@ +/* 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: 7.3-4.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "multiline comment ", + "pass", + "pass"); + return ( array ); +} +function test() { + + /*testcases[tc].actual = "fail";*/ + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-5.js new file mode 100644 index 0000000..2ce6844 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-5.js @@ -0,0 +1,66 @@ +/* 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: 7.3-5.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); + return ( array ); +} +function test() { + + // "\u000A" testcases[tc].actual = "fail"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-6.js new file mode 100644 index 0000000..d010817 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-6.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: 7.3-6.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "comment with multiple asterisks", + "pass", + "fail"); + return ( array ); +} +function test() { + + /* + ***/testcases[tc].actual="pass"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-7.js new file mode 100644 index 0000000..8bdf623 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-7.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: 7.3-7.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "single line comment following multiline comment", + "pass", + "pass"); + return ( array ); +} +function test() { + + /* + ***///testcases[tc].actual="fail"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-8.js new file mode 100644 index 0000000..6d686cf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-8.js @@ -0,0 +1,67 @@ +/* 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: 7.3-7.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + /**/testcases[tc].actual="pass"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-9.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-9.js new file mode 100644 index 0000000..701e115 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.3-9.js @@ -0,0 +1,66 @@ +/* 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: 7.3-9.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-9"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + /*/*/testcases[tc].actual="pass"; + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js new file mode 100644 index 0000000..37b1c4e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js @@ -0,0 +1,71 @@ +/* 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: 7.4.1-1-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var null = true", "error", "var null = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.1-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-2-n.js new file mode 100644 index 0000000..f85891b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-2-n.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: 7.4.1-2.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var true = false", "error", "var true = false" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.1-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-3-n.js new file mode 100644 index 0000000..a05480a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.1-3-n.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: 7.4.1-3-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var false = true", "error", "var false = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-1-n.js new file mode 100644 index 0000000..43d0425 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-1-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-1.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var break = true", "error", "var break = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-10-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-10-n.js new file mode 100644 index 0000000..0ad19db --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-10-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-10.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-10-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var if = true", "error", "var if = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-11-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-11-n.js new file mode 100644 index 0000000..e8a0f80 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-11-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-11-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-11-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var this = true", "error", "var this = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-12-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-12-n.js new file mode 100644 index 0000000..ffc3350 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-12-n.js @@ -0,0 +1,77 @@ +/* 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: 7.4.2-12-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-12-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var while = true", "error", "var while = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-13-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-13-n.js new file mode 100644 index 0000000..78320b2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-13-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-13-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-13-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var else = true", "error", "var else = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-14-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-14-n.js new file mode 100644 index 0000000..4b8bb0f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-14-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-14-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-14-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var in = true", "error", "var in = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-15-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-15-n.js new file mode 100644 index 0000000..d84f9d7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-15-n.js @@ -0,0 +1,77 @@ +/* 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: 7.4.2-15-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-15-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var typeof = true", "error", "var typeof = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-16-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-16-n.js new file mode 100644 index 0000000..8293eee --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-16-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-16-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-16-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var with = true", "error", "var with = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-2-n.js new file mode 100644 index 0000000..2b799b1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-2-n.js @@ -0,0 +1,75 @@ +/* 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: 7.4.2-2-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var for = true", "error", "var for = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-3-n.js new file mode 100644 index 0000000..3b5feb0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-3-n.js @@ -0,0 +1,75 @@ +/* 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: 7.4.2-3-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var new = true", "error", "var new = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-4-n.js new file mode 100644 index 0000000..13faf32 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-4-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-4-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var var = true", "error", "var var = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-5-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-5-n.js new file mode 100644 index 0000000..004249b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-5-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-5-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-5-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var continue = true", "error", "var continue = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-6-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-6-n.js new file mode 100644 index 0000000..3b830f8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-6-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-6.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-6-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var function = true", "error", "var function = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-7-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-7-n.js new file mode 100644 index 0000000..c84ca9d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-7-n.js @@ -0,0 +1,73 @@ +/* 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: 7.4.2-7-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-7"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + writeHeaderToLog( SECTION + " Keywords"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var return = true", "error", "var return = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-8-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-8-n.js new file mode 100644 index 0000000..f2397bb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-8-n.js @@ -0,0 +1,73 @@ +/* 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: 7.4.2-8-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-8"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + writeHeaderToLog( SECTION + " Keywords"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var void = true", "error", "var void = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.2-9-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-9-n.js new file mode 100644 index 0000000..5b5a288 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.2-9-n.js @@ -0,0 +1,76 @@ +/* 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: 7.4.2-9-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var delete = true", "error", "var delete = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-1-n.js new file mode 100644 index 0000000..5a626a4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-1-n.js @@ -0,0 +1,71 @@ +/* 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: 7.4.3-1-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var case = true", "error", "var case = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-10-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-10-n.js new file mode 100644 index 0000000..84d6cf3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-10-n.js @@ -0,0 +1,71 @@ +/* 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: 7.4.3-10-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-10-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var do = true", "error", "var do = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-11-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-11-n.js new file mode 100644 index 0000000..b850584 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-11-n.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: 7.4.3-11-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-11-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var finally = true", "error", "var finally = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-12-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-12-n.js new file mode 100644 index 0000000..7dfe3cc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-12-n.js @@ -0,0 +1,72 @@ +/* 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: 7.4.3-12-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-12-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var throw = true", "error", "var throw = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-13-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-13-n.js new file mode 100644 index 0000000..ede44c1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-13-n.js @@ -0,0 +1,72 @@ +/* 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: 7.4.3-13-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-13-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var const = true", "error", "var const = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-14-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-14-n.js new file mode 100644 index 0000000..31b6794 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-14-n.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: 7.4.3-14-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-14-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var enum = true", "error", "var enum = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-15-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-15-n.js new file mode 100644 index 0000000..dfda054 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-15-n.js @@ -0,0 +1,72 @@ +/* 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: 7.4.3-15-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-15-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var import = true", "error", "var import = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-16-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-16-n.js new file mode 100644 index 0000000..cf61635 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-16-n.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: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-023.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + try = true; + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js new file mode 100644 index 0000000..46da571 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js @@ -0,0 +1,72 @@ +/* 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: 7.4.3-2-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var debugger = true", "error", "var debugger = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-3-n.js new file mode 100644 index 0000000..bfdbe3b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-3-n.js @@ -0,0 +1,72 @@ +/* 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: 7.4.3-3-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var export = true", "error", "var export = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-4-n.js new file mode 100644 index 0000000..11b97c9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-4-n.js @@ -0,0 +1,72 @@ +/* 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: 7.4.3-4-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var super = true", "error", "var super = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-5-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-5-n.js new file mode 100644 index 0000000..8acbbcd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-5-n.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: 7.4.3-5-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-5-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var catch = true", "error", "var catch = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-6-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-6-n.js new file mode 100644 index 0000000..d5ea75e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-6-n.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: 7.4.3-6-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-6-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var default = true", "error", "var default = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-7-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-7-n.js new file mode 100644 index 0000000..93cf4cd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-7-n.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: 7.4.3-7-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-7-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var extends = true", "error", "var extends = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-8-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-8-n.js new file mode 100644 index 0000000..7d09f0c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-8-n.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: 7.4.3-8-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var switch = true", "error", "var switch = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.4.3-9-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-9-n.js new file mode 100644 index 0000000..f0e71f9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.4.3-9-n.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: 7.4.3-9-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var class = true", "error", "var class = true" ); + return ( array ); +} + +function test() { + 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/LexicalConventions/7.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-1.js new file mode 100644 index 0000000..ef1b257 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-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: 7.5-1.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var $123 = 5", 5, eval("var $123 = 5;$123") ); + array[item++] = new TestCase( SECTION, "var _123 = 5", 5, eval("var _123 = 5;_123") ); + + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-10-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-10-n.js new file mode 100644 index 0000000..b1bb872 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-10-n.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: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item] = new TestCase( SECTION, "var 123=\"hi\"", "error", "" ); + + 123 = "hi"; + + array[item] = 123; + + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-2-n.js new file mode 100644 index 0000000..b8a161d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-2-n.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: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 0abc" ); + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-3-n.js new file mode 100644 index 0000000..0d0aa84 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-3-n.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: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 1abc" ); + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-4-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-4-n.js new file mode 100644 index 0000000..8a21a77 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-4-n.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: 7.5-4-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 2abc" ); + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-5-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-5-n.js new file mode 100644 index 0000000..7a17f16 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-5-n.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: 7.5-5-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-5-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 3abc" ); + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-6.js new file mode 100644 index 0000000..8b19307 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-6.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: 7.5-6.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var _0abc = 5", 5, "var _0abc = 5; _0abc" ); + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-7.js new file mode 100644 index 0000000..7ade939 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-7.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: 7.5-7.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var $0abc = 5", 5, "var $0abc = 5; $0abc" ); + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-8-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-8-n.js new file mode 100644 index 0000000..f17e071 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-8-n.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: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-8-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var @0abc = 5", "error", "var @0abc = 5; @0abc" ); + return ( array ); +} + +function test() {s + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-9-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-9-n.js new file mode 100644 index 0000000..8ef78d6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.5-9-n.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: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item] = new TestCase( SECTION, "var 123=\"hi\"", "error", "" ); + + var 123 = "hi"; + + array[item] = 123; + + return ( array ); +} + +function test() { + 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 ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.6.js new file mode 100644 index 0000000..68b66be --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.6.js @@ -0,0 +1,309 @@ +/* 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: 7.6.js + ECMA Section: Punctuators + Description: + + This tests verifies that all ECMA punctutors are recognized as a + token separator, but does not attempt to verify the functionality + of any punctuator. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "7.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Punctuators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // == + testcases[tc++] = new TestCase( SECTION, + "var c,d;c==d", + true, + eval("var c,d;c==d") ); + + // = + + testcases[tc++] = new TestCase( SECTION, + "var a=true;a", + true, + eval("var a=true;a") ); + + // > + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a>b", + true, + eval("var a=true,b=false;a>b") ); + + // < + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a<b", + false, + eval("var a=true,b=false;a<b") ); + + // <= + testcases[tc++] = new TestCase( SECTION, + "var a=0xFFFF,b=0X0FFF;a<=b", + false, + eval("var a=0xFFFF,b=0X0FFF;a<=b") ); + + // >= + testcases[tc++] = new TestCase( SECTION, + "var a=0xFFFF,b=0XFFFE;a>=b", + true, + eval("var a=0xFFFF,b=0XFFFE;a>=b") ); + + // != + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a!=b", + true, + eval("var a=true,b=false;a!=b") ); + + testcases[tc++] = new TestCase( SECTION, + "var a=false,b=false;a!=b", + false, + eval("var a=false,b=false;a!=b") ); + // , + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a,b", + false, + eval("var a=true,b=false;a,b") ); + // ! + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;!a", + false, + eval("var a=true,b=false;!a") ); + + // ~ + testcases[tc++] = new TestCase( SECTION, + "var a=true;~a", + -2, + eval("var a=true;~a") ); + // ? + testcases[tc++] = new TestCase( SECTION, + "var a=true; (a ? 'PASS' : '')", + "PASS", + eval("var a=true; (a ? 'PASS' : '')") ); + + // : + + testcases[tc++] = new TestCase( SECTION, + "var a=false; (a ? 'FAIL' : 'PASS')", + "PASS", + eval("var a=false; (a ? 'FAIL' : 'PASS')") ); + // . + + testcases[tc++] = new TestCase( SECTION, + "var a=Number;a.NaN", + NaN, + eval("var a=Number;a.NaN") ); + + // && + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", + "PASS", + eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); + + // || + testcases[tc++] = new TestCase( SECTION, + "var a=false,b=false;if(a||b)'FAIL';else'PASS'", + "PASS", + eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); + // ++ + testcases[tc++] = new TestCase( SECTION, + "var a=false,b=false;++a", + 1, + eval("var a=false,b=false;++a") ); + // -- + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false--a", + 0, + eval("var a=true,b=false;--a") ); + // + + + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a+b", + 2, + eval("var a=true,b=true;a+b") ); + // - + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a-b", + 0, + eval("var a=true,b=true;a-b") ); + // * + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a*b", + 1, + eval("var a=true,b=true;a*b") ); + // / + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a/b", + 1, + eval("var a=true,b=true;a/b") ); + // & + testcases[tc++] = new TestCase( SECTION, + "var a=3,b=2;a&b", + 2, + eval("var a=3,b=2;a&b") ); + // | + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a|b", + 7, + eval("var a=4,b=3;a|b") ); + + // | + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a^b", + 7, + eval("var a=4,b=3;a^b") ); + + // % + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a|b", + 1, + eval("var a=4,b=3;a%b") ); + + // << + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a<<b", + 32, + eval("var a=4,b=3;a<<b") ); + + // >> + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=1;a>>b", + 2, + eval("var a=4,b=1;a>>b") ); + + // >>> + testcases[tc++] = new TestCase( SECTION, + "var a=1,b=1;a>>>b", + 0, + eval("var a=1,b=1;a>>>b") ); + // += + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); + + // -= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a-=b;a", + 1, + eval("var a=4,b=3;a-=b;a") ); + // *= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a*=b;a", + 12, + eval("var a=4,b=3;a*=b;a") ); + // += + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); + // /= + testcases[tc++] = new TestCase( SECTION, + "var a=12,b=3;a/=b;a", + 4, + eval("var a=12,b=3;a/=b;a") ); + + // &= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 4, + eval("var a=4,b=5;a&=b;a") ); + + // |= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 5, + eval("var a=4,b=5;a|=b;a") ); + // ^= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=5;a^=b;a", + 1, + eval("var a=4,b=5;a^=b;a") ); + // %= + testcases[tc++] = new TestCase( SECTION, + "var a=12,b=5;a%=b;a", + 2, + eval("var a=12,b=5;a%=b;a") ); + // <<= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a<<=b;a", + 32, + eval("var a=4,b=3;a<<=b;a") ); + + // >> + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=1;a>>=b;a", + 2, + eval("var a=4,b=1;a>>=b;a") ); + + // >>> + testcases[tc++] = new TestCase( SECTION, + "var a=1,b=1;a>>>=b;a", + 0, + eval("var a=1,b=1;a>>>=b;a") ); + + // () + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;(a)", + 4, + eval("var a=4,b=3;(a)") ); + // {} + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;{b}", + 3, + eval("var a=4,b=3;{b}") ); + + // [] + testcases[tc++] = new TestCase( SECTION, + "var a=new Array('hi');a[0]", + "hi", + eval("var a=new Array('hi');a[0]") ); + // [] + testcases[tc++] = new TestCase( SECTION, + ";", + void 0, + eval(";") ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.1.js new file mode 100644 index 0000000..a939e51 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.1.js @@ -0,0 +1,72 @@ +/* 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: 7.7.1.js + ECMA Section: 7.7.1 Null Literals + + Description: NullLiteral:: + null + + + The value of the null literal null is the sole value + of the Null type, namely null. + + Author: christine@netscape.com + Date: 21 october 1997 +*/ + var SECTION = "7.7.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Null Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "null", null, null); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = 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(); + + // all tests must return the test array + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.2.js new file mode 100644 index 0000000..1202df3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.2.js @@ -0,0 +1,75 @@ +/* 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: 7.7.2.js + ECMA Section: 7.7.2 Boolean Literals + + Description: BooleanLiteral:: + true + false + + The value of the Boolean literal true is a value of the + Boolean type, namely true. + + The value of the Boolean literal false is a value of the + Boolean type, namely false. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "7.7.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // StringLiteral:: "" and '' + + array[item++] = new TestCase( SECTION, "true", Boolean(true), true ); + array[item++] = new TestCase( SECTION, "false", Boolean(false), false ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = 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/LexicalConventions/7.7.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.3-1.js new file mode 100644 index 0000000..91becca --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.3-1.js @@ -0,0 +1,197 @@ +/* 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: 7.7.3-1.js + ECMA Section: 7.7.3 Numeric Literals + + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. + + These test cases came from Waldemar. + + Author: christine@netscape.com + Date: 12 June 1998 +*/ + +var SECTION = "7.7.3-1"; +var VERSION = "ECMA_1"; + startTest(); +var TITLE = "Numeric Literals"; +var BUGNUMBER="122877"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = new Array(); + + +testcases[tc++] = new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); + +testcases[tc++] = new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); + +test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = 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/LexicalConventions/7.7.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.3-2.js new file mode 100644 index 0000000..b6e750c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.3-2.js @@ -0,0 +1,93 @@ +/* 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: 7.7.3-2.js + ECMA Section: 7.7.3 Numeric Literals + + Description: + + This is a regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122884 + + Waldemar's comments: + + A numeric literal that starts with either '08' or '09' is interpreted as a + decimal literal; it should be an error instead. (Strictly speaking, according + to ECMA v1 such literals should be interpreted as two integers -- a zero + followed by a decimal number whose first digit is 8 or 9, but this is a bug in + ECMA that will be fixed in v2. In any case, there is no place in the grammar + where two consecutive numbers would be legal.) + + Author: christine@netscape.com + Date: 15 june 1998 + +*/ + var SECTION = "7.7.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Numeric Literals"; + var BUGNUMBER="122884"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "9", + 9, + 9 ); + + testcases[tc++] = new TestCase( SECTION, + "09", + 9, + 09 ); + + testcases[tc++] = new TestCase( SECTION, + "099", + 99, + 099 ); + + + testcases[tc++] = new TestCase( SECTION, + "077", + 63, + 077 ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = 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/LexicalConventions/7.7.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.3.js new file mode 100644 index 0000000..7d47a40 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.3.js @@ -0,0 +1,337 @@ +/* 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: 7.7.3.js + ECMA Section: 7.7.3 Numeric Literals + + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "7.7.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Numeric Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "0", 0, 0 ); + array[item++] = new TestCase( SECTION, "1", 1, 1 ); + array[item++] = new TestCase( SECTION, "2", 2, 2 ); + array[item++] = new TestCase( SECTION, "3", 3, 3 ); + array[item++] = new TestCase( SECTION, "4", 4, 4 ); + array[item++] = new TestCase( SECTION, "5", 5, 5 ); + array[item++] = new TestCase( SECTION, "6", 6, 6 ); + array[item++] = new TestCase( SECTION, "7", 7, 7 ); + array[item++] = new TestCase( SECTION, "8", 8, 8 ); + array[item++] = new TestCase( SECTION, "9", 9, 9 ); + + array[item++] = new TestCase( SECTION, "0.", 0, 0. ); + array[item++] = new TestCase( SECTION, "1.", 1, 1. ); + array[item++] = new TestCase( SECTION, "2.", 2, 2. ); + array[item++] = new TestCase( SECTION, "3.", 3, 3. ); + array[item++] = new TestCase( SECTION, "4.", 4, 4. ); + + array[item++] = new TestCase( SECTION, "0.e0", 0, 0.e0 ); + array[item++] = new TestCase( SECTION, "1.e1", 10, 1.e1 ); + array[item++] = new TestCase( SECTION, "2.e2", 200, 2.e2 ); + array[item++] = new TestCase( SECTION, "3.e3", 3000, 3.e3 ); + array[item++] = new TestCase( SECTION, "4.e4", 40000, 4.e4 ); + + array[item++] = new TestCase( SECTION, "0.1e0", .1, 0.1e0 ); + array[item++] = new TestCase( SECTION, "1.1e1", 11, 1.1e1 ); + array[item++] = new TestCase( SECTION, "2.2e2", 220, 2.2e2 ); + array[item++] = new TestCase( SECTION, "3.3e3", 3300, 3.3e3 ); + array[item++] = new TestCase( SECTION, "4.4e4", 44000, 4.4e4 ); + + array[item++] = new TestCase( SECTION, ".1e0", .1, .1e0 ); + array[item++] = new TestCase( SECTION, ".1e1", 1, .1e1 ); + array[item++] = new TestCase( SECTION, ".2e2", 20, .2e2 ); + array[item++] = new TestCase( SECTION, ".3e3", 300, .3e3 ); + array[item++] = new TestCase( SECTION, ".4e4", 4000, .4e4 ); + + array[item++] = new TestCase( SECTION, "0e0", 0, 0e0 ); + array[item++] = new TestCase( SECTION, "1e1", 10, 1e1 ); + array[item++] = new TestCase( SECTION, "2e2", 200, 2e2 ); + array[item++] = new TestCase( SECTION, "3e3", 3000, 3e3 ); + array[item++] = new TestCase( SECTION, "4e4", 40000, 4e4 ); + + array[item++] = new TestCase( SECTION, "0e0", 0, 0e0 ); + array[item++] = new TestCase( SECTION, "1e1", 10, 1e1 ); + array[item++] = new TestCase( SECTION, "2e2", 200, 2e2 ); + array[item++] = new TestCase( SECTION, "3e3", 3000, 3e3 ); + array[item++] = new TestCase( SECTION, "4e4", 40000, 4e4 ); + + array[item++] = new TestCase( SECTION, "0E0", 0, 0E0 ); + array[item++] = new TestCase( SECTION, "1E1", 10, 1E1 ); + array[item++] = new TestCase( SECTION, "2E2", 200, 2E2 ); + array[item++] = new TestCase( SECTION, "3E3", 3000, 3E3 ); + array[item++] = new TestCase( SECTION, "4E4", 40000, 4E4 ); + + array[item++] = new TestCase( SECTION, "1.e-1", 0.1, 1.e-1 ); + array[item++] = new TestCase( SECTION, "2.e-2", 0.02, 2.e-2 ); + array[item++] = new TestCase( SECTION, "3.e-3", 0.003, 3.e-3 ); + array[item++] = new TestCase( SECTION, "4.e-4", 0.0004, 4.e-4 ); + + array[item++] = new TestCase( SECTION, "0.1e-0", .1, 0.1e-0 ); + array[item++] = new TestCase( SECTION, "1.1e-1", 0.11, 1.1e-1 ); + array[item++] = new TestCase( SECTION, "2.2e-2", .022, 2.2e-2 ); + array[item++] = new TestCase( SECTION, "3.3e-3", .0033, 3.3e-3 ); + array[item++] = new TestCase( SECTION, "4.4e-4", .00044, 4.4e-4 ); + + array[item++] = new TestCase( SECTION, ".1e-0", .1, .1e-0 ); + array[item++] = new TestCase( SECTION, ".1e-1", .01, .1e-1 ); + array[item++] = new TestCase( SECTION, ".2e-2", .002, .2e-2 ); + array[item++] = new TestCase( SECTION, ".3e-3", .0003, .3e-3 ); + array[item++] = new TestCase( SECTION, ".4e-4", .00004, .4e-4 ); + + array[item++] = new TestCase( SECTION, "1.e+1", 10, 1.e+1 ); + array[item++] = new TestCase( SECTION, "2.e+2", 200, 2.e+2 ); + array[item++] = new TestCase( SECTION, "3.e+3", 3000, 3.e+3 ); + array[item++] = new TestCase( SECTION, "4.e+4", 40000, 4.e+4 ); + + array[item++] = new TestCase( SECTION, "0.1e+0", .1, 0.1e+0 ); + array[item++] = new TestCase( SECTION, "1.1e+1", 11, 1.1e+1 ); + array[item++] = new TestCase( SECTION, "2.2e+2", 220, 2.2e+2 ); + array[item++] = new TestCase( SECTION, "3.3e+3", 3300, 3.3e+3 ); + array[item++] = new TestCase( SECTION, "4.4e+4", 44000, 4.4e+4 ); + + array[item++] = new TestCase( SECTION, ".1e+0", .1, .1e+0 ); + array[item++] = new TestCase( SECTION, ".1e+1", 1, .1e+1 ); + array[item++] = new TestCase( SECTION, ".2e+2", 20, .2e+2 ); + array[item++] = new TestCase( SECTION, ".3e+3", 300, .3e+3 ); + array[item++] = new TestCase( SECTION, ".4e+4", 4000, .4e+4 ); + + array[item++] = new TestCase( SECTION, "0x0", 0, 0x0 ); + array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); + array[item++] = new TestCase( SECTION, "0x2", 2, 0x2 ); + array[item++] = new TestCase( SECTION, "0x3", 3, 0x3 ); + array[item++] = new TestCase( SECTION, "0x4", 4, 0x4 ); + array[item++] = new TestCase( SECTION, "0x5", 5, 0x5 ); + array[item++] = new TestCase( SECTION, "0x6", 6, 0x6 ); + array[item++] = new TestCase( SECTION, "0x7", 7, 0x7 ); + array[item++] = new TestCase( SECTION, "0x8", 8, 0x8 ); + array[item++] = new TestCase( SECTION, "0x9", 9, 0x9 ); + array[item++] = new TestCase( SECTION, "0xa", 10, 0xa ); + array[item++] = new TestCase( SECTION, "0xb", 11, 0xb ); + array[item++] = new TestCase( SECTION, "0xc", 12, 0xc ); + array[item++] = new TestCase( SECTION, "0xd", 13, 0xd ); + array[item++] = new TestCase( SECTION, "0xe", 14, 0xe ); + array[item++] = new TestCase( SECTION, "0xf", 15, 0xf ); + + array[item++] = new TestCase( SECTION, "0X0", 0, 0X0 ); + array[item++] = new TestCase( SECTION, "0X1", 1, 0X1 ); + array[item++] = new TestCase( SECTION, "0X2", 2, 0X2 ); + array[item++] = new TestCase( SECTION, "0X3", 3, 0X3 ); + array[item++] = new TestCase( SECTION, "0X4", 4, 0X4 ); + array[item++] = new TestCase( SECTION, "0X5", 5, 0X5 ); + array[item++] = new TestCase( SECTION, "0X6", 6, 0X6 ); + array[item++] = new TestCase( SECTION, "0X7", 7, 0X7 ); + array[item++] = new TestCase( SECTION, "0X8", 8, 0X8 ); + array[item++] = new TestCase( SECTION, "0X9", 9, 0X9 ); + array[item++] = new TestCase( SECTION, "0Xa", 10, 0Xa ); + array[item++] = new TestCase( SECTION, "0Xb", 11, 0Xb ); + array[item++] = new TestCase( SECTION, "0Xc", 12, 0Xc ); + array[item++] = new TestCase( SECTION, "0Xd", 13, 0Xd ); + array[item++] = new TestCase( SECTION, "0Xe", 14, 0Xe ); + array[item++] = new TestCase( SECTION, "0Xf", 15, 0Xf ); + + array[item++] = new TestCase( SECTION, "0x0", 0, 0x0 ); + array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); + array[item++] = new TestCase( SECTION, "0x2", 2, 0x2 ); + array[item++] = new TestCase( SECTION, "0x3", 3, 0x3 ); + array[item++] = new TestCase( SECTION, "0x4", 4, 0x4 ); + array[item++] = new TestCase( SECTION, "0x5", 5, 0x5 ); + array[item++] = new TestCase( SECTION, "0x6", 6, 0x6 ); + array[item++] = new TestCase( SECTION, "0x7", 7, 0x7 ); + array[item++] = new TestCase( SECTION, "0x8", 8, 0x8 ); + array[item++] = new TestCase( SECTION, "0x9", 9, 0x9 ); + array[item++] = new TestCase( SECTION, "0xA", 10, 0xA ); + array[item++] = new TestCase( SECTION, "0xB", 11, 0xB ); + array[item++] = new TestCase( SECTION, "0xC", 12, 0xC ); + array[item++] = new TestCase( SECTION, "0xD", 13, 0xD ); + array[item++] = new TestCase( SECTION, "0xE", 14, 0xE ); + array[item++] = new TestCase( SECTION, "0xF", 15, 0xF ); + + array[item++] = new TestCase( SECTION, "0X0", 0, 0X0 ); + array[item++] = new TestCase( SECTION, "0X1", 1, 0X1 ); + array[item++] = new TestCase( SECTION, "0X2", 2, 0X2 ); + array[item++] = new TestCase( SECTION, "0X3", 3, 0X3 ); + array[item++] = new TestCase( SECTION, "0X4", 4, 0X4 ); + array[item++] = new TestCase( SECTION, "0X5", 5, 0X5 ); + array[item++] = new TestCase( SECTION, "0X6", 6, 0X6 ); + array[item++] = new TestCase( SECTION, "0X7", 7, 0X7 ); + array[item++] = new TestCase( SECTION, "0X8", 8, 0X8 ); + array[item++] = new TestCase( SECTION, "0X9", 9, 0X9 ); + array[item++] = new TestCase( SECTION, "0XA", 10, 0XA ); + array[item++] = new TestCase( SECTION, "0XB", 11, 0XB ); + array[item++] = new TestCase( SECTION, "0XC", 12, 0XC ); + array[item++] = new TestCase( SECTION, "0XD", 13, 0XD ); + array[item++] = new TestCase( SECTION, "0XE", 14, 0XE ); + array[item++] = new TestCase( SECTION, "0XF", 15, 0XF ); + + + array[item++] = new TestCase( SECTION, "00", 0, 00 ); + array[item++] = new TestCase( SECTION, "01", 1, 01 ); + array[item++] = new TestCase( SECTION, "02", 2, 02 ); + array[item++] = new TestCase( SECTION, "03", 3, 03 ); + array[item++] = new TestCase( SECTION, "04", 4, 04 ); + array[item++] = new TestCase( SECTION, "05", 5, 05 ); + array[item++] = new TestCase( SECTION, "06", 6, 06 ); + array[item++] = new TestCase( SECTION, "07", 7, 07 ); + + array[item++] = new TestCase( SECTION, "000", 0, 000 ); + array[item++] = new TestCase( SECTION, "011", 9, 011 ); + array[item++] = new TestCase( SECTION, "022", 18, 022 ); + array[item++] = new TestCase( SECTION, "033", 27, 033 ); + array[item++] = new TestCase( SECTION, "044", 36, 044 ); + array[item++] = new TestCase( SECTION, "055", 45, 055 ); + array[item++] = new TestCase( SECTION, "066", 54, 066 ); + array[item++] = new TestCase( SECTION, "077", 63, 077 ); + + array[item++] = new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); + array[item++] = new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); + + + array[item++] = new TestCase( SECTION, + "123456789012345671.9999", + "123456789012345660", + 123456789012345671.9999 +""); + array[item++] = new TestCase( SECTION, + "123456789012345672", + "123456789012345660", + 123456789012345672 +""); + + array[item++] = new TestCase( SECTION, + "123456789012345672.000000000000000000000000000", + "123456789012345660", + 123456789012345672.000000000000000000000000000 +""); + + array[item++] = new TestCase( SECTION, + "123456789012345672.01", + "123456789012345680", + 123456789012345672.01 +""); + + array[item++] = new TestCase( SECTION, + "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660", + true, + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 ) + || + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) ); + + array[item++] = new TestCase( SECTION, + "123456789012345673", + "123456789012345680", + 123456789012345673 +"" ); + + array[item++] = new TestCase( SECTION, + "-123456789012345671.9999", + "-123456789012345660", + -123456789012345671.9999 +"" ); + + array[item++] = new TestCase( SECTION, + "-123456789012345672", + "-123456789012345660", + -123456789012345672+""); + + array[item++] = new TestCase( SECTION, + "-123456789012345672.000000000000000000000000000", + "-123456789012345660", + -123456789012345672.000000000000000000000000000 +""); + + array[item++] = new TestCase( SECTION, + "-123456789012345672.01", + "-123456789012345680", + -123456789012345672.01 +"" ); + + array[item++] = new TestCase( SECTION, + "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660", + true, + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680) + || + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660)); + + array[item++] = new TestCase( SECTION, + -123456789012345673, + "-123456789012345680", + -123456789012345673 +""); + + array[item++] = new TestCase( SECTION, + "12345678901234567890", + "12345678901234567000", + 12345678901234567890 +"" ); + + +/* + array[item++] = new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" ); + array[item++] = new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" ); + array[item++] = new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" ); + array[item++] = new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" ); + array[item++] = new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" ); + array[item++] = new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" ); +*/ + array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); + array[item++] = new TestCase( SECTION, "0x10", 16, 0x10 ); + array[item++] = new TestCase( SECTION, "0x100", 256, 0x100 ); + array[item++] = new TestCase( SECTION, "0x1000", 4096, 0x1000 ); + array[item++] = new TestCase( SECTION, "0x10000", 65536, 0x10000 ); + array[item++] = new TestCase( SECTION, "0x100000", 1048576, 0x100000 ); + array[item++] = new TestCase( SECTION, "0x1000000", 16777216, 0x1000000 ); + array[item++] = new TestCase( SECTION, "0x10000000", 268435456, 0x10000000 ); +/* + array[item++] = new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 ); + array[item++] = new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 ); + array[item++] = new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 ); +*/ + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = 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/LexicalConventions/7.7.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.4.js new file mode 100644 index 0000000..769b819 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.7.4.js @@ -0,0 +1,275 @@ +/* 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: 7.7.4.js + ECMA Section: 7.7.4 String Literals + + Description: A string literal is zero or more characters enclosed in + single or double quotes. Each character may be + represented by an escape sequence. + + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "7.7.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // StringLiteral:: "" and '' + + array[item++] = new TestCase( SECTION, "\"\"", "", "" ); + array[item++] = new TestCase( SECTION, "\'\'", "", '' ); + + // DoubleStringCharacters:: DoubleStringCharacter :: EscapeSequence :: CharacterEscapeSequence + array[item++] = new TestCase( SECTION, "\\\"", String.fromCharCode(0x0022), "\"" ); + array[item++] = new TestCase( SECTION, "\\\'", String.fromCharCode(0x0027), "\'" ); + array[item++] = new TestCase( SECTION, "\\", String.fromCharCode(0x005C), "\\" ); + array[item++] = new TestCase( SECTION, "\\b", String.fromCharCode(0x0008), "\b" ); + array[item++] = new TestCase( SECTION, "\\f", String.fromCharCode(0x000C), "\f" ); + array[item++] = new TestCase( SECTION, "\\n", String.fromCharCode(0x000A), "\n" ); + array[item++] = new TestCase( SECTION, "\\r", String.fromCharCode(0x000D), "\r" ); + array[item++] = new TestCase( SECTION, "\\t", String.fromCharCode(0x0009), "\t" ); + array[item++] = new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" ); + + // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence + + array[item++] = new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" ); + array[item++] = new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" ); + array[item++] = new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" ); + array[item++] = new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" ); + array[item++] = new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" ); + array[item++] = new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" ); + array[item++] = new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" ); + array[item++] = new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" ); + + array[item++] = new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" ); + array[item++] = new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" ); + array[item++] = new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" ); + array[item++] = new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" ); + array[item++] = new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" ); + array[item++] = new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" ); + array[item++] = new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" ); + array[item++] = new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" ); + array[item++] = new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" ); + array[item++] = new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" ); + + array[item++] = new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" ); + array[item++] = new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" ); + array[item++] = new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" ); + array[item++] = new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" ); + array[item++] = new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" ); + array[item++] = new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" ); + array[item++] = new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" ); + array[item++] = new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" ); + + array[item++] = new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" ); + array[item++] = new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" ); + array[item++] = new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" ); + array[item++] = new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" ); + array[item++] = new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" ); + array[item++] = new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" ); + array[item++] = new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" ); + array[item++] = new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" ); + array[item++] = new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" ); + array[item++] = new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" ); + + array[item++] = new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" ); + array[item++] = new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" ); + array[item++] = new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" ); + array[item++] = new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" ); + +// following line commented out as it causes a compile time error +// array[item++] = new TestCase( SECTION, "\\444", "444", "\444" ); + + // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence +/* + array[item++] = new TestCase( SECTION, "\\x0", String.fromCharCode(0), "\x0" ); + array[item++] = new TestCase( SECTION, "\\x1", String.fromCharCode(1), "\x1" ); + array[item++] = new TestCase( SECTION, "\\x2", String.fromCharCode(2), "\x2" ); + array[item++] = new TestCase( SECTION, "\\x3", String.fromCharCode(3), "\x3" ); + array[item++] = new TestCase( SECTION, "\\x4", String.fromCharCode(4), "\x4" ); + array[item++] = new TestCase( SECTION, "\\x5", String.fromCharCode(5), "\x5" ); + array[item++] = new TestCase( SECTION, "\\x6", String.fromCharCode(6), "\x6" ); + array[item++] = new TestCase( SECTION, "\\x7", String.fromCharCode(7), "\x7" ); + array[item++] = new TestCase( SECTION, "\\x8", String.fromCharCode(8), "\x8" ); + array[item++] = new TestCase( SECTION, "\\x9", String.fromCharCode(9), "\x9" ); + array[item++] = new TestCase( SECTION, "\\xA", String.fromCharCode(10), "\xA" ); + array[item++] = new TestCase( SECTION, "\\xB", String.fromCharCode(11), "\xB" ); + array[item++] = new TestCase( SECTION, "\\xC", String.fromCharCode(12), "\xC" ); + array[item++] = new TestCase( SECTION, "\\xD", String.fromCharCode(13), "\xD" ); + array[item++] = new TestCase( SECTION, "\\xE", String.fromCharCode(14), "\xE" ); + array[item++] = new TestCase( SECTION, "\\xF", String.fromCharCode(15), "\xF" ); + +*/ + array[item++] = new TestCase( SECTION, "\\xF0", String.fromCharCode(240), "\xF0" ); + array[item++] = new TestCase( SECTION, "\\xE1", String.fromCharCode(225), "\xE1" ); + array[item++] = new TestCase( SECTION, "\\xD2", String.fromCharCode(210), "\xD2" ); + array[item++] = new TestCase( SECTION, "\\xC3", String.fromCharCode(195), "\xC3" ); + array[item++] = new TestCase( SECTION, "\\xB4", String.fromCharCode(180), "\xB4" ); + array[item++] = new TestCase( SECTION, "\\xA5", String.fromCharCode(165), "\xA5" ); + array[item++] = new TestCase( SECTION, "\\x96", String.fromCharCode(150), "\x96" ); + array[item++] = new TestCase( SECTION, "\\x87", String.fromCharCode(135), "\x87" ); + array[item++] = new TestCase( SECTION, "\\x78", String.fromCharCode(120), "\x78" ); + array[item++] = new TestCase( SECTION, "\\x69", String.fromCharCode(105), "\x69" ); + array[item++] = new TestCase( SECTION, "\\x5A", String.fromCharCode(90), "\x5A" ); + array[item++] = new TestCase( SECTION, "\\x4B", String.fromCharCode(75), "\x4B" ); + array[item++] = new TestCase( SECTION, "\\x3C", String.fromCharCode(60), "\x3C" ); + array[item++] = new TestCase( SECTION, "\\x2D", String.fromCharCode(45), "\x2D" ); + array[item++] = new TestCase( SECTION, "\\x1E", String.fromCharCode(30), "\x1E" ); + array[item++] = new TestCase( SECTION, "\\x0F", String.fromCharCode(15), "\x0F" ); + + // string literals only take up to two hext digits. therefore, the third character in this string + // should be interpreted as a StringCharacter and not part of the HextEscapeSequence + + array[item++] = new TestCase( SECTION, "\\xF0F", String.fromCharCode(240)+"F", "\xF0F" ); + array[item++] = new TestCase( SECTION, "\\xE1E", String.fromCharCode(225)+"E", "\xE1E" ); + array[item++] = new TestCase( SECTION, "\\xD2D", String.fromCharCode(210)+"D", "\xD2D" ); + array[item++] = new TestCase( SECTION, "\\xC3C", String.fromCharCode(195)+"C", "\xC3C" ); + array[item++] = new TestCase( SECTION, "\\xB4B", String.fromCharCode(180)+"B", "\xB4B" ); + array[item++] = new TestCase( SECTION, "\\xA5A", String.fromCharCode(165)+"A", "\xA5A" ); + array[item++] = new TestCase( SECTION, "\\x969", String.fromCharCode(150)+"9", "\x969" ); + array[item++] = new TestCase( SECTION, "\\x878", String.fromCharCode(135)+"8", "\x878" ); + array[item++] = new TestCase( SECTION, "\\x787", String.fromCharCode(120)+"7", "\x787" ); + array[item++] = new TestCase( SECTION, "\\x696", String.fromCharCode(105)+"6", "\x696" ); + array[item++] = new TestCase( SECTION, "\\x5A5", String.fromCharCode(90)+"5", "\x5A5" ); + array[item++] = new TestCase( SECTION, "\\x4B4", String.fromCharCode(75)+"4", "\x4B4" ); + array[item++] = new TestCase( SECTION, "\\x3C3", String.fromCharCode(60)+"3", "\x3C3" ); + array[item++] = new TestCase( SECTION, "\\x2D2", String.fromCharCode(45)+"2", "\x2D2" ); + array[item++] = new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E1" ); + array[item++] = new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" ); + + // G is out of hex range + + array[item++] = new TestCase( SECTION, "\\xG", "xG", "\xG" ); + array[item++] = new TestCase( SECTION, "\\xCG", "xCG", "\xCG" ); + + // DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter + array[item++] = new TestCase( SECTION, "\\a", "a", "\a" ); + array[item++] = new TestCase( SECTION, "\\c", "c", "\c" ); + array[item++] = new TestCase( SECTION, "\\d", "d", "\d" ); + array[item++] = new TestCase( SECTION, "\\e", "e", "\e" ); + array[item++] = new TestCase( SECTION, "\\g", "g", "\g" ); + array[item++] = new TestCase( SECTION, "\\h", "h", "\h" ); + array[item++] = new TestCase( SECTION, "\\i", "i", "\i" ); + array[item++] = new TestCase( SECTION, "\\j", "j", "\j" ); + array[item++] = new TestCase( SECTION, "\\k", "k", "\k" ); + array[item++] = new TestCase( SECTION, "\\l", "l", "\l" ); + array[item++] = new TestCase( SECTION, "\\m", "m", "\m" ); + array[item++] = new TestCase( SECTION, "\\o", "o", "\o" ); + array[item++] = new TestCase( SECTION, "\\p", "p", "\p" ); + array[item++] = new TestCase( SECTION, "\\q", "q", "\q" ); + array[item++] = new TestCase( SECTION, "\\s", "s", "\s" ); + array[item++] = new TestCase( SECTION, "\\u", "u", "\u" ); + + array[item++] = new TestCase( SECTION, "\\w", "w", "\w" ); + array[item++] = new TestCase( SECTION, "\\x", "x", "\x" ); + array[item++] = new TestCase( SECTION, "\\y", "y", "\y" ); + array[item++] = new TestCase( SECTION, "\\z", "z", "\z" ); + array[item++] = new TestCase( SECTION, "\\9", "9", "\9" ); + + array[item++] = new TestCase( SECTION, "\\A", "A", "\A" ); + array[item++] = new TestCase( SECTION, "\\B", "B", "\B" ); + array[item++] = new TestCase( SECTION, "\\C", "C", "\C" ); + array[item++] = new TestCase( SECTION, "\\D", "D", "\D" ); + array[item++] = new TestCase( SECTION, "\\E", "E", "\E" ); + array[item++] = new TestCase( SECTION, "\\F", "F", "\F" ); + array[item++] = new TestCase( SECTION, "\\G", "G", "\G" ); + array[item++] = new TestCase( SECTION, "\\H", "H", "\H" ); + array[item++] = new TestCase( SECTION, "\\I", "I", "\I" ); + array[item++] = new TestCase( SECTION, "\\J", "J", "\J" ); + array[item++] = new TestCase( SECTION, "\\K", "K", "\K" ); + array[item++] = new TestCase( SECTION, "\\L", "L", "\L" ); + array[item++] = new TestCase( SECTION, "\\M", "M", "\M" ); + array[item++] = new TestCase( SECTION, "\\N", "N", "\N" ); + array[item++] = new TestCase( SECTION, "\\O", "O", "\O" ); + array[item++] = new TestCase( SECTION, "\\P", "P", "\P" ); + array[item++] = new TestCase( SECTION, "\\Q", "Q", "\Q" ); + array[item++] = new TestCase( SECTION, "\\R", "R", "\R" ); + array[item++] = new TestCase( SECTION, "\\S", "S", "\S" ); + array[item++] = new TestCase( SECTION, "\\T", "T", "\T" ); + array[item++] = new TestCase( SECTION, "\\U", "U", "\U" ); + array[item++] = new TestCase( SECTION, "\\V", "V", "\V" ); + array[item++] = new TestCase( SECTION, "\\W", "W", "\W" ); + array[item++] = new TestCase( SECTION, "\\X", "X", "\X" ); + array[item++] = new TestCase( SECTION, "\\Y", "Y", "\Y" ); + array[item++] = new TestCase( SECTION, "\\Z", "Z", "\Z" ); + + // DoubleStringCharacter::EscapeSequence::UnicodeEscapeSequence + + array[item++] = new TestCase( SECTION, "\\u0020", " ", "\u0020" ); + array[item++] = new TestCase( SECTION, "\\u0021", "!", "\u0021" ); + array[item++] = new TestCase( SECTION, "\\u0022", "\"", "\u0022" ); + array[item++] = new TestCase( SECTION, "\\u0023", "#", "\u0023" ); + array[item++] = new TestCase( SECTION, "\\u0024", "$", "\u0024" ); + array[item++] = new TestCase( SECTION, "\\u0025", "%", "\u0025" ); + array[item++] = new TestCase( SECTION, "\\u0026", "&", "\u0026" ); + array[item++] = new TestCase( SECTION, "\\u0027", "'", "\u0027" ); + array[item++] = new TestCase( SECTION, "\\u0028", "(", "\u0028" ); + array[item++] = new TestCase( SECTION, "\\u0029", ")", "\u0029" ); + array[item++] = new TestCase( SECTION, "\\u002A", "*", "\u002A" ); + array[item++] = new TestCase( SECTION, "\\u002B", "+", "\u002B" ); + array[item++] = new TestCase( SECTION, "\\u002C", ",", "\u002C" ); + array[item++] = new TestCase( SECTION, "\\u002D", "-", "\u002D" ); + array[item++] = new TestCase( SECTION, "\\u002E", ".", "\u002E" ); + array[item++] = new TestCase( SECTION, "\\u002F", "/", "\u002F" ); + array[item++] = new TestCase( SECTION, "\\u0030", "0", "\u0030" ); + array[item++] = new TestCase( SECTION, "\\u0031", "1", "\u0031" ); + array[item++] = new TestCase( SECTION, "\\u0032", "2", "\u0032" ); + array[item++] = new TestCase( SECTION, "\\u0033", "3", "\u0033" ); + array[item++] = new TestCase( SECTION, "\\u0034", "4", "\u0034" ); + array[item++] = new TestCase( SECTION, "\\u0035", "5", "\u0035" ); + array[item++] = new TestCase( SECTION, "\\u0036", "6", "\u0036" ); + array[item++] = new TestCase( SECTION, "\\u0037", "7", "\u0037" ); + array[item++] = new TestCase( SECTION, "\\u0038", "8", "\u0038" ); + array[item++] = new TestCase( SECTION, "\\u0039", "9", "\u0039" ); + + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = 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/LexicalConventions/7.8.2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.8.2-n.js new file mode 100644 index 0000000..82bd7c4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/LexicalConventions/7.8.2-n.js @@ -0,0 +1,48 @@ +/* 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: 7.8.2.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION="7.8.2"; + var VERSION="ECMA_1" + startTest(); + writeHeaderToLog(SECTION+" "+"Examples of Semicolon Insertion"); + + testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase( "7.8.2", "{ 1 \n 2 } 3", 3, "{ 1 \n 2 } 3" ); + array[item++] = new TestCase( "7.8.2", "{ 1 2 } 3", "error", eval("{1 2 } 3") ); + + return ( array ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-1.js new file mode 100644 index 0000000..8b08eb6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-1.js @@ -0,0 +1,84 @@ +/* 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.8-1.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + + var SECTION = "15.8-1"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "The Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "Math.__proto__ == Object.prototype", + true, + Math.__proto__ == Object.prototype ); + + array[item++] = new TestCase( SECTION, + "Math.__proto__", + Object.prototype, + Math.__proto__ ); + 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/Math/15.8-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-2-n.js new file mode 100644 index 0000000..2bf41c0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-2-n.js @@ -0,0 +1,83 @@ +/* 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.8-2.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + + var SECTION = "15.8-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "MYMATH = new Math()", + "error", + "MYMATH = new Math()" ); + + return ( array ); +} +function test() { + 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 += "Math does not have the [Construct] property"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-3-n.js new file mode 100644 index 0000000..4896f48 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8-3-n.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.8-3.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.8-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "MYMATH = Math()", + "error", + "MYMATH = Math()" ); + + return ( array ); +} +function test() { + 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 += "Math does not have the [Call] property"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.1-1.js new file mode 100644 index 0000000..f22fdca --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.1-1.js @@ -0,0 +1,62 @@ +/* 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.8.1.1-1.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.E = 0; Math.E", 2.7182818284590452354, ("Math.E=0;Math.E") ); + return ( array ); +} +function test() { + 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 ) ? "" : "Math.E should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.1-2.js new file mode 100644 index 0000000..2aea4ff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.1-2.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.8.1.1-2.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MATH_E = 2.7182818284590452354 + array[item++] = new TestCase( SECTION, "delete(Math.E)", false, "delete Math.E" ); + array[item++] = new TestCase( SECTION, "delete(Math.E); Math.E", MATH_E, "delete Math.E; Math.E" ); + return ( array ); +} +function test() { + 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 ) ? "" : "should not be able to delete property"; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.2-1.js new file mode 100644 index 0000000..a9d8c0d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.2-1.js @@ -0,0 +1,62 @@ +/* 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.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN10"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.LN10=0; Math.LN10", 2.302585092994046, "Math.LN10=0; Math.LN10" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.2-2.js new file mode 100644 index 0000000..2774177 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.2-2.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.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN10"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete( Math.LN10 ); Math.LN10", 2.302585092994046, "delete(Math.LN10); Math.LN10" ); + array[item++] = new TestCase( SECTION, "delete( Math.LN10 ); ", false, "delete(Math.LN10)" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.3-1.js new file mode 100644 index 0000000..d8354ad --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.3-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.8.1.3-1.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.LN2=0; Math.LN2", 0.6931471805599453, ("Math.LN2=0; Math.LN2") ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.3-2.js new file mode 100644 index 0000000..a26ef79 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.3-2.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.8.1.3-3.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MATH_LN2 = 0.6931471805599453; + + array[item++] = new TestCase( SECTION, "delete(Math.LN2)", false, "delete(Math.LN2)" ); + array[item++] = new TestCase( SECTION, "delete(Math.LN2); Math.LN2", MATH_LN2, "delete(Math.LN2); Math.LN2" ); + + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.4-1.js new file mode 100644 index 0000000..82e2fea --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.4-1.js @@ -0,0 +1,64 @@ +/* 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.8.1.4-1.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG2E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.L0G2E=0; Math.LOG2E", 1.4426950408889634, ("Math.LOG2E=0; Math.LOG2E") ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.4-2.js new file mode 100644 index 0000000..9208b46 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.4-2.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.8.1.4-2.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG2E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete(Math.L0G2E);Math.LOG2E", 1.4426950408889634, "delete(Math.LOG2E);Math.LOG2E" ); + array[item++] = new TestCase( SECTION, "delete(Math.L0G2E)", false, "delete(Math.LOG2E)" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.5-1.js new file mode 100644 index 0000000..1ad5000 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.5-1.js @@ -0,0 +1,67 @@ +/* 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.8.1.5-1.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.8.1.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG10E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.LOG10E=0; Math.LOG10E", 0.4342944819032518, ("Math.LOG10E=0; Math.LOG10E") ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.5-2.js new file mode 100644 index 0000000..7b204e7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.5-2.js @@ -0,0 +1,66 @@ +/* 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.8.1.5-2.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG10E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.LOG10E; Math.LOG10E", 0.4342944819032518, "delete Math.LOG10E; Math.LOG10E" ); + array[item++] = new TestCase( SECTION, "delete Math.LOG10E", false, "delete Math.LOG10E" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.6-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.6-1.js new file mode 100644 index 0000000..4a998cc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.6-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.8.1.6-1.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.PI"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.PI=0; Math.PI", 3.1415926535897923846, "Math.PI=0; Math.PI" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.6-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.6-2.js new file mode 100644 index 0000000..3a0fb1f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.6-2.js @@ -0,0 +1,64 @@ +/* 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.8.1.6-2.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.6-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.PI"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.PI; Math.PI", 3.1415926535897923846, "delete Math.PI; Math.PI" ); + array[item++] = new TestCase( SECTION, "delete Math.PI; Math.PI", false, "delete Math.PI" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.7-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.7-1.js new file mode 100644 index 0000000..9eeb6d7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.7-1.js @@ -0,0 +1,64 @@ +/* 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.8.1.7-1.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.7-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT1_2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.SQRT1_2=0; Math.SQRT1_2", 0.7071067811865476, "Math.SQRT1_2=0; Math.SQRT1_2" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.7-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.7-2.js new file mode 100644 index 0000000..85dd054 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.7-2.js @@ -0,0 +1,64 @@ +/* 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.8.1.7-2.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.7-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT1_2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.SQRT1_2; Math.SQRT1_2", 0.7071067811865476, "delete Math.SQRT1_2; Math.SQRT1_2" ); + array[item++] = new TestCase( SECTION, "delete Math.SQRT1_2", false, "delete Math.SQRT1_2" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-1.js new file mode 100644 index 0000000..1b3615d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-1.js @@ -0,0 +1,64 @@ +/* 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.8.1.8-1.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.8-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.SQRT2=0; Math.SQRT2", 1.4142135623730951, ("Math.SQRT2=0; Math.SQRT2") ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-2.js new file mode 100644 index 0000000..25634dd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-2.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.8.1.8-2.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.SQRT2; Math.SQRT2", 1.4142135623730951, "delete Math.SQRT2; Math.SQRT2" ); + array[item++] = new TestCase( SECTION, "delete Math.SQRT2", false, "delete Math.SQRT2" ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-3.js new file mode 100644 index 0000000..d1df188 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.8-3.js @@ -0,0 +1,61 @@ +/* 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.8.1.8-3.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.8-3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Math.SQRT2: DontDelete"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.SQRT2", false, ("delete Math.SQRT2") ); + return ( array ); +} +function test() { + 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 ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.js new file mode 100644 index 0000000..a0fdf26 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.1.js @@ -0,0 +1,86 @@ +/* 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.8.1.js + ECMA Section: 15.8.1.js Value Properties of the Math Object + 15.8.1.1 E + 15.8.1.2 LN10 + 15.8.1.3 LN2 + 15.8.1.4 LOG2E + 15.8.1.5 LOG10E + 15.8.1.6 PI + 15.8.1.7 SQRT1_2 + 15.8.1.8 SQRT2 + Description: verify the values of some math constants + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.1" + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Value Properties of the Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "15.8.1.1", "Math.E", 2.7182818284590452354, Math.E ); + array[item++] = new TestCase( "15.8.1.1", "typeof Math.E", "number", typeof Math.E ); + array[item++] = new TestCase( "15.8.1.2", "Math.LN10", 2.302585092994046, Math.LN10 ); + array[item++] = new TestCase( "15.8.1.2", "typeof Math.LN10", "number", typeof Math.LN10 ); + array[item++] = new TestCase( "15.8.1.3", "Math.LN2", 0.6931471805599453, Math.LN2 ); + array[item++] = new TestCase( "15.8.1.3", "typeof Math.LN2", "number", typeof Math.LN2 ); + array[item++] = new TestCase( "15.8.1.4", "Math.LOG2E", 1.4426950408889634, Math.LOG2E ); + array[item++] = new TestCase( "15.8.1.4", "typeof Math.LOG2E", "number", typeof Math.LOG2E ); + array[item++] = new TestCase( "15.8.1.5", "Math.LOG10E", 0.4342944819032518, Math.LOG10E); + array[item++] = new TestCase( "15.8.1.5", "typeof Math.LOG10E", "number", typeof Math.LOG10E); + array[item++] = new TestCase( "15.8.1.6", "Math.PI", 3.14159265358979323846, Math.PI ); + array[item++] = new TestCase( "15.8.1.6", "typeof Math.PI", "number", typeof Math.PI ); + array[item++] = new TestCase( "15.8.1.7", "Math.SQRT1_2", 0.7071067811865476, Math.SQRT1_2); + array[item++] = new TestCase( "15.8.1.7", "typeof Math.SQRT1_2", "number", typeof Math.SQRT1_2); + array[item++] = new TestCase( "15.8.1.8", "Math.SQRT2", 1.4142135623730951, Math.SQRT2 ); + array[item++] = new TestCase( "15.8.1.8", "typeof Math.SQRT2", "number", typeof Math.SQRT2 ); + + array[item++] = new TestCase( SECTION, "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", + "", + eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); + + return ( array ); +} + +function test() { + for ( i = 0; i < testcases.length; i++ ) { + testcases[i].passed = writeTestCaseResult( + testcases[i].expect, + testcases[i].actual, + testcases[i].description +" = "+ testcases[i].actual ); + testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.1.js new file mode 100644 index 0000000..4f0ba21 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.1.js @@ -0,0 +1,103 @@ +/* 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.8.2.1.js + ECMA Section: 15.8.2.1 abs( x ) + Description: return the absolute value of the argument, + which should be the magnitude of the argument + with a positive sign. + - if x is NaN, return NaN + - if x is -0, result is +0 + - if x is -Infinity, result is +Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + var SECTION = "15.8.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.abs()"; + var BUGNUMBER = "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.abs.length", 1, Math.abs.length ); + + array[item++] = new TestCase( SECTION, "Math.abs()", Number.NaN, Math.abs() ); + array[item++] = new TestCase( SECTION, "Math.abs( void 0 )", Number.NaN, Math.abs(void 0) ); + array[item++] = new TestCase( SECTION, "Math.abs( null )", 0, Math.abs(null) ); + array[item++] = new TestCase( SECTION, "Math.abs( true )", 1, Math.abs(true) ); + array[item++] = new TestCase( SECTION, "Math.abs( false )", 0, Math.abs(false) ); + array[item++] = new TestCase( SECTION, "Math.abs( string primitive)", Number.NaN, Math.abs("a string primitive") ); + array[item++] = new TestCase( SECTION, "Math.abs( string object )", Number.NaN, Math.abs(new String( 'a String object' )) ); + array[item++] = new TestCase( SECTION, "Math.abs( Number.NaN )", Number.NaN, Math.abs(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.abs(0)", 0, Math.abs( 0 ) ); + array[item++] = new TestCase( SECTION, "Math.abs( -0 )", 0, Math.abs(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.abs(-0)", Infinity, Infinity/Math.abs(-0) ); + + array[item++] = new TestCase( SECTION, "Math.abs( -Infinity )", Number.POSITIVE_INFINITY, Math.abs( Number.NEGATIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "Math.abs( Infinity )", Number.POSITIVE_INFINITY, Math.abs( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "Math.abs( - MAX_VALUE )", Number.MAX_VALUE, Math.abs( - Number.MAX_VALUE ) ); + array[item++] = new TestCase( SECTION, "Math.abs( - MIN_VALUE )", Number.MIN_VALUE, Math.abs( -Number.MIN_VALUE ) ); + array[item++] = new TestCase( SECTION, "Math.abs( MAX_VALUE )", Number.MAX_VALUE, Math.abs( Number.MAX_VALUE ) ); + array[item++] = new TestCase( SECTION, "Math.abs( MIN_VALUE )", Number.MIN_VALUE, Math.abs( Number.MIN_VALUE ) ); + + array[item++] = new TestCase( SECTION, "Math.abs( -1 )", 1, Math.abs( -1 ) ); + array[item++] = new TestCase( SECTION, "Math.abs( new Number( -1 ) )", 1, Math.abs( new Number(-1) ) ); + array[item++] = new TestCase( SECTION, "Math.abs( 1 )", 1, Math.abs( 1 ) ); + array[item++] = new TestCase( SECTION, "Math.abs( Math.PI )", Math.PI, Math.abs( Math.PI ) ); + array[item++] = new TestCase( SECTION, "Math.abs( -Math.PI )", Math.PI, Math.abs( -Math.PI ) ); + array[item++] = new TestCase( SECTION, "Math.abs(-1/100000000)", 1/100000000, Math.abs(-1/100000000) ); + array[item++] = new TestCase( SECTION, "Math.abs(-Math.pow(2,32))", Math.pow(2,32), Math.abs(-Math.pow(2,32)) ); + array[item++] = new TestCase( SECTION, "Math.abs(Math.pow(2,32))", Math.pow(2,32), Math.abs(Math.pow(2,32)) ); + array[item++] = new TestCase( SECTION, "Math.abs( -0xfff )", 4095, Math.abs( -0xfff ) ); + array[item++] = new TestCase( SECTION, "Math.abs( -0777 )", 511, Math.abs(-0777 ) ); + + array[item++] = new TestCase( SECTION, "Math.abs('-1e-1')", 0.1, Math.abs('-1e-1') ); + array[item++] = new TestCase( SECTION, "Math.abs('0xff')", 255, Math.abs('0xff') ); + array[item++] = new TestCase( SECTION, "Math.abs('077')", 77, Math.abs('077') ); + array[item++] = new TestCase( SECTION, "Math.abs( 'Infinity' )", Infinity, Math.abs('Infinity') ); + array[item++] = new TestCase( SECTION, "Math.abs( '-Infinity' )", Infinity, Math.abs('-Infinity') ); + + 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/Math/15.8.2.10.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.10.js new file mode 100644 index 0000000..24b6cb8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.10.js @@ -0,0 +1,86 @@ +/* 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.8.2.10.js + ECMA Section: 15.8.2.10 Math.log(x) + Description: return an approximiation to the natural logarithm of + the argument. + special cases: + - if arg is NaN result is NaN + - if arg is <0 result is NaN + - if arg is 0 or -0 result is -Infinity + - if arg is 1 result is 0 + - if arg is Infinity result is Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.log(x)"; + var BUGNUMBER = "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.log.length", 1, Math.log.length ); + + array[item++] = new TestCase( SECTION, "Math.log()", Number.NaN, Math.log() ); + array[item++] = new TestCase( SECTION, "Math.log(void 0)", Number.NaN, Math.log(void 0) ); + array[item++] = new TestCase( SECTION, "Math.log(null)", Number.NEGATIVE_INFINITY, Math.log(null) ); + array[item++] = new TestCase( SECTION, "Math.log(true)", 0, Math.log(true) ); + array[item++] = new TestCase( SECTION, "Math.log(false)", -Infinity, Math.log(false) ); + array[item++] = new TestCase( SECTION, "Math.log('0')", -Infinity, Math.log('0') ); + array[item++] = new TestCase( SECTION, "Math.log('1')", 0, Math.log('1') ); + array[item++] = new TestCase( SECTION, "Math.log('Infinity')", Infinity, Math.log("Infinity") ); + + array[item++] = new TestCase( SECTION, "Math.log(NaN)", Number.NaN, Math.log(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.log(-0.0000001)", Number.NaN, Math.log(-0.000001) ); + array[item++] = new TestCase( SECTION, "Math.log(-1)", Number.NaN, Math.log(-1) ); + array[item++] = new TestCase( SECTION, "Math.log(0)", Number.NEGATIVE_INFINITY, Math.log(0) ); + array[item++] = new TestCase( SECTION, "Math.log(-0)", Number.NEGATIVE_INFINITY, Math.log(-0)); + array[item++] = new TestCase( SECTION, "Math.log(1)", 0, Math.log(1) ); + array[item++] = new TestCase( SECTION, "Math.log(Infinity)", Number.POSITIVE_INFINITY, Math.log(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.log(-Infinity)", Number.NaN, Math.log(Number.NEGATIVE_INFINITY) ); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.11.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.11.js new file mode 100644 index 0000000..4be499c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.11.js @@ -0,0 +1,98 @@ +/* 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.8.2.11.js + ECMA Section: 15.8.2.11 Math.max(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.max(x, y)"; + var BUGNUMBER="76439"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.max.length", 2, Math.max.length ); + + array[item++] = new TestCase( SECTION, "Math.max()", -Infinity, Math.max() ); + array[item++] = new TestCase( SECTION, "Math.max(void 0, 1)", Number.NaN, Math.max( void 0, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.max(void 0, void 0)", Number.NaN, Math.max( void 0, void 0 ) ); + array[item++] = new TestCase( SECTION, "Math.max(null, 1)", 1, Math.max( null, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.max(-1, null)", 0, Math.max( -1, null ) ); + array[item++] = new TestCase( SECTION, "Math.max(true, false)", 1, Math.max(true,false) ); + + array[item++] = new TestCase( SECTION, "Math.max('-99','99')", 99, Math.max( "-99","99") ); + + array[item++] = new TestCase( SECTION, "Math.max(NaN, Infinity)", Number.NaN, Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(NaN, 0)", Number.NaN, Math.max(Number.NaN, 0) ); + array[item++] = new TestCase( SECTION, "Math.max('a string', 0)", Number.NaN, Math.max("a string", 0) ); + array[item++] = new TestCase( SECTION, "Math.max(NaN, 1)", Number.NaN, Math.max(Number.NaN,1) ); + array[item++] = new TestCase( SECTION, "Math.max('a string',Infinity)", Number.NaN, Math.max("a string", Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(Infinity, NaN)", Number.NaN, Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(NaN, NaN)", Number.NaN, Math.max(Number.NaN, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(0,NaN)", Number.NaN, Math.max(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(1, NaN)", Number.NaN, Math.max(1, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(0,0)", 0, Math.max(0,0) ); + array[item++] = new TestCase( SECTION, "Math.max(0,-0)", 0, Math.max(0,-0) ); + array[item++] = new TestCase( SECTION, "Math.max(-0,0)", 0, Math.max(-0,0) ); + array[item++] = new TestCase( SECTION, "Math.max(-0,-0)", -0, Math.max(-0,-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.max(-0,-0)", -Infinity, Infinity/Math.max(-0,-0) ); + array[item++] = new TestCase( SECTION, "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "Math.max(Infinity, Infinity)", Number.POSITIVE_INFINITY, Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(-Infinity,-Infinity)", Number.NEGATIVE_INFINITY, Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(1,.99999999999999)", 1, Math.max(1,.99999999999999) ); + array[item++] = new TestCase( SECTION, "Math.max(-1,-.99999999999999)", -.99999999999999, Math.max(-1,-.99999999999999) ); + + 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/Math/15.8.2.12.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.12.js new file mode 100644 index 0000000..0706e0b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.12.js @@ -0,0 +1,96 @@ +/* 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.8.2.12.js + ECMA Section: 15.8.2.12 Math.min(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + + var SECTION = "15.8.2.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.min(x, y)"; + var BUGNUMBER="76439"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.min.length", 2, Math.min.length ); + + array[item++] = new TestCase( SECTION, "Math.min()", Infinity, Math.min() ); + array[item++] = new TestCase( SECTION, "Math.min(void 0, 1)", Number.NaN, Math.min( void 0, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.min(void 0, void 0)", Number.NaN, Math.min( void 0, void 0 ) ); + array[item++] = new TestCase( SECTION, "Math.min(null, 1)", 0, Math.min( null, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.min(-1, null)", -1, Math.min( -1, null ) ); + array[item++] = new TestCase( SECTION, "Math.min(true, false)", 0, Math.min(true,false) ); + + array[item++] = new TestCase( SECTION, "Math.min('-99','99')", -99, Math.min( "-99","99") ); + + array[item++] = new TestCase( SECTION, "Math.min(NaN,0)", Number.NaN, Math.min(Number.NaN,0) ); + array[item++] = new TestCase( SECTION, "Math.min(NaN,1)", Number.NaN, Math.min(Number.NaN,1) ); + array[item++] = new TestCase( SECTION, "Math.min(NaN,-1)", Number.NaN, Math.min(Number.NaN,-1) ); + array[item++] = new TestCase( SECTION, "Math.min(0,NaN)", Number.NaN, Math.min(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(1,NaN)", Number.NaN, Math.min(1,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(-1,NaN)", Number.NaN, Math.min(-1,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(NaN,NaN)", Number.NaN, Math.min(Number.NaN,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(1,1.0000000001)", 1, Math.min(1,1.0000000001) ); + array[item++] = new TestCase( SECTION, "Math.min(1.0000000001,1)", 1, Math.min(1.0000000001,1) ); + array[item++] = new TestCase( SECTION, "Math.min(0,0)", 0, Math.min(0,0) ); + array[item++] = new TestCase( SECTION, "Math.min(0,-0)", -0, Math.min(0,-0) ); + array[item++] = new TestCase( SECTION, "Math.min(-0,-0)", -0, Math.min(-0,-0) ); + + array[item++] = new TestCase( SECTION, "Infinity/Math.min(0,-0)", -Infinity, Infinity/Math.min(0,-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.min(-0,-0)", -Infinity, Infinity/Math.min(-0,-0) ); + + + 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/Math/15.8.2.13.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.13.js new file mode 100644 index 0000000..4744eb0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.13.js @@ -0,0 +1,132 @@ +/* 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.8.2.13.js + ECMA Section: 15.8.2.13 Math.pow(x, y) + Description: return an approximation to the result of x + to the power of y. there are many special cases; + refer to the spec. + Author: christine@netscape.com + Date: 9 july 1997 +*/ + + var SECTION = "15.8.2.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.pow(x, y)"; + var BUGNUMBER="77141"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.pow.length", 2, Math.pow.length ); + + array[item++] = new TestCase( SECTION, "Math.pow()", Number.NaN, Math.pow() ); + array[item++] = new TestCase( SECTION, "Math.pow(null, null)", 1, Math.pow(null,null) ); + array[item++] = new TestCase( SECTION, "Math.pow(void 0, void 0)", Number.NaN, Math.pow(void 0, void 0)); + array[item++] = new TestCase( SECTION, "Math.pow(true, false)", 1, Math.pow(true, false) ); + array[item++] = new TestCase( SECTION, "Math.pow(false,true)", 0, Math.pow(false,true) ); + array[item++] = new TestCase( SECTION, "Math.pow('2','32')", 4294967296, Math.pow('2','32') ); + + array[item++] = new TestCase( SECTION, "Math.pow(1,NaN)", Number.NaN, Math.pow(1,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.pow(0,NaN)", Number.NaN, Math.pow(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,0)", 1, Math.pow(Number.NaN,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,-0)", 1, Math.pow(Number.NaN,-0) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,1)", Number.NaN, Math.pow(Number.NaN, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,.5)", Number.NaN, Math.pow(Number.NaN, .5) ); + array[item++] = new TestCase( SECTION, "Math.pow(1.00000001, Infinity)", Number.POSITIVE_INFINITY, Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(1.00000001, -Infinity)", 0, Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1.00000001, Infinity)", Number.POSITIVE_INFINITY, Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1.00000001, -Infinity)", 0, Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(1, Infinity)", Number.NaN, Math.pow(1, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(1, -Infinity)", Number.NaN, Math.pow(1, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, Infinity)", Number.NaN, Math.pow(-1, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, -Infinity)", Number.NaN, Math.pow(-1, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(.0000000009, Infinity)", 0, Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-.0000000009, Infinity)", 0, Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(.0000000009, -Infinity)", Number.POSITIVE_INFINITY, Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, .00000000001)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, 1)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, -.00000000001)",0, Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, -1)", 0, Math.pow(Number.POSITIVE_INFINITY, -1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 1)", Number.NEGATIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 333)", Number.NEGATIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 333) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, 2)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY, 2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 666)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 666) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 0.5)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, Infinity)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -1)", -0, Math.pow(Number.NEGATIVE_INFINITY, -1) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-Infinity, -1)", -Infinity, Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); + + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -3)", -0, Math.pow(Number.NEGATIVE_INFINITY, -3) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -2)", 0, Math.pow(Number.NEGATIVE_INFINITY, -2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -0.5)", 0, Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -Infinity)", 0, Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 1)", 0, Math.pow(0,1) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 0)", 1, Math.pow(0,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(1, 0)", 1, Math.pow(1,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, 0)", 1, Math.pow(-1,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 0.5)", 0, Math.pow(0,0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 1000)", 0, Math.pow(0,1000) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, Infinity)", 0, Math.pow(0, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -1)", Number.POSITIVE_INFINITY, Math.pow(0, -1) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -0.5)", Number.POSITIVE_INFINITY, Math.pow(0, -0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -1000)", Number.POSITIVE_INFINITY, Math.pow(0, -1000) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -Infinity)", Number.POSITIVE_INFINITY, Math.pow(0, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, 1)", -0, Math.pow(-0, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, 3)", -0, Math.pow(-0,3) ); + + array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-0, 1)", -Infinity, Infinity/Math.pow(-0, 1) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-0, 3)", -Infinity, Infinity/Math.pow(-0,3) ); + + array[item++] = new TestCase( SECTION, "Math.pow(-0, 2)", 0, Math.pow(-0,2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, Infinity)", 0, Math.pow(-0, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, -1)", Number.NEGATIVE_INFINITY, Math.pow(-0, -1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, -10001)", Number.NEGATIVE_INFINITY, Math.pow(-0, -10001) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, -2)", Number.POSITIVE_INFINITY, Math.pow(-0, -2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, 0.5)", 0, Math.pow(-0, 0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, Infinity)", 0, Math.pow(-0, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, 0.5)", Number.NaN, Math.pow(-1, 0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, NaN)", Number.NaN, Math.pow(-1, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, -0.5)", Number.NaN, Math.pow(-1, -0.5) ); + + 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/Math/15.8.2.14.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.14.js new file mode 100644 index 0000000..e5ed1fb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.14.js @@ -0,0 +1,83 @@ +/* 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.8.2.14.js + ECMA Section: 15.8.2.14 Math.random() + returns a number value x with a positive sign + with 1 > x >= 0 with approximately uniform + distribution over that range, using an + implementation-dependent algorithm or strategy. + This function takes no arguments. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.2.14"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.random()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( item = 0; item < 100; item++ ) { + array[item] = new TestCase( SECTION, "Math.random()", "pass", null ); + } + + return ( array ); +} +function getRandom( caseno ) { + testcases[caseno].reason = Math.random(); + testcases[caseno].actual = "pass"; + + if ( ! ( testcases[caseno].reason >= 0) ) { + testcases[caseno].actual = "fail"; + } + + if ( ! (testcases[caseno].reason < 1) ) { + testcases[caseno].actual = "fail"; + } +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + getRandom( 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/Math/15.8.2.15.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.15.js new file mode 100644 index 0000000..ca8cc94 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.15.js @@ -0,0 +1,113 @@ +/* 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.8.2.15.js + ECMA Section: 15.8.2.15 Math.round(x) + Description: return the greatest number value that is closest to the + argument and is an integer. if two integers are equally + close to the argument. then the result is the number value + that is closer to Infinity. if the argument is an integer, + return the argument. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if 0 < x < 0.5 return 0 + - if -0.5 <= x < 0 return -0 + example: + Math.round( 3.5 ) == 4 + Math.round( -3.5 ) == 3 + also: + - Math.round(x) == Math.floor( x + 0.5 ) + except if x = -0. in that case, Math.round(x) = -0 + + and Math.floor( x+0.5 ) = +0 + + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.15"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.round(x)"; + var BUGNUMBER="331411"; + + var EXCLUDE = "true"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.round.length", 1, Math.round.length ); + + array[item++] = new TestCase( SECTION, "Math.round()", Number.NaN, Math.round() ); + array[item++] = new TestCase( SECTION, "Math.round(null)", 0, Math.round(0) ); + array[item++] = new TestCase( SECTION, "Math.round(void 0)", Number.NaN, Math.round(void 0) ); + array[item++] = new TestCase( SECTION, "Math.round(true)", 1, Math.round(true) ); + array[item++] = new TestCase( SECTION, "Math.round(false)", 0, Math.round(false) ); + array[item++] = new TestCase( SECTION, "Math.round('.99999')", 1, Math.round('.99999') ); + array[item++] = new TestCase( SECTION, "Math.round('12345e-2')", 123, Math.round('12345e-2') ); + + array[item++] = new TestCase( SECTION, "Math.round(NaN)", Number.NaN, Math.round(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.round(0)", 0, Math.round(0) ); + array[item++] = new TestCase( SECTION, "Math.round(-0)", -0, Math.round(-0)); + array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0)", -Infinity, Infinity/Math.round(-0) ); + + array[item++] = new TestCase( SECTION, "Math.round(Infinity)", Number.POSITIVE_INFINITY, Math.round(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.round(-Infinity)",Number.NEGATIVE_INFINITY, Math.round(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.round(0.49)", 0, Math.round(0.49)); + array[item++] = new TestCase( SECTION, "Math.round(0.5)", 1, Math.round(0.5)); + array[item++] = new TestCase( SECTION, "Math.round(0.51)", 1, Math.round(0.51)); + + array[item++] = new TestCase( SECTION, "Math.round(-0.49)", -0, Math.round(-0.49)); + array[item++] = new TestCase( SECTION, "Math.round(-0.5)", -0, Math.round(-0.5)); + array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0.49)", -Infinity, Infinity/Math.round(-0.49)); + array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0.5)", -Infinity, Infinity/Math.round(-0.5)); + + array[item++] = new TestCase( SECTION, "Math.round(-0.51)", -1, Math.round(-0.51)); + array[item++] = new TestCase( SECTION, "Math.round(3.5)", 4, Math.round(3.5)); + array[item++] = new TestCase( SECTION, "Math.round(-3.5)", -3, Math.round(-3)); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.16.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.16.js new file mode 100644 index 0000000..b144d9b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.16.js @@ -0,0 +1,78 @@ +/* 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.8.2.16.js + ECMA Section: 15.8.2.16 sin( x ) + Description: return an approximation to the sine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.2.16"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.sin(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.sin.length", 1, Math.sin.length ); + + array[item++] = new TestCase( SECTION, "Math.sin()", Number.NaN, Math.sin() ); + array[item++] = new TestCase( SECTION, "Math.sin(null)", 0, Math.sin(null) ); + array[item++] = new TestCase( SECTION, "Math.sin(void 0)", Number.NaN, Math.sin(void 0) ); + array[item++] = new TestCase( SECTION, "Math.sin(false)", 0, Math.sin(false) ); + array[item++] = new TestCase( SECTION, "Math.sin('2.356194490192')", 0.7071067811865, Math.sin('2.356194490192') ); + + array[item++] = new TestCase( SECTION, "Math.sin(NaN)", Number.NaN, Math.sin(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.sin(0)", 0, Math.sin(0) ); + array[item++] = new TestCase( SECTION, "Math.sin(-0)", -0, Math.sin(-0)); + array[item++] = new TestCase( SECTION, "Math.sin(Infinity)", Number.NaN, Math.sin(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sin(-Infinity)", Number.NaN, Math.sin(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sin(0.7853981633974)", 0.7071067811865, Math.sin(0.7853981633974)); + array[item++] = new TestCase( SECTION, "Math.sin(1.570796326795)", 1, Math.sin(1.570796326795)); + array[item++] = new TestCase( SECTION, "Math.sin(2.356194490192)", 0.7071067811865, Math.sin(2.356194490192)); + array[item++] = new TestCase( SECTION, "Math.sin(3.14159265359)", 0, Math.sin(3.14159265359)); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.17.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.17.js new file mode 100644 index 0000000..16859ed --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.17.js @@ -0,0 +1,99 @@ +/* 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.8.2.17.js + ECMA Section: 15.8.2.17 Math.sqrt(x) + Description: return an approximation to the squareroot of the argument. + special cases: + - if x is NaN return NaN + - if x < 0 return NaN + - if x == 0 return 0 + - if x == -0 return -0 + - if x == Infinity return Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.17"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.sqrt(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.sqrt.length", 1, Math.sqrt.length ); + + array[item++] = new TestCase( SECTION, "Math.sqrt()", Number.NaN, Math.sqrt() ); + array[item++] = new TestCase( SECTION, "Math.sqrt(void 0)", Number.NaN, Math.sqrt(void 0) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(null)", 0, Math.sqrt(null) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(true)", 1, Math.sqrt(1) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(false)", 0, Math.sqrt(false) ); + array[item++] = new TestCase( SECTION, "Math.sqrt('225')", 15, Math.sqrt('225') ); + + array[item++] = new TestCase( SECTION, "Math.sqrt(NaN)", Number.NaN, Math.sqrt(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(-Infinity)", Number.NaN, Math.sqrt(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sqrt(-1)", Number.NaN, Math.sqrt(-1)); + array[item++] = new TestCase( SECTION, "Math.sqrt(-0.5)", Number.NaN, Math.sqrt(-0.5)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0)", 0, Math.sqrt(0)); + array[item++] = new TestCase( SECTION, "Math.sqrt(-0)", -0, Math.sqrt(-0)); + array[item++] = new TestCase( SECTION, "Infinity/Math.sqrt(-0)", -Infinity, Infinity/Math.sqrt(-0) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(Infinity)", Number.POSITIVE_INFINITY, Math.sqrt(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sqrt(1)", 1, Math.sqrt(1)); + array[item++] = new TestCase( SECTION, "Math.sqrt(2)", Math.SQRT2, Math.sqrt(2)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.5)", Math.SQRT1_2, Math.sqrt(0.5)); + array[item++] = new TestCase( SECTION, "Math.sqrt(4)", 2, Math.sqrt(4)); + array[item++] = new TestCase( SECTION, "Math.sqrt(9)", 3, Math.sqrt(9)); + array[item++] = new TestCase( SECTION, "Math.sqrt(16)", 4, Math.sqrt(16)); + array[item++] = new TestCase( SECTION, "Math.sqrt(25)", 5, Math.sqrt(25)); + array[item++] = new TestCase( SECTION, "Math.sqrt(36)", 6, Math.sqrt(36)); + array[item++] = new TestCase( SECTION, "Math.sqrt(49)", 7, Math.sqrt(49)); + array[item++] = new TestCase( SECTION, "Math.sqrt(64)", 8, Math.sqrt(64)); + array[item++] = new TestCase( SECTION, "Math.sqrt(256)", 16, Math.sqrt(256)); + array[item++] = new TestCase( SECTION, "Math.sqrt(10000)", 100, Math.sqrt(10000)); + array[item++] = new TestCase( SECTION, "Math.sqrt(65536)", 256, Math.sqrt(65536)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.09)", 0.3, Math.sqrt(0.09)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.01)", 0.1, Math.sqrt(0.01)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.00000001)",0.0001, Math.sqrt(0.00000001)); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.18.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.18.js new file mode 100644 index 0000000..f745dd7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.18.js @@ -0,0 +1,98 @@ +/* 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.8.2.18.js + ECMA Section: 15.8.2.18 tan( x ) + Description: return an approximation to the tan of the + argument. argument is expressed in radians + special cases: + - if x is NaN result is NaN + - if x is 0 result is 0 + - if x is -0 result is -0 + - if x is Infinity or -Infinity result is NaN + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.18"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.tan(x)"; + var EXCLUDE = "true"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.tan.length", 1, Math.tan.length ); + + array[item++] = new TestCase( SECTION, "Math.tan()", Number.NaN, Math.tan() ); + array[item++] = new TestCase( SECTION, "Math.tan(void 0)", Number.NaN, Math.tan(void 0)); + array[item++] = new TestCase( SECTION, "Math.tan(null)", 0, Math.tan(null) ); + array[item++] = new TestCase( SECTION, "Math.tan(false)", 0, Math.tan(false) ); + + array[item++] = new TestCase( SECTION, "Math.tan(NaN)", Number.NaN, Math.tan(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.tan(0)", 0, Math.tan(0)); + array[item++] = new TestCase( SECTION, "Math.tan(-0)", -0, Math.tan(-0)); + array[item++] = new TestCase( SECTION, "Math.tan(Infinity)", Number.NaN, Math.tan(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.tan(-Infinity)", Number.NaN, Math.tan(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.tan(Math.PI/4)", 1, Math.tan(Math.PI/4)); + array[item++] = new TestCase( SECTION, "Math.tan(3*Math.PI/4)", -1, Math.tan(3*Math.PI/4)); + array[item++] = new TestCase( SECTION, "Math.tan(Math.PI)", -0, Math.tan(Math.PI)); + array[item++] = new TestCase( SECTION, "Math.tan(5*Math.PI/4)", 1, Math.tan(5*Math.PI/4)); + array[item++] = new TestCase( SECTION, "Math.tan(7*Math.PI/4)", -1, Math.tan(7*Math.PI/4)); + array[item++] = new TestCase( SECTION, "Infinity/Math.tan(-0)", -Infinity, Infinity/Math.tan(-0) ); + +/* + Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2. + That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. + + This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I + suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest + results to infinity that the algorithm can deliver. + + In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger. + = C = +*/ + array[item++] = new TestCase( SECTION, "Math.tan(3*Math.PI/2) >= 5443000000000000", true, Math.tan(3*Math.PI/2) >= 5443000000000000 ); + array[item++] = new TestCase( SECTION, "Math.tan(Math.PI/2) >= 5443000000000000", true, Math.tan(Math.PI/2) >= 5443000000000000 ); + + 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/Math/15.8.2.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.2.js new file mode 100644 index 0000000..4a6f11e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.2.js @@ -0,0 +1,86 @@ +/* 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.8.2.2.js + ECMA Section: 15.8.2.2 acos( x ) + Description: return an approximation to the arc cosine of the + argument. the result is expressed in radians and + range is from +0 to +PI. special cases: + - if x is NaN, return NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == 1, the result is +0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + var SECTION = "15.8.2.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.acos()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.acos.length", 1, Math.acos.length ); + + array[item++] = new TestCase( SECTION, "Math.acos(void 0)", Number.NaN, Math.acos(void 0) ); + array[item++] = new TestCase( SECTION, "Math.acos()", Number.NaN, Math.acos() ); + array[item++] = new TestCase( SECTION, "Math.acos(null)", Math.PI/2, Math.acos(null) ); + array[item++] = new TestCase( SECTION, "Math.acos(NaN)", Number.NaN, Math.acos(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.acos(a string)", Number.NaN, Math.acos("a string") ); + array[item++] = new TestCase( SECTION, "Math.acos('0')", Math.PI/2, Math.acos('0') ); + array[item++] = new TestCase( SECTION, "Math.acos('1')", 0, Math.acos('1') ); + array[item++] = new TestCase( SECTION, "Math.acos('-1')", Math.PI, Math.acos('-1') ); + + array[item++] = new TestCase( SECTION, "Math.acos(1.00000001)", Number.NaN, Math.acos(1.00000001) ); + array[item++] = new TestCase( SECTION, "Math.acos(11.00000001)", Number.NaN, Math.acos(-1.00000001) ); + array[item++] = new TestCase( SECTION, "Math.acos(1)", 0, Math.acos(1) ); + array[item++] = new TestCase( SECTION, "Math.acos(-1)", Math.PI, Math.acos(-1) ); + array[item++] = new TestCase( SECTION, "Math.acos(0)", Math.PI/2, Math.acos(0) ); + array[item++] = new TestCase( SECTION, "Math.acos(-0)", Math.PI/2, Math.acos(-0) ); + array[item++] = new TestCase( SECTION, "Math.acos(Math.SQRT1_2)", Math.PI/4, Math.acos(Math.SQRT1_2)); + array[item++] = new TestCase( SECTION, "Math.acos(-Math.SQRT1_2)", Math.PI/4*3, Math.acos(-Math.SQRT1_2)); + array[item++] = new TestCase( SECTION, "Math.acos(0.9999619230642)", Math.PI/360, Math.acos(0.9999619230642)); + + 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/Math/15.8.2.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.3.js new file mode 100644 index 0000000..2a00e93 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.3.js @@ -0,0 +1,90 @@ +/* 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.8.2.3.js + ECMA Section: 15.8.2.3 asin( x ) + Description: return an approximation to the arc sine of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.2.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.asin()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.asin()", Number.NaN, Math.asin() ); + array[item++] = new TestCase( SECTION, "Math.asin(void 0)", Number.NaN, Math.asin(void 0) ); + array[item++] = new TestCase( SECTION, "Math.asin(null)", 0, Math.asin(null) ); + array[item++] = new TestCase( SECTION, "Math.asin(NaN)", Number.NaN, Math.asin(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.asin('string')", Number.NaN, Math.asin("string") ); + array[item++] = new TestCase( SECTION, "Math.asin('0')", 0, Math.asin("0") ); + array[item++] = new TestCase( SECTION, "Math.asin('1')", Math.PI/2, Math.asin("1") ); + array[item++] = new TestCase( SECTION, "Math.asin('-1')", -Math.PI/2, Math.asin("-1") ); + array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2+'')", Math.PI/4, Math.asin(Math.SQRT1_2+'') ); + array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2+'')", -Math.PI/4, Math.asin(-Math.SQRT1_2+'') ); + + array[item++] = new TestCase( SECTION, "Math.asin(1.000001)", Number.NaN, Math.asin(1.000001) ); + array[item++] = new TestCase( SECTION, "Math.asin(-1.000001)", Number.NaN, Math.asin(-1.000001) ); + array[item++] = new TestCase( SECTION, "Math.asin(0)", 0, Math.asin(0) ); + array[item++] = new TestCase( SECTION, "Math.asin(-0)", -0, Math.asin(-0) ); + + array[item++] = new TestCase( SECTION, "Infinity/Math.asin(-0)", -Infinity, Infinity/Math.asin(-0) ); + + array[item++] = new TestCase( SECTION, "Math.asin(1)", Math.PI/2, Math.asin(1) ); + array[item++] = new TestCase( SECTION, "Math.asin(-1)", -Math.PI/2, Math.asin(-1) ); + array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2))", Math.PI/4, Math.asin(Math.SQRT1_2) ); + array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2))", -Math.PI/4, Math.asin(-Math.SQRT1_2)); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.4.js new file mode 100644 index 0000000..3711331 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.4.js @@ -0,0 +1,88 @@ +/* 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.8.2.4.js + ECMA Section: 15.8.2.4 atan( x ) + Description: return an approximation to the arc tangent of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + - if x == +Infinity, the result is approximately +PI/2 + - if x == -Infinity, the result is approximately -PI/2 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + var SECTION = "15.8.2.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.atan()"; + var BUGNUMBER="77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.atan.length", 1, Math.atan.length ); + + array[item++] = new TestCase( SECTION, "Math.atan()", Number.NaN, Math.atan() ); + array[item++] = new TestCase( SECTION, "Math.atan(void 0)", Number.NaN, Math.atan(void 0) ); + array[item++] = new TestCase( SECTION, "Math.atan(null)", 0, Math.atan(null) ); + array[item++] = new TestCase( SECTION, "Math.atan(NaN)", Number.NaN, Math.atan(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.atan('a string')", Number.NaN, Math.atan("a string") ); + array[item++] = new TestCase( SECTION, "Math.atan('0')", 0, Math.atan('0') ); + array[item++] = new TestCase( SECTION, "Math.atan('1')", Math.PI/4, Math.atan('1') ); + array[item++] = new TestCase( SECTION, "Math.atan('-1')", -Math.PI/4, Math.atan('-1') ); + array[item++] = new TestCase( SECTION, "Math.atan('Infinity)", Math.PI/2, Math.atan('Infinity') ); + array[item++] = new TestCase( SECTION, "Math.atan('-Infinity)", -Math.PI/2, Math.atan('-Infinity') ); + + array[item++] = new TestCase( SECTION, "Math.atan(0)", 0, Math.atan(0) ); + array[item++] = new TestCase( SECTION, "Math.atan(-0)", -0, Math.atan(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.atan(-0)", -Infinity, Infinity/Math.atan(-0) ); + array[item++] = new TestCase( SECTION, "Math.atan(Infinity)", Math.PI/2, Math.atan(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan(-Infinity)", -Math.PI/2, Math.atan(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan(1)", Math.PI/4, Math.atan(1) ); + array[item++] = new TestCase( SECTION, "Math.atan(-1)", -Math.PI/4, Math.atan(-1) ); + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.5.js new file mode 100644 index 0000000..d1eeead --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.5.js @@ -0,0 +1,105 @@ +/* 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.8.2.5.js + ECMA Section: 15.8.2.5 atan2( y, x ) + Description: + + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.2.5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.atan2(x,y)"; + var BUGNUMBER="76111"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.atan2.length", 2, Math.atan2.length ); + + array[item++] = new TestCase( SECTION, "Math.atan2(NaN, 0)", Number.NaN, Math.atan2(Number.NaN,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(null, null)", 0, Math.atan2(null, null) ); + array[item++] = new TestCase( SECTION, "Math.atan2(void 0, void 0)", Number.NaN, Math.atan2(void 0, void 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2()", Number.NaN, Math.atan2() ); + + array[item++] = new TestCase( SECTION, "Math.atan2(0, NaN)", Number.NaN, Math.atan2(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1, 0)", Math.PI/2, Math.atan2(1,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1,-0)", Math.PI/2, Math.atan2(1,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0,0.001)", 0, Math.atan2(0,0.001) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0,0)", 0, Math.atan2(0,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0, -0)", Math.PI, Math.atan2(0,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0, -1)", Math.PI, Math.atan2(0, -1) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-0, 1)", -0, Math.atan2(-0, 1) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-0, 1)", -Infinity, Infinity/Math.atan2(-0,1) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-0, 0)", -0, Math.atan2(-0,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-0, -0)", -Math.PI, Math.atan2(-0, -0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-0, -1)", -Math.PI, Math.atan2(-0, -1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-1, 0)", -Math.PI/2, Math.atan2(-1, 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-1, -0)", -Math.PI/2, Math.atan2(-1, -0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1, Infinity)", 0, Math.atan2(1, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1,-Infinity)", Math.PI, Math.atan2(1, Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-1, Infinity)", -0, Math.atan2(-1,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-1, Infinity)", -Infinity, Infinity/Math.atan2(-1,Infinity) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-1,-Infinity)", -Math.PI, Math.atan2(-1,Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity,-0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, Infinity)", Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, -Infinity)", 3*Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, Infinity)", -Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -Infinity)", -3*Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-1, 1)", -Math.PI/4, Math.atan2( -1, 1) ); + + 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/Math/15.8.2.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.6.js new file mode 100644 index 0000000..738bfe4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.6.js @@ -0,0 +1,108 @@ +/* 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.8.2.6.js + ECMA Section: 15.8.2.6 Math.ceil(x) + Description: return the smallest number value that is not less than the + argument and is equal to a mathematical integer. if the + number is already an integer, return the number itself. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = 0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.ceil(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ + var SECTION = "15.8.2.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.ceil(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.ceil.length", 1, Math.ceil.length ); + + array[item++] = new TestCase( SECTION, "Math.ceil(NaN)", Number.NaN, Math.ceil(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.ceil(null)", 0, Math.ceil(null) ); + array[item++] = new TestCase( SECTION, "Math.ceil()", Number.NaN, Math.ceil() ); + array[item++] = new TestCase( SECTION, "Math.ceil(void 0)", Number.NaN, Math.ceil(void 0) ); + + array[item++] = new TestCase( SECTION, "Math.ceil('0')", 0, Math.ceil('0') ); + array[item++] = new TestCase( SECTION, "Math.ceil('-0')", -0, Math.ceil('-0') ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil('0')", Infinity, Infinity/Math.ceil('0')); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil('-0')", -Infinity, Infinity/Math.ceil('-0')); + + array[item++] = new TestCase( SECTION, "Math.ceil(0)", 0, Math.ceil(0) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-0)", -0, Math.ceil(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(0)", Infinity, Infinity/Math.ceil(0)); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-0)", -Infinity, Infinity/Math.ceil(-0)); + + array[item++] = new TestCase( SECTION, "Math.ceil(Infinity)", Number.POSITIVE_INFINITY, Math.ceil(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Infinity)", Number.NEGATIVE_INFINITY, Math.ceil(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Number.MIN_VALUE)", -0, Math.ceil(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-Number.MIN_VALUE)", -Infinity, Infinity/Math.ceil(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "Math.ceil(1)", 1, Math.ceil(1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1)", -1, Math.ceil(-1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-0.9)", -0, Math.ceil(-0.9) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-0.9)", -Infinity, Infinity/Math.ceil(-0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(0.9 )", 1, Math.ceil( 0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1.1)", -1, Math.ceil( -1.1)); + array[item++] = new TestCase( SECTION, "Math.ceil( 1.1)", 2, Math.ceil( 1.1)); + + array[item++] = new TestCase( SECTION, "Math.ceil(Infinity)", -Math.floor(-Infinity), Math.ceil(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Infinity)", -Math.floor(Infinity), Math.ceil(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Number.MIN_VALUE)", -Math.floor(Number.MIN_VALUE), Math.ceil(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "Math.ceil(1)", -Math.floor(-1), Math.ceil(1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1)", -Math.floor(1), Math.ceil(-1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-0.9)", -Math.floor(0.9), Math.ceil(-0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(0.9 )", -Math.floor(-0.9), Math.ceil( 0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1.1)", -Math.floor(1.1), Math.ceil( -1.1)); + array[item++] = new TestCase( SECTION, "Math.ceil( 1.1)", -Math.floor(-1.1), Math.ceil( 1.1)); + + 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/Math/15.8.2.7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.7.js new file mode 100644 index 0000000..6b7dcfe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.7.js @@ -0,0 +1,111 @@ +/* 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.8.2.7.js + ECMA Section: 15.8.2.7 cos( x ) + Description: return an approximation to the cosine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + var SECTION = "15.8.2.7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.cos(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.cos.length", 1, Math.cos.length ); + + array[item++] = new TestCase( SECTION, "Math.cos()", Number.NaN, Math.cos() ); + array[item++] = new TestCase( SECTION, "Math.cos(void 0)", Number.NaN, Math.cos(void 0) ); + array[item++] = new TestCase( SECTION, "Math.cos(false)", 1, Math.cos(false) ); + array[item++] = new TestCase( SECTION, "Math.cos(null)", 1, Math.cos(null) ); + + array[item++] = new TestCase( SECTION, "Math.cos('0')", 1, Math.cos('0') ); + array[item++] = new TestCase( SECTION, "Math.cos('Infinity')", Number.NaN, Math.cos("Infinity") ); + array[item++] = new TestCase( SECTION, "Math.cos('3.14159265359')", -1, Math.cos('3.14159265359') ); + + array[item++] = new TestCase( SECTION, "Math.cos(NaN)", Number.NaN, Math.cos(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.cos(0)", 1, Math.cos(0) ); + array[item++] = new TestCase( SECTION, "Math.cos(-0)", 1, Math.cos(-0) ); + array[item++] = new TestCase( SECTION, "Math.cos(Infinity)", Number.NaN, Math.cos(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Infinity)", Number.NaN, Math.cos(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.cos(0.7853981633974)", 0.7071067811865, Math.cos(0.7853981633974) ); + array[item++] = new TestCase( SECTION, "Math.cos(1.570796326795)", 0, Math.cos(1.570796326795) ); + array[item++] = new TestCase( SECTION, "Math.cos(2.356194490192)", -0.7071067811865, Math.cos(2.356194490192) ); + array[item++] = new TestCase( SECTION, "Math.cos(3.14159265359)", -1, Math.cos(3.14159265359) ); + array[item++] = new TestCase( SECTION, "Math.cos(3.926990816987)", -0.7071067811865, Math.cos(3.926990816987) ); + array[item++] = new TestCase( SECTION, "Math.cos(4.712388980385)", 0, Math.cos(4.712388980385) ); + array[item++] = new TestCase( SECTION, "Math.cos(5.497787143782)", 0.7071067811865, Math.cos(5.497787143782) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)", 1, Math.cos(Math.PI*2) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/4)", Math.SQRT2/2, Math.cos(Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/2)", 0, Math.cos(Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/4)", -Math.SQRT2/2, Math.cos(3*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI)", -1, Math.cos(Math.PI) ); + array[item++] = new TestCase( SECTION, "Math.cos(5*Math.PI/4)", -Math.SQRT2/2, Math.cos(5*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/2)", 0, Math.cos(3*Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(7*Math.PI/4)", Math.SQRT2/2, Math.cos(7*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)", 1, Math.cos(2*Math.PI) ); + array[item++] = new TestCase( SECTION, "Math.cos(-0.7853981633974)", 0.7071067811865, Math.cos(-0.7853981633974) ); + array[item++] = new TestCase( SECTION, "Math.cos(-1.570796326795)", 0, Math.cos(-1.570796326795) ); + array[item++] = new TestCase( SECTION, "Math.cos(-2.3561944901920)", -.7071067811865, Math.cos(2.3561944901920) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3.14159265359)", -1, Math.cos(3.14159265359) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3.926990816987)", -0.7071067811865, Math.cos(3.926990816987) ); + array[item++] = new TestCase( SECTION, "Math.cos(-4.712388980385)", 0, Math.cos(4.712388980385) ); + array[item++] = new TestCase( SECTION, "Math.cos(-5.497787143782)", 0.7071067811865, Math.cos(5.497787143782) ); + array[item++] = new TestCase( SECTION, "Math.cos(-6.28318530718)", 1, Math.cos(6.28318530718) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/4)", Math.SQRT2/2, Math.cos(-Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/2)", 0, Math.cos(-Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/4)", -Math.SQRT2/2, Math.cos(-3*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI)", -1, Math.cos(-Math.PI) ); + array[item++] = new TestCase( SECTION, "Math.cos(-5*Math.PI/4)", -Math.SQRT2/2, Math.cos(-5*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/2)", 0, Math.cos(-3*Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(-7*Math.PI/4)", Math.SQRT2/2, Math.cos(-7*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI*2)", 1, Math.cos(-Math.PI*2) ); + + 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/Math/15.8.2.8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.8.js new file mode 100644 index 0000000..c0a4924 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.8.js @@ -0,0 +1,84 @@ +/* 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.8.2.8.js + ECMA Section: 15.8.2.8 Math.exp(x) + Description: return an approximation to the exponential function of + the argument (e raised to the power of the argument) + special cases: + - if x is NaN return NaN + - if x is 0 return 1 + - if x is -0 return 1 + - if x is Infinity return Infinity + - if x is -Infinity return 0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + + var SECTION = "15.8.2.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.exp(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.exp.length", 1, Math.exp.length ); + + array[item++] = new TestCase( SECTION, "Math.exp()", Number.NaN, Math.exp() ); + array[item++] = new TestCase( SECTION, "Math.exp(null)", 1, Math.exp(null) ); + array[item++] = new TestCase( SECTION, "Math.exp(void 0)", Number.NaN, Math.exp(void 0) ); + array[item++] = new TestCase( SECTION, "Math.exp(1)", Math.E, Math.exp(1) ); + array[item++] = new TestCase( SECTION, "Math.exp(true)", Math.E, Math.exp(true) ); + array[item++] = new TestCase( SECTION, "Math.exp(false)", 1, Math.exp(false) ); + + array[item++] = new TestCase( SECTION, "Math.exp('1')", Math.E, Math.exp('1') ); + array[item++] = new TestCase( SECTION, "Math.exp('0')", 1, Math.exp('0') ); + + array[item++] = new TestCase( SECTION, "Math.exp(NaN)", Number.NaN, Math.exp(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.exp(0)", 1, Math.exp(0) ); + array[item++] = new TestCase( SECTION, "Math.exp(-0)", 1, Math.exp(-0) ); + array[item++] = new TestCase( SECTION, "Math.exp(Infinity)", Number.POSITIVE_INFINITY, Math.exp(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.exp(-Infinity)", 0, Math.exp(Number.NEGATIVE_INFINITY) ); + + 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/Math/15.8.2.9.js b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.9.js new file mode 100644 index 0000000..c1ea987 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Math/15.8.2.9.js @@ -0,0 +1,105 @@ +/* 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.8.2.9.js + ECMA Section: 15.8.2.9 Math.floor(x) + Description: return the greatest number value that is not greater + than the argument and is equal to a mathematical integer. + if the number is already an integer, return the number + itself. special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.floor(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.9"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.floor(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.floor.length", 1, Math.floor.length ); + + array[item++] = new TestCase( SECTION, "Math.floor()", Number.NaN, Math.floor() ); + array[item++] = new TestCase( SECTION, "Math.floor(void 0)", Number.NaN, Math.floor(void 0) ); + array[item++] = new TestCase( SECTION, "Math.floor(null)", 0, Math.floor(null) ); + array[item++] = new TestCase( SECTION, "Math.floor(true)", 1, Math.floor(true) ); + array[item++] = new TestCase( SECTION, "Math.floor(false)", 0, Math.floor(false) ); + + array[item++] = new TestCase( SECTION, "Math.floor('1.1')", 1, Math.floor("1.1") ); + array[item++] = new TestCase( SECTION, "Math.floor('-1.1')", -2, Math.floor("-1.1") ); + array[item++] = new TestCase( SECTION, "Math.floor('0.1')", 0, Math.floor("0.1") ); + array[item++] = new TestCase( SECTION, "Math.floor('-0.1')", -1, Math.floor("-0.1") ); + + array[item++] = new TestCase( SECTION, "Math.floor(NaN)", Number.NaN, Math.floor(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.floor(NaN)==-Math.ceil(-NaN)", false, Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.floor(0)", 0, Math.floor(0) ); + array[item++] = new TestCase( SECTION, "Math.floor(0)==-Math.ceil(-0)", true, Math.floor(0) == -Math.ceil(-0) ); + + array[item++] = new TestCase( SECTION, "Math.floor(-0)", -0, Math.floor(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.floor(-0)", -Infinity, Infinity/Math.floor(-0) ); + array[item++] = new TestCase( SECTION, "Math.floor(-0)==-Math.ceil(0)", true, Math.floor(-0)== -Math.ceil(0) ); + + array[item++] = new TestCase( SECTION, "Math.floor(Infinity)", Number.POSITIVE_INFINITY, Math.floor(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.floor(Infinity)==-Math.ceil(-Infinity)", true, Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.floor(-Infinity)", Number.NEGATIVE_INFINITY, Math.floor(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.floor(-Infinity)==-Math.ceil(Infinity)", true, Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)", 0, Math.floor(0.0000001) ); + array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, Math.floor(0.0000001)==-Math.ceil(-0.0000001) ); + + array[item++] = new TestCase( SECTION, "Math.floor(-0.0000001)", -1, Math.floor(-0.0000001) ); + array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, Math.floor(-0.0000001)==-Math.ceil(0.0000001) ); + + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/NativeObjects/15-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/NativeObjects/15-1.js new file mode 100644 index 0000000..cecdd90 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/NativeObjects/15-1.js @@ -0,0 +1,95 @@ +/* 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.js + ECMA Section: 15 Native ECMAScript Objects + Description: Every built-in prototype object has the Object prototype + object, which is the value of the expression + Object.prototype (15.2.3.1) as the value of its internal + [[Prototype]] property, except the Object prototype + object itself. + + Every native object associated with a program-created + function also has the Object prototype object as the + value of its internal [[Prototype]] property. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Native ECMAScript Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; +/* + array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// array[item++] = new TestCase( SECTION, "Math.prototype.__proto__", Object.prototype, Math.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Date.prototype.__proto__", Object.prototype, Date.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "TestCase.prototype.__proto__", Object.prototype, TestCase.prototype.__proto__ ); + + array[item++] = new TestCase( SECTION, "MyObject.prototype.__proto__", Object.prototype, MyObject.prototype.__proto__ ); +*/ + array[item++] = new TestCase( SECTION, "Function.prototype.__proto__ == Object.prototype", true, Function.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Array.prototype.__proto__ == Object.prototype", true, Array.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "String.prototype.__proto__ == Object.prototype", true, String.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__ == Object.prototype", true, Boolean.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); +// array[item++] = new TestCase( SECTION, "Math.prototype.__proto__ == Object.prototype", true, Math.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Date.prototype.__proto__ == Object.prototype", true, Date.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "TestCase.prototype.__proto__ == Object.prototype", true, TestCase.prototype.__proto__ == Object.prototype ); + + array[item++] = new TestCase( SECTION, "MyObject.prototype.__proto__ == Object.prototype", true, MyObject.prototype.__proto__ == Object.prototype ); + + + 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" ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/NativeObjects/15-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/NativeObjects/15-2.js new file mode 100644 index 0000000..612e1b4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/NativeObjects/15-2.js @@ -0,0 +1,78 @@ +/* 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.js + ECMA Section: 15 Native ECMAScript Objects + + Description: Every built-in function and every built-in constructor + has the Function prototype object, which is the value of + the expression Function.prototype as the value of its + internal [[Prototype]] property, except the Function + prototype object itself. + + That is, the __proto__ property of builtin functions and + constructors should be the Function.prototype object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Native ECMAScript Objects"; + + 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, "Array.__proto__", Function.prototype, Array.__proto__ ); + array[item++] = new TestCase( SECTION, "String.__proto__", Function.prototype, String.__proto__ ); + array[item++] = new TestCase( SECTION, "Boolean.__proto__", Function.prototype, Boolean.__proto__ ); + array[item++] = new TestCase( SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); + array[item++] = new TestCase( SECTION, "Date.__proto__", Function.prototype, Date.__proto__ ); + array[item++] = new TestCase( SECTION, "TestCase.__proto__", Function.prototype, TestCase.__proto__ ); + + array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); + array[item++] = new TestCase( SECTION, "Math.pow.__proto__", Function.prototype, Math.pow.__proto__ ); + array[item++] = new TestCase( SECTION, "String.prototype.indexOf.__proto__", Function.prototype, String.prototype.indexOf.__proto__ ); + + return ( array ); +} +function test() { + 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/Number/15.7.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.1.js new file mode 100644 index 0000000..102912d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.1.js @@ -0,0 +1,90 @@ +/* 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.7.1.js + ECMA Section: 15.7.1 The Number Constructor Called as a Function + 15.7.1.1 + 15.7.1.2 + + Description: When Number is called as a function rather than as a + constructor, it performs a type conversion. + 15.7.1.1 Return a number value (not a Number object) + computed by ToNumber( value ) + 15.7.1.2 Number() returns 0. + + need to add more test cases. see the testcases for + TypeConversion ToNumber. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + + var SECTION = "15.7.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Number Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "Number()", 0, Number() ); + array[item++] = new TestCase(SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); + array[item++] = new TestCase(SECTION, "Number(null)", 0, Number(null) ); + array[item++] = new TestCase(SECTION, "Number()", 0, Number() ); + array[item++] = new TestCase(SECTION, "Number(new Number())", 0, Number( new Number() ) ); + array[item++] = new TestCase(SECTION, "Number(0)", 0, Number(0) ); + array[item++] = new TestCase(SECTION, "Number(1)", 1, Number(1) ); + array[item++] = new TestCase(SECTION, "Number(-1)", -1, Number(-1) ); + array[item++] = new TestCase(SECTION, "Number(NaN)", Number.NaN, Number( Number.NaN ) ); + array[item++] = new TestCase(SECTION, "Number('string')", Number.NaN, Number( "string") ); + array[item++] = new TestCase(SECTION, "Number(new String())", 0, Number( new String() ) ); + array[item++] = new TestCase(SECTION, "Number('')", 0, Number( "" ) ); + array[item++] = new TestCase(SECTION, "Number(Infinity)", Number.POSITIVE_INFINITY, Number("Infinity") ); + + array[item++] = new TestCase(SECTION, "Number(new MyObject(100))", 100, Number(new MyObject(100)) ); + + 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" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.2.js new file mode 100644 index 0000000..6e3982b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.2.js @@ -0,0 +1,173 @@ +/* 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.7.2.js + ECMA Section: 15.7.2 The Number Constructor + 15.7.2.1 + 15.7.2.2 + + Description: 15.7.2 When Number is called as part of a new + expression, it is a constructor: it initializes + the newly created object. + + 15.7.2.1 The [[Prototype]] property of the newly + constructed object is set to othe original Number + prototype object, the one that is the initial value + of Number.prototype(0). The [[Class]] property is + set to "Number". The [[Value]] property of the + newly constructed object is set to ToNumber(value) + + 15.7.2.2 new Number(). same as in 15.7.2.1, except + the [[Value]] property is set to +0. + + need to add more test cases. see the testcases for + TypeConversion ToNumber. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + + var SECTION = "15.7.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Number Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // To verify that the object's prototype is the Number.prototype, check to see if the object's + // constructor property is the same as Number.prototype.constructor. + + array[item++] = new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + + array[item++] = new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); + array[item++] = new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(0)).constructor", Number.prototype.constructor, (new Number(0)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(0))", "object", typeof (new Number(0)) ); + array[item++] = new TestCase(SECTION, "(new Number(0)).valueOf()", 0, (new Number(0)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(1)).constructor", Number.prototype.constructor, (new Number(1)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(1))", "object", typeof (new Number(1)) ); + array[item++] = new TestCase(SECTION, "(new Number(1)).valueOf()", 1, (new Number(1)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(-1)).constructor", Number.prototype.constructor, (new Number(-1)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(-1))", "object", typeof (new Number(-1)) ); + array[item++] = new TestCase(SECTION, "(new Number(-1)).valueOf()", -1, (new Number(-1)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(Number.NaN)).constructor", Number.prototype.constructor, (new Number(Number.NaN)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(Number.NaN))", "object", typeof (new Number(Number.NaN)) ); + array[item++] = new TestCase(SECTION, "(new Number(Number.NaN)).valueOf()", Number.NaN, (new Number(Number.NaN)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number('string')).constructor", Number.prototype.constructor, (new Number('string')).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number('string'))", "object", typeof (new Number('string')) ); + array[item++] = new TestCase(SECTION, "(new Number('string')).valueOf()", Number.NaN, (new Number('string')).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(new String())).constructor", Number.prototype.constructor, (new Number(new String())).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(new String()))", "object", typeof (new Number(new String())) ); + array[item++] = new TestCase(SECTION, "(new Number(new String())).valueOf()", 0, (new Number(new String())).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number('')).constructor", Number.prototype.constructor, (new Number('')).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(''))", "object", typeof (new Number('')) ); + array[item++] = new TestCase(SECTION, "(new Number('')).valueOf()", 0, (new Number('')).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.POSITIVE_INFINITY)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(Number.POSITIVE_INFINITY))", "object", typeof (new Number(Number.POSITIVE_INFINITY)) ); + array[item++] = new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, (new Number(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.NEGATIVE_INFINITY)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(Number.NEGATIVE_INFINITY))", "object", typeof (new Number(Number.NEGATIVE_INFINITY)) ); + array[item++] = new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).valueOf()", Number.NEGATIVE_INFINITY, (new Number(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + + array[item++] = new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); + array[item++] = new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-1.js new file mode 100644 index 0000000..71aea75 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.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.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.1-1"; +var VERSION = "ECMA_1"; + startTest(); +var TITLE = "Number.prototype"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +var testcases = getTestCases(); +test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype", true, "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype" ); + array[item++] = new TestCase(SECTION, "delete( Number.prototype )", false, "delete( Number.prototype )" ); + + return ( array ); +} + +function test() { + 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 ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-2.js new file mode 100644 index 0000000..dbce0e1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-2.js @@ -0,0 +1,75 @@ +/* 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.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT", + true, + eval("var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT") ); + + array[item++] = new TestCase( SECTION, + "Number.prototype=0; Number.prototype", + Number.prototype, + eval("Number.prototype=0; Number.prototype") ); + + return ( array ); +} + +function test() { + 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 ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-3.js new file mode 100644 index 0000000..34bd2ff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.1-3.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.7.3.1-4.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.7.3.1-3"; + var TITLE = "Number.prototype"; + + writeHeaderToLog( SECTION + " Number.prototype: DontEnum Attribute"); + + var testcases = getTestCases(); + + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop: '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop : '' } string;") + ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-1.js new file mode 100644 index 0000000..51d679a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-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.7.3.2-1.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE", 1.7976931348623157e308, Number.MAX_VALUE ); + + + 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 ); + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-2.js new file mode 100644 index 0000000..b5f57c9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-2.js @@ -0,0 +1,64 @@ +/* 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.7.3.2-2.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE: DontDelete Attribute"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "delete( Number.MAX_VALUE ); Number.MAX_VALUE", 1.7976931348623157e308, "delete( Number.MAX_VALUE );Number.MAX_VALUE" ); + array[item++] = new TestCase( SECTION, "delete( Number.MAX_VALUE )", false, "delete( Number.MAX_VALUE )" ); + + return ( array ); +} +function test() { + 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 ); + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-3.js new file mode 100644 index 0000000..c8040cd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-3.js @@ -0,0 +1,66 @@ +/* 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.7.3.2-3.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MAX_VAL = 1.7976931348623157e308; + + array[item++] = new TestCase( SECTION, + "Number.MAX_VALUE=0; Number.MAX_VALUE", + MAX_VAL, + eval("Number.MAX_VALUE=0; Number.MAX_VALUE") ); + 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 ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-4.js new file mode 100644 index 0000000..846a3c1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.2-4.js @@ -0,0 +1,66 @@ +/* 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.7.3.2-4.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE: DontEnum Attribute"; + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;") + ); + + return ( array ); +} +function test( testcases ) { + for ( tc = 0; tc < testcases.length; tc++ ) { + writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-1.js new file mode 100644 index 0000000..f912583 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-1.js @@ -0,0 +1,64 @@ +/* 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.7.3.3-1.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MIN_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MIN_VAL = 5e-324; + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE", MIN_VAL, Number.MIN_VALUE ); + 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 ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-2.js new file mode 100644 index 0000000..fdcfb0a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-2.js @@ -0,0 +1,66 @@ +/* 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.7.3.3-2.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MIN_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MIN_VAL = 5e-324; + + array[item++] = new TestCase( SECTION, "delete( Number.MIN_VALUE )", false, "delete( Number.MIN_VALUE )" ); + array[item++] = new TestCase( SECTION, "delete( Number.MIN_VALUE ); Number.MIN_VALUE", MIN_VAL, "delete( Number.MIN_VALUE );Number.MIN_VALUE" ); + return ( array ); +} +function test() { + 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 ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-3.js new file mode 100644 index 0000000..f1c4380 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-3.js @@ -0,0 +1,67 @@ +/* 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.7.3.3-3.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MIN_VALUE: ReadOnly Attribute"; + + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "Number.MIN_VALUE=0; Number.MIN_VALUE", + Number.MIN_VALUE, + "Number.MIN_VALUE=0; Number.MIN_VALUE" ); + return ( array ); +} +function test() { + 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 += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-4.js new file mode 100644 index 0000000..7b3fa19 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.3-4.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.7.3.3-4.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.3-4"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Number.MIN_VALUE: DontEnum Attribute"); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;") + ); + + 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 += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-1.js new file mode 100644 index 0000000..2ff39f6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.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.7.3.4-1.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase(SECTION, "NaN", NaN, Number.NaN ); + return ( array ); +} +function test() { + 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 ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-2.js new file mode 100644 index 0000000..96535f1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-2.js @@ -0,0 +1,67 @@ +/* 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.7.3.4-2.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "delete( Number.NaN ); Number.NaN", NaN, "delete( Number.NaN );Number.NaN" ); + array[item++] = new TestCase( SECTION, "delete( Number.NaN )", false, "delete( Number.NaN )" ); + + return ( array ); +} +function test() { + 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 ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-3.js new file mode 100644 index 0000000..3f13a2f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-3.js @@ -0,0 +1,71 @@ +/* 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.7.3.4-3.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.4-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "Number.NaN=0; Number.NaN", + Number.NaN, + "Number.NaN=0; Number.NaN" ); + + return ( array ); +} + +function test() { + 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 += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-4.js new file mode 100644 index 0000000..33b1667 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.4-4.js @@ -0,0 +1,71 @@ +/* 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.7.3.4-4.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.4-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " " + TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;") + ); + + return ( array ); +} + +function test( testcases ) { + 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 += "property should not be enumerated "; + passed = false; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-1.js new file mode 100644 index 0000000..1ca04eb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-1.js @@ -0,0 +1,61 @@ +/* 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.7.3.5-1.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase(SECTION, "Number.NEGATIVE_INFINITY", -Infinity, Number.NEGATIVE_INFINITY ); + + 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/Number/15.7.3.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-2.js new file mode 100644 index 0000000..2291552 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-2.js @@ -0,0 +1,72 @@ +/* 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.7.3.5-2.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY )", + false, + "delete( Number.NEGATIVE_INFINITY )" ); + + array[item++] = new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY ); Number.NEGATIVE_INFINITY", + -Infinity, + "delete( Number.NEGATIVE_INFINITY );Number.NEGATIVE_INFINITY" ); + return ( array ); +} +function test( testcases ) { + 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 ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-3.js new file mode 100644 index 0000000..c14fcf8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-3.js @@ -0,0 +1,67 @@ +/* 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.7.3.5-3.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY", + -Infinity, + "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY" ); + return ( array ); +} +function test() { + 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 += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-4.js new file mode 100644 index 0000000..fd3fd4e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.5-4.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.7.3.5-4.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.5-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;") + ); + return ( array ); +} + +function test( testcases ) { + 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 += "property should not be enumerated "; + + } + stopTest(); + return ( testcases ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-1.js new file mode 100644 index 0000000..a14b35e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-1.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.7.3.6-1.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY", Infinity, Number.POSITIVE_INFINITY ); + 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/Number/15.7.3.6-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-2.js new file mode 100644 index 0000000..573648b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-2.js @@ -0,0 +1,64 @@ +/* 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.7.3.6-2.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.6-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "delete( Number.POSITIVE_INFINITY )", false, "delete( Number.POSITIVE_INFINITY )" ); + array[item++] = new TestCase(SECTION, "delete( Number.POSITIVE_INFINITY ); Number.POSITIVE_INFINITY", Infinity, "delete( Number.POSITIVE_INFINITY );Number.POSITIVE_INFINITY" ); + return ( array ); +} + +function test( testcases ) { + 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 ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-3.js new file mode 100644 index 0000000..c4c5973 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-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.7.3.6-3.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.6-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY", + Number.POSITIVE_INFINITY, + "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY" ); + return ( array ); +} +function test() { + 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 += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-4.js new file mode 100644 index 0000000..25b2b4f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.6-4.js @@ -0,0 +1,66 @@ +/* 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.7.3.6-4.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.6-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;") + ); + + 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 += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.3.js new file mode 100644 index 0000000..c832cfc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.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.7.3.js + 15.7.3 Properties of the Number Constructor + + Description: The value of the internal [[Prototype]] property + of the Number constructor is the Function prototype + object. The Number constructor also has the internal + [[Call]] and [[Construct]] properties, and the length + property. + + Other properties are in subsequent tests. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + + var SECTION = "15.7.3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Number Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase(SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); + array[item++] = new TestCase(SECTION, "Number.length", 1, Number.length ); + + 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/Number/15.7.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4-1.js new file mode 100644 index 0000000..8d7c79d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.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.7.4-1.js + ECMA Section: 15.7.4.1 Properties of the Number Prototype Object + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.4-1"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + "Properties of the Number prototype object"); + + var testcases = getTestCases(); + + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); + array[item++] = new TestCase(SECTION, "typeof(Number.prototype)", "object", typeof(Number.prototype) ); + array[item++] = new TestCase(SECTION, "Number.prototype.constructor == Number", true, Number.prototype.constructor == Number ); +// array[item++] = new TestCase(SECTION, "Number.prototype == Number.__proto__", true, Number.prototype == Number.__proto__ ); + 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 ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.1.js new file mode 100644 index 0000000..789e71c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.1.js @@ -0,0 +1,64 @@ +/* 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.7.4.1.js + ECMA Section: 15.7.4.1.1 Number.prototype.constructor + + Number.prototype.constructor is the built-in Number constructor. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "Number.prototype.constructor", + Number, + Number.prototype.constructor ); + 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/Number/15.7.4.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-1.js new file mode 100644 index 0000000..f41b698 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-1.js @@ -0,0 +1,80 @@ +/* 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.7.4.2.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// the following two lines cause navigator to crash -- cmb 9/16/97 + array[item++] = new TestCase(SECTION, "Number.prototype.toString()", "0", "Number.prototype.toString()" ); + array[item++] = new TestCase(SECTION, "typeof(Number.prototype.toString())", "string", "typeof(Number.prototype.toString())" ); + + array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()", "0", "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()" ); + array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()", "1", "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()" ); + array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()", "-1", "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()" ); + + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(255); MYNUM.toString(10)", "255", "var MYNUM = new Number(255); MYNUM.toString(10)" ); + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)", "NaN", "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)" ); + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(Infinity); MYNUM.toString(10)", "Infinity", "var MYNUM = new Number(Infinity); MYNUM.toString(10)" ); + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(-Infinity); MYNUM.toString(10)", "-Infinity", "var MYNUM = new Number(-Infinity); MYNUM.toString(10)" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.2-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-2-n.js new file mode 100644 index 0000000..2aa035a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-2-n.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.7.4.2-2-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "o = new Object(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new Object(); o.toString = Number.prototype.toString; o.toString()" ); +// array[item++] = new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new String(); o.toString = Number.prototype.toString; o.toString()" ); +// array[item++] = new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "error", "o = 3; o.toString = Number.prototype.toString; o.toString()" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.2-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-3-n.js new file mode 100644 index 0000000..8e73acb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-3-n.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.7.4.2-3-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new String(); o.toString = Number.prototype.toString; o.toString()" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.2-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-4.js new file mode 100644 index 0000000..4896ba9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.2-4.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.7.4.2-4.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "3", "o = 3; o.toString = Number.prototype.toString; o.toString()" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.3-1.js new file mode 100644 index 0000000..341b347 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.3-1.js @@ -0,0 +1,72 @@ +/* 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.7.4.3-1.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + +// the following two line causes navigator to crash -- cmb 9/16/97 + array[item++] = new TestCase("15.7.4.1", "Number.prototype.valueOf()", 0, "Number.prototype.valueOf()" ); + + array[item++] = new TestCase("15.7.4.1", "(new Number(1)).valueOf()", 1, "(new Number(1)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(-1)).valueOf()", -1, "(new Number(-1)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(0)).valueOf()", 0, "(new Number(0)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, "(new Number(Number.POSITIVE_INFINITY)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(Number.NaN)).valueOf()", Number.NaN, "(new Number(Number.NaN)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number()).valueOf()", 0, "(new Number()).valueOf()" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.3-2.js new file mode 100644 index 0000000..6b81da6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.3-2.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.7.4.3-2.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", 3, "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.3-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.3-3-n.js new file mode 100644 index 0000000..8905f25 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.3-3-n.js @@ -0,0 +1,66 @@ +/* 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.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.3-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", "error", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()", "error", "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()" ); +// array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()", "error", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()" ); + + return ( array ); +} +function test() { + 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/Number/15.7.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.js new file mode 100644 index 0000000..fd62ad5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Number/15.7.4.js @@ -0,0 +1,86 @@ +/* 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.7.4.js + ECMA Section: 15.7.4 + + Description: + + The Number prototype object is itself a Number object (its [[Class]] is + "Number") whose value is +0. + + The value of the internal [[Prototype]] property of the Number prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Number + prototype object, the phrase "this Number object" refers to the object + that is the this value for the invocation of the function; it is an error + if this does not refer to an object for which the value of the internal + [[Class]] property is "Number". Also, the phrase "this number value" refers + to the number value represented by this Number object, that is, the value + of the internal [[Value]] property of this Number object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.7.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Number Prototype Object"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()", + "[object Number]", + eval("Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()") ); + array[item++] = new TestCase( SECTION, "typeof Number.prototype", "object", typeof Number.prototype ); + array[item++] = new TestCase( SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); + + +// The __proto__ property cannot be used in ECMA_1 tests. +// array[item++] = new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// array[item++] = new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); + + + 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.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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/SourceText/6-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/SourceText/6-1.js new file mode 100644 index 0000000..759402b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/SourceText/6-1.js @@ -0,0 +1,124 @@ +/* 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: 6-1.js + ECMA Section: Source Text + Description: + + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. + + SourceCharacter :: + any Unicode character + + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. + + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Source Text"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \u000A", + 'PASSED', + "PASSED" ); + + // \u000A testcases[tc].actual = "FAILED!"; + + tc++; + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'", + 'PASSED', + 'PASSED' ); + + // the following character should noy be interpreted as a line terminator: \\n testcases[tc].actual = "FAILED" + + tc++; + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'", + 'PASSED', + 'PASSED' ) + + // the following character should not be interpreted as a line terminator: \u000A testcases[tc].actual = "FAILED" + + testcases[tc++] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'", + 'PASSED', + 'PASSED' ) + // the following character should not be interpreted as a line terminator: \n testcases[tc].actual = 'FAILED' + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: u000D", + 'PASSED', + 'PASSED' ) + + // the following character should not be interpreted as a line terminator: \u000D testcases[tc].actual = "FAILED" + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/SourceText/6-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/SourceText/6-2.js new file mode 100644 index 0000000..9e7c7f9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/SourceText/6-2.js @@ -0,0 +1,129 @@ +/* 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: 6-1.js + ECMA Section: Source Text + Description: + + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. + + SourceCharacter :: + any Unicode character + + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. + + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Source Text"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // encoded quotes should not end a quote + + testcases[tc++]= new TestCase( SECTION, + "var s = 'PAS\\u0022SED'; s", + "PAS\"SED", + eval("var s = 'PAS\\u0022SED'; s") ); + + testcases[tc++]= new TestCase( SECTION, + 'var s = "PAS\\u0022SED"; s', + "PAS\"SED", + eval('var s = "PAS\\u0022SED"; s') ); + + + testcases[tc++]= new TestCase( SECTION, + "var s = 'PAS\\u0027SED'; s", + "PAS\'SED", + eval("var s = 'PAS\\u0027SED'; s") ); + + + testcases[tc++]= new TestCase( SECTION, + 'var s = "PAS\\u0027SED"; s', + "PAS\'SED", + eval('var s = "PAS\\u0027SED"; s') ); + + testcases[tc] = new TestCase( SECTION, + 'var s="PAS\\u0027SED"; s', + "PAS\'SED", + "" ) + var s = "PAS\u0027SED"; + + testcases[tc].actual = s; + + tc++; + + testcases[tc]= new TestCase( SECTION, + 'var s = "PAS\\u0027SED"; s', + "PAS\"SED", + "" ); + var s = "PAS\u0022SED"; + + testcases[tc].actual = s; + + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.10-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.10-1.js new file mode 100644 index 0000000..cf33b0a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.10-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: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + WithStatement : + with ( Expression ) Statement + + The with statement adds a computed object to the front of the scope chain + of the current execution context, then executes a statement with this + augmented scope chain, then restores the scope chain. + + Semantics + + The production WithStatement : with ( Expression ) Statement is evaluated + as follows: + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Add Result(3) to the front of the scope chain. + 5. Evaluate Statement using the augmented scope chain from step 4. + 6. Remove Result(3) from the front of the scope chain. + 7. Return Result(5). + + Discussion + Note that no matter how control leaves the embedded Statement, whether + normally or by some form of abrupt completion, the scope chain is always + restored to its former state. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.10-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The with statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // although the scope chain changes, the this value is immutable for a given + // execution context. + + array[item++] = new TestCase( SECTION, + "with( new Number() ) { this +'' }", + "[object global]", + eval("with( new Number() ) { this +'' }") ); + + // the object's functions and properties should override those of the + // global object. + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(true); with (MYOB) { parseInt() }", + true, + eval("var MYOB = new WithObject(true); with (MYOB) { parseInt() }") ); + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { NaN }", + false, + eval("var MYOB = new WithObject(false); with (MYOB) { NaN }") ); + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(NaN); with (MYOB) { Infinity }", + Number.NaN, + eval("var MYOB = new WithObject(NaN); with (MYOB) { Infinity }") ); + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { }; Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(false); with (MYOB) { }; Infinity") ); + + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }") ); + + // let us leave the with block via a break. + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity") ); + + return ( array ); +} +function WithObject( value ) { + this.prop1 = 1; + this.prop2 = new Boolean(true); + this.prop3 = "a string"; + this.value = value; + + // now we will override global functions + + this.parseInt = new Function( "return this.value" ); + this.NaN = value; + this.Infinity = value; + this.unescape = new Function( "return this.value" ); + this.escape = new Function( "return this.value" ); + this.eval = new Function( "return this.value" ); + this.parseFloat = new Function( "return this.value" ); + this.isNaN = new Function( "return this.value" ); + this.isFinite = new Function( "return this.value" ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.10.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.10.js new file mode 100644 index 0000000..08e8ebc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.10.js @@ -0,0 +1,64 @@ +/* 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: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.10-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The with statement"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION +" "+ TITLE); + + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var x; with (7) x = valueOf(); typeof x;", + "number", + eval("var x; with(7) x = valueOf(); typeof x;") ); + return ( array ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.2-1.js new file mode 100644 index 0000000..44f64b8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.2-1.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: 12.2-1.js + ECMA Section: The variable statement + Description: + + If the variable statement occurs inside a FunctionDeclaration, the + variables are defined with function-local scope in that function, as + described in section 10.1.3. Otherwise, they are defined with global + scope, that is, they are created as members of the global object, as + described in section 0. Variables are created when the execution scope + is entered. A Block does not define a new execution scope. Only Program and + FunctionDeclaration produce a new scope. Variables are initialized to the + undefined value when created. A variable with an Initializer is assigned + the value of its AssignmentExpression when the VariableStatement is executed, + not when the variable is created. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The variable statement"; + + writeHeaderToLog( SECTION +" "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( "SECTION", + "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", + void 0, + eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-1.js new file mode 100644 index 0000000..b0fe400 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-1.js @@ -0,0 +1,98 @@ +/* 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: 12.5-1.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "12.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The if statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-2.js new file mode 100644 index 0000000..9b30bfd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-2.js @@ -0,0 +1,96 @@ +/* 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: 12.5-2.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The if statement" ; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.1-1.js new file mode 100644 index 0000000..0b43603 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.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: 12.6.1-1.js + ECMA Section: The while statement + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.6.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The While statement"; + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ", + 1, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ")); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ", + 100, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ")); + + testcases[tc++] = new TestCase( SECTION, + "function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)", + 2, + eval("function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)")); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-1.js new file mode 100644 index 0000000..387cf14 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-1.js @@ -0,0 +1,75 @@ +/* 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: 12.6.2-1.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "12.6.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( "12.6.2-1", "for statement", 99, "" ); + return ( array ); +} + +function testprogram() { + myVar = 0; + + for ( ; ; ) { + if ( ++myVar == 99 ) + break; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-2.js new file mode 100644 index 0000000..788a5d0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-2.js @@ -0,0 +1,76 @@ +/* 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: 12.6.2-2.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 99, "" ); + return ( array ); +} + +function testprogram() { + myVar = 0; + + for ( ; ; myVar++ ) { + if ( myVar < 99 ) { + continue; + } else { + break; + } + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-3.js new file mode 100644 index 0000000..706f224 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-3.js @@ -0,0 +1,67 @@ +/* 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: 12.6.2-3.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + testcases[0] = new TestCase( SECTION, "for statement", 100, "" ); + + test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + continue; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-4.js new file mode 100644 index 0000000..887dea4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-4.js @@ -0,0 +1,66 @@ +/* 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: 12.6.2-4.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "12.6.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[testcases.length] = new TestCase( SECTION, + "for statement", 100, testprogram() ); + + test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + } + + return myVar; +} +function test() { + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-5.js new file mode 100644 index 0000000..3404ecf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-5.js @@ -0,0 +1,71 @@ +/* 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: 12.6.2-5.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 99, "" ); + return ( array ); +} + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + if (myVar == 99) + break; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-6.js new file mode 100644 index 0000000..1ed50d8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-6.js @@ -0,0 +1,75 @@ +/* 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: 12.6.2-6.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( "12.6.2-6", "for statement", 256, "" ); + return ( array ); +} + +function testprogram() { + var myVar; + + for ( myVar=2; ; myVar *= myVar ) { + + if (myVar > 100) + break; + continue; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-7.js new file mode 100644 index 0000000..ec9f246 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-7.js @@ -0,0 +1,72 @@ +/* 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: 12.6.2-7.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 256, "" ); + return ( array ); +} + +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 100 ; myVar *= myVar ) { + + continue; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-8.js new file mode 100644 index 0000000..ecabc06 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-8.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: 12.6.2-8.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 256, "" ); + return ( array ); +} +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 256; myVar *= myVar ) { + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-9-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-9-n.js new file mode 100644 index 0000000..ef7c12e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.2-9-n.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: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + + var SECTION = "12.6.2-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[testcases.length] = new TestCase( SECTION, + "for (i)", + "error", + "" ); + + for (i) { + } + + test(); + +function test() { + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-1.js new file mode 100644 index 0000000..9b2aa2b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-1.js @@ -0,0 +1,71 @@ +/* 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: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "12.6.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var x; Number.prototype.foo = 34; for ( j in 7 ) x = j; x", + "foo", + eval("var x; Number.prototype.foo = 34; for ( j in 7 ){x = j;} x") ); + + 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(a, b, c, d, e) { + + +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-10.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-10.js new file mode 100644 index 0000000..f2f042b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-10.js @@ -0,0 +1,112 @@ +/* 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: 12.6.3-10.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + var count = 0; + function f() { count++; return new Array("h","e","l","l","o"); } + + var result = ""; + for ( p in f() ) { result += f()[p] }; + + testcases[testcases.length] = new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + + testcases[testcases.length] = new TestCase( SECTION, + "result", + "hello", + result ); + + // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] + // LeftHandSideExpression:NewExpression:MemberExpression . Identifier + // LeftHandSideExpression:NewExpression:new MemberExpression Arguments + // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) + // LeftHandSideExpression:CallExpression:MemberExpression Arguments + // LeftHandSideExpression:CallExpression Arguments + // LeftHandSideExpression:CallExpression [ Expression ] + // LeftHandSideExpression:CallExpression . Identifier + + 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 ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-11.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-11.js new file mode 100644 index 0000000..579845a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-11.js @@ -0,0 +1,93 @@ +/* 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: 12.6.3-11.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +// 5. Get the name of the next property of Result(3) that doesn't have the +// DontEnum attribute. If there is no such property, go to step 14. + + var result = ""; + + for ( p in Number ) { result += String(p) }; + + testcases[testcases.length] = new TestCase( SECTION, + "result = \"\"; for ( p in Number ) { result += String(p) };", + "", + result ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-12.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-12.js new file mode 100644 index 0000000..b5c4b18 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-12.js @@ -0,0 +1,100 @@ +/* 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: 12.6.3-12.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. + + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var result = "PASSED"; + + for ( aVar in this ) { + if (aVar == "aVar") { + result = "FAILED" + } + }; + + testcases[testcases.length] = new TestCase( + SECTION, + "var result=''; for ( aVar in this ) { " + + "if (aVar == 'aVar') {return a failure}; result", + "PASSED", + result ); + + 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 ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-19.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-19.js new file mode 100644 index 0000000..4f386d8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-19.js @@ -0,0 +1,114 @@ +/* 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: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + var count = 0; + function f() { count++; return new Array("h","e","l","l","o"); } + + var result = ""; + for ( p in f() ) { result += f()[p] }; + + testcases[testcases.length] = new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + + testcases[testcases.length] = new TestCase( SECTION, + "result", + "hello", + result ); + + + + // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] + // LeftHandSideExpression:NewExpression:MemberExpression . Identifier + // LeftHandSideExpression:NewExpression:new MemberExpression Arguments + // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) + // LeftHandSideExpression:CallExpression:MemberExpression Arguments + // LeftHandSideExpression:CallExpression Arguments + // LeftHandSideExpression:CallExpression [ Expression ] + // LeftHandSideExpression:CallExpression . Identifier + + 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 ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-2.js new file mode 100644 index 0000000..f025a09 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-2.js @@ -0,0 +1,66 @@ +/* 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: 12.6.3-2.js + ECMA Section: 12.6.3 The for...in Statement + Description: Check the Boolean Object + + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "12.6.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", + 34, + eval("Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j] ") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-3.js new file mode 100644 index 0000000..32cce34 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-3.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: 12.6.3-3.js + ECMA Section: for..in loops + Description: + + This verifies the fix to + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112156 + for..in should take general lvalue for first argument + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.6.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var o = {}; + + var result = ""; + + for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } + + testcases[testcases.length] = new TestCase( SECTION, + "for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } result", + "123", + result ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-4.js new file mode 100644 index 0000000..d0876b6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-4.js @@ -0,0 +1,193 @@ +/* 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: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + var o = new MyObject(); + var result = 0; + + for ( MyObject in o ) { + result += o[MyObject]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "for ( MyObject in o ) { result += o[MyObject] }", + 6, + result ); + + var result = 0; + + for ( value in o ) { + result += o[value]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "for ( value in o ) { result += o[value]", + 6, + result ); + + var value = "value"; + var result = 0; + for ( value in o ) { + result += o[value]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "value = \"value\"; for ( value in o ) { result += o[value]", + 6, + result ); + + var value = 0; + var result = 0; + for ( value in o ) { + result += o[value]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( value in o ) { result += o[value]", + 6, + result ); + + // this causes a segv + + var ob = { 0:"hello" }; + var result = 0; + for ( ob[0] in o ) { + result += o[ob[0]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[0] in o ) { result += o[ob[0]]", + 6, + result ); + + var result = 0; + for ( ob["0"] in o ) { + result += o[ob["0"]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( ob[\"0\"] in o ) { result += o[o[\"0\"]]", + 6, + result ); + + var result = 0; + var ob = { value:"hello" }; + for ( ob[value] in o ) { + result += o[ob[value]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[value] in o ) { result += o[ob[value]]", + 6, + result ); + + var result = 0; + for ( ob["value"] in o ) { + result += o[ob["value"]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( ob[\"value\"] in o ) { result += o[ob[\"value\"]]", + 6, + result ); + + var result = 0; + for ( ob.value in o ) { + result += o[ob.value]; + } + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( ob.value in o ) { result += o[ob.value]", + 6, + result ); + + // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] + // LeftHandSideExpression:NewExpression:MemberExpression . Identifier + // LeftHandSideExpression:NewExpression:new MemberExpression Arguments + // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) + // LeftHandSideExpression:CallExpression:MemberExpression Arguments + // LeftHandSideExpression:CallExpression Arguments + // LeftHandSideExpression:CallExpression [ Expression ] + // LeftHandSideExpression:CallExpression . Identifier + + 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 ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-5-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-5-n.js new file mode 100644 index 0000000..1fb4ce5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-5-n.js @@ -0,0 +1,102 @@ +/* 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: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "more than one member expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( var i, p in this) { + result += this[p]; + } + + 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 ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-6-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-6-n.js new file mode 100644 index 0000000..bd6bb1b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-6-n.js @@ -0,0 +1,102 @@ +/* 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: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "bad left-hand side expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( this in o) { + result += this[p]; + } + + 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 ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-7-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-7-n.js new file mode 100644 index 0000000..5dfad13 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-7-n.js @@ -0,0 +1,102 @@ +/* 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: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "bad left-hand side expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( "a" in o) { + result += this[p]; + } + + 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 ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-8-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-8-n.js new file mode 100644 index 0000000..ac93487 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-8-n.js @@ -0,0 +1,102 @@ +/* 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: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "bad left-hand side expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( 1 in o) { + result += this[p]; + } + + 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 ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-9-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-9-n.js new file mode 100644 index 0000000..06000a4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.6.3-9-n.js @@ -0,0 +1,102 @@ +/* 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: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "object is not defined", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( var o in foo) { + result += this[o]; + } + + 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 ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.7-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.7-1-n.js new file mode 100644 index 0000000..b9b13e8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.7-1-n.js @@ -0,0 +1,67 @@ +/* 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: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "12.7.1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The continue statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "continue", + "error", + "continue" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.8-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.8-1-n.js new file mode 100644 index 0000000..9594a73 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.8-1-n.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: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.8-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The break in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "break", + "error", + "break" ); + + return ( array ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.9-1-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.9-1-n.js new file mode 100644 index 0000000..c0383c2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.9-1-n.js @@ -0,0 +1,64 @@ +/* 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: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "12.9-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The return statement"); + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "return", + "error", + "return" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.1.js new file mode 100644 index 0000000..7971afe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.1.js @@ -0,0 +1,137 @@ +/* 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.5.1.js + ECMA Section: 15.5.1 The String Constructor called as a Function + 15.5.1.1 String(value) + 15.5.1.2 String() + + Description: + When String is called as a function rather than as + a constructor, it performs a type conversion. + - String(value) returns a string value (not a String + object) computed by ToString(value) + - String() returns the empty string "" + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The String Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String('string primitive')", "string primitive", String('string primitive') ); + array[item++] = new TestCase( SECTION, "String(void 0)", "undefined", String( void 0) ); + array[item++] = new TestCase( SECTION, "String(null)", "null", String( null ) ); + array[item++] = new TestCase( SECTION, "String(true)", "true", String( true) ); + array[item++] = new TestCase( SECTION, "String(false)", "false", String( false ) ); + array[item++] = new TestCase( SECTION, "String(Boolean(true))", "true", String(Boolean(true)) ); + array[item++] = new TestCase( SECTION, "String(Boolean(false))", "false", String(Boolean(false)) ); + array[item++] = new TestCase( SECTION, "String(Boolean())", "false", String(Boolean(false)) ); + array[item++] = new TestCase( SECTION, "String(new Array())", "", String( new Array()) ); + array[item++] = new TestCase( SECTION, "String(new Array(1,2,3))", "1,2,3", String( new Array(1,2,3)) ); + + + array[item++] = new TestCase( SECTION, "String( Number.NaN )", "NaN", String( Number.NaN ) ); + array[item++] = new TestCase( SECTION, "String( 0 )", "0", String( 0 ) ); + array[item++] = new TestCase( SECTION, "String( -0 )", "0", String( -0 ) ); + array[item++] = new TestCase( SECTION, "String( Number.POSITIVE_INFINITY )", "Infinity", String( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "String( Number.NEGATIVE_INFINITY )", "-Infinity", String( Number.NEGATIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); + + // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 + + array[item++] = new TestCase( SECTION, "String( 1 )", "1", String( 1 ) ); + array[item++] = new TestCase( SECTION, "String( 10 )", "10", String( 10 ) ); + array[item++] = new TestCase( SECTION, "String( 100 )", "100", String( 100 ) ); + array[item++] = new TestCase( SECTION, "String( 1000 )", "1000", String( 1000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000 )", "10000", String( 10000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000000000 )", "10000000000", String( 10000000000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) ); + + array[item++] = new TestCase( SECTION, "String( 12345 )", "12345", String( 12345 ) ); + array[item++] = new TestCase( SECTION, "String( 1234567890 )", "1234567890", String( 1234567890 ) ); + + array[item++] = new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); + array[item++] = new TestCase( SECTION, "String( -10 )", "-10", String( -10 ) ); + array[item++] = new TestCase( SECTION, "String( -100 )", "-100", String( -100 ) ); + array[item++] = new TestCase( SECTION, "String( -1000 )", "-1000", String( -1000 ) ); + array[item++] = new TestCase( SECTION, "String( -1000000000 )", "-1000000000", String( -1000000000 ) ); + array[item++] = new TestCase( SECTION, "String( -1000000000000000 )", "-1000000000000000", String( -1000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( -100000000000000000000 )", "-100000000000000000000", String( -100000000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( -1000000000000000000000 )", "-1e+21", String( -1000000000000000000000 ) ); + + array[item++] = new TestCase( SECTION, "String( -12345 )", "-12345", String( -12345 ) ); + array[item++] = new TestCase( SECTION, "String( -1234567890 )", "-1234567890", String( -1234567890 ) ); + + // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, + array[item++] = new TestCase( SECTION, "String( 1.0000001 )", "1.0000001", String( 1.0000001 ) ); + + + // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 + + // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 + + array[item++] = new TestCase( SECTION, "String( 1000000000000000000000 )", "1e+21", String( 1000000000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000000000000000000000 )", "1e+22", String( 10000000000000000000000 ) ); + + // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 + array[item++] = new TestCase( SECTION, "String( 1.2345 )", "1.2345", String( 1.2345)); + array[item++] = new TestCase( SECTION, "String( 1.234567890 )", "1.23456789", String( 1.234567890 )); + + array[item++] = new TestCase( SECTION, "String( .12345 )", "0.12345", String(.12345 ) ); + array[item++] = new TestCase( SECTION, "String( .012345 )", "0.012345", String(.012345) ); + array[item++] = new TestCase( SECTION, "String( .0012345 )", "0.0012345", String(.0012345) ); + array[item++] = new TestCase( SECTION, "String( .00012345 )", "0.00012345", String(.00012345) ); + array[item++] = new TestCase( SECTION, "String( .000012345 )", "0.000012345", String(.000012345) ); + array[item++] = new TestCase( SECTION, "String( .0000012345 )", "0.0000012345", String(.0000012345) ); + array[item++] = new TestCase( SECTION, "String( .00000012345 )", "1.2345e-7", String(.00000012345)); + + array[item++] = new TestCase( "15.5.2", "String()", "", String() ); + + 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/String/15.5.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.2.js new file mode 100644 index 0000000..59daad0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.2.js @@ -0,0 +1,112 @@ +/* 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.5.2.js + ECMA Section: 15.5.2 The String Constructor + 15.5.2.1 new String(value) + 15.5.2.2 new String() + + Description: When String is called as part of a new expression, it + is a constructor; it initializes the newly constructed + object. + + - The prototype property of the newly constructed + object is set to the original String prototype object, + the one that is the intial value of String.prototype + - The internal [[Class]] property of the object is "String" + - The value of the object is ToString(value). + - If no value is specified, its value is the empty string. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new String('string primitive')", "object", typeof new String('string primitive') ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String('string primitive')).valueOf()", 'string primitive', (new String('string primitive')).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String('string primitive')).substring", String.prototype.substring, (new String('string primitive')).substring ); + + array[item++] = new TestCase( SECTION, "typeof new String(void 0)", "object", typeof new String(void 0) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(void 0)).valueOf()", "undefined", (new String(void 0)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(void 0)).toString", String.prototype.toString, (new String(void 0)).toString ); + + array[item++] = new TestCase( SECTION, "typeof new String(null)", "object", typeof new String(null) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(null)).valueOf()", "null", (new String(null)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(null)).valueOf", String.prototype.valueOf, (new String(null)).valueOf ); + + array[item++] = new TestCase( SECTION, "typeof new String(true)", "object", typeof new String(true) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(true)).valueOf()", "true", (new String(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(true)).charAt", String.prototype.charAt, (new String(true)).charAt ); + + array[item++] = new TestCase( SECTION, "typeof new String(false)", "object", typeof new String(false) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(false)).valueOf()", "false", (new String(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(false)).charCodeAt", String.prototype.charCodeAt, (new String(false)).charCodeAt ); + + array[item++] = new TestCase( SECTION, "typeof new String(new Boolean(true))", "object", typeof new String(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(new Boolean(true))).valueOf()", "true", (new String(new Boolean(true))).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(new Boolean(true))).indexOf", String.prototype.indexOf, (new String(new Boolean(true))).indexOf ); + + array[item++] = new TestCase( SECTION, "typeof new String()", "object", typeof new String() ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String()).valueOf()", '', (new String()).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String()).lastIndexOf", String.prototype.lastIndexOf, (new String()).lastIndexOf ); + + array[item++] = new TestCase( SECTION, "typeof new String('')", "object", typeof new String('') ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String('')).valueOf()", '', (new String('')).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String('')).split", String.prototype.split, (new String('')).split ); + + 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/String/15.5.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-1.js new file mode 100644 index 0000000..af15536 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-1.js @@ -0,0 +1,73 @@ +/* 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.5.3.1-1.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontEnum attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); + + array[item++] = new TestCase( SECTION, + "var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str", + "", + eval("var str='';for ( p in String ) { if ( p == 'prototype' ) 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/String/15.5.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-2.js new file mode 100644 index 0000000..d4d7fa3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.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.5.3.1-2.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the ReadOnly attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "String.prototype=null;String.prototype", + String.prototype, + eval("String.prototype=null;String.prototype") ); + 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/String/15.5.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-3.js new file mode 100644 index 0000000..01da54a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-3.js @@ -0,0 +1,67 @@ +/* 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.5.3.1-3.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "delete( String.prototype )", false, eval("delete ( String.prototype )") ); + 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/String/15.5.3.1-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-4.js new file mode 100644 index 0000000..fbaea31 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.1-4.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.5.3.1-4.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "delete( String.prototype );String.prototype", String.prototype, eval("delete ( String.prototype );String.prototype") ); + 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/String/15.5.3.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.2-1.js new file mode 100644 index 0000000..f5fb16d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.2-1.js @@ -0,0 +1,195 @@ +/* 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.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This test covers Basic Latin (range U+0020 - U+007F) + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + + var SECTION = "15.5.3.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.fromCharCode()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof String.fromCharCode", "function", typeof String.fromCharCode ); + array[item++] = new TestCase( SECTION, "typeof String.prototype.fromCharCode", "undefined", typeof String.prototype.fromCharCode ); + array[item++] = new TestCase( SECTION, "var x = new String(); typeof x.fromCharCode", "undefined", eval("var x = new String(); typeof x.fromCharCode") ); + array[item++] = new TestCase( SECTION, "String.fromCharCode.length", 1, String.fromCharCode.length ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode()", "", String.fromCharCode() ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0020)", " ", String.fromCharCode(0x0020) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0021)", "!", String.fromCharCode(0x0021) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0022)", "\"", String.fromCharCode(0x0022) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0023)", "#", String.fromCharCode(0x0023) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0024)", "$", String.fromCharCode(0x0024) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0025)", "%", String.fromCharCode(0x0025) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0026)", "&", String.fromCharCode(0x0026) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0027)", "\'", String.fromCharCode(0x0027) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0028)", "(", String.fromCharCode(0x0028) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0029)", ")", String.fromCharCode(0x0029) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002A)", "*", String.fromCharCode(0x002A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002B)", "+", String.fromCharCode(0x002B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002C)", ",", String.fromCharCode(0x002C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002D)", "-", String.fromCharCode(0x002D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002E)", ".", String.fromCharCode(0x002E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002F)", "/", String.fromCharCode(0x002F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0030)", "0", String.fromCharCode(0x0030) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0031)", "1", String.fromCharCode(0x0031) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0032)", "2", String.fromCharCode(0x0032) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0033)", "3", String.fromCharCode(0x0033) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0034)", "4", String.fromCharCode(0x0034) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0035)", "5", String.fromCharCode(0x0035) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0036)", "6", String.fromCharCode(0x0036) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0037)", "7", String.fromCharCode(0x0037) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0038)", "8", String.fromCharCode(0x0038) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0039)", "9", String.fromCharCode(0x0039) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003A)", ":", String.fromCharCode(0x003A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003B)", ";", String.fromCharCode(0x003B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003C)", "<", String.fromCharCode(0x003C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003D)", "=", String.fromCharCode(0x003D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003E)", ">", String.fromCharCode(0x003E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003F)", "?", String.fromCharCode(0x003F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0050)", "P", String.fromCharCode(0x0050) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0051)", "Q", String.fromCharCode(0x0051) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0052)", "R", String.fromCharCode(0x0052) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0053)", "S", String.fromCharCode(0x0053) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0054)", "T", String.fromCharCode(0x0054) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0055)", "U", String.fromCharCode(0x0055) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0056)", "V", String.fromCharCode(0x0056) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0057)", "W", String.fromCharCode(0x0057) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0058)", "X", String.fromCharCode(0x0058) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0059)", "Y", String.fromCharCode(0x0059) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005A)", "Z", String.fromCharCode(0x005A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005B)", "[", String.fromCharCode(0x005B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005C)", "\\", String.fromCharCode(0x005C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005D)", "]", String.fromCharCode(0x005D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005E)", "^", String.fromCharCode(0x005E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005F)", "_", String.fromCharCode(0x005F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0060)", "`", String.fromCharCode(0x0060) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0061)", "a", String.fromCharCode(0x0061) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0062)", "b", String.fromCharCode(0x0062) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0063)", "c", String.fromCharCode(0x0063) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0064)", "d", String.fromCharCode(0x0064) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0065)", "e", String.fromCharCode(0x0065) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0066)", "f", String.fromCharCode(0x0066) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0067)", "g", String.fromCharCode(0x0067) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0068)", "h", String.fromCharCode(0x0068) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0069)", "i", String.fromCharCode(0x0069) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006A)", "j", String.fromCharCode(0x006A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006B)", "k", String.fromCharCode(0x006B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006C)", "l", String.fromCharCode(0x006C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006D)", "m", String.fromCharCode(0x006D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006E)", "n", String.fromCharCode(0x006E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006F)", "o", String.fromCharCode(0x006F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0070)", "p", String.fromCharCode(0x0070) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0071)", "q", String.fromCharCode(0x0071) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0072)", "r", String.fromCharCode(0x0072) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0073)", "s", String.fromCharCode(0x0073) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0074)", "t", String.fromCharCode(0x0074) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0075)", "u", String.fromCharCode(0x0075) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0076)", "v", String.fromCharCode(0x0076) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0077)", "w", String.fromCharCode(0x0077) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0078)", "x", String.fromCharCode(0x0078) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0079)", "y", String.fromCharCode(0x0079) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007A)", "z", String.fromCharCode(0x007A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007B)", "{", String.fromCharCode(0x007B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007C)", "|", String.fromCharCode(0x007C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007D)", "}", String.fromCharCode(0x007D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007E)", "~", String.fromCharCode(0x007E) ); +// array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0020, 0x007F)", "", String.fromCharCode(0x0040, 0x007F) ); + + 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/String/15.5.3.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.2-2.js new file mode 100644 index 0000000..4ff3693 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.2-2.js @@ -0,0 +1,80 @@ +/* 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.5.3.2-2.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This tests String.fromCharCode with multiple arguments. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + + var SECTION = "15.5.3.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.fromCharCode()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var MYSTRING = String.fromCharCode(eval(\"var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;\")); MYSTRING", + " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", + eval( "var MYSTRING = String.fromCharCode(" + eval("var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;") +"); MYSTRING" )); + + array[item++] = new TestCase( SECTION, + "MYSTRING.length", + 0x007f - 0x0020, + MYSTRING.length ); + 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/String/15.5.3.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.2-3.js new file mode 100644 index 0000000..e6b515e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.2-3.js @@ -0,0 +1,122 @@ +/* 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.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This test covers Basic Latin (range U+0020 - U+007F) + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + + var SECTION = "15.5.3.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.fromCharCode()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = 256; CHARCODE < 65536; CHARCODE+=333 ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = 65535; CHARCODE < 65538; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = Math.pow(2,32)-1; CHARCODE < Math.pow(2,32)+1; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = 0; CHARCODE > -65536; CHARCODE-=3333 ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65536)).charCodeAt(0)", 0, (String.fromCharCode(65536)).charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65537)).charCodeAt(0)", 1, (String.fromCharCode(65537)).charCodeAt(0) ); + + return array; +} +function ToUint16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + num = num % Math.pow(2,16); + num = ( num > -65536 && num < 0) ? 65536 + num : num; + return num; +} + +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/String/15.5.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.js new file mode 100644 index 0000000..3a1012d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.3.js @@ -0,0 +1,74 @@ +/* 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.5.3.1.js + ECMA Section: 15.5.3 Properties of the String Constructor + + Description: The value of the internal [[Prototype]] property of + the String constructor is the Function prototype + object. + + In addition to the internal [[Call]] and [[Construct]] + properties, the String constructor also has the length + property, as well as properties described in 15.5.3.1 + and 15.5.3.2. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3"; + var VERSION = "ECMA_2"; + startTest(); + var passed = true; + writeHeaderToLog( SECTION + " Properties of the String Constructor" ); + + var testcases = getTestCases(); + var tc= 0; + +// all tests must call a function that returns an array of TestCase objects. + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype", Function.prototype, String.__proto__ ); + array[item++] = new TestCase( SECTION, "String.length", 1, String.length ); + 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(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.1.js new file mode 100644 index 0000000..393f25a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.1.js @@ -0,0 +1,66 @@ +/* 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.5.4.1.js + ECMA Section: 15.5.4.1 String.prototype.constructor + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.5.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.constructor == String", true, String.prototype.constructor == String ); + array[item++] = new TestCase( SECTION, "var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()", + "[object String]", + eval("var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()") ); + return ( array ); +} +function test( array ) { + for ( ; 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(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.10-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.10-1.js new file mode 100644 index 0000000..454afef --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.10-1.js @@ -0,0 +1,218 @@ +/* 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.5.4.10-1.js + ECMA Section: 15.5.4.10 String.prototype.substring( start, end ) + Description: + + 15.5.4.10 String.prototype.substring(start, end) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to character position + end of the string. The result is a string value, not a String object. + + If either argument is NaN or negative, it is replaced with zero; if either + argument is larger than the length of the string, it is replaced with the + length of the string. + + If start is larger than end, they are swapped. + + When the substring method is called with two arguments start and end, the + following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Call ToInteger(start). + 3. Call ToInteger (end). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(2), 0), Result(4)). + 6. Compute min(max(Result(3), 0), Result(4)). + 7. Compute min(Result(5), Result(6)). + 8. Compute max(Result(5), Result(6)). + 9. Return a string whose length is the difference between Result(8) and + Result(7), containing characters from Result(1), namely the characters + with indices Result(7) through Result(8)1, in ascending order. + + Note that the substring function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.10-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.substring( start, end )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + + // test cases for when substring is called with no arguments. + + // this is a string object + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(''); s.substring(1,0)", + "", + eval("var s = new String(''); s.substring(1,0)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(true, false)", + "t", + eval("var s = new String('this is a string object'); s.substring(false, true)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN, Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN, Infinity)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(Infinity, NaN)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity, Infinity)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01, 0)", + "", + eval("var s = new String('this is a string object'); s.substring(-0.01,0)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length, s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length, s.length)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1, 0)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(s.length+1, 0)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)") ); + + // this is not a String object, start is not an integer + + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)", + "1", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')", + "3", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')") ); + + + // this is an object object + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)", + "[object ", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,obj.toString().length)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8, obj.toString().length)") ); + + // this is a function object + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8, Infinity)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8,Infinity)") ); + // this is a number object + array[item++] = new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)") ); + + // this is the Math object + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)", + "[ob", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)") ); + + // this is a Boolean object + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))", + "f", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))") ); + + // this is a user defined object + + array[item++] = new TestCase( SECTION, + "var obj = new MyObject( void 0 ); obj.substring(0, 100)", + "undefined", + eval( "var obj = new MyObject( void 0 ); obj.substring(0,100)") ); + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-1.js new file mode 100644 index 0000000..b24a9cc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-1.js @@ -0,0 +1,514 @@ +/* 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.5.4.11-1.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); + + // Basic Latin, Latin-1 Supplement, Latin Extended A + for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode(i); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + + } + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-2.js new file mode 100644 index 0000000..b75f3e8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-2.js @@ -0,0 +1,633 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +/* + Safari Changes: This test differs from the mozilla tests in two significant + ways. + First, the lower case range for Georgian letters in this file is the + correct range according to the Unicode 5.0 standard, as opposed to the + Georgian caseless range that mozilla uses. + Secondly this test uses an array for expected results with two entries, + instead of a single expected result. This allows us to accept Unicode 4.0 or + Unicode 5.0 results as correct, as opposed to the mozilla test, which assumes + Unicode 5.0. This allows Safari to pass this test on OS' with different + Unicode standards implemented (e.g. Tiger and XP) +*/ + var SECTION = "15.5.4.11-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Georgian + // Range: U+10A0 to U+10FF + for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Array(new Unicode( i, 4 ), new Unicode( i, 5 )); + +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCaseDualExpected( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + } + + return array; +} + +/* + * TestCase constructor + * + */ + +function TestCaseDualExpected( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResultDualExpected( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} + +// Added so that either Unicode 4.0 or 5.0 results will be considered correct. +function writeTestCaseResultDualExpected( expect, actual, string ) { + var passed = getTestCaseResultDualExpected( expect, actual ); + writeFormattedResult( expect[1].lower, actual, string, passed ); + return passed; +} +/* + * Added so that either Unicode 4.0 or 5.0 results will be considered correct. + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ +function getTestCaseResultDualExpected( expect, actual ) { + expectedU4 = expect[0].lower; + expectedU5 = expect[1].lower; + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + + if ( expectedU4 != expectedU4 ) { + if ( typeof expectedU4 == "object" ) { + expectedU4 = "NaN object"; + } else { + expectedU4 = "NaN number"; + } + } + if ( expectedU5 != expectedU5 ) { + if ( typeof expectedU5 == "object" ) { + expectedU5 = "NaN object"; + } else { + expectedU5 = "NaN number"; + } + } + + var passed = ( expectedU4 == actual || expectedU5 == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed && + typeof(actual) == "number" && + (typeof(expectedU4) == "number" || + typeof(expectedU5) == "number")) { + if (( Math.abs(actual-expectedU4) < 0.0000001 ) || ( Math.abs(actual-expectedU5) < 0.0000001 )) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expectedU4) != typeof(actual) && typeof(expectedU5) != typeof(actual) ) { + passed = false; + } + + return passed; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResultDualExpected( + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} + +function Unicode( c, version ) { + u = GetUnicodeValues( c, version ); + this.upper = u[0]; + this.lower = u[1] + return this; +} + +function GetUnicodeValues( c, version ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( version == 5 ) { + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 7264; //48; + return u; + } + if ( c >= 0x2D00 && c <= 0x2D25 ) { + u[0] = c; + u[1] = c; + return u; + } + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-3.js new file mode 100644 index 0000000..b718188 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-3.js @@ -0,0 +1,509 @@ +/* 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.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + var U = new Unicode(i); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + } + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-4.js new file mode 100644 index 0000000..5258dc2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-4.js @@ -0,0 +1,508 @@ +/* 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.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Hiragana (no upper / lower case) + // Range: U+3040 to U+309F + + for ( var i = 0x3040; i <= 0x309F; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + } + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + this.upper = c; + this.lower = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + this.upper = c - 32; + this.lower = c; + return this; + } + if ( c == 0x00FF ) { + this.upper = 0x0178; + this.lower = c; + return this; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + this.upper = c; + this.lower = 0x0069; + return this; + } + if ( c == 0x0131 ) { + this.upper = 0x0049; + this.lower = c; + return this; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x0178 ) { + this.upper = c; + this.lower = 0x00FF; + return this; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x017F ) { + this.upper = 0x0053; + this.lower = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c+1; + } else { + this.upper = c-1; + this.lower = c; + } + return this; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + this.upper = c; + this.lower = c + 80; + return this; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + this.upper = c - 32; + this.lower = c; + return this; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + this.upper = c -80; + this.lower = c; + return this; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c +1; + } else { + this.upper = c - 1; + this.lower = c; + } + return this; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x0561 && c < 0x0587 ) { + this.upper = c - 48; + this.lower = c; + return this; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + this.upper = c; + this.lower = c; + return this; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return this; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-5.js new file mode 100644 index 0000000..4d42091 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-5.js @@ -0,0 +1,514 @@ +/* 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.5.4.11-5.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); + + // Cyrillic (part) + // Range: U+0400 to U+04FF + for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + + } + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-6.js new file mode 100644 index 0000000..a3282f6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.11-6.js @@ -0,0 +1,511 @@ +/* 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.5.4.11-6.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Armenian + // Range: U+0530 to U+058F + for ( var i = 0x0530; i <= 0x058F; i++ ) { + + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + + } + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-1.js new file mode 100644 index 0000000..fb8f0df --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-1.js @@ -0,0 +1,527 @@ +/* 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.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toUpperCase.length", 0, String.prototype.toUpperCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toUpperCase.length", false, delete String.prototype.toUpperCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toupperCase.length; String.prototype.toupperCase.length", 0, eval("delete String.prototype.toUpperCase.length; String.prototype.toUpperCase.length") ); + + // Basic Latin, Latin-1 Supplement, Latin Extended A + for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode( i ); + + // XXX DF fails in java + + if ( i == 0x00DF ) { + continue; + } + + + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + } + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, uppercase takes two code points + if (c == 0x0149) { + u[0] = 0x02bc; + u[1] = c; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + if (c == 0x0587) { + u[0] = 0x0535; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-2.js new file mode 100644 index 0000000..2d8c694 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-2.js @@ -0,0 +1,514 @@ +/* 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.5.4.12-2.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var TEST_STRING = ""; + var EXPECT_STRING = ""; + + // basic latin test + + for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); + } + + // don't print out the value of the strings since they contain control + // characters that break the driver + var isEqual = EXPECT_STRING == (new String( TEST_STRING )).toUpperCase(); + + array[item++] = new TestCase( SECTION, + "isEqual", + true, + isEqual); + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-3.js new file mode 100644 index 0000000..1561db5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-3.js @@ -0,0 +1,556 @@ +/* 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.5.4.12-3.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Georgian + // Range: U+10A0 to U+10FF + for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + + } + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); + } + + // Hiragana (no upper / lower case) + // Range: U+3040 to U+309F + + for ( var i = 0x3040; i <= 0x309F; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); + } + + +/* + var TEST_STRING = ""; + var EXPECT_STRING = ""; + + // basic latin test + + for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); + } +*/ + + + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-4.js new file mode 100644 index 0000000..54e365e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-4.js @@ -0,0 +1,511 @@ +/* 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.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Cyrillic (part) + // Range: U+0400 to U+04FF + for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U =new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + U.upper, + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + + } + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-5.js new file mode 100644 index 0000000..bbcfad4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.12-5.js @@ -0,0 +1,523 @@ +/* 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.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Armenian + // Range: U+0530 to U+058F + for ( var i = 0x0530; i <= 0x058F; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + + } + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, uppercase takes two code points + if (c == 0x0149) { + u[0] = 0x02bc; + u[1] = c; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + if (c == 0x0587) { + u[0] = 0x0535; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-1.js new file mode 100644 index 0000000..3569556 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-1.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.5.4.2-1.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.4.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); + array[item++] = new TestCase( SECTION, "(new String()).toString()", "", (new String()).toString() ); + array[item++] = new TestCase( SECTION, "(new String(\"\")).toString()", "", (new String("")).toString() ); + array[item++] = new TestCase( SECTION, "(new String( String() )).toString()","", (new String(String())).toString() ); + array[item++] = new TestCase( SECTION, "(new String( \"h e l l o\" )).toString()", "h e l l o", (new String("h e l l o")).toString() ); + array[item++] = new TestCase( SECTION, "(new String( 0 )).toString()", "0", (new String(0)).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 ); + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-2-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-2-n.js new file mode 100644 index 0000000..b444bae --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-2-n.js @@ -0,0 +1,74 @@ +/* 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.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.4.2-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()", + "error", + "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-3.js new file mode 100644 index 0000000..f1855e2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2-3.js @@ -0,0 +1,87 @@ +/* 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.5.4.2-3.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + + var SECTION = "15.5.4.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()", + "", + "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()" ); + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()", + "0", + "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()" ); + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()", + "hello", + "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()" ); + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()", + "", + "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2.js new file mode 100644 index 0000000..8779e33 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.2.js @@ -0,0 +1,92 @@ +/* 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.5.4.2.js + ECMA Section: 15.5.4.2 String.prototype.toString + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.5.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.tostring"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toString.__proto__", Function.prototype, String.prototype.toString.__proto__ ); + array[item++] = new TestCase( SECTION, + "String.prototype.toString() == String.prototype.valueOf()", + true, + String.prototype.toString() == String.prototype.valueOf() ); + + array[item++] = new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); + array[item++] = new TestCase( SECTION, "String.prototype.toString.length", 0, String.prototype.toString.length ); + + + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); + + return ( array ); +} +function test( array ) { + for ( ; 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(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-1.js new file mode 100644 index 0000000..d55c437 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-1.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.5.4.3-1.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.valueOf.length", 0, String.prototype.valueOf.length ); + + array[item++] = new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); + array[item++] = new TestCase( SECTION, "(new String()).valueOf()", "", (new String()).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(\"\")).valueOf()", "", (new String("")).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String( String() )).valueOf()","", (new String(String())).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String( \"h e l l o\" )).valueOf()", "h e l l o", (new String("h e l l o")).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String( 0 )).valueOf()", "0", (new String(0)).valueOf() ); + 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 ); + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-2.js new file mode 100644 index 0000000..21d3407 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-2.js @@ -0,0 +1,89 @@ +/* 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.5.4.3-2.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + + var SECTION = "15.5.4.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valof()", + "", + "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valueOf()" ); + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valof()", + "0", + "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valueOf()" ); + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valof()", + "hello", + "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valueOf()" ); + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valof()", + "", + "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valueOf()" ); +/* + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()" ); +*/ + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-3-n.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-3-n.js new file mode 100644 index 0000000..f7c420a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.3-3-n.js @@ -0,0 +1,72 @@ +/* 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.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + + var SECTION = "15.5.4.3-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-1.js new file mode 100644 index 0000000..e0dc042 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-1.js @@ -0,0 +1,87 @@ +/* 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.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + + In this test, this is a String, pos is an integer, and + all pos are in range. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( i = 0x0020; i < 0x007e; i++, item++) { + array[item] = new TestCase( SECTION, + "TEST_STRING.charAt("+item+")", + String.fromCharCode( i ), + TEST_STRING.charAt( item ) ); + } + for ( i = 0x0020; i < 0x007e; i++, item++) { + array[item] = new TestCase( SECTION, + "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")", + true, + TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 ) + ); + } + array[item++] = new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length ); + + return array; +} +function test() { + writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + 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/String/15.5.4.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-2.js new file mode 100644 index 0000000..0ca8fb2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-2.js @@ -0,0 +1,141 @@ +/* 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.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)", "u", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)", "e", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(0)", "", eval("x=new String();x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(1)", "", eval("x=new String();x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(-1)", "", eval("x=new String();x.charAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(NaN)", "", eval("x=new String();x.charAt(Number.NaN)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(Number.POSITIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.POSITIVE_INFINITY)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(Number.NEGATIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.NEGATIVE_INFINITY)") ); + + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(0)", "1", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(0)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(1)", "2", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(1)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(2)", "3", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(2)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(3)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(3)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(4)", "5", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(4)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(5)", "6", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(5)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(6)", "7", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(6)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(7)", "8", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(7)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(8)", "9", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(8)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(9)", "0", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(9)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(10)", "", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(10)") ); + + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)") ); + + // MyOtherObject.toString will return "[object Object] + + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)", "[", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)", "o", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)", " ", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)", "O", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)", "]", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)") ); + + 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 +''" ); + this.charAt = String.prototype.charAt; +} +function MyOtherObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.charAt = String.prototype.charAt; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-3.js new file mode 100644 index 0000000..7de6788 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-3.js @@ -0,0 +1,117 @@ +/* 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.5.4.4-3.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to a user-defined function. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function MyObject (v) { + this.value = v; + this.toString = new Function( "return this.value +'';" ); + this.valueOf = new Function( "return this.value" ); + this.charAt = String.prototype.charAt; +} +function getTestCases() { + var array = new Array(); + var item = 0; + + var foo = new MyObject('hello'); + + + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "h", foo.charAt(0) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "e", foo.charAt(1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(2) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(3) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "o", foo.charAt(4) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(-1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(5) ); + + var boo = new MyObject(true); + + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "t", boo.charAt(0) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "r", boo.charAt(1) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "u", boo.charAt(2) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "e", boo.charAt(3) ); + + var noo = new MyObject( Math.PI ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "3", noo.charAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", ".", noo.charAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "4", noo.charAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(4) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "5", noo.charAt(5) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "9", noo.charAt(6) ); + + 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(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-4.js new file mode 100644 index 0000000..69ee2e5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.4-4.js @@ -0,0 +1,159 @@ +/* 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.5.4.4-4.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to primitive types.. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-4"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; +/* + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); +*/ + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") ); + + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + + array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + + array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + + + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)", "2", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)", "3", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)") ); + + array[item++] = new TestCase( SECTION, "x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)", "", eval("x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)") ); + + array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)") ); + + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(5)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(6)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(7)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(8)", "O", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(8)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(9)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(9)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(10)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(10)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(11)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(11)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(12)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(12)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(13)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(13)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(14)", "]", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(14)") ); + + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)", "F", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)", "u", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)", "i", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)", "]", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)", "", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)") ); + + + 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/String/15.5.4.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-1.js new file mode 100644 index 0000000..62d42b4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-1.js @@ -0,0 +1,89 @@ +/* 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.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + + for ( j = 0, i = 0x0020; i < 0x007e; i++, j++ ) { + array[j] = new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", i, TEST_STRING.charCodeAt( j ) ); + } + + item = array.length; + + array[item++] = new TestCase( SECTION, 'TEST_STRING.charCodeAt('+i+')', NaN, TEST_STRING.charCodeAt( i ) ); + 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/String/15.5.4.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-2.js new file mode 100644 index 0000000..2570687 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-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.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var x; + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)", 0x0031, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)", 0x0032, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)", 0x0033, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)", NaN, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)") ); + + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)", 0x005B, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)", 0x006F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)", 0x0065, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)", 0x0063, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)", 0x0074, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)") ); + + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)", 0x0020, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)") ); + + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)", 0x004F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)") ); + + 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/String/15.5.4.5-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-3.js new file mode 100644 index 0000000..20d380b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-3.js @@ -0,0 +1,136 @@ +/* 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.5.4.5-3.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + test(); + +function MyObject (v) { + this.value = v; + this.toString = new Function ( "return this.value +\"\"" ); + this.charCodeAt = String.prototype.charCodeAt; +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + var foo = new MyObject('hello'); + + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(0)", 0x0068, foo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(1)", 0x0065, foo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(2)", 0x006c, foo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(3)", 0x006c, foo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(4)", 0x006f, foo.charCodeAt(4) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(-1)", Number.NaN, foo.charCodeAt(-1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(5)", Number.NaN, foo.charCodeAt(5) ); + + var boo = new MyObject(true); + + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(0)", 0x0074, boo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(1)", 0x0072, boo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(2)", 0x0075, boo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(3)", 0x0065, boo.charCodeAt(3) ); + + var noo = new MyObject( Math.PI ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(0)", 0x0033, noo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(1)", 0x002E, noo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(2)", 0x0031, noo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(3)", 0x0034, noo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(4)", 0x0031, noo.charCodeAt(4) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(5)", 0x0035, noo.charCodeAt(5) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(6)", 0x0039, noo.charCodeAt(6) ); + + var noo = new MyObject( null ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(0)", 0x006E, noo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(1)", 0x0075, noo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(2)", 0x006C, noo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(3)", 0x006C, noo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(4)", NaN, noo.charCodeAt(4) ); + + var noo = new MyObject( void 0 ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(0)", 0x0075, noo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(1)", 0x006E, noo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(2)", 0x0064, noo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(3)", 0x0065, noo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(4)", 0x0066, noo.charCodeAt(4) ); + + 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/String/15.5.4.5-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-4.js new file mode 100644 index 0000000..cd99bc2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-4.js @@ -0,0 +1,80 @@ +/* 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.5.4.5-4.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + + Description: Returns a nonnegative integer less than 2^16. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var VERSION = "0697"; + startTest(); + var SECTION = "15.5.4.5-4"; + + writeHeaderToLog( SECTION + " String.prototype.charCodeAt(pos)" ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var MAXCHARCODE = Math.pow(2,16); + var item=0, CHARCODE; + + for ( CHARCODE=0; CHARCODE <256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); + } + for ( CHARCODE=256; CHARCODE < 65536; CHARCODE+=999 ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); + } + + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); + + 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(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-5.js new file mode 100644 index 0000000..091f5e8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-5.js @@ -0,0 +1,111 @@ +/* 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.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = ""; + + for ( var i = 0x0000; i < 255; i++ ) { + TEST_STRING += String.fromCharCode( i ); + } + + + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + + for ( var j = 0; j < 255; j++ ) { + array[item++] = new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", j, TEST_STRING.charCodeAt(j) ); + } + 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/String/15.5.4.5-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-6.js new file mode 100644 index 0000000..8b7ae18 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.5-6.js @@ -0,0 +1,97 @@ +/* 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.5.4.5-6.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-6"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "true", + eval("var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + + array[item++] = new TestCase( SECTION, + "var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "1234", + eval("var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + + array[item++] = new TestCase( SECTION, + "var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "hello", + eval("var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + 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/String/15.5.4.6-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.6-1.js new file mode 100644 index 0000000..ab9d725 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.6-1.js @@ -0,0 +1,158 @@ +/* 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.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.indexOf"; + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var j = 0; + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf(" +String.fromCharCode(i)+ ", 0)", + k, + TEST_STRING.indexOf( String.fromCharCode(i), 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.indexOf( String.fromCharCode(i), k ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+k+1+")", + -1, + TEST_STRING.indexOf( String.fromCharCode(i), k+1 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+0+")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); + } + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + -1, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); + } + + array[j++] = new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.indexOf( TEST_STRING, 0 ) ); + array[j++] = new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 1 )", -1, TEST_STRING.indexOf( TEST_STRING, 1 )); + + return array; +} + +function test() { + writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + + 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/String/15.5.4.6-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.6-2.js new file mode 100644 index 0000000..6054a51 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.6-2.js @@ -0,0 +1,259 @@ +/* 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.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.7 + The length property of the indexOf method is 1 +* +*/ + var SECTION = "15.5.4.6-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.indexOf"; + var BUGNUMBER="105721"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +// the following test regresses http://scopus/bugsplat/show_bug.cgi?id=105721 + +function f() { + return this; +} +function g() { + var h = f; + return h(); +} + +function MyObject (v) { + this.value = v; + this.toString = new Function ( "return this.value +\"\""); + this.indexOf = String.prototype.indexOf; +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + // regress http://scopus/bugsplat/show_bug.cgi?id=105721 + + array[item++] = new TestCase( SECTION, "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", GLOBAL, g().toString() ); + + + array[item++] = new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length ); + array[item++] = new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") ); + array[item++] = new TestCase( SECTION, "delete String.prototype.indexOf.length", false, delete String.prototype.indexOf.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.indexOf.length; String.prototype.indexOf.length", 1, eval("delete String.prototype.indexOf.length; String.prototype.indexOf.length") ); + + array[item++] = new TestCase( SECTION, "var s = new String(); s.indexOf()", -1, eval("var s = new String(); s.indexOf()") ); + + // some Unicode tests. + + // generate a test string. + + var TEST_STRING = ""; + + for ( var u = 0x00A1; u <= 0x00FF; u++ ) { + TEST_STRING += String.fromCharCode( u ); + } + + for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + array[item++] = new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + " )", + i, + TEST_STRING.indexOf( String.fromCharCode(u) ) ); + } + for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + array[item++] = new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + ", void 0 )", + i, + TEST_STRING.indexOf( String.fromCharCode(u), void 0 ) ); + } + + + + var foo = new MyObject('hello'); + + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('h')", 0, foo.indexOf("h") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('e')", 1, foo.indexOf("e") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('o')", 4, foo.indexOf("o") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('X')", -1, foo.indexOf("X") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf(5) ", -1, foo.indexOf(5) ); + + var boo = new MyObject(true); + + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('t')", 0, boo.indexOf("t") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('r')", 1, boo.indexOf("r") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('u')", 2, boo.indexOf("u") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('e')", 3, boo.indexOf("e") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('true')", 0, boo.indexOf("true") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('rue')", 1, boo.indexOf("rue") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('ue')", 2, boo.indexOf("ue") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('oy')", -1, boo.indexOf("oy") ); + + + var noo = new MyObject( Math.PI ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('3') ", 0, noo.indexOf('3') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('.') ", 1, noo.indexOf('.') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('4') ", 3, noo.indexOf('4') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('5') ", 5, noo.indexOf('5') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('9') ", 6, noo.indexOf('9') ); + + array[item++] = new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')", + 0, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')") ); + + array[item++] = new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')", + 3, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')", + 0, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')", + 2, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')") ); + + array[item++] = new TestCase( SECTION, + "var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')", + 0, + eval("var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')") ); + + array[item++] = new TestCase( SECTION, + "var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')", + 0, + eval("var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')") ); + + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')") ); + + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)") ); + + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)", + 0, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)") ); + + array[item++] = new TestCase( SECTION, + "var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')", + 1, + eval("var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')") ); + + array[item++] = new TestCase( SECTION, + "var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')", + 0, + eval("var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')") ); + + array[item++] = new TestCase( SECTION, + "var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')", + 1, + eval("var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')") ); + + array[item++] = new TestCase( SECTION, + "var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )", + 8, + eval("var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )") ); + + // new Date(0) has '31' or '01' at index 8 depending on whether tester is (GMT-) or (GMT+), respectively + array[item++] = new TestCase( SECTION, + "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')", + 8, + eval("var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')") ); + + + 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(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-1.js new file mode 100644 index 0000000..55d0313 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-1.js @@ -0,0 +1,221 @@ +/* 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.5.4.7-1.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.7-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.lastIndexOf"; + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var j = 0; + + for ( k = 0, i = 0x0021; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf(" +String.fromCharCode(i)+ ", 0)", + -1, + TEST_STRING.lastIndexOf( String.fromCharCode(i), 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+k+1+")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k+1 ) ); + } + + for ( k = 9, i = 0x0021; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ 0 + ")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), 0), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); + } + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); + } + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+ + (String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ (k-1) +")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), k-1), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k-1 ) ); + } + + array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 0 ) ); +// array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 1 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 1 )); + array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ")", 0, TEST_STRING.lastIndexOf( TEST_STRING )); + + return array; +} + +function test() { + writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + + 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 LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-2.js new file mode 100644 index 0000000..9972c7e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-2.js @@ -0,0 +1,220 @@ +/* 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.5.4.7-2.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.8 + The length property of the lastIndexOf method is 1 +* +*/ + var SECTION = "15.5.4.7-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.lastIndexOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.lastIndexOf.length", 1, String.prototype.lastIndexOf.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.lastIndexOf.length", false, delete String.prototype.lastIndexOf.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length", 1, eval("delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length" ) ); + + array[item++] = new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('', 0)", LastIndexOf("","",0), eval("var s = new String(''); s.lastIndexOf('', 0)") ); + array[item++] = new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('')", LastIndexOf("",""), eval("var s = new String(''); s.lastIndexOf('')") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('', 0)", LastIndexOf("hello","",0), eval("var s = new String('hello'); s.lastIndexOf('',0)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('')", LastIndexOf("hello",""), eval("var s = new String('hello'); s.lastIndexOf('')") ); + + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll')", LastIndexOf("hello","ll"), eval("var s = new String('hello'); s.lastIndexOf('ll')") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 0)", LastIndexOf("hello","ll",0), eval("var s = new String('hello'); s.lastIndexOf('ll', 0)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1)", LastIndexOf("hello","ll",1), eval("var s = new String('hello'); s.lastIndexOf('ll', 1)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2)", LastIndexOf("hello","ll",2), eval("var s = new String('hello'); s.lastIndexOf('ll', 2)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 3)", LastIndexOf("hello","ll",3), eval("var s = new String('hello'); s.lastIndexOf('ll', 3)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 4)", LastIndexOf("hello","ll",4), eval("var s = new String('hello'); s.lastIndexOf('ll', 4)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 5)", LastIndexOf("hello","ll",5), eval("var s = new String('hello'); s.lastIndexOf('ll', 5)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 6)", LastIndexOf("hello","ll",6), eval("var s = new String('hello'); s.lastIndexOf('ll', 6)") ); + + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1.5)", LastIndexOf('hello','ll', 1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 1.5)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2.5)", LastIndexOf('hello','ll', 2.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 2.5)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1)", LastIndexOf('hello','ll', -1), eval("var s = new String('hello'); s.lastIndexOf('ll', -1)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1.5)",LastIndexOf('hello','ll', -1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', -1.5)") ); + + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -Infinity)", LastIndexOf("hello","ll",-Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', -Infinity)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', Infinity)", LastIndexOf("hello","ll",Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', Infinity)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', NaN)", LastIndexOf("hello","ll",NaN), eval("var s = new String('hello'); s.lastIndexOf('ll', NaN)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -0)", LastIndexOf("hello","ll",-0), eval("var s = new String('hello'); s.lastIndexOf('ll', -0)") ); + for ( var i = 0; i < ( "[object Object]" ).length; i++ ) { + array[item++] = new TestCase( SECTION, + "var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")", + ( i < 2 ? -1 : ( i < 9 ? 2 : 9 )) , + eval("var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")") ); + } + for ( var i = 0; i < 5; i ++ ) { + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")", + ( i < 2 ? -1 : 2 ), + eval("var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")") ); + } + for ( var i = 0; i < 5; i ++ ) { + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")", + ( i < 1 ? -1 : ( i < 9 ? 1 : ( i < 10 ? 9 : 10 ) ) ), + eval("var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")") ); + } + for ( var i = 0; i < 9; i++ ) { + array[item++] = new TestCase( SECTION, + "var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )", + ( i < 3 ? -1 : ( i < 5 ? 3 : 5 ) ), + eval("var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )") ); + } + var a = new Array( "abc","def","ghi","jkl","mno","pqr","stu","vwx","yz" ); + + for ( var i = 0; i < (a.toString()).length; i++ ) { + array[item++] = new TestCase( SECTION, + "var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )", + ( i < 15 ? -1 : 15 ), + eval("var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )") ); + } + + for ( var i = 0; i < 15; i ++ ) { + array[item++] = new TestCase( SECTION, + "var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")", + ( i < 6 ? -1 : ( i < 10 ? 6 : 10 ) ), + eval("var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")") ); + } +/* + for ( var i = 0; i < 15; i++ ) { + array[item++] = new TestCase( SECTION, + "var d = new Date(); d.lastIndexOf = String.prototype.lastIndexOf; d.lastIndexOf( '0' )", + ) + } + +*/ + 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 LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-3.js new file mode 100644 index 0000000..aed400c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.7-3.js @@ -0,0 +1,166 @@ +/* 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.5.4.7-3.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.7-3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "String.protoype.lastIndexOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )", + -1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )") ); + + 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 LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-1.js new file mode 100644 index 0000000..1dddd41 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-1.js @@ -0,0 +1,234 @@ +/* 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.5.4.8-1.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.14 + The length property of the split method is 2 +* +*/ + + var SECTION = "15.5.4.8-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.split"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") ); + + // test cases for when split is called with no arguments. + + // this is a string object + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.split()", + "object", + eval("var s = new String('this is a string object'); typeof s.split()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()", + "[object Array]", + eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.split().length", + 1, + eval("var s = new String('this is a string object'); s.split().length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.split()[0]", + "this is a string object", + eval("var s = new String('this is a string object'); s.split()[0]") ); + + // this is an object object + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]", + "[object Object]", + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") ); + + // this is a function object + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]", + "[object Function]", + eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") ); + + // this is a number object + array[item++] = new TestCase( SECTION, + "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]", + "-1e+21", + eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") ); + + + // this is the Math object + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split()[0]", + "[object Math]", + eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") ); + + // this is an array object + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]", + "1,2,3,4,5", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") ); + + // this is a Boolean object + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]", + "false", + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") ); + + + 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/String/15.5.4.8-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-2.js new file mode 100644 index 0000000..18e41cd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-2.js @@ -0,0 +1,248 @@ +/* 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.5.4.8-2.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + When the split method is called with one argument separator, the following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Create a new Array object of length 0 and call it A. + 3. If separator is not supplied, call the [[Put]] method of A with 0 and + Result(1) as arguments, and then return A. + 4. Call ToString(separator). + 5. Compute the number of characters in Result(1). + 6. Compute the number of characters in the string that is Result(4). + 7. Let p be 0. + 8. If Result(6) is zero (the separator string is empty), go to step 17. + 9. Compute the smallest possible integer k not smaller than p such that + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. + +Note that the split function is intentionally generic; it does not require that its this value be a String +object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.split"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // case where separator is the empty string. + + var TEST_STRING = "this is a string object"; + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split('').length", + TEST_STRING.length, + eval("var s = new String( TEST_STRING ); s.split('').length") ); + + for ( var i = 0; i < TEST_STRING.length; i++ ) { + + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('')["+i+"]", + TEST_STRING.charAt(i), + eval("var s = new String( TEST_STRING ); s.split('')["+i+"]") ); + } + + // case where the value of the separator is undefined. in this case. the value of the separator + // should be ToString( separator ), or "undefined". + + var TEST_STRING = "thisundefinedisundefinedaundefinedstringundefinedobject"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(void 0).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(void 0).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(void 0)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(void 0)["+i+"]") ); + } + + // case where the value of the separator is null. in this case the value of the separator is "null". + TEST_STRING = "thisnullisnullanullstringnullobject"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(null).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(null).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(null)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(null)["+i+"]") ); + } + + // case where the value of the separator is a boolean. + TEST_STRING = "thistrueistrueatruestringtrueobject"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(true).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(true).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(true)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(true)["+i+"]") ); + } + + // case where the value of the separator is a number + TEST_STRING = "this123is123a123string123object"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); + } + + + // case where the value of the separator is a number + TEST_STRING = "this123is123a123string123object"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); + } + + // case where the separator is not in the string + TEST_STRING = "this is a string"; + EXPECT_STRING = new Array( "this is a string" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':').length", + 1, + eval("var s = new String( TEST_STRING ); s.split(':').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split(':')[0]") ); + + // case where part but not all of separator is in the string. + TEST_STRING = "this is a string"; + EXPECT_STRING = new Array( "this is a string" ); + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings').length", + 1, + eval("var s = new String( TEST_STRING ); s.split('strings').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split('strings')[0]") ); + + // case where the separator is at the end of the string + TEST_STRING = "this is a string"; + EXPECT_STRING = new Array( "this is a " ); + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('string').length", + 2, + eval("var s = new String( TEST_STRING ); s.split('string').length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('string')["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split('string')["+i+"]") ); + } + 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/String/15.5.4.8-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-3.js new file mode 100644 index 0000000..d3861bb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.8-3.js @@ -0,0 +1,205 @@ +/* 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.5.4.8-3.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + When the split method is called with one argument separator, the following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Create a new Array object of length 0 and call it A. + 3. If separator is not supplied, call the [[Put]] method of A with 0 and + Result(1) as arguments, and then return A. + 4. Call ToString(separator). + 5. Compute the number of characters in Result(1). + 6. Compute the number of characters in the string that is Result(4). + 7. Let p be 0. + 8. If Result(6) is zero (the separator string is empty), go to step 17. + 9. Compute the smallest possible integer k not smaller than p such that + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. + +Note that the split function is intentionally generic; it does not require that its this value be a String +object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.8-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.split"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var TEST_STRING = ""; + var EXPECT = new Array(); + + // this.toString is the empty string. + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split().length", + 1, + eval("var s = new String(); s.split().length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split()[0]", + "", + eval("var s = new String(); s.split()[0]") ); + + // this.toString() is the empty string, separator is specified. + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split('').length", + 0, + eval("var s = new String(); s.split('').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split(' ').length", + 1, + eval("var s = new String(); s.split(' ').length") ); + + // this to string is " " + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split().length", + 1, + eval("var s = new String(' '); s.split().length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split()[0]", + " ", + eval("var s = new String(' '); s.split()[0]") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split('').length", + 1, + eval("var s = new String(' '); s.split('').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split('')[0]", + " ", + eval("var s = new String(' '); s.split('')[0]") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split(' ').length", + 2, + eval("var s = new String(' '); s.split(' ').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split(' ')[0]", + "", + eval("var s = new String(' '); s.split(' ')[0]") ); + + array[item++] = new TestCase( SECTION, + "\"\".split(\"\").length", + 0, + ("".split("")).length ); + + array[item++] = new TestCase( SECTION, + "\"\".split(\"x\").length", + 1, + ("".split("x")).length ); + + array[item++] = new TestCase( SECTION, + "\"\".split(\"x\")[0]", + "", + ("".split("x"))[0] ); + + 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 Split( string, separator ) { + string = String( string ); + + var A = new Array(); + + if ( arguments.length < 2 ) { + A[0] = string; + return A; + } + + separator = String( separator ); + + var str_len = String( string ).length; + var sep_len = String( separator ).length; + + var p = 0; + var k = 0; + + if ( sep_len == 0 ) { + for ( ; p < str_len; p++ ) { + A[A.length] = String( string.charAt(p) ); + } + } + return A; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.9-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.9-1.js new file mode 100644 index 0000000..9ae08dc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.9-1.js @@ -0,0 +1,202 @@ +/* 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.5.4.9-1.js + ECMA Section: 15.5.4.9 String.prototype.substring( start ) + Description: + + 15.5.4.9 String.prototype.substring(start) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to the end of the + string. The result is a string value, not a String object. + + If the argument is NaN or negative, it is replaced with zero; if the + argument is larger than the length of the string, it is replaced with the + length of the string. + + When the substring method is called with one argument start, the following + steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToInteger(start). + 3.Compute the number of characters in Result(1). + 4.Compute min(max(Result(2), 0), Result(3)). + 5.Return a string whose length is the difference between Result(3) and Result(4), + containing characters from Result(1), namely the characters with indices Result(4) + through Result(3)1, in ascending order. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.9-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.substring( start )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + + // test cases for when substring is called with no arguments. + + // this is a string object + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(''); s.substring()", + "", + eval("var s = new String(''); s.substring()") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring()", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-0.01)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length+1)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-Infinity)") ); + + // this is not a String object, start is not an integer + + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)", + ",2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')", + "3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(); s.substring = String.prototype.substring; s.substring('4')", + "", + eval("var s = new Array(); s.substring = String.prototype.substring; s.substring('4')") ); + + // this is an object object + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)") ); + + // this is a function object + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)") ); + // this is a number object + array[item++] = new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)") ); + + // this is the Math object + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)", + "ject Math]", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)") ); + + // this is a Boolean object + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())", + "false", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())") ); + + // this is a user defined object + + array[item++] = new TestCase( SECTION, + "var obj = new MyObject( null ); obj.substring(0)", + "null", + eval( "var obj = new MyObject( null ); obj.substring(0)") ); + + 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.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.js new file mode 100644 index 0000000..3456a09 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.4.js @@ -0,0 +1,74 @@ +/* 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.5.4.js + ECMA Section: 15.5.4 Properties of the String prototype object + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.5.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Prototype objecta"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()", + "[object String]", + eval("String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()") ); + + array[item++] = new TestCase( SECTION, "typeof String.prototype", "object", typeof String.prototype ); + array[item++] = new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); + array[item++] = new TestCase( SECTION, "String.prototype +''", "", String.prototype + '' ); + array[item++] = new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); +// array[item++] = new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); + + + 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(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.5.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.5.1.js new file mode 100644 index 0000000..5f0fe29 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/String/15.5.5.1.js @@ -0,0 +1,90 @@ +/* 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.5.5.1 + ECMA Section: String.length + Description: + + The number of characters in the String value represented by this String + object. + + Once a String object is created, this property is unchanging. It has the + attributes { DontEnum, DontDelete, ReadOnly }. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.length", + 0, + eval("var s = new String(); s.length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.length = 10; s.length", + 0, + eval("var s = new String(); s.length = 10; s.length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props", + "", + eval("var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); delete s.length", + false, + eval("var s = new String(); delete s.length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('hello'); delete s.length; s.length", + 5, + eval("var s = new String('hello'); delete s.length; s.length") ); + 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/TypeConversion/9.2.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.2.js new file mode 100644 index 0000000..c0cb331 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.2.js @@ -0,0 +1,111 @@ +/* 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: 9.2.js + ECMA Section: 9.2 Type Conversion: ToBoolean + Description: rules for converting an argument to a boolean. + undefined false + Null false + Boolean input argument( no conversion ) + Number returns false for 0, -0, and NaN + otherwise return true + String return false if the string is empty + (length is 0) otherwise the result is + true + Object all return true + + Author: christine@netscape.com + Date: 14 july 1997 +*/ + var SECTION = "9.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToBoolean"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // special cases here + + testcases[tc++] = new TestCase( SECTION, "Boolean()", false, Boolean() ); + testcases[tc++] = new TestCase( SECTION, "Boolean(var x)", false, Boolean(eval("var x")) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(void 0)", false, Boolean(void 0) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(-0)", false, Boolean(-0) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); + testcases[tc++] = new TestCase( SECTION, "Boolean('')", false, Boolean("") ); + + // normal test cases here + + testcases[tc++] = new TestCase( SECTION, "Boolean(Infinity)", true, Boolean(Number.POSITIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(Math.PI)", true, Boolean(Math.PI) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); + testcases[tc++] = new TestCase( SECTION, "Boolean([tab])", true, Boolean("\t") ); + testcases[tc++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); + testcases[tc++] = new TestCase( SECTION, "Boolean('string')", true, Boolean("string") ); + + // ToBoolean (object) should always return true. + testcases[tc++] = new TestCase( SECTION, "Boolean(new String() )", true, Boolean(new String()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new String('') )", true, Boolean(new String("")) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean(true))", true, Boolean(new Boolean(true)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean(false))", true, Boolean(new Boolean(false)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean() )", true, Boolean(new Boolean()) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Array())", true, Boolean(new Array()) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number())", true, Boolean(new Number()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-0))", true, Boolean(new Number(-0)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(0))", true, Boolean(new Number(0)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(NaN))", true, Boolean(new Number(Number.NaN)) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-1))", true, Boolean(new Number(-1)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(Infinity))", true, Boolean(new Number(Number.POSITIVE_INFINITY)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-Infinity))",true, Boolean(new Number(Number.NEGATIVE_INFINITY)) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Object())", true, Boolean(new Object()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Function())", true, Boolean(new Function()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Date())", true, Boolean(new Date()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Date(0))", true, Boolean(new Date(0)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(Math)", true, Boolean(Math) ); + + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3-1.js new file mode 100644 index 0000000..39af328 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3-1.js @@ -0,0 +1,96 @@ +/* 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: 9.3-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + This tests ToNumber applied to the object type, except + if object is string. See 9.3-2 for + ToNumber( String object). + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TYPE = "number"; + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " ToNumber"); + 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].passed = writeTestCaseResult( + TYPE, + typeof(testcases[tc].actual), + "typeof( " + testcases[tc].description + + " ) = " + typeof(testcases[tc].actual) ) + ? testcases[tc].passed + : false; + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // object is Number + array[item++] = new TestCase( SECTION, "Number(new Number())", 0, Number(new Number()) ); + array[item++] = new TestCase( SECTION, "Number(new Number(Number.NaN))",Number.NaN, Number(new Number(Number.NaN)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(0))", 0, Number(new Number(0)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(null))", 0, Number(new Number(null)) ); +// array[item++] = new TestCase( SECTION, "Number(new Number(void 0))", Number.NaN, Number(new Number(void 0)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(true))", 1, Number(new Number(true)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(false))", 0, Number(new Number(false)) ); + + // object is boolean + + array[item++] = new TestCase( SECTION, "Number(new Boolean(true))", 1, Number(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "Number(new Boolean(false))", 0, Number(new Boolean(false)) ); + + // object is array + array[item++] = new TestCase( SECTION, "Number(new Array(2,4,8,16,32))", Number.NaN, Number(new Array(2,4,8,16,32)) ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-1.js new file mode 100644 index 0000000..4cc8ce0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-1.js @@ -0,0 +1,323 @@ +/* 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: 9.3.1-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + This tests ToNumber applied to the string type + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToNumber applied to the String type"; + var BUGNUMBER="77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // StringNumericLiteral:::StrWhiteSpace:::StrWhiteSpaceChar StrWhiteSpace::: + // + // Name Unicode Value Escape Sequence + // <TAB> 0X0009 \t + // <SP> 0X0020 + // <FF> 0X000C \f + // <VT> 0X000B + // <CR> 0X000D \r + // <LF> 0X000A \n + array[item++] = new TestCase( SECTION, "Number('')", 0, Number("") ); + array[item++] = new TestCase( SECTION, "Number(' ')", 0, Number(" ") ); + array[item++] = new TestCase( SECTION, "Number(\\t)", 0, Number("\t") ); + array[item++] = new TestCase( SECTION, "Number(\\n)", 0, Number("\n") ); + array[item++] = new TestCase( SECTION, "Number(\\r)", 0, Number("\r") ); + array[item++] = new TestCase( SECTION, "Number(\\f)", 0, Number("\f") ); + + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x0009)", 0, Number(String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x0020)", 0, Number(String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000C)", 0, Number(String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000B)", 0, Number(String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000D)", 0, Number(String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000A)", 0, Number(String.fromCharCode(0x000A)) ); + + // a StringNumericLiteral may be preceeded or followed by whitespace and/or + // line terminators + + array[item++] = new TestCase( SECTION, "Number( ' ' + 999 )", 999, Number( ' '+999) ); + array[item++] = new TestCase( SECTION, "Number( '\\n' + 999 )", 999, Number( '\n' +999) ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + 999 )", 999, Number( '\r' +999) ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + 999 )", 999, Number( '\t' +999) ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + 999 )", 999, Number( '\f' +999) ); + + array[item++] = new TestCase( SECTION, "Number( 999 + ' ' )", 999, Number( 999+' ') ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\n' )", 999, Number( 999+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\r' )", 999, Number( 999+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\t' )", 999, Number( 999+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\f' )", 999, Number( 999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( '\\n' + 999 + '\\n' )", 999, Number( '\n' +999+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + 999 + '\\r' )", 999, Number( '\r' +999+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + 999 + '\\t' )", 999, Number( '\t' +999+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + 999 + '\\f' )", 999, Number( '\f' +999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( ' ' + '999' )", 999, Number( ' '+'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\n' + '999' )", 999, Number( '\n' +'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + '999' )", 999, Number( '\r' +'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + '999' )", 999, Number( '\t' +'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + '999' )", 999, Number( '\f' +'999') ); + + array[item++] = new TestCase( SECTION, "Number( '999' + ' ' )", 999, Number( '999'+' ') ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\n' )", 999, Number( '999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\r' )", 999, Number( '999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\t' )", 999, Number( '999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\f' )", 999, Number( '999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( '\\n' + '999' + '\\n' )", 999, Number( '\n' +'999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + '999' + '\\r' )", 999, Number( '\r' +'999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + '999' + '\\t' )", 999, Number( '\t' +'999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + '999' + '\\f' )", 999, Number( '\f' +'999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' )", 99, Number( String.fromCharCode(0x0009) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' )", 99, Number( String.fromCharCode(0x0020) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' )", 99, Number( String.fromCharCode(0x000C) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' )", 99, Number( String.fromCharCode(0x000B) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' )", 99, Number( String.fromCharCode(0x000D) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' )", 99, Number( String.fromCharCode(0x000A) + '99' ) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0009)", 99, Number( '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0020)", 99, Number( '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000C)", 99, Number( '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000D)", 99, Number( '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000B)", 99, Number( '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000A)", 99, Number( '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 )", 99, Number( String.fromCharCode(0x0009) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 )", 99, Number( String.fromCharCode(0x0020) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 )", 99, Number( String.fromCharCode(0x000C) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 )", 99, Number( String.fromCharCode(0x000B) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 )", 99, Number( String.fromCharCode(0x000D) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 )", 99, Number( String.fromCharCode(0x000A) + 99 ) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0009)", 99, Number( 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0020)", 99, Number( 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000C)", 99, Number( 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000D)", 99, Number( 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000B)", 99, Number( 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000A)", 99, Number( 99 + String.fromCharCode(0x000A)) ); + + + // StrNumericLiteral:::StrDecimalLiteral:::Infinity + + array[item++] = new TestCase( SECTION, "Number('Infinity')", Math.pow(10,10000), Number("Infinity") ); + array[item++] = new TestCase( SECTION, "Number('-Infinity')", -Math.pow(10,10000), Number("-Infinity") ); + array[item++] = new TestCase( SECTION, "Number('+Infinity')", Math.pow(10,10000), Number("+Infinity") ); + + // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + + array[item++] = new TestCase( SECTION, "Number('0')", 0, Number("0") ); + array[item++] = new TestCase( SECTION, "Number('-0')", -0, Number("-0") ); + array[item++] = new TestCase( SECTION, "Number('+0')", 0, Number("+0") ); + + array[item++] = new TestCase( SECTION, "Number('1')", 1, Number("1") ); + array[item++] = new TestCase( SECTION, "Number('-1')", -1, Number("-1") ); + array[item++] = new TestCase( SECTION, "Number('+1')", 1, Number("+1") ); + + array[item++] = new TestCase( SECTION, "Number('2')", 2, Number("2") ); + array[item++] = new TestCase( SECTION, "Number('-2')", -2, Number("-2") ); + array[item++] = new TestCase( SECTION, "Number('+2')", 2, Number("+2") ); + + array[item++] = new TestCase( SECTION, "Number('3')", 3, Number("3") ); + array[item++] = new TestCase( SECTION, "Number('-3')", -3, Number("-3") ); + array[item++] = new TestCase( SECTION, "Number('+3')", 3, Number("+3") ); + + array[item++] = new TestCase( SECTION, "Number('4')", 4, Number("4") ); + array[item++] = new TestCase( SECTION, "Number('-4')", -4, Number("-4") ); + array[item++] = new TestCase( SECTION, "Number('+4')", 4, Number("+4") ); + + array[item++] = new TestCase( SECTION, "Number('5')", 5, Number("5") ); + array[item++] = new TestCase( SECTION, "Number('-5')", -5, Number("-5") ); + array[item++] = new TestCase( SECTION, "Number('+5')", 5, Number("+5") ); + + array[item++] = new TestCase( SECTION, "Number('6')", 6, Number("6") ); + array[item++] = new TestCase( SECTION, "Number('-6')", -6, Number("-6") ); + array[item++] = new TestCase( SECTION, "Number('+6')", 6, Number("+6") ); + + array[item++] = new TestCase( SECTION, "Number('7')", 7, Number("7") ); + array[item++] = new TestCase( SECTION, "Number('-7')", -7, Number("-7") ); + array[item++] = new TestCase( SECTION, "Number('+7')", 7, Number("+7") ); + + array[item++] = new TestCase( SECTION, "Number('8')", 8, Number("8") ); + array[item++] = new TestCase( SECTION, "Number('-8')", -8, Number("-8") ); + array[item++] = new TestCase( SECTION, "Number('+8')", 8, Number("+8") ); + + array[item++] = new TestCase( SECTION, "Number('9')", 9, Number("9") ); + array[item++] = new TestCase( SECTION, "Number('-9')", -9, Number("-9") ); + array[item++] = new TestCase( SECTION, "Number('+9')", 9, Number("+9") ); + + array[item++] = new TestCase( SECTION, "Number('3.14159')", 3.14159, Number("3.14159") ); + array[item++] = new TestCase( SECTION, "Number('-3.14159')", -3.14159, Number("-3.14159") ); + array[item++] = new TestCase( SECTION, "Number('+3.14159')", 3.14159, Number("+3.14159") ); + + array[item++] = new TestCase( SECTION, "Number('3.')", 3, Number("3.") ); + array[item++] = new TestCase( SECTION, "Number('-3.')", -3, Number("-3.") ); + array[item++] = new TestCase( SECTION, "Number('+3.')", 3, Number("+3.") ); + + array[item++] = new TestCase( SECTION, "Number('3.e1')", 30, Number("3.e1") ); + array[item++] = new TestCase( SECTION, "Number('-3.e1')", -30, Number("-3.e1") ); + array[item++] = new TestCase( SECTION, "Number('+3.e1')", 30, Number("+3.e1") ); + + array[item++] = new TestCase( SECTION, "Number('3.e+1')", 30, Number("3.e+1") ); + array[item++] = new TestCase( SECTION, "Number('-3.e+1')", -30, Number("-3.e+1") ); + array[item++] = new TestCase( SECTION, "Number('+3.e+1')", 30, Number("+3.e+1") ); + + array[item++] = new TestCase( SECTION, "Number('3.e-1')", .30, Number("3.e-1") ); + array[item++] = new TestCase( SECTION, "Number('-3.e-1')", -.30, Number("-3.e-1") ); + array[item++] = new TestCase( SECTION, "Number('+3.e-1')", .30, Number("+3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "Number('.00001')", 0.00001, Number(".00001") ); + array[item++] = new TestCase( SECTION, "Number('+.00001')", 0.00001, Number("+.00001") ); + array[item++] = new TestCase( SECTION, "Number('-0.0001')", -0.00001, Number("-.00001") ); + + array[item++] = new TestCase( SECTION, "Number('.01e2')", 1, Number(".01e2") ); + array[item++] = new TestCase( SECTION, "Number('+.01e2')", 1, Number("+.01e2") ); + array[item++] = new TestCase( SECTION, "Number('-.01e2')", -1, Number("-.01e2") ); + + array[item++] = new TestCase( SECTION, "Number('.01e+2')", 1, Number(".01e+2") ); + array[item++] = new TestCase( SECTION, "Number('+.01e+2')", 1, Number("+.01e+2") ); + array[item++] = new TestCase( SECTION, "Number('-.01e+2')", -1, Number("-.01e+2") ); + + array[item++] = new TestCase( SECTION, "Number('.01e-2')", 0.0001, Number(".01e-2") ); + array[item++] = new TestCase( SECTION, "Number('+.01e-2')", 0.0001, Number("+.01e-2") ); + array[item++] = new TestCase( SECTION, "Number('-.01e-2')", -0.0001, Number("-.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "Number('1234e5')", 123400000, Number("1234e5") ); + array[item++] = new TestCase( SECTION, "Number('+1234e5')", 123400000, Number("+1234e5") ); + array[item++] = new TestCase( SECTION, "Number('-1234e5')", -123400000, Number("-1234e5") ); + + array[item++] = new TestCase( SECTION, "Number('1234e+5')", 123400000, Number("1234e+5") ); + array[item++] = new TestCase( SECTION, "Number('+1234e+5')", 123400000, Number("+1234e+5") ); + array[item++] = new TestCase( SECTION, "Number('-1234e+5')", -123400000, Number("-1234e+5") ); + + array[item++] = new TestCase( SECTION, "Number('1234e-5')", 0.01234, Number("1234e-5") ); + array[item++] = new TestCase( SECTION, "Number('+1234e-5')", 0.01234, Number("+1234e-5") ); + array[item++] = new TestCase( SECTION, "Number('-1234e-5')", -0.01234, Number("-1234e-5") ); + + // StrNumericLiteral::: HexIntegerLiteral + + array[item++] = new TestCase( SECTION, "Number('0x0')", 0, Number("0x0")); + array[item++] = new TestCase( SECTION, "Number('0x1')", 1, Number("0x1")); + array[item++] = new TestCase( SECTION, "Number('0x2')", 2, Number("0x2")); + array[item++] = new TestCase( SECTION, "Number('0x3')", 3, Number("0x3")); + array[item++] = new TestCase( SECTION, "Number('0x4')", 4, Number("0x4")); + array[item++] = new TestCase( SECTION, "Number('0x5')", 5, Number("0x5")); + array[item++] = new TestCase( SECTION, "Number('0x6')", 6, Number("0x6")); + array[item++] = new TestCase( SECTION, "Number('0x7')", 7, Number("0x7")); + array[item++] = new TestCase( SECTION, "Number('0x8')", 8, Number("0x8")); + array[item++] = new TestCase( SECTION, "Number('0x9')", 9, Number("0x9")); + array[item++] = new TestCase( SECTION, "Number('0xa')", 10, Number("0xa")); + array[item++] = new TestCase( SECTION, "Number('0xb')", 11, Number("0xb")); + array[item++] = new TestCase( SECTION, "Number('0xc')", 12, Number("0xc")); + array[item++] = new TestCase( SECTION, "Number('0xd')", 13, Number("0xd")); + array[item++] = new TestCase( SECTION, "Number('0xe')", 14, Number("0xe")); + array[item++] = new TestCase( SECTION, "Number('0xf')", 15, Number("0xf")); + array[item++] = new TestCase( SECTION, "Number('0xA')", 10, Number("0xA")); + array[item++] = new TestCase( SECTION, "Number('0xB')", 11, Number("0xB")); + array[item++] = new TestCase( SECTION, "Number('0xC')", 12, Number("0xC")); + array[item++] = new TestCase( SECTION, "Number('0xD')", 13, Number("0xD")); + array[item++] = new TestCase( SECTION, "Number('0xE')", 14, Number("0xE")); + array[item++] = new TestCase( SECTION, "Number('0xF')", 15, Number("0xF")); + + array[item++] = new TestCase( SECTION, "Number('0X0')", 0, Number("0X0")); + array[item++] = new TestCase( SECTION, "Number('0X1')", 1, Number("0X1")); + array[item++] = new TestCase( SECTION, "Number('0X2')", 2, Number("0X2")); + array[item++] = new TestCase( SECTION, "Number('0X3')", 3, Number("0X3")); + array[item++] = new TestCase( SECTION, "Number('0X4')", 4, Number("0X4")); + array[item++] = new TestCase( SECTION, "Number('0X5')", 5, Number("0X5")); + array[item++] = new TestCase( SECTION, "Number('0X6')", 6, Number("0X6")); + array[item++] = new TestCase( SECTION, "Number('0X7')", 7, Number("0X7")); + array[item++] = new TestCase( SECTION, "Number('0X8')", 8, Number("0X8")); + array[item++] = new TestCase( SECTION, "Number('0X9')", 9, Number("0X9")); + array[item++] = new TestCase( SECTION, "Number('0Xa')", 10, Number("0Xa")); + array[item++] = new TestCase( SECTION, "Number('0Xb')", 11, Number("0Xb")); + array[item++] = new TestCase( SECTION, "Number('0Xc')", 12, Number("0Xc")); + array[item++] = new TestCase( SECTION, "Number('0Xd')", 13, Number("0Xd")); + array[item++] = new TestCase( SECTION, "Number('0Xe')", 14, Number("0Xe")); + array[item++] = new TestCase( SECTION, "Number('0Xf')", 15, Number("0Xf")); + array[item++] = new TestCase( SECTION, "Number('0XA')", 10, Number("0XA")); + array[item++] = new TestCase( SECTION, "Number('0XB')", 11, Number("0XB")); + array[item++] = new TestCase( SECTION, "Number('0XC')", 12, Number("0XC")); + array[item++] = new TestCase( SECTION, "Number('0XD')", 13, Number("0XD")); + array[item++] = new TestCase( SECTION, "Number('0XE')", 14, Number("0XE")); + array[item++] = new TestCase( SECTION, "Number('0XF')", 15, Number("0XF")); + + return ( array ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-2.js new file mode 100644 index 0000000..c675e57 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-2.js @@ -0,0 +1,89 @@ +/* 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: 9.3.1-2.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + This tests special cases of ToNumber(string) that are + not covered in 9.3.1-1.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToNumber applied to the String type"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // A StringNumericLiteral may not use octal notation + + array[item++] = new TestCase( SECTION, "Number(00)", 0, Number("00")); + array[item++] = new TestCase( SECTION, "Number(01)", 1, Number("01")); + array[item++] = new TestCase( SECTION, "Number(02)", 2, Number("02")); + array[item++] = new TestCase( SECTION, "Number(03)", 3, Number("03")); + array[item++] = new TestCase( SECTION, "Number(04)", 4, Number("04")); + array[item++] = new TestCase( SECTION, "Number(05)", 5, Number("05")); + array[item++] = new TestCase( SECTION, "Number(06)", 6, Number("06")); + array[item++] = new TestCase( SECTION, "Number(07)", 7, Number("07")); + array[item++] = new TestCase( SECTION, "Number(010)", 10, Number("010")); + array[item++] = new TestCase( SECTION, "Number(011)", 11, Number("011")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "Number(001)", 1, Number("001")); + array[item++] = new TestCase( SECTION, "Number(0001)", 1, Number("0001")); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-3.js new file mode 100644 index 0000000..69407fb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-3.js @@ -0,0 +1,726 @@ +/* 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: 9.3.1-3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + Test cases provided by waldemar. + + + Author: christine@netscape.com + Date: 10 june 1998 + +*/ + +var SECTION = "9.3.1-3"; +var VERSION = "ECMA_1"; + startTest(); +var BUGNUMBER="129087"; + +var TITLE = "Number To String, String To Number"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = new Array(); + + +// test case from http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312954 +var z = 0; + +testcases[tc++] = new TestCase( + SECTION, + "var z = 0; print(1/-z)", + -Infinity, + 1/-z ); + + + + + +// test cases from bug http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122882 + + + +testcases[tc++] = new TestCase( SECTION, + '- -"0x80000000"', + 2147483648, + - -"0x80000000" ); + +testcases[tc++] = new TestCase( SECTION, + '- -"0x100000000"', + 4294967296, + - -"0x100000000" ); + +testcases[tc++] = new TestCase( SECTION, + '- "-0x123456789abcde8"', + 81985529216486880, + - "-0x123456789abcde8" ); + +// Convert some large numbers to string + + +testcases[tc++] = new TestCase( SECTION, + "1e2000 +''", + "Infinity", + 1e2000 +"" ); + +testcases[tc++] = new TestCase( SECTION, + "1e2000", + Infinity, + 1e2000 ); + +testcases[tc++] = new TestCase( SECTION, + "-1e2000 +''", + "-Infinity", + -1e2000 +"" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"1e2000\"", + -Infinity, + -"1e2000" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-1e2000\" +''", + "Infinity", + -"-1e2000" +"" ); + +testcases[tc++] = new TestCase( SECTION, + "1e-2000", + 0, + 1e-2000 ); + +testcases[tc++] = new TestCase( SECTION, + "1/1e-2000", + Infinity, + 1/1e-2000 ); + +// convert some strings to large numbers + +testcases[tc++] = new TestCase( SECTION, + "1/-1e-2000", + -Infinity, + 1/-1e-2000 ); + +testcases[tc++] = new TestCase( SECTION, + "1/\"1e-2000\"", + Infinity, + 1/"1e-2000" ); + +testcases[tc++] = new TestCase( SECTION, + "1/\"-1e-2000\"", + -Infinity, + 1/"-1e-2000" ); + +testcases[tc++] = new TestCase( SECTION, + "parseFloat(\"1e2000\")", + Infinity, + parseFloat("1e2000") ); + +testcases[tc++] = new TestCase( SECTION, + "parseFloat(\"1e-2000\")", + 0, + parseFloat("1e-2000") ); + +testcases[tc++] = new TestCase( SECTION, + "1.7976931348623157E+308", + 1.7976931348623157e+308, + 1.7976931348623157E+308 ); + +testcases[tc++] = new TestCase( SECTION, + "1.7976931348623158e+308", + 1.7976931348623157e+308, + 1.7976931348623158e+308 ); + +testcases[tc++] = new TestCase( SECTION, + "1.7976931348623159e+308", + Infinity, + 1.7976931348623159e+308 ); + +s = +"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s +"; s +="+ +"\"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779\""+ + ++"; s", +"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779", +s += +"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779" +); + +s1 = s+1; + +testcases[tc++] = new TestCase( SECTION, +"s1 = s+1; s1", +"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791", +s1 ); + +/***** This answer is preferred but -Infinity is also acceptable here *****/ + +testcases[tc++] = new TestCase( SECTION, +"-s1 == Infinity || s1 == 1.7976931348623157e+308", +true, +-s1 == Infinity || s1 == 1.7976931348623157e+308 ); + +s2 = s + 2; + +testcases[tc++] = new TestCase( SECTION, +"s2 = s+2; s2", +"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792", +s2 ); + +// ***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** +testcases[tc++] = new TestCase( SECTION, +"-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ", +true, +-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ); + +s3 = s+3; + +testcases[tc++] = new TestCase( SECTION, +"s3 = s+3; s3", +"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497793", +s3 ); + +//***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** + +testcases[tc++] = new TestCase( SECTION, +"-s3 == -Infinity || -s3 == -1.7976931348623157e+308", +true, +-s3 == -Infinity || -s3 == -1.7976931348623157e+308 ); + + +//***** This answer is preferred but Infinity is also acceptable here ***** + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity", +true, +parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity ); + +//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** +testcases[tc++] = new TestCase( SECTION, +"parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308", +true , +parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 ); + +//***** This answer is preferred but Infinity is also acceptable here ***** + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity", +true, +parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity); + +//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** +testcases[tc++] = new TestCase( SECTION, +"parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308", +true, +parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 ); + +testcases[tc++] = new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); + +testcases[tc++] = new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); + +/***** These test the round-to-nearest-or-even-if-equally-close rule *****/ + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); +testcases[tc++] = new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)", +9027215253084860, +parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)", +9027215253084860, +parseInt("000000100000000100100011010001010110011110001001101010111101",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)", +9027215253084864, +parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)", +18054430506169720, +parseInt("0000001000000001001000110100010101100111100010011010101111010",2)); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)", +18054430506169724, +parseInt("0000001000000001001000110100010101100111100010011010101111011",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)", +18054430506169724, +parseInt("0000001000000001001000110100010101100111100010011010101111100",2)); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)", +18054430506169728, +parseInt("0000001000000001001000110100010101100111100010011010101111110",2)); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"yz\",35)", + 34, + parseInt("yz",35) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"yz\",36)", + 1259, + parseInt("yz",36) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"yz\",37)", + NaN, + parseInt("yz",37) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"+77\")", + 77, + parseInt("+77") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"-77\",9)", + -70, + parseInt("-77",9) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"\\u20001234\\u2000\")", + 1234, + parseInt("\u20001234\u2000") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"123456789012345678\")", + 123456789012345680, + parseInt("123456789012345678") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"9\",8)", + NaN, + parseInt("9",8) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"1e2\")", + 1, + parseInt("1e2") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"1.9999999999999999999\")", + 1, + parseInt("1.9999999999999999999") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x10\")", + 16, + parseInt("0x10") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x10\",10)", + 0, + parseInt("0x10",10) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0022\")", + 18, + parseInt("0022") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0022\",10)", + 22, + parseInt("0022",10) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x1000000000000080\")", + 1152921504606847000, + parseInt("0x1000000000000080") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x1000000000000081\")", + 1152921504606847200, + parseInt("0x1000000000000081") ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, "s = "+ +"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ +"s", +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s ); + + +testcases[tc++] = new TestCase( SECTION, "s +="+ +"\"0000000000000000000000000000000000000\"; s", +"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s += "0000000000000000000000000000000000000" ); + +testcases[tc++] = new TestCase( SECTION, "-s", +-1.7976931348623157e+308, +-s ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, "s ="+ +"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ +"s", +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s ); + +testcases[tc++] = new TestCase( SECTION, +"s += \"0000000000000000000000000000000000001\"", +"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", +s += "0000000000000000000000000000000000001" ); + +testcases[tc++] = new TestCase( SECTION, +"-s", +-1.7976931348623157e+308, +-s ); + +s = +"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, +"s ="+ +"\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ +"s", +"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s ); + + +testcases[tc++] = new TestCase( SECTION, +"s += \"0000000000000000000000000000000000000\"", +"0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s += "0000000000000000000000000000000000000"); + + +testcases[tc++] = new TestCase( SECTION, +"-s", +-Infinity, +-s ); + +s = +"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, +"s = "+ +"\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s", +"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s); + +testcases[tc++] = new TestCase( SECTION, +"s += \"0000000000000000000000000000000000001\"", +"0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", +s += "0000000000000000000000000000000000001" ); + +testcases[tc++] = new TestCase( SECTION, +"-s", +-1.7976931348623157e+308, +-s ); + +testcases[tc++] = new TestCase( SECTION, +"s += \"0\"", +"0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", +s += "0" ); + +testcases[tc++] = new TestCase( SECTION, +"-s", +-Infinity, +-s ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s)", +Infinity, +parseInt(s) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s,32)", +0, +parseInt(s,32) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s,36)", +Infinity, +parseInt(s,36) ); + +testcases[tc++] = new TestCase( SECTION, + "-\"\"", + 0, + -"" ); + +testcases[tc++] = new TestCase( SECTION, + "-\" \"", + 0, + -" " ); + +testcases[tc++] = new TestCase( SECTION, + "-\"999\"", + -999, + -"999" ); + +testcases[tc++] = new TestCase( SECTION, + "-\" 999\"", + -999, + -" 999" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"\\t999\"", + -999, + -"\t999" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"013 \"", + -13, + -"013 " ); + +testcases[tc++] = new TestCase( SECTION, + "-\"999\\t\"", + -999, + -"999\t" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-Infinity\"", + Infinity, + -"-Infinity" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-infinity\"", + NaN, + -"-infinity" ); + + +testcases[tc++] = new TestCase( SECTION, + "-\"+Infinity\"", + -Infinity, + -"+Infinity" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"+Infiniti\"", + NaN, + -"+Infiniti" ); + +testcases[tc++] = new TestCase( SECTION, + "- -\"0x80000000\"", + 2147483648, + - -"0x80000000" ); + +testcases[tc++] = new TestCase( SECTION, + "- -\"0x100000000\"", + 4294967296, + - -"0x100000000" ); + +testcases[tc++] = new TestCase( SECTION, + "- \"-0x123456789abcde8\"", + 81985529216486880, + - "-0x123456789abcde8" ); + +// the following two tests are not strictly ECMA 1.0 + +testcases[tc++] = new TestCase( SECTION, + "-\"\\u20001234\\u2001\"", + -1234, + -"\u20001234\u2001" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"\\u20001234\\0\"", + NaN, + -"\u20001234\0" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"0x10\"", + -16, + -"0x10" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"+\"", + NaN, + -"+" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-\"", + NaN, + -"-" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-0-\"", + NaN, + -"-0-" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"1e-\"", + NaN, + -"1e-" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"1e-1\"", + -0.1, + -"1e-1" ); + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.js new file mode 100644 index 0000000..4645692 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.js @@ -0,0 +1,89 @@ +/* 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: 9.3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + For ToNumber applied to the String type, see test 9.3.1. + For ToNumber applied to the object type, see test 9.3-1. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToNumber"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special cases here + + array[item++] = new TestCase( SECTION, "Number()", 0, Number() ); + array[item++] = new TestCase( SECTION, "Number(eval('var x'))", Number.NaN, Number(eval("var x")) ); + array[item++] = new TestCase( SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); + array[item++] = new TestCase( SECTION, "Number(null)", 0, Number(null) ); + array[item++] = new TestCase( SECTION, "Number(true)", 1, Number(true) ); + array[item++] = new TestCase( SECTION, "Number(false)", 0, Number(false) ); + array[item++] = new TestCase( SECTION, "Number(0)", 0, Number(0) ); + array[item++] = new TestCase( SECTION, "Number(-0)", -0, Number(-0) ); + array[item++] = new TestCase( SECTION, "Number(1)", 1, Number(1) ); + array[item++] = new TestCase( SECTION, "Number(-1)", -1, Number(-1) ); + array[item++] = new TestCase( SECTION, "Number(Number.MAX_VALUE)", 1.7976931348623157e308, Number(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "Number(Number.MIN_VALUE)", 5e-324, Number(Number.MIN_VALUE) ); + + array[item++] = new TestCase( SECTION, "Number(Number.NaN)", Number.NaN, Number(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Number(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, Number(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Number(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, Number(Number.NEGATIVE_INFINITY) ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.4-1.js new file mode 100644 index 0000000..4dd331d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.4-1.js @@ -0,0 +1,120 @@ +/* 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: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). + + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: + + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). + + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. + + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToInteger"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + 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].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 getTestCases() { + var array = new Array(); + var item = 0; + + // some special cases + + array[item++] = new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); + + // value is not an integer + + array[item++] = new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); + + // value is not a number + + array[item++] = new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + + // edge cases + array[item++] = new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.4-2.js new file mode 100644 index 0000000..4dd331d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.4-2.js @@ -0,0 +1,120 @@ +/* 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: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). + + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: + + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). + + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. + + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToInteger"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + 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].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 getTestCases() { + var array = new Array(); + var item = 0; + + // some special cases + + array[item++] = new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); + + // value is not an integer + + array[item++] = new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); + + // value is not a number + + array[item++] = new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + + // edge cases + array[item++] = new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.5-2.js new file mode 100644 index 0000000..598cce7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.5-2.js @@ -0,0 +1,171 @@ +/* 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: 9.5-2.js + ECMA Section: 9.5 Type Conversion: ToInt32 + Description: rules for converting an argument to a signed 32 bit integer + + this test uses << 0 to convert the argument to a 32bit + integer. + + The operator ToInt32 converts its argument to one of 2^32 + integer values in the range -2^31 through 2^31 inclusive. + This operator functions as follows: + + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 if result(4) is greater than or equal to 2^31, return + result(5)-2^32. otherwise, return result(5) + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + Numbers greater than 2^31 (see step 5 above) + (note http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + var SECTION = "9.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " ToInt32"); + 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 ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + if ( sign == -1 ) { + n = ( n < -Math.pow(2,31) ) ? n + Math.pow(2,32) : n; + } else{ + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + } + + return ( n ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "0 << 0", 0, 0 << 0 ); + array[item++] = new TestCase( SECTION, "-0 << 0", 0, -0 << 0 ); + array[item++] = new TestCase( SECTION, "Infinity << 0", 0, "Infinity" << 0 ); + array[item++] = new TestCase( SECTION, "-Infinity << 0", 0, "-Infinity" << 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY << 0", 0, Number.POSITIVE_INFINITY << 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY << 0", 0, Number.NEGATIVE_INFINITY << 0 ); + array[item++] = new TestCase( SECTION, "Number.NaN << 0", 0, Number.NaN << 0 ); + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE << 0", 0, Number.MIN_VALUE << 0 ); + array[item++] = new TestCase( SECTION, "-Number.MIN_VALUE << 0", 0, -Number.MIN_VALUE << 0 ); + array[item++] = new TestCase( SECTION, "0.1 << 0", 0, 0.1 << 0 ); + array[item++] = new TestCase( SECTION, "-0.1 << 0", 0, -0.1 << 0 ); + array[item++] = new TestCase( SECTION, "1 << 0", 1, 1 << 0 ); + array[item++] = new TestCase( SECTION, "1.1 << 0", 1, 1.1 << 0 ); + array[item++] = new TestCase( SECTION, "-1 << 0", ToInt32(-1), -1 << 0 ); + + + array[item++] = new TestCase( SECTION, "2147483647 << 0", ToInt32(2147483647), 2147483647 << 0 ); + array[item++] = new TestCase( SECTION, "2147483648 << 0", ToInt32(2147483648), 2147483648 << 0 ); + array[item++] = new TestCase( SECTION, "2147483649 << 0", ToInt32(2147483649), 2147483649 << 0 ); + + array[item++] = new TestCase( SECTION, "(Math.pow(2,31)-1) << 0", ToInt32(2147483647), (Math.pow(2,31)-1) << 0 ); + array[item++] = new TestCase( SECTION, "Math.pow(2,31) << 0", ToInt32(2147483648), Math.pow(2,31) << 0 ); + array[item++] = new TestCase( SECTION, "(Math.pow(2,31)+1) << 0", ToInt32(2147483649), (Math.pow(2,31)+1) << 0 ); + + array[item++] = new TestCase( SECTION, "(Math.pow(2,32)-1) << 0", ToInt32(4294967295), (Math.pow(2,32)-1) << 0 ); + array[item++] = new TestCase( SECTION, "(Math.pow(2,32)) << 0", ToInt32(4294967296), (Math.pow(2,32)) << 0 ); + array[item++] = new TestCase( SECTION, "(Math.pow(2,32)+1) << 0", ToInt32(4294967297), (Math.pow(2,32)+1) << 0 ); + + array[item++] = new TestCase( SECTION, "4294967295 << 0", ToInt32(4294967295), 4294967295 << 0 ); + array[item++] = new TestCase( SECTION, "4294967296 << 0", ToInt32(4294967296), 4294967296 << 0 ); + array[item++] = new TestCase( SECTION, "4294967297 << 0", ToInt32(4294967297), 4294967297 << 0 ); + + array[item++] = new TestCase( SECTION, "'2147483647' << 0", ToInt32(2147483647), '2147483647' << 0 ); + array[item++] = new TestCase( SECTION, "'2147483648' << 0", ToInt32(2147483648), '2147483648' << 0 ); + array[item++] = new TestCase( SECTION, "'2147483649' << 0", ToInt32(2147483649), '2147483649' << 0 ); + + array[item++] = new TestCase( SECTION, "'4294967295' << 0", ToInt32(4294967295), '4294967295' << 0 ); + array[item++] = new TestCase( SECTION, "'4294967296' << 0", ToInt32(4294967296), '4294967296' << 0 ); + array[item++] = new TestCase( SECTION, "'4294967297' << 0", ToInt32(4294967297), '4294967297' << 0 ); + + array[item++] = new TestCase( SECTION, "-2147483647 << 0", ToInt32(-2147483647), -2147483647 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483648 << 0", ToInt32(-2147483648), -2147483648 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483649 << 0", ToInt32(-2147483649), -2147483649 << 0 ); + + array[item++] = new TestCase( SECTION, "-4294967295 << 0", ToInt32(-4294967295), -4294967295 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967296 << 0", ToInt32(-4294967296), -4294967296 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967297 << 0", ToInt32(-4294967297), -4294967297 << 0 ); + + /* + * Numbers between 2^31 and 2^32 will have a negative ToInt32 per ECMA (see step 5 of introduction) + * (These are by stevechapel@earthlink.net; cf. http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + */ + array[item++] = new TestCase( SECTION, "2147483648.25 << 0", ToInt32(2147483648.25), 2147483648.25 << 0 ); + array[item++] = new TestCase( SECTION, "2147483648.5 << 0", ToInt32(2147483648.5), 2147483648.5 << 0 ); + array[item++] = new TestCase( SECTION, "2147483648.75 << 0", ToInt32(2147483648.75), 2147483648.75 << 0 ); + array[item++] = new TestCase( SECTION, "4294967295.25 << 0", ToInt32(4294967295.25), 4294967295.25 << 0 ); + array[item++] = new TestCase( SECTION, "4294967295.5 << 0", ToInt32(4294967295.5), 4294967295.5 << 0 ); + array[item++] = new TestCase( SECTION, "4294967295.75 << 0", ToInt32(4294967295.75), 4294967295.75 << 0 ); + array[item++] = new TestCase( SECTION, "3000000000.25 << 0", ToInt32(3000000000.25), 3000000000.25 << 0 ); + array[item++] = new TestCase( SECTION, "3000000000.5 << 0", ToInt32(3000000000.5), 3000000000.5 << 0 ); + array[item++] = new TestCase( SECTION, "3000000000.75 << 0", ToInt32(3000000000.75), 3000000000.75 << 0 ); + + /* + * Numbers between - 2^31 and - 2^32 + */ + array[item++] = new TestCase( SECTION, "-2147483648.25 << 0", ToInt32(-2147483648.25), -2147483648.25 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483648.5 << 0", ToInt32(-2147483648.5), -2147483648.5 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483648.75 << 0", ToInt32(-2147483648.75), -2147483648.75 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967295.25 << 0", ToInt32(-4294967295.25), -4294967295.25 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967295.5 << 0", ToInt32(-4294967295.5), -4294967295.5 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967295.75 << 0", ToInt32(-4294967295.75), -4294967295.75 << 0 ); + array[item++] = new TestCase( SECTION, "-3000000000.25 << 0", ToInt32(-3000000000.25), -3000000000.25 << 0 ); + array[item++] = new TestCase( SECTION, "-3000000000.5 << 0", ToInt32(-3000000000.5), -3000000000.5 << 0 ); + array[item++] = new TestCase( SECTION, "-3000000000.75 << 0", ToInt32(-3000000000.75), -3000000000.75 << 0 ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.6.js new file mode 100644 index 0000000..c4c3bff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.6.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: 9.6.js + ECMA Section: 9.6 Type Conversion: ToUint32 + Description: rules for converting an argument to an unsigned + 32 bit integer + + this test uses >>> 0 to convert the argument to + an unsigned 32bit integer. + + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, Infinity, -Infinity + return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 return result(4) + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + ** NEED TO DO THIS PART IN A SEPARATE TEST FILE ** + + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + + var SECTION = "9.6"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Type Conversion: ToUint32"); + 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 ); +} + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "0 >>> 0", 0, 0 >>> 0 ); +// array[item++] = new TestCase( SECTION, "+0 >>> 0", 0, +0 >>> 0); + array[item++] = new TestCase( SECTION, "-0 >>> 0", 0, -0 >>> 0 ); + array[item++] = new TestCase( SECTION, "'Infinity' >>> 0", 0, "Infinity" >>> 0 ); + array[item++] = new TestCase( SECTION, "'-Infinity' >>> 0", 0, "-Infinity" >>> 0); + array[item++] = new TestCase( SECTION, "'+Infinity' >>> 0", 0, "+Infinity" >>> 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY >>> 0", 0, Number.POSITIVE_INFINITY >>> 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY >>> 0", 0, Number.NEGATIVE_INFINITY >>> 0 ); + array[item++] = new TestCase( SECTION, "Number.NaN >>> 0", 0, Number.NaN >>> 0 ); + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); + array[item++] = new TestCase( SECTION, "-Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); + array[item++] = new TestCase( SECTION, "0.1 >>> 0", 0, 0.1 >>> 0 ); + array[item++] = new TestCase( SECTION, "-0.1 >>> 0", 0, -0.1 >>> 0 ); + array[item++] = new TestCase( SECTION, "1 >>> 0", 1, 1 >>> 0 ); + array[item++] = new TestCase( SECTION, "1.1 >>> 0", 1, 1.1 >>> 0 ); + + array[item++] = new TestCase( SECTION, "-1.1 >>> 0", ToUint32(-1.1), -1.1 >>> 0 ); + array[item++] = new TestCase( SECTION, "-1 >>> 0", ToUint32(-1), -1 >>> 0 ); + + array[item++] = new TestCase( SECTION, "2147483647 >>> 0", ToUint32(2147483647), 2147483647 >>> 0 ); + array[item++] = new TestCase( SECTION, "2147483648 >>> 0", ToUint32(2147483648), 2147483648 >>> 0 ); + array[item++] = new TestCase( SECTION, "2147483649 >>> 0", ToUint32(2147483649), 2147483649 >>> 0 ); + + array[item++] = new TestCase( SECTION, "4294967295 >>> 0", ToUint32(4294967295), 4294967295 >>> 0 ); + array[item++] = new TestCase( SECTION, "4294967296 >>> 0", ToUint32(4294967296), 4294967296 >>> 0 ); + array[item++] = new TestCase( SECTION, "4294967297 >>> 0", ToUint32(4294967297), 4294967297 >>> 0 ); + + array[item++] = new TestCase( SECTION, "-2147483647 >>> 0", ToUint32(-2147483647), -2147483647 >>> 0 ); + array[item++] = new TestCase( SECTION, "-2147483648 >>> 0", ToUint32(-2147483648), -2147483648 >>> 0 ); + array[item++] = new TestCase( SECTION, "-2147483649 >>> 0", ToUint32(-2147483649), -2147483649 >>> 0 ); + + array[item++] = new TestCase( SECTION, "-4294967295 >>> 0", ToUint32(-4294967295), -4294967295 >>> 0 ); + array[item++] = new TestCase( SECTION, "-4294967296 >>> 0", ToUint32(-4294967296), -4294967296 >>> 0 ); + array[item++] = new TestCase( SECTION, "-4294967297 >>> 0", ToUint32(-4294967297), -4294967297 >>> 0 ); + + array[item++] = new TestCase( SECTION, "'2147483647' >>> 0", ToUint32(2147483647), '2147483647' >>> 0 ); + array[item++] = new TestCase( SECTION, "'2147483648' >>> 0", ToUint32(2147483648), '2147483648' >>> 0 ); + array[item++] = new TestCase( SECTION, "'2147483649' >>> 0", ToUint32(2147483649), '2147483649' >>> 0 ); + + array[item++] = new TestCase( SECTION, "'4294967295' >>> 0", ToUint32(4294967295), '4294967295' >>> 0 ); + array[item++] = new TestCase( SECTION, "'4294967296' >>> 0", ToUint32(4294967296), '4294967296' >>> 0 ); + array[item++] = new TestCase( SECTION, "'4294967297' >>> 0", ToUint32(4294967297), '4294967297' >>> 0 ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.7.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.7.js new file mode 100644 index 0000000..60322d4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.7.js @@ -0,0 +1,158 @@ +/* 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: 9.7.js + ECMA Section: 9.7 Type Conversion: ToInt16 + Description: rules for converting an argument to an unsigned + 16 bit integer in the range 0 to 2^16-1. + + this test uses String.prototype.fromCharCode() and + String.prototype.charCodeAt() to test ToInt16. + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + var SECTION = "9.7"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Type Conversion: ToInt16"); + 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 ); +} +function ToInt16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + + num = num % Math.pow(2,16); + + num = ( num > -65536 && num < 0) ? 65536 + num : num; + + return num; +} + +function getTestCases() { + var array = new Array(); + var item = 0; +/* + array[item++] = new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", 0, String.fromCharCode(0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", 0, String.fromCharCode(-0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", 1, String.fromCharCode(1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", 64, String.fromCharCode(64).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", 126, String.fromCharCode(126).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", 127, String.fromCharCode(127).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", 128, String.fromCharCode(128).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", 130, String.fromCharCode(130).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", 255, String.fromCharCode(255).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", 256, String.fromCharCode(256).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); +*/ + + + array[item++] = new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", ToInt16(0), String.fromCharCode(0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", ToInt16(0), String.fromCharCode(-0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", ToInt16(1), String.fromCharCode(1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", ToInt16(64), String.fromCharCode(64).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", ToInt16(126), String.fromCharCode(126).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", ToInt16(127), String.fromCharCode(127).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", ToInt16(128), String.fromCharCode(128).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", ToInt16(130), String.fromCharCode(130).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", ToInt16(255), String.fromCharCode(255).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", ToInt16(256), String.fromCharCode(256).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(65535).charCodeAt(0)", ToInt16(65535), String.fromCharCode(65535).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(65536).charCodeAt(0)", ToInt16(65536), String.fromCharCode(65536).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(65537).charCodeAt(0)", ToInt16(65537), String.fromCharCode(65537).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(131071).charCodeAt(0)", ToInt16(131071), String.fromCharCode(131071).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(131072).charCodeAt(0)", ToInt16(131072), String.fromCharCode(131072).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(131073).charCodeAt(0)", ToInt16(131073), String.fromCharCode(131073).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode('65535').charCodeAt(0)", 65535, String.fromCharCode("65535").charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode('65536').charCodeAt(0)", 0, String.fromCharCode("65536").charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-1).charCodeAt(0)", ToInt16(-1), String.fromCharCode(-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-64).charCodeAt(0)", ToInt16(-64), String.fromCharCode(-64).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-126).charCodeAt(0)", ToInt16(-126), String.fromCharCode(-126).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-127).charCodeAt(0)", ToInt16(-127), String.fromCharCode(-127).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-128).charCodeAt(0)", ToInt16(-128), String.fromCharCode(-128).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-130).charCodeAt(0)", ToInt16(-130), String.fromCharCode(-130).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-255).charCodeAt(0)", ToInt16(-255), String.fromCharCode(-255).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-256).charCodeAt(0)", ToInt16(-256), String.fromCharCode(-256).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(-Math.pow(2,16)).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-65535).charCodeAt(0)", ToInt16(-65535), String.fromCharCode(-65535).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-65536).charCodeAt(0)", ToInt16(-65536), String.fromCharCode(-65536).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-65537).charCodeAt(0)", ToInt16(-65537), String.fromCharCode(-65537).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-131071).charCodeAt(0)", ToInt16(-131071), String.fromCharCode(-131071).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-131072).charCodeAt(0)", ToInt16(-131072), String.fromCharCode(-131072).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-131073).charCodeAt(0)", ToInt16(-131073), String.fromCharCode(-131073).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode('-65535').charCodeAt(0)", ToInt16(-65535), String.fromCharCode("-65535").charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode('-65536').charCodeAt(0)", ToInt16(-65536), String.fromCharCode("-65536").charCodeAt(0) ); + + +// array[item++] = new TestCase( "9.7", "String.fromCharCode(2147483648).charCodeAt(0)", ToInt16(2147483648), String.fromCharCode(2147483648).charCodeAt(0) ); + + + +// the following test cases cause a runtime error. see: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=78878 + +// array[item++] = new TestCase( "9.7", "String.fromCharCode(Infinity).charCodeAt(0)", 0, String.fromCharCode("Infinity").charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(-Infinity).charCodeAt(0)", 0, String.fromCharCode("-Infinity").charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(NaN).charCodeAt(0)", 0, String.fromCharCode(Number.NaN).charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) ); + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.8.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.8.1.js new file mode 100644 index 0000000..38cbb0a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.8.1.js @@ -0,0 +1,166 @@ +/* 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: 9.8.1.js + ECMA Section: 9.8.1 ToString Applied to the Number Type + Description: The operator ToString convers a number m to string + as follows: + + 1. if m is NaN, return the string "NaN" + 2. if m is +0 or -0, return the string "0" + 3. if m is less than zero, return the string + concatenation of the string "-" and ToString(-m). + 4. If m is Infinity, return the string "Infinity". + 5. Otherwise, let n, k, and s be integers such that + k >= 1, 10k1 <= s < 10k, the number value for s10nk + is m, and k is as small as possible. Note that k is + the number of digits in the decimal representation + of s, that s is not divisible by 10, and that the + least significant digit of s is not necessarily + uniquely determined by these criteria. + 6. If k <= n <= 21, return the string consisting of the + k digits of the decimal representation of s (in order, + with no leading zeroes), followed by n-k occurences + of the character '0'. + 7. If 0 < n <= 21, return the string consisting of the + most significant n digits of the decimal + representation of s, followed by a decimal point + '.', followed by the remaining kn digits of the + decimal representation of s. + 8. If 6 < n <= 0, return the string consisting of the + character '0', followed by a decimal point '.', + followed by n occurences of the character '0', + followed by the k digits of the decimal + representation of s. + 9. Otherwise, if k = 1, return the string consisting + of the single digit of s, followed by lowercase + character 'e', followed by a plus sign '+' or minus + sign '' according to whether n1 is positive or + negative, followed by the decimal representation + of the integer abs(n1) (with no leading zeros). + 10. Return the string consisting of the most significant + digit of the decimal representation of s, followed + by a decimal point '.', followed by the remaining k1 + digits of the decimal representation of s, followed + by the lowercase character 'e', followed by a plus + sign '+' or minus sign '' according to whether n1 is + positive or negative, followed by the decimal + representation of the integer abs(n1) (with no + leading zeros). + + Note that if x is any number value other than 0, then + ToNumber(ToString(x)) is exactly the same number value as x. + + As noted, the least significant digit of s is not always + uniquely determined by the requirements listed in step 5. + The following specification for step 5 was considered, but + not adopted: + + Author: christine@netscape.com + Date: 10 july 1997 +*/ + + var SECTION = "9.8.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " ToString applied to the Number type"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.NaN", "NaN", Number.NaN + "" ); + array[item++] = new TestCase( SECTION, "0", "0", 0 + "" ); + array[item++] = new TestCase( SECTION, "-0", "0", -0 + "" ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY", "Infinity", Number.POSITIVE_INFINITY + "" ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY", "-Infinity", Number.NEGATIVE_INFINITY + "" ); + array[item++] = new TestCase( SECTION, "-1", "-1", -1 + "" ); + + // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 + + array[item++] = new TestCase( SECTION, "1", "1", 1 + "" ); + array[item++] = new TestCase( SECTION, "10", "10", 10 + "" ); + array[item++] = new TestCase( SECTION, "100", "100", 100 + "" ); + array[item++] = new TestCase( SECTION, "1000", "1000", 1000 + "" ); + array[item++] = new TestCase( SECTION, "10000", "10000", 10000 + "" ); + array[item++] = new TestCase( SECTION, "10000000000", "10000000000", 10000000000 + "" ); + array[item++] = new TestCase( SECTION, "10000000000000000000", "10000000000000000000", 10000000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "100000000000000000000","100000000000000000000",100000000000000000000 + "" ); + + array[item++] = new TestCase( SECTION, "12345", "12345", 12345 + "" ); + array[item++] = new TestCase( SECTION, "1234567890", "1234567890", 1234567890 + "" ); + + array[item++] = new TestCase( SECTION, "-1", "-1", -1 + "" ); + array[item++] = new TestCase( SECTION, "-10", "-10", -10 + "" ); + array[item++] = new TestCase( SECTION, "-100", "-100", -100 + "" ); + array[item++] = new TestCase( SECTION, "-1000", "-1000", -1000 + "" ); + array[item++] = new TestCase( SECTION, "-1000000000", "-1000000000", -1000000000 + "" ); + array[item++] = new TestCase( SECTION, "-1000000000000000", "-1000000000000000", -1000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "-100000000000000000000", "-100000000000000000000", -100000000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "-1000000000000000000000", "-1e+21", -1000000000000000000000 + "" ); + + array[item++] = new TestCase( SECTION, "-12345", "-12345", -12345 + "" ); + array[item++] = new TestCase( SECTION, "-1234567890", "-1234567890", -1234567890 + "" ); + + // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, + array[item++] = new TestCase( SECTION, "1.0000001", "1.0000001", 1.0000001 + "" ); + + // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 + + // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 + + array[item++] = new TestCase( SECTION, "1000000000000000000000", "1e+21", 1000000000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "10000000000000000000000", "1e+22", 10000000000000000000000 + "" ); + + // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 + + array[item++] = new TestCase( SECTION, "1.2345", "1.2345", String( 1.2345)); + array[item++] = new TestCase( SECTION, "1.234567890", "1.23456789", String( 1.234567890 )); + + + array[item++] = new TestCase( SECTION, ".12345", "0.12345", String(.12345 ) ); + array[item++] = new TestCase( SECTION, ".012345", "0.012345", String(.012345) ); + array[item++] = new TestCase( SECTION, ".0012345", "0.0012345", String(.0012345) ); + array[item++] = new TestCase( SECTION, ".00012345", "0.00012345", String(.00012345) ); + array[item++] = new TestCase( SECTION, ".000012345", "0.000012345", String(.000012345) ); + array[item++] = new TestCase( SECTION, ".0000012345", "0.0000012345", String(.0000012345) ); + array[item++] = new TestCase( SECTION, ".00000012345", "1.2345e-7", String(.00000012345)); + + array[item++] = new TestCase( SECTION, "-1e21", "-1e+21", String(-1e21) ); + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.9-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.9-1.js new file mode 100644 index 0000000..0df39f3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.9-1.js @@ -0,0 +1,143 @@ +/* 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: 9.9-1.js + ECMA Section: 9.9 Type Conversion: ToObject + Description: + + 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 VERSION = "ECMA_1"; + startTest(); + var SECTION = "9.9-1"; + + writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + 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, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); + + 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, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); + + 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, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ ); + + 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, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ ); + + 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, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ ); + + 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, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ ); + + 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, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ ); + + 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, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ ); + + 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, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ ); + + 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, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ ); + + 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, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ ); + + 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, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); + array[item++] = new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ ); + + 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, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); + array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object( new MyObject(true) ).valueOf()", true, eval("Object( new MyObject(true) ).valueOf()") ); + array[item++] = new TestCase( SECTION, "typeof Object( new MyObject(true) )", "object", eval("typeof Object( new MyObject(true) )") ); + array[item++] = new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).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(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.1.js new file mode 100644 index 0000000..efc4792 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.1.js @@ -0,0 +1,71 @@ +/* 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: 8.1.js + ECMA Section: The undefined type + Description: + + The Undefined type has exactly one value, called undefined. Any variable + that has not been assigned a value is of type Undefined. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "8.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The undefined type"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var x; typeof x", + "undefined", + eval("var x; typeof x") ); + + testcases[tc++] = new TestCase( SECTION, + "var x; typeof x == 'undefined", + true, + eval("var x; typeof x == 'undefined'") ); + + testcases[tc++] = new TestCase( SECTION, + "var x; x == void 0", + true, + eval("var x; x == void 0") ); + 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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.4.js b/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.4.js new file mode 100644 index 0000000..c18f744 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.4.js @@ -0,0 +1,125 @@ +/* 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: 8.4.js + ECMA Section: The String type + Description: + + The String type is the set of all finite ordered sequences of zero or more + Unicode characters. Each character is regarded as occupying a position + within the sequence. These positions are identified by nonnegative + integers. The leftmost character (if any) is at position 0, the next + character (if any) at position 1, and so on. The length of a string is the + number of distinct positions within it. The empty string has length zero + and therefore contains no characters. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "8.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The String type"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var s = ''; s.length", + 0, + eval("var s = ''; s.length") ); + + testcases[tc++] = new TestCase( SECTION, + "var s = ''; s.charAt(0)", + "", + eval("var s = ''; s.charAt(0)") ); + + + for ( var i = 0x0041, TEST_STRING = "", EXPECT_STRING = ""; i < 0x007B; i++ ) { + TEST_STRING += ("\\u"+ DecimalToHexString( i ) ); + EXPECT_STRING += String.fromCharCode(i); + } + + testcases[tc++] = new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s", + EXPECT_STRING, + eval("var s = '" + TEST_STRING+ "'; s") ); + + testcases[tc++] = new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s.length", + 0x007B-0x0041, + eval("var s = '" + TEST_STRING+ "'; s.length") ); + + test(); +function DecimalToHexString( n ) { + n = Number( n ); + var h = ""; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} + +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/Types/8.6.2.1-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.6.2.1-1.js new file mode 100644 index 0000000..05b9400 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/Types/8.6.2.1-1.js @@ -0,0 +1,105 @@ +/* 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: 8.6.2.1-1.js + ECMA Section: 8.6.2.1 Get (Value) + Description: + + When the [[Get]] method of O is called with property name P, the following + steps are taken: + + 1. If O doesn't have a property with name P, go to step 4. + 2. Get the value of the property. + 3. Return Result(2). + 4. If the [[Prototype]] of O is null, return undefined. + 5. Call the [[Get]] method of [[Prototype]] with property name P. + 6. Return Result(5). + + This tests [[Get]] (Value). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "8.6.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " [[Get]] (Value)"); + 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 ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); +// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + + array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); +// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); + + array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); +// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyObject('string'); OBJ.valueOf()") ); + + return ( array ); +} +function MyProtoValuelessObject(value) { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} + +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/browser.js b/Source/JavaScriptCore/tests/mozilla/ecma/browser.js new file mode 100644 index 0000000..5bbdf7c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/browser.js @@ -0,0 +1,80 @@ +/* +* 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.org code. +* +* 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): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * <script src="./../shell.js"></script> + * <script src="./../browser.js"></script> + * <script src="./mytest.js"></script> + */ + +onerror = err; + +function startTest() { + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "<br>\n"); +} +function writeHeaderToLog( string ) { + document.write( "<h2>" + string + "</h2>" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "<hr>" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900> " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/jsref.js b/Source/JavaScriptCore/tests/mozilla/ecma/jsref.js new file mode 100644 index 0000000..51b5a83 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/jsref.js @@ -0,0 +1,669 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +TITLE = ""; + +/* + * constant strings + */ +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; +var DEBUG = false; + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +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 ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} + +/* + * Set up test environment. + * + */ +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + } + + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + + +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 getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +/** + * Type Conversion functions used by Type Conversion + * + */ + + + + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour + +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+t+") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetSecondSundayInMarch(t) + 2*msPerHour; + var dst_end = GetFirstSundayInNovember(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/shell.js b/Source/JavaScriptCore/tests/mozilla/ecma/shell.js new file mode 100644 index 0000000..1c82aed --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/shell.js @@ -0,0 +1,712 @@ +/* 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): + * + */ +/* + * JavaScript shared functions file for running the tests in either + * stand-alone JavaScript engine. To run a test, first load this file, + * then load the test script. + */ + +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; + +/* + * constant strings + */ +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +var DEBUG = false; + + + +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +/* + * TestCase constructor + * + */ + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} + +/* + * Set up test environment. + * + */ +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + } + + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + + +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 ); +} + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} + +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + + +/* + * When running in the shell, run the garbage collector after the + * test has completed. + */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} + +/* + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour +var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC +var TZ_PST = -8; // offset of Pacific Standard Time from UTC +var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; +var TIME_YEAR_0 = -62167219200000; + + +/* + * Originally, the test suite used a hard-coded value TZ_DIFF = -8. + * But that was only valid for testers in the Pacific Standard Time Zone! + * We calculate the proper number dynamically for any tester. We just + * have to be careful not to use a date subject to Daylight Savings Time... +*/ +function getTimeZoneDiff() +{ + return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; +} + + +/* + * Date test "ResultArrays" are hard-coded for Pacific Standard Time. + * We must adjust them for the tester's own timezone - + */ +function adjustResultArray(ResultArray, msMode) +{ + // If the tester's system clock is in PST, no need to continue - + if (!PST_DIFF) {return;} + + /* The date testcases instantiate Date objects in two different ways: + * + * millisecond mode: e.g. dt = new Date(10000000); + * year-month-day mode: dt = new Date(2000, 5, 1, ...); + * + * In the first case, the date is measured from Time 0 in Greenwich (i.e. UTC). + * In the second case, it is measured with reference to the tester's local timezone. + * + * In the first case we must correct those values expected for local measurements, + * like dt.getHours() etc. No correction is necessary for dt.getUTCHours() etc. + * + * In the second case, it is exactly the other way around - + */ + if (msMode) + { + // The hard-coded UTC milliseconds from Time 0 derives from a UTC date. + // Shift to the right by the offset between UTC and the tester. + var t = ResultArray[TIME] + TZ_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the local hour, day, etc. + ResultArray[HOURS] = HourFromTime(t); + ResultArray[DAY] = WeekDay(t); + ResultArray[DATE] = DateFromTime(t); + ResultArray[MONTH] = MonthFromTime(t); + ResultArray[YEAR] = YearFromTime(t); + } + else + { + // The hard-coded UTC milliseconds from Time 0 derives from a PST date. + // Shift to the left by the offset between PST and the tester. + var t = ResultArray[TIME] - PST_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the UTC hour, day, etc. + ResultArray[TIME] = t; + ResultArray[UTC_HOURS] = HourFromTime(t); + ResultArray[UTC_DAY] = WeekDay(t); + ResultArray[UTC_DATE] = DateFromTime(t); + ResultArray[UTC_MONTH] = MonthFromTime(t); + ResultArray[UTC_YEAR] = YearFromTime(t); + } +} + + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+ t + ") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} + +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetSecondSundayInMarch(t) + 2*msPerHour; + var dst_end = GetFirstSundayInNovember(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} + +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var p; + for ( p in o ) { + print( p +": " + o[p] ); + } +} + +/* these functions are useful for running tests manually in Rhino */ + +function GetContext() { + return Packages.com.netscape.javascript.Context.getCurrentContext(); +} +function OptLevel( i ) { + i = Number(i); + var cx = GetContext(); + cx.setOptimizationLevel(i); +} +/* end of Rhino functions */ |