js/src/tests/ecma/Array/15.4.4.2.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     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/. */
     7 /**
     8    File Name:          15.4.4.2.js
     9    ECMA Section:       15.4.4.2 Array.prototype.toString()
    10    Description:        The elements of this object are converted to strings
    11    and these strings are then concatenated, separated by
    12    comma characters.  The result is the same as if the
    13    built-in join method were invoiked for this object
    14    with no argument.
    15    Author:             christine@netscape.com
    16    Date:               7 october 1997
    17 */
    19 var SECTION = "15.4.4.2";
    20 var VERSION = "ECMA_1";
    21 startTest();
    22 var TITLE   = "Array.prototype.toString";
    24 writeHeaderToLog( SECTION + " "+ TITLE);
    26 new TestCase( SECTION, 
    27 	      "Array.prototype.toString.length", 
    28 	      0, 
    29 	      Array.prototype.toString.length );
    31 new TestCase( SECTION, 
    32 	      "(new Array()).toString()",    
    33 	      "",    
    34 	      (new Array()).toString() );
    36 new TestCase( SECTION, 
    37 	      "(new Array(2)).toString()",   
    38 	      ",",   
    39 	      (new Array(2)).toString() );
    41 new TestCase( SECTION, 
    42 	      "(new Array(0,1)).toString()", 
    43 	      "0,1", 
    44 	      (new Array(0,1)).toString() );
    46 new TestCase( SECTION, 
    47 	      "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", 
    48 	      "NaN,Infinity,-Infinity",  
    49 	      (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() );
    51 new TestCase( SECTION, 
    52 	      "(new Array( Boolean(1), Boolean(0))).toString()",  
    53 	      "true,false",  
    54 	      (new Array(Boolean(1),Boolean(0))).toString() );
    56 new TestCase( SECTION, 
    57 	      "(new Array(void 0,null)).toString()",   
    58 	      ",",   
    59 	      (new Array(void 0,null)).toString() );
    61 var EXPECT_STRING = "";
    62 var MYARR = new Array();
    64 for ( var i = -50; i < 50; i+= 0.25 ) {
    65   MYARR[MYARR.length] = i;
    66   EXPECT_STRING += i +",";
    67 }
    69 EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 );
    71 new TestCase( SECTION,
    72 	      "MYARR.toString()", 
    73 	      EXPECT_STRING, 
    74 	      MYARR.toString() );
    76 test();

mercurial