Debian Codegraph @

rhino/testsrc/tests/ecma/Array/15.4-2.js

raw symbols SCIP
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 gTestfile = '15.4-2.js';
7
8 /**
9 File Name: 15.4-2.js
10 ECMA Section: 15.4 Array Objects
11
12 Description: Whenever a property is added whose name is an array
13 index, the length property is changed, if necessary,
14 to be one more than the numeric value of that array
15 index; and whenever the length property is changed,
16 every property whose name is an array index whose value
17 is not smaller than the new length is automatically
18 deleted. This constraint applies only to the Array
19 object itself, and is unaffected by length or array
20 index properties that may be inherited from its
21 prototype.
22
23 Author: [email protected]
24 Date: 28 october 1997
25
26 */
27 var SECTION = "15.4-2";
28 var VERSION = "ECMA_1";
29 startTest();
30 var TITLE = "Array Objects";
31
32 writeHeaderToLog( SECTION + " "+ TITLE);
33
34 new TestCase( SECTION,
35 "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length",
36 Math.pow(2,16)+1,
37 eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") );
38
39 new TestCase( SECTION,
40 "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length",
41 Math.pow(2,30)-1,
42 eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") );
43
44 new TestCase( SECTION,
45 "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length",
46 Math.pow(2,30),
47 eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") );
48
49 new TestCase( SECTION,
50 "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length",
51 Math.pow(2,30)+1,
52 eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") );
53
54
55 new TestCase( SECTION,
56 "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length",
57 Math.pow(2,31)-1,
58 eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") );
59
60 new TestCase( SECTION,
61 "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length",
62 Math.pow(2,31),
63 eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") );
64
65 new TestCase( SECTION,
66 "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length",
67 Math.pow(2,31)+1,
68 eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") );
69
70 new TestCase( SECTION,
71 "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)",
72 "0,1",
73 eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") );
74
75 new TestCase( SECTION,
76 "var arr = new Array(0,1); arr.length = 3; String(arr)",
77 "0,1,",
78 eval("var arr = new Array(0,1); arr.length = 3; String(arr)") );
79
80 test();
81