|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 15.4.1.js |
|
9 ECMA Section: 15.4.1 The Array Constructor Called as a Function |
|
10 |
|
11 Description: When Array is called as a function rather than as a |
|
12 constructor, it creates and initializes a new array |
|
13 object. Thus, the function call Array(...) is |
|
14 equivalent to the object creationi new Array(...) with |
|
15 the same arguments. |
|
16 |
|
17 Author: christine@netscape.com |
|
18 Date: 7 october 1997 |
|
19 */ |
|
20 |
|
21 var SECTION = "15.4.1"; |
|
22 var VERSION = "ECMA_1"; |
|
23 startTest(); |
|
24 var TITLE = "The Array Constructor Called as a Function"; |
|
25 |
|
26 writeHeaderToLog( SECTION + " "+ TITLE); |
|
27 |
|
28 new TestCase( SECTION, |
|
29 "Array() +''", |
|
30 "", |
|
31 Array() +"" ); |
|
32 |
|
33 new TestCase( SECTION, |
|
34 "typeof Array()", |
|
35 "object", |
|
36 typeof Array() ); |
|
37 |
|
38 new TestCase( SECTION, |
|
39 "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", |
|
40 "[object Array]", |
|
41 eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); |
|
42 |
|
43 new TestCase( SECTION, |
|
44 "var arr = Array(); arr.toString == Array.prototype.toString", |
|
45 true, |
|
46 eval("var arr = Array(); arr.toString == Array.prototype.toString") ); |
|
47 |
|
48 new TestCase( SECTION, |
|
49 "Array().length", |
|
50 0, |
|
51 Array().length ); |
|
52 |
|
53 new TestCase( SECTION, |
|
54 "Array(1,2,3) +''", |
|
55 "1,2,3", |
|
56 Array(1,2,3) +"" ); |
|
57 |
|
58 new TestCase( SECTION, |
|
59 "typeof Array(1,2,3)", |
|
60 "object", |
|
61 typeof Array(1,2,3) ); |
|
62 |
|
63 new TestCase( SECTION, |
|
64 "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", |
|
65 "[object Array]", |
|
66 eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); |
|
67 |
|
68 new TestCase( SECTION, |
|
69 "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", |
|
70 true, |
|
71 eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); |
|
72 |
|
73 new TestCase( SECTION, |
|
74 "Array(1,2,3).length", |
|
75 3, |
|
76 Array(1,2,3).length ); |
|
77 |
|
78 new TestCase( SECTION, |
|
79 "typeof Array(12345)", |
|
80 "object", |
|
81 typeof Array(12345) ); |
|
82 |
|
83 new TestCase( SECTION, |
|
84 "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", |
|
85 "[object Array]", |
|
86 eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); |
|
87 |
|
88 new TestCase( SECTION, |
|
89 "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", |
|
90 true, |
|
91 eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); |
|
92 |
|
93 new TestCase( SECTION, |
|
94 "Array(12345).length", |
|
95 12345, |
|
96 Array(12345).length ); |
|
97 |
|
98 test(); |