diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma/Array | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma/Array')
32 files changed, 2818 insertions, 0 deletions
diff --git a/js/src/tests/ecma/Array/15.4-1.js b/js/src/tests/ecma/Array/15.4-1.js new file mode 100644 index 000000000..5371d71bc --- /dev/null +++ b/js/src/tests/ecma/Array/15.4-1.js @@ -0,0 +1,99 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +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]") + ); + +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") + ); + +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]") + ); + +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") + ); + +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]") + ); + +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") + ); + +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]") + ); + +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") + ); + +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)]") + ); + +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") + ); + +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]") + ); + +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") + ); + +test(); + diff --git a/js/src/tests/ecma/Array/15.4-2.js b/js/src/tests/ecma/Array/15.4-2.js new file mode 100644 index 000000000..d16167844 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4-2.js @@ -0,0 +1,80 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +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") ); + +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") ); + +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") ); + +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") ); + + +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") ); + +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") ); + +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") ); + +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)") ); + +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)") ); + +test(); + diff --git a/js/src/tests/ecma/Array/15.4.1.1.js b/js/src/tests/ecma/Array/15.4.1.1.js new file mode 100644 index 000000000..b64198517 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.1.1.js @@ -0,0 +1,77 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "typeof Array(1,2)", + "object", + typeof Array(1,2) ); + +new TestCase( SECTION, + "(Array(1,2)).toString", + Array.prototype.toString, + (Array(1,2)).toString ); + +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()") ); + +new TestCase( SECTION, + "(Array(1,2)).length", + 2, + (Array(1,2)).length ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); arr[0]", + 1, + eval("var arr = (Array(1,2)); arr[0]") ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); arr[1]", + 2, + eval("var arr = (Array(1,2)); arr[1]") ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); String(arr)", + "1,2", + eval("var arr = (Array(1,2)); String(arr)") ); + +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); +} + diff --git a/js/src/tests/ecma/Array/15.4.1.2.js b/js/src/tests/ecma/Array/15.4.1.2.js new file mode 100644 index 000000000..08e3c0d77 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.1.2.js @@ -0,0 +1,128 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "(Array()).length", + 0, + (Array()).length ); + +new TestCase( SECTION, + "(Array(0)).length", + 0, + (Array(0)).length ); + +new TestCase( SECTION, + "(Array(1)).length", + 1, + (Array(1)).length ); + +new TestCase( SECTION, + "(Array(10)).length", + 10, + (Array(10)).length ); + +new TestCase( SECTION, + "(Array('1')).length", + 1, + (Array('1')).length ); + +new TestCase( SECTION, + "(Array(1000)).length", + 1000, + (Array(1000)).length ); + +new TestCase( SECTION, + "(Array('1000')).length", + 1, + (Array('1000')).length ); + +new TestCase( SECTION, + "(Array(4294967295)).length", + ToUint32(4294967295), + (Array(4294967295)).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31)-1)).length", + ToUint32(Math.pow(2,31)-1), + (Array(Math.pow(2,31)-1)).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31))).length", + ToUint32(Math.pow(2,31)), + (Array(Math.pow(2,31))).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31)+1)).length", + ToUint32(Math.pow(2,31)+1), + (Array(Math.pow(2,31)+1)).length ); + +new TestCase( SECTION, + "(Array('8589934592')).length", + 1, + (Array("8589934592")).length ); + +new TestCase( SECTION, + "(Array('4294967296')).length", + 1, + (Array("4294967296")).length ); + +new TestCase( SECTION, + "(Array(1073741823)).length", + ToUint32(1073741823), + (Array(1073741823)).length ); + +new TestCase( SECTION, + "(Array(1073741824)).length", + ToUint32(1073741824), + (Array(1073741824)).length ); + +new TestCase( SECTION, + "(Array('a string')).length", + 1, + (Array("a string")).length ); + +test(); + +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 ); +} diff --git a/js/src/tests/ecma/Array/15.4.1.3.js b/js/src/tests/ecma/Array/15.4.1.3.js new file mode 100644 index 000000000..b6f09ce8b --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.1.3.js @@ -0,0 +1,50 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + +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()") ); + +new TestCase( SECTION, + "(Array()).length", + 0, + (Array()).length ); + +new TestCase( SECTION, + "Array().toString()", + "", + Array().toString() ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.1.js b/js/src/tests/ecma/Array/15.4.1.js new file mode 100644 index 000000000..18208b1ba --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.1.js @@ -0,0 +1,98 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "Array() +''", + "", + Array() +"" ); + +new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + +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()") ); + +new TestCase( SECTION, + "var arr = Array(); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(); arr.toString == Array.prototype.toString") ); + +new TestCase( SECTION, + "Array().length", + 0, + Array().length ); + +new TestCase( SECTION, + "Array(1,2,3) +''", + "1,2,3", + Array(1,2,3) +"" ); + +new TestCase( SECTION, + "typeof Array(1,2,3)", + "object", + typeof Array(1,2,3) ); + +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()") ); + +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") ); + +new TestCase( SECTION, + "Array(1,2,3).length", + 3, + Array(1,2,3).length ); + +new TestCase( SECTION, + "typeof Array(12345)", + "object", + typeof Array(12345) ); + +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()") ); + +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") ); + +new TestCase( SECTION, + "Array(12345).length", + 12345, + Array(12345).length ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.2.1-1.js b/js/src/tests/ecma/Array/15.4.2.1-1.js new file mode 100644 index 000000000..af31fed87 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.2.1-1.js @@ -0,0 +1,78 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "typeof new Array(1,2)", + "object", + typeof new Array(1,2) ); + +new TestCase( SECTION, + "(new Array(1,2)).toString", + Array.prototype.toString, + (new Array(1,2)).toString ); + +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()") ); + +new TestCase( SECTION, + "(new Array(1,2)).length", + 2, + (new Array(1,2)).length ); + +new TestCase( SECTION, + "var arr = (new Array(1,2)); arr[0]", + 1, + eval("var arr = (new Array(1,2)); arr[0]") ); + +new TestCase( SECTION, + "var arr = (new Array(1,2)); arr[1]", + 2, + eval("var arr = (new Array(1,2)); arr[1]") ); + +new TestCase( SECTION, + "var arr = (new Array(1,2)); String(arr)", + "1,2", + eval("var arr = (new Array(1,2)); String(arr)") ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.2.1-2.js b/js/src/tests/ecma/Array/15.4.2.1-2.js new file mode 100644 index 000000000..4cb1ce2b3 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.2.1-2.js @@ -0,0 +1,67 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + + +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 ( var item = 0; item < TEST_LENGTH; item++ ) { + new TestCase( SECTION, + "["+item+"]", + item, + TEST_ARRAY[item] ); +} + +new TestCase( SECTION, + "new Array( ["+TEST_LENGTH+" arguments] ) +''", + ARGUMENTS, + TEST_ARRAY +"" ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.2.1-3.js b/js/src/tests/ecma/Array/15.4.2.1-3.js new file mode 100644 index 000000000..36910aef8 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.2.1-3.js @@ -0,0 +1,103 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 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 ( var item = 0; item < TEST_LENGTH; item++ ) { + new TestCase( SECTION, + "TEST_ARRAY["+item+"]", + item, + TEST_ARRAY[item] ); +} + +new TestCase( SECTION, + "new Array( ["+TEST_LENGTH+" arguments] ) +''", + ARGUMENTS, + TEST_ARRAY +"" ); + +new TestCase( SECTION, + "TEST_ARRAY.toString", + Array.prototype.toString, + TEST_ARRAY.toString ); + +new TestCase( SECTION, + "TEST_ARRAY.join", + Array.prototype.join, + TEST_ARRAY.join ); + +new TestCase( SECTION, + "TEST_ARRAY.sort", + Array.prototype.sort, + TEST_ARRAY.sort ); + +new TestCase( SECTION, + "TEST_ARRAY.reverse", + Array.prototype.reverse, + TEST_ARRAY.reverse ); + +new TestCase( SECTION, + "TEST_ARRAY.length", + TEST_LENGTH, + TEST_ARRAY.length ); + +new TestCase( SECTION, + "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", + "[object Array]", + eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.2.2-1.js b/js/src/tests/ecma/Array/15.4.2.2-1.js new file mode 100644 index 000000000..6a8956113 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.2.2-1.js @@ -0,0 +1,149 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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_t 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); + +new TestCase( SECTION, + "new Array(0)", + "", + (new Array(0)).toString() ); + +new TestCase( SECTION, + "typeof new Array(0)", + "object", + (typeof new Array(0)) ); + +new TestCase( SECTION, + "(new Array(0)).length", + 0, + (new Array(0)).length ); + +new TestCase( SECTION, + "(new Array(0)).toString", + Array.prototype.toString, + (new Array(0)).toString ); + +new TestCase( SECTION, + "new Array(1)", + "", + (new Array(1)).toString() ); + +new TestCase( SECTION, + "new Array(1).length", + 1, + (new Array(1)).length ); + +new TestCase( SECTION, + "(new Array(1)).toString", + Array.prototype.toString, + (new Array(1)).toString ); + +new TestCase( SECTION, + "(new Array(-0)).length", + 0, + (new Array(-0)).length ); + +new TestCase( SECTION, + "(new Array(0)).length", + 0, + (new Array(0)).length ); + +new TestCase( SECTION, + "(new Array(10)).length", + 10, + (new Array(10)).length ); + +new TestCase( SECTION, + "(new Array('1')).length", + 1, + (new Array('1')).length ); + +new TestCase( SECTION, + "(new Array(1000)).length", + 1000, + (new Array(1000)).length ); + +new TestCase( SECTION, + "(new Array('1000')).length", + 1, + (new Array('1000')).length ); + +new TestCase( SECTION, + "(new Array(4294967295)).length", + ToUint32(4294967295), + (new Array(4294967295)).length ); + +new TestCase( SECTION, + "(new Array('8589934592')).length", + 1, + (new Array("8589934592")).length ); + +new TestCase( SECTION, + "(new Array('4294967296')).length", + 1, + (new Array("4294967296")).length ); + +new TestCase( SECTION, + "(new Array(1073741824)).length", + ToUint32(1073741824), + (new Array(1073741824)).length ); + +test(); + +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 ); +} diff --git a/js/src/tests/ecma/Array/15.4.2.2-2.js b/js/src/tests/ecma/Array/15.4.2.2-2.js new file mode 100644 index 000000000..f8c88f862 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.2.2-2.js @@ -0,0 +1,84 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "(new Array(new Number(1073741823))).length", + 1, + (new Array(new Number(1073741823))).length ); + +new TestCase( SECTION, + "(new Array(new Number(0))).length", + 1, + (new Array(new Number(0))).length ); + +new TestCase( SECTION, + "(new Array(new Number(1000))).length", + 1, + (new Array(new Number(1000))).length ); + +new TestCase( SECTION, + "(new Array('mozilla, larryzilla, curlyzilla')).length", + 1, + (new Array('mozilla, larryzilla, curlyzilla')).length ); + +new TestCase( SECTION, + "(new Array(true)).length", + 1, + (new Array(true)).length ); + +new TestCase( SECTION, + "(new Array(false)).length", + 1, + (new Array(false)).length); + +new TestCase( SECTION, + "(new Array(new Boolean(true)).length", + 1, + (new Array(new Boolean(true))).length ); + +new TestCase( SECTION, + "(new Array(new Boolean(false)).length", + 1, + (new Array(new Boolean(false))).length ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.2.3.js b/js/src/tests/ecma/Array/15.4.2.3.js new file mode 100644 index 000000000..5ec7989dc --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.2.3.js @@ -0,0 +1,67 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "new Array() +''", + "", + (new Array()) +"" ); + +new TestCase( SECTION, + "typeof new Array()", + "object", + (typeof new Array()) ); + +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()") ); + +new TestCase( SECTION, + "(new Array()).length", + 0, + (new Array()).length ); + +new TestCase( SECTION, + "(new Array()).toString == Array.prototype.toString", + true, + (new Array()).toString == Array.prototype.toString ); + +new TestCase( SECTION, + "(new Array()).join == Array.prototype.join", + true, + (new Array()).join == Array.prototype.join ); + +new TestCase( SECTION, + "(new Array()).reverse == Array.prototype.reverse", + true, + (new Array()).reverse == Array.prototype.reverse ); + +new TestCase( SECTION, + "(new Array()).sort == Array.prototype.sort", + true, + (new Array()).sort == Array.prototype.sort ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.3.1-2.js b/js/src/tests/ecma/Array/15.4.3.1-2.js new file mode 100644 index 000000000..70f38f831 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.3.1-2.js @@ -0,0 +1,47 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 ARRAY_PROTO = Array.prototype; + +new TestCase( SECTION, + "var props = ''; for ( p in Array ) { props += p } props", + "", + eval("var props = ''; for ( p in Array ) { props += p } props") ); + +new TestCase( SECTION, + "Array.prototype = null; Array.prototype", + ARRAY_PROTO, + eval("Array.prototype = null; Array.prototype") ); + +new TestCase( SECTION, + "delete Array.prototype", + false, + delete Array.prototype ); + +new TestCase( SECTION, + "delete Array.prototype; Array.prototype", + ARRAY_PROTO, + eval("delete Array.prototype; Array.prototype") ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.3.2.js b/js/src/tests/ecma/Array/15.4.3.2.js new file mode 100644 index 000000000..33d50005a --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.3.2.js @@ -0,0 +1,28 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "Array.length", + 1, + Array.length ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.4.1.js b/js/src/tests/ecma/Array/15.4.4.1.js new file mode 100644 index 000000000..7ffe56002 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.1.js @@ -0,0 +1,29 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + + +new TestCase( SECTION, + "Array.prototype.constructor == Array", + true, + Array.prototype.constructor == Array); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.4.2.js b/js/src/tests/ecma/Array/15.4.4.2.js new file mode 100644 index 000000000..a471da1cc --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.2.js @@ -0,0 +1,76 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "Array.prototype.toString.length", + 0, + Array.prototype.toString.length ); + +new TestCase( SECTION, + "(new Array()).toString()", + "", + (new Array()).toString() ); + +new TestCase( SECTION, + "(new Array(2)).toString()", + ",", + (new Array(2)).toString() ); + +new TestCase( SECTION, + "(new Array(0,1)).toString()", + "0,1", + (new Array(0,1)).toString() ); + +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() ); + +new TestCase( SECTION, + "(new Array( Boolean(1), Boolean(0))).toString()", + "true,false", + (new Array(Boolean(1),Boolean(0))).toString() ); + +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 ); + +new TestCase( SECTION, + "MYARR.toString()", + EXPECT_STRING, + MYARR.toString() ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.4.3-1.js b/js/src/tests/ecma/Array/15.4.4.3-1.js new file mode 100644 index 000000000..dd550e511 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.3-1.js @@ -0,0 +1,127 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 ARR_PROTOTYPE = Array.prototype; + +new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length ); + +// case where array length is 0 + +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 + +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 +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 +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 +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 +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 +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')", + decodeURIComponent("%0B%0Btrue%0Bfalse%0B123%0B[object Object]%0Btrue"), + 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 +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 +")" ); + +new TestCase( SECTION, + "TEST_ARRAY.join("+SEPARATOR+")", + TEST_RESULT, + TEST_ARRAY.join( SEPARATOR ) ); + +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 +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(':')") ); + +test(); + +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/js/src/tests/ecma/Array/15.4.4.3-2.js b/js/src/tests/ecma/Array/15.4.4.3-2.js new file mode 100644 index 000000000..9b01737c2 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.3-2.js @@ -0,0 +1,39 @@ +var arr = [0,1,,3,4]; +Object.prototype[2] = 2; + +assertEq(arr.join(""), "01234"); +assertEq(arr.join(","), "0,1,2,3,4"); + +arr[2] = "porkchops"; +assertEq(arr.join("*"), "0*1*porkchops*3*4"); + +delete Object.prototype[2]; +assertEq(arr.join("*"), "0*1*porkchops*3*4"); + +delete arr[2]; +assertEq(arr.join("*"), "0*1**3*4"); + +Object.prototype[2] = null; +assertEq(arr.join("*"), "0*1**3*4"); +Object.prototype[2] = undefined; +assertEq(arr.join("*"), "0*1**3*4"); +arr[2] = null; +assertEq(arr.join("*"), "0*1**3*4"); +arr[2] = undefined; +assertEq(arr.join("*"), "0*1**3*4"); + +var arr = new Array(10); +assertEq(arr.join(""), ""); +assertEq(arr.join(), ",,,,,,,,,"); +assertEq(arr.join("|"), "|||||||||"); + +arr[2] = "doubt"; +assertEq(arr.join(","), ",,doubt,,,,,,,"); + +arr[9] = "failure"; +assertEq(arr.join(","), ",,doubt,,,,,,,failure"); + +delete arr[2]; +assertEq(arr.join(","), ",,,,,,,,,failure"); + +reportCompare(true, true); diff --git a/js/src/tests/ecma/Array/15.4.4.4-1.js b/js/src/tests/ecma/Array/15.4.4.4-1.js new file mode 100644 index 000000000..da3e2ecdf --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.4-1.js @@ -0,0 +1,250 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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"; +var BUGNUMBER="123724"; +startTest(); + +writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + +var ARR_PROTOTYPE = Array.prototype; + +new TestCase( SECTION, + "Array.prototype.reverse.length", + 0, + Array.prototype.reverse.length ); + +// length of array is 0 +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); + +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); + +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); + +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); + +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); + +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); + +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); + +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 ); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +test(); + +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "]", + R[i], + 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.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/js/src/tests/ecma/Array/15.4.4.4-2.js b/js/src/tests/ecma/Array/15.4.4.4-2.js new file mode 100644 index 000000000..60ad9049f --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.4-2.js @@ -0,0 +1,133 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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(); + +writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + +var ARR_PROTOTYPE = Array.prototype; + +new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); + +// length of array is 0 +new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + +test(); + +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} +test(); + +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/js/src/tests/ecma/Array/15.4.4.5-1.js b/js/src/tests/ecma/Array/15.4.4.5-1.js new file mode 100644 index 000000000..967e54715 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.5-1.js @@ -0,0 +1,191 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 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] ); +} + +test(); + +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + new TestCase( SECTION, + S +"; A.sort(); A.length", + E.length, + eval( S + "; A.sort(); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + 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/js/src/tests/ecma/Array/15.4.4.5-2.js b/js/src/tests/ecma/Array/15.4.4.5-2.js new file mode 100644 index 000000000..c242cddbb --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.5-2.js @@ -0,0 +1,193 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 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] ); +} + +test(); + +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + 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++ ) { + new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + 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/js/src/tests/ecma/Array/15.4.4.5-3.js b/js/src/tests/ecma/Array/15.4.4.5-3.js new file mode 100644 index 000000000..5b69e33ec --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.5-3.js @@ -0,0 +1,148 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 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; i < array.length; i++) { + new TestCase( + SECTION, + "testarr1["+i+"]", + realarr[i], + testarr1[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr2["+i+"]", + realarr[i], + testarr2[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr3["+i+"]", + realarr[i], + testarr3[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr4["+i+"]", + stringarr[i].toString(), + testarr4[i].toString() ); +} + +test(); + +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; +} diff --git a/js/src/tests/ecma/Array/15.4.4.js b/js/src/tests/ecma/Array/15.4.4.js new file mode 100644 index 000000000..b3410d873 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.4.js @@ -0,0 +1,40 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + + +new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length ); + +// verify that prototype object is an Array object. +new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype ); + +new TestCase( SECTION, + "Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()", + "[object Array]", + eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()") ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.5.1-1.js b/js/src/tests/ecma/Array/15.4.5.1-1.js new file mode 100644 index 000000000..724710aa3 --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.5.1-1.js @@ -0,0 +1,138 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + + +// P is "length" + +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 +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") ); + +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 + +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]") ); + +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++ ) { + if (i === "u".charCodeAt(0) || i === "x".charCodeAt(0)) + continue; + TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'"; + if ( i < 0x00FF - 1 ) { + TEST_STRING += ","; + } else { + TEST_STRING += ");" + } +} + +var LENGTH = 0x00ff - 0x0020 - 2 /* "u"/"x" exclusions above */; + +new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + 'hello', + eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) ); + +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 + +new TestCase( SECTION, + "var A = new Array(); A[123] = true; A.length", + 124, + eval("var A = new Array(); A[123] = true; A.length") ); + +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++ ) { + 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" + +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") ); + +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") ); + +test(); diff --git a/js/src/tests/ecma/Array/15.4.5.1-2.js b/js/src/tests/ecma/Array/15.4.5.1-2.js new file mode 100644 index 000000000..6cb93fc3d --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.5.1-2.js @@ -0,0 +1,118 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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 gTestcases 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 a = new Array(); + +AddCase( "3.00", "three" ); +AddCase( "00010", "eight" ); +AddCase( "37xyz", "thirty-five" ); +AddCase("5000000000", 5) + AddCase( "-2", -3 ); + +new TestCase( SECTION, + "a[10]", + void 0, + a[10] ); + +new TestCase( SECTION, + "a[3]", + void 0, + a[3] ); + +a[4] = "four"; + +new TestCase( SECTION, + "a[4] = \"four\"; a[4]", + "four", + a[4] ); + +new TestCase( SECTION, + "a[\"4\"]", + "four", + a["4"] ); + +new TestCase( SECTION, + "a[\"4.00\"]", + void 0, + a["4.00"] ); + +new TestCase( SECTION, + "a.length", + 5, + a.length ); + + +a["5000000000"] = 5; + +new TestCase( SECTION, + "a[\"5000000000\"] = 5; a.length", + 5, + a.length ); + +new TestCase( SECTION, + "a[\"-2\"] = -3; a.length", + 5, + a.length ); + +test(); + +function AddCase ( arg, value ) { + + a[arg] = value; + + new TestCase( SECTION, + "a[\"" + arg + "\"] = "+ value +"; a.length", + 0, + a.length ); +} diff --git a/js/src/tests/ecma/Array/15.4.5.2-1.js b/js/src/tests/ecma/Array/15.4.5.2-1.js new file mode 100644 index 000000000..767c85c6f --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.5.2-1.js @@ -0,0 +1,52 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +new TestCase( SECTION, + "var A = new Array(); A.length", + 0, + eval("var A = new Array(); A.length") ); +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") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; A.length", + 123, + eval("var A = new Array(); A.length = 123; A.length") ); +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") ); +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") ); +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") ); +test(); + diff --git a/js/src/tests/ecma/Array/15.4.5.2-2.js b/js/src/tests/ecma/Array/15.4.5.2-2.js new file mode 100644 index 000000000..7a21410bb --- /dev/null +++ b/js/src/tests/ecma/Array/15.4.5.2-2.js @@ -0,0 +1,93 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.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); + +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; + + 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; + } + } + 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; + } + } + new TestCase( SECTION, + "verify that new items are undefined", + true, + passed ); + } + } + +} + diff --git a/js/src/tests/ecma/Array/array-length-set-during-for-in.js b/js/src/tests/ecma/Array/array-length-set-during-for-in.js new file mode 100644 index 000000000..83d476f7f --- /dev/null +++ b/js/src/tests/ecma/Array/array-length-set-during-for-in.js @@ -0,0 +1,10 @@ +var a = [0, 1]; +var iterations = 0; +for (var k in a) { + iterations++; + a.length = 1; +} +assertEq(iterations, 1); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/ecma/Array/array-length-set-on-nonarray.js b/js/src/tests/ecma/Array/array-length-set-on-nonarray.js new file mode 100644 index 000000000..bc47c7477 --- /dev/null +++ b/js/src/tests/ecma/Array/array-length-set-on-nonarray.js @@ -0,0 +1,26 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 548671; +var summary = + "Don't use a shared-permanent inherited property to implement " + + "[].length or (function(){}).length"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var a = []; +a.p = 1; +var x = Object.create(a); +assertEq(x.length, 0); +assertEq(x.p, 1); +assertEq(a.length, 0); + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/ecma/Array/browser.js b/js/src/tests/ecma/Array/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Array/browser.js diff --git a/js/src/tests/ecma/Array/shell.js b/js/src/tests/ecma/Array/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Array/shell.js |