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/ 5 * 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. 10 * 11 * The Original Code is Mozilla Communicator client code, released March 12 * 31, 1998. 13 * 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 17 * Rights Reserved. 18 * 19 * Contributor(s): 20 * 21 */ 22 /** 23 File Name: 15.4.4.2.js 24 ECMA Section: 15.4.4.2 Array.prototype.toString() 25 Description: The elements of this object are converted to strings 26 and these strings are then concatenated, separated by 27 comma characters. The result is the same as if the 28 built-in join method were invoiked for this object 29 with no argument. 30 Author: christine (at) netscape.com 31 Date: 7 october 1997 32 */ 33 34 var SECTION = "15.4.4.2"; 35 var VERSION = "ECMA_1"; 36 startTest(); 37 var TITLE = "Array.prototype.toString"; 38 39 writeHeaderToLog( SECTION + " "+ TITLE); 40 41 var testcases = getTestCases(); 42 test(); 43 44 function getTestCases() { 45 var array = new Array(); 46 var item = 0; 47 48 array[item++] = new TestCase( SECTION, "Array.prototype.toString.length", 0, Array.prototype.toString.length ); 49 50 array[item++] = new TestCase( SECTION, "(new Array()).toString()", "", (new Array()).toString() ); 51 array[item++] = new TestCase( SECTION, "(new Array(2)).toString()", ",", (new Array(2)).toString() ); 52 array[item++] = new TestCase( SECTION, "(new Array(0,1)).toString()", "0,1", (new Array(0,1)).toString() ); 53 array[item++] = new TestCase( SECTION, "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", "NaN,Infinity,-Infinity", (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); 54 55 array[item++] = new TestCase( SECTION, "(new Array( Boolean(1), Boolean(0))).toString()", "true,false", (new Array(Boolean(1),Boolean(0))).toString() ); 56 array[item++] = new TestCase( SECTION, "(new Array(void 0,null)).toString()", ",", (new Array(void 0,null)).toString() ); 57 58 var EXPECT_STRING = ""; 59 var MYARR = new Array(); 60 61 for ( var i = -50; i < 50; i+= 0.25 ) { 62 MYARR[MYARR.length] = i; 63 EXPECT_STRING += i +","; 64 } 65 66 EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); 67 68 array[item++] = new TestCase( SECTION, "MYARR.toString()", EXPECT_STRING, MYARR.toString() ); 69 70 71 return ( array ); 72 } 73 function test() { 74 for ( tc=0 ; tc < testcases.length; tc++ ) { 75 testcases[tc].passed = writeTestCaseResult( 76 testcases[tc].expect, 77 testcases[tc].actual, 78 testcases[tc].description +" = "+ testcases[tc].actual ); 79 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; 80 } 81 stopTest(); 82 return ( testcases ); 83 } 84