]>
Commit | Line | Data |
---|---|---|
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.2-2.js | |
24 | ECMA Section: 15.4.2.2 new Array(len) | |
25 | ||
26 | Description: This description only applies of the constructor is | |
27 | given two or more arguments. | |
28 | ||
29 | The [[Prototype]] property of the newly constructed | |
30 | object is set to the original Array prototype object, | |
31 | the one that is the initial value of Array.prototype(0) | |
32 | (15.4.3.1). | |
33 | ||
34 | The [[Class]] property of the newly constructed object | |
35 | is set to "Array". | |
36 | ||
37 | If the argument len is a number, then the length | |
38 | property of the newly constructed object is set to | |
39 | ToUint32(len). | |
40 | ||
41 | If the argument len is not a number, then the length | |
42 | property of the newly constructed object is set to 1 | |
43 | and the 0 property of the newly constructed object is | |
44 | set to len. | |
45 | ||
46 | This file tests length of the newly constructed array | |
47 | when len is not a number. | |
48 | ||
49 | Author: christine@netscape.com | |
50 | Date: 7 october 1997 | |
51 | */ | |
52 | var SECTION = "15.4.2.2-2"; | |
53 | var VERSION = "ECMA_1"; | |
54 | startTest(); | |
55 | var TITLE = "The Array Constructor: new Array( len )"; | |
56 | ||
57 | writeHeaderToLog( SECTION + " "+ TITLE); | |
58 | ||
59 | var testcases = getTestCases(); | |
60 | test(); | |
61 | ||
62 | function getTestCases() { | |
63 | var array = new Array(); | |
64 | var item = 0; | |
65 | ||
66 | array[item++] = new TestCase( SECTION, "(new Array(new Number(1073741823))).length", 1, (new Array(new Number(1073741823))).length ); | |
67 | array[item++] = new TestCase( SECTION, "(new Array(new Number(0))).length", 1, (new Array(new Number(0))).length ); | |
68 | array[item++] = new TestCase( SECTION, "(new Array(new Number(1000))).length", 1, (new Array(new Number(1000))).length ); | |
69 | array[item++] = new TestCase( SECTION, "(new Array('mozilla, larryzilla, curlyzilla')).length", 1, (new Array('mozilla, larryzilla, curlyzilla')).length ); | |
70 | array[item++] = new TestCase( SECTION, "(new Array(true)).length", 1, (new Array(true)).length ); | |
71 | array[item++] = new TestCase( SECTION, "(new Array(false)).length", 1, (new Array(false)).length); | |
72 | array[item++] = new TestCase( SECTION, "(new Array(new Boolean(true)).length", 1, (new Array(new Boolean(true))).length ); | |
73 | array[item++] = new TestCase( SECTION, "(new Array(new Boolean(false)).length", 1, (new Array(new Boolean(false))).length ); | |
74 | return ( array ); | |
75 | } | |
76 | function test() { | |
77 | for ( tc=0; tc < testcases.length; tc++ ) { | |
78 | testcases[tc].passed = writeTestCaseResult( | |
79 | testcases[tc].expect, | |
80 | testcases[tc].actual, | |
81 | testcases[tc].description +" = "+ | |
82 | testcases[tc].actual ); | |
83 | testcases[tc].reason += ( testcases[tc].passed ) | |
84 | ? "" | |
85 | : "wrong value "; | |
86 | } | |
87 | stopTest(); | |
88 | return ( testcases ); | |
89 | } |