|
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.2.1-1.js |
|
9 ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) |
|
10 Description: This description only applies of the constructor is |
|
11 given two or more arguments. |
|
12 |
|
13 The [[Prototype]] property of the newly constructed |
|
14 object is set to the original Array prototype object, |
|
15 the one that is the initial value of Array.prototype |
|
16 (15.4.3.1). |
|
17 |
|
18 The [[Class]] property of the newly constructed object |
|
19 is set to "Array". |
|
20 |
|
21 The length property of the newly constructed object is |
|
22 set to the number of arguments. |
|
23 |
|
24 The 0 property of the newly constructed object is set |
|
25 to item0... in general, for as many arguments as there |
|
26 are, the k property of the newly constructed object is |
|
27 set to argument k, where the first argument is |
|
28 considered to be argument number 0. |
|
29 |
|
30 This file tests the typeof the newly constructed object. |
|
31 |
|
32 Author: christine@netscape.com |
|
33 Date: 7 october 1997 |
|
34 */ |
|
35 |
|
36 var SECTION = "15.4.2.1-1"; |
|
37 var VERSION = "ECMA_1"; |
|
38 startTest(); |
|
39 var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; |
|
40 |
|
41 writeHeaderToLog( SECTION + " "+ TITLE); |
|
42 |
|
43 new TestCase( SECTION, |
|
44 "typeof new Array(1,2)", |
|
45 "object", |
|
46 typeof new Array(1,2) ); |
|
47 |
|
48 new TestCase( SECTION, |
|
49 "(new Array(1,2)).toString", |
|
50 Array.prototype.toString, |
|
51 (new Array(1,2)).toString ); |
|
52 |
|
53 new TestCase( SECTION, |
|
54 "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", |
|
55 "[object Array]", |
|
56 eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); |
|
57 |
|
58 new TestCase( SECTION, |
|
59 "(new Array(1,2)).length", |
|
60 2, |
|
61 (new Array(1,2)).length ); |
|
62 |
|
63 new TestCase( SECTION, |
|
64 "var arr = (new Array(1,2)); arr[0]", |
|
65 1, |
|
66 eval("var arr = (new Array(1,2)); arr[0]") ); |
|
67 |
|
68 new TestCase( SECTION, |
|
69 "var arr = (new Array(1,2)); arr[1]", |
|
70 2, |
|
71 eval("var arr = (new Array(1,2)); arr[1]") ); |
|
72 |
|
73 new TestCase( SECTION, |
|
74 "var arr = (new Array(1,2)); String(arr)", |
|
75 "1,2", |
|
76 eval("var arr = (new Array(1,2)); String(arr)") ); |
|
77 |
|
78 test(); |