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.5.2-1.js
24    ECMA Section:       Array.length
25    Description:
26    15.4.5.2 length
27    The length property of this Array object is always numerically greater
28    than the name of every property whose name is an array index.
29
30    The length property has the attributes { DontEnum, DontDelete }.
31    Author:             christine@netscape.com
32    Date:               12 november 1997
33*/
34
35    var SECTION = "15.4.5.2-1";
36    var VERSION = "ECMA_1";
37    startTest();
38    var TITLE   = "Array.length";
39
40    writeHeaderToLog( SECTION + " "+ TITLE);
41
42    var testcases = getTestCases();
43    test();
44function getTestCases() {
45    var array = new Array();
46    var item = 0;
47
48    array[item++] = new TestCase(   SECTION,
49                                    "var A = new Array(); A.length",
50                                    0,
51                                    eval("var A = new Array(); A.length") );
52
53    array[item++] = new TestCase(   SECTION,
54                                    "var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length",
55                                    Math.pow(2,32)-1,
56                                    eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") );
57
58    array[item++] = new TestCase(   SECTION,
59                                    "var A = new Array(); A.length = 123; A.length",
60                                    123,
61                                    eval("var A = new Array(); A.length = 123; A.length") );
62
63    array[item++] = new TestCase(   SECTION,
64                                    "var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS",
65                                    "",
66                                    eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") );
67
68
69    array[item++] = new TestCase(   SECTION,
70                                    "var A = new Array(); A.length = 123; delete A.length",
71                                    false ,
72                                    eval("var A = new Array(); A.length = 123; delete A.length") );
73
74    array[item++] = new TestCase(   SECTION,
75                                    "var A = new Array(); A.length = 123; delete A.length; A.length",
76                                    123,
77                                    eval("var A = new Array(); A.length = 123; delete A.length; A.length") );
78    return array;
79}
80
81function test() {
82    for ( tc=0; tc < testcases.length; tc++ ) {
83        testcases[tc].passed = writeTestCaseResult(
84                            testcases[tc].expect,
85                            testcases[tc].actual,
86                            testcases[tc].description +" = "+
87                            testcases[tc].actual );
88
89        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
90    }
91    stopTest();
92    return ( testcases );
93}
94