1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Array/15.4.2.1-3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.4.2.1-3.js 1.12 + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) 1.13 + Description: This description only applies of the constructor is 1.14 + given two or more arguments. 1.15 + 1.16 + The [[Prototype]] property of the newly constructed 1.17 + object is set to the original Array prototype object, 1.18 + the one that is the initial value of Array.prototype 1.19 + (15.4.3.1). 1.20 + 1.21 + The [[Class]] property of the newly constructed object 1.22 + is set to "Array". 1.23 + 1.24 + The length property of the newly constructed object is 1.25 + set to the number of arguments. 1.26 + 1.27 + The 0 property of the newly constructed object is set 1.28 + to item0... in general, for as many arguments as there 1.29 + are, the k property of the newly constructed object is 1.30 + set to argument k, where the first argument is 1.31 + considered to be argument number 0. 1.32 + 1.33 + This test stresses the number of arguments presented to 1.34 + the Array constructor. Should support up to Math.pow 1.35 + (2,32) arguments, since that is the maximum length of an 1.36 + ECMAScript array. 1.37 + 1.38 + ***Change TEST_LENGTH to Math.pow(2,32) when larger array 1.39 + lengths are supported. 1.40 + 1.41 + Author: christine@netscape.com 1.42 + Date: 7 october 1997 1.43 +*/ 1.44 +var SECTION = "15.4.2.1-3"; 1.45 +var VERSION = "ECMA_1"; 1.46 +startTest(); 1.47 +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; 1.48 + 1.49 +writeHeaderToLog( SECTION + " "+ TITLE); 1.50 + 1.51 +var TEST_STRING = "new Array("; 1.52 +var ARGUMENTS = "" 1.53 + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); 1.54 + 1.55 +for ( var index = 0; index < TEST_LENGTH; index++ ) { 1.56 + ARGUMENTS += index; 1.57 + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; 1.58 +} 1.59 + 1.60 +TEST_STRING += ARGUMENTS + ")"; 1.61 + 1.62 +TEST_ARRAY = eval( TEST_STRING ); 1.63 + 1.64 +for ( var item = 0; item < TEST_LENGTH; item++ ) { 1.65 + new TestCase( SECTION, 1.66 + "TEST_ARRAY["+item+"]", 1.67 + item, 1.68 + TEST_ARRAY[item] ); 1.69 +} 1.70 + 1.71 +new TestCase( SECTION, 1.72 + "new Array( ["+TEST_LENGTH+" arguments] ) +''", 1.73 + ARGUMENTS, 1.74 + TEST_ARRAY +"" ); 1.75 + 1.76 +new TestCase( SECTION, 1.77 + "TEST_ARRAY.toString", 1.78 + Array.prototype.toString, 1.79 + TEST_ARRAY.toString ); 1.80 + 1.81 +new TestCase( SECTION, 1.82 + "TEST_ARRAY.join", 1.83 + Array.prototype.join, 1.84 + TEST_ARRAY.join ); 1.85 + 1.86 +new TestCase( SECTION, 1.87 + "TEST_ARRAY.sort", 1.88 + Array.prototype.sort, 1.89 + TEST_ARRAY.sort ); 1.90 + 1.91 +new TestCase( SECTION, 1.92 + "TEST_ARRAY.reverse", 1.93 + Array.prototype.reverse, 1.94 + TEST_ARRAY.reverse ); 1.95 + 1.96 +new TestCase( SECTION, 1.97 + "TEST_ARRAY.length", 1.98 + TEST_LENGTH, 1.99 + TEST_ARRAY.length ); 1.100 + 1.101 +new TestCase( SECTION, 1.102 + "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", 1.103 + "[object Array]", 1.104 + eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); 1.105 + 1.106 +test();