|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 15.4-2.js |
|
9 ECMA Section: 15.4 Array Objects |
|
10 |
|
11 Description: Whenever a property is added whose name is an array |
|
12 index, the length property is changed, if necessary, |
|
13 to be one more than the numeric value of that array |
|
14 index; and whenever the length property is changed, |
|
15 every property whose name is an array index whose value |
|
16 is not smaller than the new length is automatically |
|
17 deleted. This constraint applies only to the Array |
|
18 object itself, and is unaffected by length or array |
|
19 index properties that may be inherited from its |
|
20 prototype. |
|
21 |
|
22 Author: christine@netscape.com |
|
23 Date: 28 october 1997 |
|
24 |
|
25 */ |
|
26 var SECTION = "15.4-2"; |
|
27 var VERSION = "ECMA_1"; |
|
28 startTest(); |
|
29 var TITLE = "Array Objects"; |
|
30 |
|
31 writeHeaderToLog( SECTION + " "+ TITLE); |
|
32 |
|
33 new TestCase( SECTION, |
|
34 "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", |
|
35 Math.pow(2,16)+1, |
|
36 eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") ); |
|
37 |
|
38 new TestCase( SECTION, |
|
39 "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", |
|
40 Math.pow(2,30)-1, |
|
41 eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") ); |
|
42 |
|
43 new TestCase( SECTION, |
|
44 "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", |
|
45 Math.pow(2,30), |
|
46 eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") ); |
|
47 |
|
48 new TestCase( SECTION, |
|
49 "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", |
|
50 Math.pow(2,30)+1, |
|
51 eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") ); |
|
52 |
|
53 |
|
54 new TestCase( SECTION, |
|
55 "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", |
|
56 Math.pow(2,31)-1, |
|
57 eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") ); |
|
58 |
|
59 new TestCase( SECTION, |
|
60 "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", |
|
61 Math.pow(2,31), |
|
62 eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") ); |
|
63 |
|
64 new TestCase( SECTION, |
|
65 "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", |
|
66 Math.pow(2,31)+1, |
|
67 eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") ); |
|
68 |
|
69 new TestCase( SECTION, |
|
70 "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", |
|
71 "0,1", |
|
72 eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") ); |
|
73 |
|
74 new TestCase( SECTION, |
|
75 "var arr = new Array(0,1); arr.length = 3; String(arr)", |
|
76 "0,1,", |
|
77 eval("var arr = new Array(0,1); arr.length = 3; String(arr)") ); |
|
78 |
|
79 test(); |
|
80 |