|
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.1-2.js |
|
9 ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) |
|
10 Description: This description only applies of the constructor is |
|
11 given two or more arguments. |
|
12 |
|
13 The [[Prototype]] property of the newly constructed |
|
14 object is set to the original Array prototype object, |
|
15 the one that is the initial value of Array.prototype |
|
16 (15.4.3.1). |
|
17 |
|
18 The [[Class]] property of the newly constructed object |
|
19 is set to "Array". |
|
20 |
|
21 The length property of the newly constructed object is |
|
22 set to the number of arguments. |
|
23 |
|
24 The 0 property of the newly constructed object is set |
|
25 to item0... in general, for as many arguments as there |
|
26 are, the k property of the newly constructed object is |
|
27 set to argument k, where the first argument is |
|
28 considered to be argument number 0. |
|
29 |
|
30 |
|
31 Author: christine@netscape.com |
|
32 Date: 7 october 1997 |
|
33 */ |
|
34 var SECTION = "15.4.2.1-2"; |
|
35 var VERSION = "ECMA_1"; |
|
36 startTest(); |
|
37 var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; |
|
38 |
|
39 writeHeaderToLog( SECTION + " "+ TITLE); |
|
40 |
|
41 |
|
42 var TEST_STRING = "new Array("; |
|
43 var ARGUMENTS = "" |
|
44 var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); |
|
45 |
|
46 for ( var index = 0; index < TEST_LENGTH; index++ ) { |
|
47 ARGUMENTS += index; |
|
48 ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; |
|
49 } |
|
50 |
|
51 TEST_STRING += ARGUMENTS + ")"; |
|
52 |
|
53 TEST_ARRAY = eval( TEST_STRING ); |
|
54 |
|
55 for ( var item = 0; item < TEST_LENGTH; item++ ) { |
|
56 new TestCase( SECTION, |
|
57 "["+item+"]", |
|
58 item, |
|
59 TEST_ARRAY[item] ); |
|
60 } |
|
61 |
|
62 new TestCase( SECTION, |
|
63 "new Array( ["+TEST_LENGTH+" arguments] ) +''", |
|
64 ARGUMENTS, |
|
65 TEST_ARRAY +"" ); |
|
66 |
|
67 test(); |