michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 15.4.4.2.js michael@0: ECMA Section: 15.4.4.2 Array.prototype.toString() michael@0: Description: The elements of this object are converted to strings michael@0: and these strings are then concatenated, separated by michael@0: comma characters. The result is the same as if the michael@0: built-in join method were invoiked for this object michael@0: with no argument. michael@0: Author: christine@netscape.com michael@0: Date: 7 october 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.4.4.2"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Array.prototype.toString"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "Array.prototype.toString.length", michael@0: 0, michael@0: Array.prototype.toString.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new Array()).toString()", michael@0: "", michael@0: (new Array()).toString() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new Array(2)).toString()", michael@0: ",", michael@0: (new Array(2)).toString() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new Array(0,1)).toString()", michael@0: "0,1", michael@0: (new Array(0,1)).toString() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", michael@0: "NaN,Infinity,-Infinity", michael@0: (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new Array( Boolean(1), Boolean(0))).toString()", michael@0: "true,false", michael@0: (new Array(Boolean(1),Boolean(0))).toString() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "(new Array(void 0,null)).toString()", michael@0: ",", michael@0: (new Array(void 0,null)).toString() ); michael@0: michael@0: var EXPECT_STRING = ""; michael@0: var MYARR = new Array(); michael@0: michael@0: for ( var i = -50; i < 50; i+= 0.25 ) { michael@0: MYARR[MYARR.length] = i; michael@0: EXPECT_STRING += i +","; michael@0: } michael@0: michael@0: EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); michael@0: michael@0: new TestCase( SECTION, michael@0: "MYARR.toString()", michael@0: EXPECT_STRING, michael@0: MYARR.toString() ); michael@0: michael@0: test();