Imported tests
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma / Array / 15.4.1.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\r
2 /* ***** BEGIN LICENSE BLOCK *****\r
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
4  *\r
5  * The contents of this file are subject to the Mozilla Public License Version\r
6  * 1.1 (the "License"); you may not use this file except in compliance with\r
7  * the License. You may obtain a copy of the License at\r
8  * http://www.mozilla.org/MPL/\r
9  *\r
10  * Software distributed under the License is distributed on an "AS IS" basis,\r
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
12  * for the specific language governing rights and limitations under the\r
13  * License.\r
14  *\r
15  * The Original Code is Mozilla Communicator client code, released\r
16  * March 31, 1998.\r
17  *\r
18  * The Initial Developer of the Original Code is\r
19  * Netscape Communications Corporation.\r
20  * Portions created by the Initial Developer are Copyright (C) 1998\r
21  * the Initial Developer. All Rights Reserved.\r
22  *\r
23  * Contributor(s):\r
24  *\r
25  * Alternatively, the contents of this file may be used under the terms of\r
26  * either the GNU General Public License Version 2 or later (the "GPL"), or\r
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
28  * in which case the provisions of the GPL or the LGPL are applicable instead\r
29  * of those above. If you wish to allow use of your version of this file only\r
30  * under the terms of either the GPL or the LGPL, and not to allow others to\r
31  * use your version of this file under the terms of the MPL, indicate your\r
32  * decision by deleting the provisions above and replace them with the notice\r
33  * and other provisions required by the GPL or the LGPL. If you do not delete\r
34  * the provisions above, a recipient may use your version of this file under\r
35  * the terms of any one of the MPL, the GPL or the LGPL.\r
36  *\r
37  * ***** END LICENSE BLOCK ***** */\r
38 \r
39 /**\r
40    File Name:          15.4.1.js\r
41    ECMA Section:       15.4.1 The Array Constructor Called as a Function\r
42 \r
43    Description:        When Array is called as a function rather than as a\r
44    constructor, it creates and initializes a new array\r
45    object.  Thus, the function call Array(...) is\r
46    equivalent to the object creationi new Array(...) with\r
47    the same arguments.\r
48 \r
49    Author:             christine@netscape.com\r
50    Date:               7 october 1997\r
51 */\r
52 \r
53 var SECTION = "15.4.1";\r
54 var VERSION = "ECMA_1";\r
55 startTest();\r
56 var TITLE   = "The Array Constructor Called as a Function";\r
57 \r
58 writeHeaderToLog( SECTION + " "+ TITLE);\r
59 \r
60 new TestCase(   SECTION,\r
61                 "Array() +''",\r
62                 "",\r
63                 Array() +"" );\r
64 \r
65 new TestCase(   SECTION,\r
66                 "typeof Array()",\r
67                 "object",\r
68                 typeof Array() );\r
69 \r
70 new TestCase(   SECTION,\r
71                 "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",\r
72                 "[object Array]",\r
73                 eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );\r
74 \r
75 new TestCase(   SECTION,\r
76                 "var arr = Array(); arr.toString == Array.prototype.toString",\r
77                 true,\r
78                 eval("var arr = Array(); arr.toString == Array.prototype.toString") );\r
79 \r
80 new TestCase(   SECTION,\r
81                 "Array().length",\r
82                 0,\r
83                 Array().length );\r
84 \r
85 new TestCase(   SECTION,\r
86                 "Array(1,2,3) +''",\r
87                 "1,2,3",\r
88                 Array(1,2,3) +"" );\r
89 \r
90 new TestCase(   SECTION,\r
91                 "typeof Array(1,2,3)",\r
92                 "object",\r
93                 typeof Array(1,2,3) );\r
94 \r
95 new TestCase(   SECTION,\r
96                 "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",\r
97                 "[object Array]",\r
98                 eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );\r
99 \r
100 new TestCase(   SECTION,\r
101                 "var arr = Array(1,2,3); arr.toString == Array.prototype.toString",\r
102                 true,\r
103                 eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") );\r
104 \r
105 new TestCase(   SECTION,\r
106                 "Array(1,2,3).length",\r
107                 3,\r
108                 Array(1,2,3).length );\r
109 \r
110 new TestCase(   SECTION,\r
111                 "typeof Array(12345)",\r
112                 "object",\r
113                 typeof Array(12345) );\r
114 \r
115 new TestCase(   SECTION,\r
116                 "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()",\r
117                 "[object Array]",\r
118                 eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") );\r
119 \r
120 new TestCase(   SECTION,\r
121                 "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString",\r
122                 true,\r
123                 eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") );\r
124 \r
125 new TestCase(   SECTION,\r
126                 "Array(12345).length",\r
127                 12345,\r
128                 Array(12345).length );\r
129 \r
130 test();\r