]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Array/15.4-2.js
JavaScriptCore-466.1.6.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / Array / 15.4-2.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
5 *
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22 /**
23 File Name: 15.4-2.js
24 ECMA Section: 15.4 Array Objects
25
26 Description: Whenever a property is added whose name is an array
27 index, the length property is changed, if necessary,
28 to be one more than the numeric value of that array
29 index; and whenever the length property is changed,
30 every property whose name is an array index whose value
31 is not smaller than the new length is automatically
32 deleted. This constraint applies only to the Array
33 object itself, and is unaffected by length or array
34 index properties that may be inherited from its
35 prototype.
36
37 Author: christine@netscape.com
38 Date: 28 october 1997
39
40 */
41 var SECTION = "15.4-2";
42 var VERSION = "ECMA_1";
43 startTest();
44 var TITLE = "Array Objects";
45
46 writeHeaderToLog( SECTION + " "+ TITLE);
47
48 var testcases = getTestCases();
49 test();
50
51 function getTestCases() {
52 var array = new Array();
53 var item = 0;
54
55 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") );
56
57 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") );
58 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") );
59 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") );
60
61 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") );
62 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") );
63 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") );
64
65 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)") );
66 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)") );
67 // 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") );
68 // 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") );
69
70 return ( array );
71 }
72 function test( array ) {
73 for ( tc=0; tc < testcases.length; tc++ ) {
74 testcases[tc].passed = writeTestCaseResult(
75 testcases[tc].expect,
76 testcases[tc].actual,
77 testcases[tc].description +" = "+ testcases[tc].actual );
78
79 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
80 }
81 stopTest();
82 return ( testcases );
83 }