JavaScriptCore-466.1.6.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / Array / 15.4.2.3.js
CommitLineData
b37bf2e1
A
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/
5 *
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.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
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
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23 File Name: 15.4.2.3.js
24 ECMA Section: 15.4.2.3 new Array()
25 Description: The [[Prototype]] property of the newly constructed
26 object is set to the origianl Array prototype object,
27 the one that is the initial value of Array.prototype.
28 The [[Class]] property of the new object is set to
29 "Array". The length of the object is set to 0.
30
31 Author: christine@netscape.com
32 Date: 7 october 1997
33*/
34
35 var SECTION = "15.4.2.3";
36 var VERSION = "ECMA_1";
37 startTest();
38 var TITLE = "The Array Constructor: new Array()";
39
40 writeHeaderToLog( SECTION + " "+ TITLE);
41
42 var testcases = getTestCases();
43 test();
44
45function getTestCases() {
46 var array = new Array();
47 var item = 0;
48 array[item++] = new TestCase( SECTION, "new Array() +''", "", (new Array()) +"" );
49 array[item++] = new TestCase( SECTION, "typeof new Array()", "object", (typeof new Array()) );
50 array[item++] = new TestCase( SECTION,
51 "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
52 "[object Array]",
53 eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
54
55 array[item++] = new TestCase( SECTION, "(new Array()).length", 0, (new Array()).length );
56 array[item++] = new TestCase( SECTION, "(new Array()).toString == Array.prototype.toString", true, (new Array()).toString == Array.prototype.toString );
57 array[item++] = new TestCase( SECTION, "(new Array()).join == Array.prototype.join", true, (new Array()).join == Array.prototype.join );
58 array[item++] = new TestCase( SECTION, "(new Array()).reverse == Array.prototype.reverse", true, (new Array()).reverse == Array.prototype.reverse );
59 array[item++] = new TestCase( SECTION, "(new Array()).sort == Array.prototype.sort", true, (new Array()).sort == Array.prototype.sort );
60
61 return ( array );
62}
63function test() {
64 for ( tc=0; tc < testcases.length; tc++ ) {
65 testcases[tc].passed = writeTestCaseResult(
66 testcases[tc].expect,
67 testcases[tc].actual,
68 testcases[tc].description +" = "+ testcases[tc].actual );
69
70 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
71 }
72 stopTest();
73 return ( testcases );
74}