Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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.2.1-3.js
9 ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
10 Description: This description only applies of the constructor is
11 given two or more arguments.
13 The [[Prototype]] property of the newly constructed
14 object is set to the original Array prototype object,
15 the one that is the initial value of Array.prototype
16 (15.4.3.1).
18 The [[Class]] property of the newly constructed object
19 is set to "Array".
21 The length property of the newly constructed object is
22 set to the number of arguments.
24 The 0 property of the newly constructed object is set
25 to item0... in general, for as many arguments as there
26 are, the k property of the newly constructed object is
27 set to argument k, where the first argument is
28 considered to be argument number 0.
30 This test stresses the number of arguments presented to
31 the Array constructor. Should support up to Math.pow
32 (2,32) arguments, since that is the maximum length of an
33 ECMAScript array.
35 ***Change TEST_LENGTH to Math.pow(2,32) when larger array
36 lengths are supported.
38 Author: christine@netscape.com
39 Date: 7 october 1997
40 */
41 var SECTION = "15.4.2.1-3";
42 var VERSION = "ECMA_1";
43 startTest();
44 var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
46 writeHeaderToLog( SECTION + " "+ TITLE);
48 var TEST_STRING = "new Array(";
49 var ARGUMENTS = ""
50 var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
52 for ( var index = 0; index < TEST_LENGTH; index++ ) {
53 ARGUMENTS += index;
54 ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
55 }
57 TEST_STRING += ARGUMENTS + ")";
59 TEST_ARRAY = eval( TEST_STRING );
61 for ( var item = 0; item < TEST_LENGTH; item++ ) {
62 new TestCase( SECTION,
63 "TEST_ARRAY["+item+"]",
64 item,
65 TEST_ARRAY[item] );
66 }
68 new TestCase( SECTION,
69 "new Array( ["+TEST_LENGTH+" arguments] ) +''",
70 ARGUMENTS,
71 TEST_ARRAY +"" );
73 new TestCase( SECTION,
74 "TEST_ARRAY.toString",
75 Array.prototype.toString,
76 TEST_ARRAY.toString );
78 new TestCase( SECTION,
79 "TEST_ARRAY.join",
80 Array.prototype.join,
81 TEST_ARRAY.join );
83 new TestCase( SECTION,
84 "TEST_ARRAY.sort",
85 Array.prototype.sort,
86 TEST_ARRAY.sort );
88 new TestCase( SECTION,
89 "TEST_ARRAY.reverse",
90 Array.prototype.reverse,
91 TEST_ARRAY.reverse );
93 new TestCase( SECTION,
94 "TEST_ARRAY.length",
95 TEST_LENGTH,
96 TEST_ARRAY.length );
98 new TestCase( SECTION,
99 "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()",
100 "[object Array]",
101 eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") );
103 test();