]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Array/15.4.2.1-3.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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
23 File Name: 15.4.2.1-3.js
24 ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
25 Description: This description only applies of the constructor is
26 given two or more arguments.
28 The [[Prototype]] property of the newly constructed
29 object is set to the original Array prototype object,
30 the one that is the initial value of Array.prototype
33 The [[Class]] property of the newly constructed object
36 The length property of the newly constructed object is
37 set to the number of arguments.
39 The 0 property of the newly constructed object is set
40 to item0... in general, for as many arguments as there
41 are, the k property of the newly constructed object is
42 set to argument k, where the first argument is
43 considered to be argument number 0.
45 This test stresses the number of arguments presented to
46 the Array constructor. Should support up to Math.pow
47 (2,32) arguments, since that is the maximum length of an
50 ***Change TEST_LENGTH to Math.pow(2,32) when larger array
51 lengths are supported.
53 Author: christine@netscape.com
56 var SECTION
= "15.4.2.1-3";
57 var VERSION
= "ECMA_1";
59 var TITLE
= "The Array Constructor: new Array( item0, item1, ...)";
61 writeHeaderToLog( SECTION
+ " "+ TITLE
);
63 var testcases
= getTestCases();
66 function getTestCases() {
67 var array
= new Array();
69 var TEST_STRING
= "new Array(";
71 var TEST_LENGTH
= Math
.pow(2,10); //Math.pow(2,32);
73 for ( var index
= 0; index
< TEST_LENGTH
; index
++ ) {
75 ARGUMENTS
+= (index
== (TEST_LENGTH
-1) ) ? "" : ",";
78 TEST_STRING
+= ARGUMENTS
+ ")";
80 TEST_ARRAY
= eval( TEST_STRING
);
82 for ( item
= 0; item
< TEST_LENGTH
; item
++ ) {
83 array
[item
] = new TestCase( SECTION
, "TEST_ARRAY["+item
+"]", item
, TEST_ARRAY
[item
] );
86 array
[item
++] = new TestCase( SECTION
, "new Array( ["+TEST_LENGTH
+" arguments] ) +''", ARGUMENTS
, TEST_ARRAY
+"" );
87 array
[item
++] = new TestCase( SECTION
, "TEST_ARRAY.toString", Array
.prototype.toString
, TEST_ARRAY
.toString
);
88 array
[item
++] = new TestCase( SECTION
, "TEST_ARRAY.join", Array
.prototype.join
, TEST_ARRAY
.join
);
89 array
[item
++] = new TestCase( SECTION
, "TEST_ARRAY.sort", Array
.prototype.sort
, TEST_ARRAY
.sort
);
90 array
[item
++] = new TestCase( SECTION
, "TEST_ARRAY.reverse", Array
.prototype.reverse
, TEST_ARRAY
.reverse
);
91 array
[item
++] = new TestCase( SECTION
, "TEST_ARRAY.length", TEST_LENGTH
, TEST_ARRAY
.length
);
92 array
[item
++] = new TestCase( SECTION
,
93 "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()",
95 eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") );
101 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
102 testcases
[tc
].passed
= writeTestCaseResult(
103 testcases
[tc
].expect
,
104 testcases
[tc
].actual
,
105 testcases
[tc
].description
+" = "+
106 testcases
[tc
].actual
);
108 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
111 return ( testcases
);