js/src/tests/ecma/Array/15.4.5.2-2.js

Thu, 15 Jan 2015 21:13:52 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:13:52 +0100
branch
TOR_BUG_9701
changeset 12
7540298fafa1
permissions
-rw-r--r--

Remove forgotten relic of ABI crash risk averse overloaded method change.

     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.5.2-2.js
     9    ECMA Section:       Array.length
    10    Description:
    11    15.4.5.2 length
    12    The length property of this Array object is always numerically greater
    13    than the name of every property whose name is an array index.
    15    The length property has the attributes { DontEnum, DontDelete }.
    17    This test verifies that the Array.length property is not Read Only.
    19    Author:             christine@netscape.com
    20    Date:               12 november 1997
    21 */
    23 var SECTION = "15.4.5.2-2";
    24 var VERSION = "ECMA_1";
    25 startTest();
    26 var TITLE   = "Array.length";
    28 writeHeaderToLog( SECTION + " "+ TITLE);
    30 addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) );
    32 addCase( new Array(), 0, 1, 1 );
    34 addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 );
    35 addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) );
    36 addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) );
    37 addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) )
    39 // some tests where array is not empty
    40 // array is populated with strings
    41   for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) {
    42     arg +=  String(i) + ( i != Math.pow(2,12)-1 ? "," : "" );
    44   }
    45 //      print(i +":"+arg);
    47 var a = eval( "new Array("+arg+")" );
    49 addCase( a, i, i, i );
    50 addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true );
    51 addCase( a, Math.pow(2,12)+5, 0, 0, true );
    53 test();
    55 function addCase( object, old_len, set_len, new_len, checkitems ) {
    56   object.length = set_len;
    58   new TestCase( SECTION,
    59 		"array = new Array("+ old_len+"); array.length = " + set_len +
    60 		"; array.length",
    61 		new_len,
    62 		object.length );
    64   if ( checkitems ) {
    65     // verify that items between old and newlen are all undefined
    66     if ( new_len < old_len ) {
    67       var passed = true;
    68       for ( var i = new_len; i < old_len; i++ ) {
    69 	if ( object[i] != void 0 ) {
    70 	  passed = false;
    71 	}
    72       }
    73       new TestCase( SECTION,
    74 		    "verify that array items have been deleted",
    75 		    true,
    76 		    passed );
    77     }
    78     if ( new_len > old_len ) {
    79       var passed = true;
    80       for ( var i = old_len; i < new_len; i++ ) {
    81 	if ( object[i] != void 0 ) {
    82 	  passed = false;
    83 	}
    84       }
    85       new TestCase( SECTION,
    86 		    "verify that new items are undefined",
    87 		    true,
    88 		    passed );
    89     }
    90   }
    92 }

mercurial