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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 15.4.2.1-3.js |
michael@0 | 9 | ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) |
michael@0 | 10 | Description: This description only applies of the constructor is |
michael@0 | 11 | given two or more arguments. |
michael@0 | 12 | |
michael@0 | 13 | The [[Prototype]] property of the newly constructed |
michael@0 | 14 | object is set to the original Array prototype object, |
michael@0 | 15 | the one that is the initial value of Array.prototype |
michael@0 | 16 | (15.4.3.1). |
michael@0 | 17 | |
michael@0 | 18 | The [[Class]] property of the newly constructed object |
michael@0 | 19 | is set to "Array". |
michael@0 | 20 | |
michael@0 | 21 | The length property of the newly constructed object is |
michael@0 | 22 | set to the number of arguments. |
michael@0 | 23 | |
michael@0 | 24 | The 0 property of the newly constructed object is set |
michael@0 | 25 | to item0... in general, for as many arguments as there |
michael@0 | 26 | are, the k property of the newly constructed object is |
michael@0 | 27 | set to argument k, where the first argument is |
michael@0 | 28 | considered to be argument number 0. |
michael@0 | 29 | |
michael@0 | 30 | This test stresses the number of arguments presented to |
michael@0 | 31 | the Array constructor. Should support up to Math.pow |
michael@0 | 32 | (2,32) arguments, since that is the maximum length of an |
michael@0 | 33 | ECMAScript array. |
michael@0 | 34 | |
michael@0 | 35 | ***Change TEST_LENGTH to Math.pow(2,32) when larger array |
michael@0 | 36 | lengths are supported. |
michael@0 | 37 | |
michael@0 | 38 | Author: christine@netscape.com |
michael@0 | 39 | Date: 7 october 1997 |
michael@0 | 40 | */ |
michael@0 | 41 | var SECTION = "15.4.2.1-3"; |
michael@0 | 42 | var VERSION = "ECMA_1"; |
michael@0 | 43 | startTest(); |
michael@0 | 44 | var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; |
michael@0 | 45 | |
michael@0 | 46 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 47 | |
michael@0 | 48 | var TEST_STRING = "new Array("; |
michael@0 | 49 | var ARGUMENTS = "" |
michael@0 | 50 | var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); |
michael@0 | 51 | |
michael@0 | 52 | for ( var index = 0; index < TEST_LENGTH; index++ ) { |
michael@0 | 53 | ARGUMENTS += index; |
michael@0 | 54 | ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | TEST_STRING += ARGUMENTS + ")"; |
michael@0 | 58 | |
michael@0 | 59 | TEST_ARRAY = eval( TEST_STRING ); |
michael@0 | 60 | |
michael@0 | 61 | for ( var item = 0; item < TEST_LENGTH; item++ ) { |
michael@0 | 62 | new TestCase( SECTION, |
michael@0 | 63 | "TEST_ARRAY["+item+"]", |
michael@0 | 64 | item, |
michael@0 | 65 | TEST_ARRAY[item] ); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | new TestCase( SECTION, |
michael@0 | 69 | "new Array( ["+TEST_LENGTH+" arguments] ) +''", |
michael@0 | 70 | ARGUMENTS, |
michael@0 | 71 | TEST_ARRAY +"" ); |
michael@0 | 72 | |
michael@0 | 73 | new TestCase( SECTION, |
michael@0 | 74 | "TEST_ARRAY.toString", |
michael@0 | 75 | Array.prototype.toString, |
michael@0 | 76 | TEST_ARRAY.toString ); |
michael@0 | 77 | |
michael@0 | 78 | new TestCase( SECTION, |
michael@0 | 79 | "TEST_ARRAY.join", |
michael@0 | 80 | Array.prototype.join, |
michael@0 | 81 | TEST_ARRAY.join ); |
michael@0 | 82 | |
michael@0 | 83 | new TestCase( SECTION, |
michael@0 | 84 | "TEST_ARRAY.sort", |
michael@0 | 85 | Array.prototype.sort, |
michael@0 | 86 | TEST_ARRAY.sort ); |
michael@0 | 87 | |
michael@0 | 88 | new TestCase( SECTION, |
michael@0 | 89 | "TEST_ARRAY.reverse", |
michael@0 | 90 | Array.prototype.reverse, |
michael@0 | 91 | TEST_ARRAY.reverse ); |
michael@0 | 92 | |
michael@0 | 93 | new TestCase( SECTION, |
michael@0 | 94 | "TEST_ARRAY.length", |
michael@0 | 95 | TEST_LENGTH, |
michael@0 | 96 | TEST_ARRAY.length ); |
michael@0 | 97 | |
michael@0 | 98 | new TestCase( SECTION, |
michael@0 | 99 | "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", |
michael@0 | 100 | "[object Array]", |
michael@0 | 101 | eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); |
michael@0 | 102 | |
michael@0 | 103 | test(); |