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
24 ECMA Section: 15.4.1 The Array Constructor Called as a Function
26 Description: When Array is called as a function rather than as a
27 constructor, it creates and initializes a new array
28 object. Thus, the function call Array(...) is
29 equivalent to the object creationi new Array(...) with
32 Author: christine@netscape.com
36 var SECTION = "15.4.1";
37 var VERSION = "ECMA_1";
39 var TITLE = "The Array Constructor Called as a Function";
41 writeHeaderToLog( SECTION + " "+ TITLE);
43 var testcases = getTestCases();
46 function getTestCases() {
47 var array = new Array();
50 array[item++] = new TestCase( SECTION,
55 array[item++] = new TestCase( SECTION,
60 array[item++] = new TestCase( SECTION,
61 "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
63 eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
65 array[item++] = new TestCase( SECTION,
66 "var arr = Array(); arr.toString == Array.prototype.toString",
68 eval("var arr = Array(); arr.toString == Array.prototype.toString") );
70 array[item++] = new TestCase( SECTION,
76 array[item++] = new TestCase( SECTION,
81 array[item++] = new TestCase( SECTION,
82 "typeof Array(1,2,3)",
84 typeof Array(1,2,3) );
86 array[item++] = new TestCase( SECTION,
87 "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
89 eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
91 array[item++] = new TestCase( SECTION,
92 "var arr = Array(1,2,3); arr.toString == Array.prototype.toString",
94 eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") );
96 array[item++] = new TestCase( SECTION,
97 "Array(1,2,3).length",
99 Array(1,2,3).length );
101 array[item++] = new TestCase( SECTION,
102 "typeof Array(12345)",
104 typeof Array(12345) );
106 array[item++] = new TestCase( SECTION,
107 "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()",
109 eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") );
111 array[item++] = new TestCase( SECTION,
112 "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString",
114 eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") );
116 array[item++] = new TestCase( SECTION,
117 "Array(12345).length",
119 Array(12345).length );
124 for (tc=0 ; tc < testcases.length; tc++ ) {
125 testcases[tc].passed = writeTestCaseResult(
126 testcases[tc].expect,
127 testcases[tc].actual,
128 testcases[tc].description +" = "+ testcases[tc].actual );
129 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
132 return ( testcases );