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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
23 File Name: tostring_1.js
24 ECMA Section: Array.toString()
27 This checks the ToString value of Array objects under JavaScript 1.2.
29 Author: christine@netscape.com
30 Date: 12 november 1997
33 var SECTION = "JS1_2";
34 var VERSION = "JS1_2";
36 var TITLE = "Array.toString()";
38 writeHeaderToLog( SECTION + " "+ TITLE);
40 var testcases = new Array();
46 /* This test assumes that if version() exists, it can set the JavaScript
47 * interpreter to an arbitrary version. To prevent unhandled exceptions in
48 * other tests, jsc implements version() as a stub function, but
49 * JavaScriptCore doesn't support setting the JavaScript engine's version.
51 * Commenting out the following lines forces the test to expect JavaScript
54 * If JavaScriptCore changes to support versioning, this test should split
55 * into a 1.2 test in js1_2/ and a 1.5 test in js1_5/.
59 if ( typeof version == "function" ) {
63 function version() { return 0; };
67 testcases[tc++] = new TestCase ( SECTION,
68 "var a = new Array(); a.toString()",
69 ( VERSION == "120" ? "[]" : "" ),
74 testcases[tc++] = new TestCase ( SECTION,
75 "a[0] = void 0; a.toString()",
76 ( VERSION == "120" ? "[, ]" : "" ),
80 testcases[tc++] = new TestCase( SECTION,
87 testcases[tc++] = new TestCase( SECTION,
88 "a[1] = void 0; a.toString()",
89 ( VERSION == "120" ? "[, , ]" : "," ),
94 testcases[tc++] = new TestCase( SECTION,
95 "a[1] = \"hi\"; a.toString()",
96 ( VERSION == "120" ? "[, \"hi\"]" : ",hi" ),
101 testcases[tc++] = new TestCase( SECTION,
102 "a[2] = void 0; a.toString()",
103 ( VERSION == "120" ?"[, \"hi\", , ]":",hi,"),
106 var b = new Array(1000);
108 for ( blen=0; blen<999; blen++) {
113 testcases[tc++] = new TestCase ( SECTION,
114 "var b = new Array(1000); b.toString()",
115 ( VERSION == "120" ? "[1000]" : bstring ),
119 testcases[tc++] = new TestCase( SECTION,
121 ( VERSION == "120" ? 1 : 1000 ),
127 for ( tc=0; tc < testcases.length; tc++ ) {
128 testcases[tc].passed = writeTestCaseResult(
129 testcases[tc].expect,
130 testcases[tc].actual,
131 testcases[tc].description +" = "+
132 testcases[tc].actual );
134 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
137 return ( testcases );