Debian Codegraph @

rhino/testsrc/tests/ecma/Array/15.4.1.js

raw symbols SCIP
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 gTestfile = '15.4.1.js';
7
8 /**
9 File Name: 15.4.1.js
10 ECMA Section: 15.4.1 The Array Constructor Called as a Function
11
12 Description: When Array is called as a function rather than as a
13 constructor, it creates and initializes a new array
14 object. Thus, the function call Array(...) is
15 equivalent to the object creationi new Array(...) with
16 the same arguments.
17
18 Author: [email protected]
19 Date: 7 october 1997
20 */
21
22 var SECTION = "15.4.1";
23 var VERSION = "ECMA_1";
24 startTest();
25 var TITLE = "The Array Constructor Called as a Function";
26
27 writeHeaderToLog( SECTION + " "+ TITLE);
28
29 new TestCase( SECTION,
30 "Array() +''",
31 "",
32 Array() +"" );
33
34 new TestCase( SECTION,
35 "typeof Array()",
36 "object",
37 typeof Array() );
38
39 new TestCase( SECTION,
40 "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
41 "[object Array]",
42 eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
43
44 new TestCase( SECTION,
45 "var arr = Array(); arr.toString == Array.prototype.toString",
46 true,
47 eval("var arr = Array(); arr.toString == Array.prototype.toString") );
48
49 new TestCase( SECTION,
50 "Array().length",
51 0,
52 Array().length );
53
54 new TestCase( SECTION,
55 "Array(1,2,3) +''",
56 "1,2,3",
57 Array(1,2,3) +"" );
58
59 new TestCase( SECTION,
60 "typeof Array(1,2,3)",
61 "object",
62 typeof Array(1,2,3) );
63
64 new TestCase( SECTION,
65 "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
66 "[object Array]",
67 eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
68
69 new TestCase( SECTION,
70 "var arr = Array(1,2,3); arr.toString == Array.prototype.toString",
71 true,
72 eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") );
73
74 new TestCase( SECTION,
75 "Array(1,2,3).length",
76 3,
77 Array(1,2,3).length );
78
79 new TestCase( SECTION,
80 "typeof Array(12345)",
81 "object",
82 typeof Array(12345) );
83
84 new TestCase( SECTION,
85 "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()",
86 "[object Array]",
87 eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") );
88
89 new TestCase( SECTION,
90 "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString",
91 true,
92 eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") );
93
94 new TestCase( SECTION,
95 "Array(12345).length",
96 12345,
97 Array(12345).length );
98
99 test();