| 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/. */ |
| 5 | |
| 6 | gTestfile = '15.4.2.1-2.js'; |
| 7 | |
| 8 | /** |
| 9 | File Name: 15.4.2.1-2.js |
| 10 | ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) |
| 11 | Description: This description only applies of the constructor is |
| 12 | given two or more arguments. |
| 13 | |
| 14 | The [[Prototype]] property of the newly constructed |
| 15 | object is set to the original Array prototype object, |
| 16 | the one that is the initial value of Array.prototype |
| 17 | (15.4.3.1). |
| 18 | |
| 19 | The [[Class]] property of the newly constructed object |
| 20 | is set to "Array". |
| 21 | |
| 22 | The length property of the newly constructed object is |
| 23 | set to the number of arguments. |
| 24 | |
| 25 | The 0 property of the newly constructed object is set |
| 26 | to item0... in general, for as many arguments as there |
| 27 | are, the k property of the newly constructed object is |
| 28 | set to argument k, where the first argument is |
| 29 | considered to be argument number 0. |
| 30 | |
| 31 | |
| 32 | Author: [email protected] |
| 33 | Date: 7 october 1997 |
| 34 | */ |
| 35 | var SECTION = "15.4.2.1-2"; |
| 36 | var VERSION = "ECMA_1"; |
| 37 | startTest(); |
| 38 | var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; |
| 39 | |
| 40 | writeHeaderToLog( SECTION + " "+ TITLE); |
| 41 | |
| 42 | |
| 43 | var TEST_STRING = "new Array("; |
| 44 | var ARGUMENTS = "" |
| 45 | var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); |
| 46 | |
| 47 | for ( var index = 0; index < TEST_LENGTH; index++ ) { |
| 48 | ARGUMENTS += index; |
| 49 | ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; |
| 50 | } |
| 51 | |
| 52 | TEST_STRING += ARGUMENTS + ")"; |
| 53 | |
| 54 | TEST_ARRAY = eval( TEST_STRING ); |
| 55 | |
| 56 | for ( var item = 0; item < TEST_LENGTH; item++ ) { |
| 57 | new TestCase( SECTION, |
| 58 | "["+item+"]", |
| 59 | item, |
| 60 | TEST_ARRAY[item] ); |
| 61 | } |
| 62 | |
| 63 | new TestCase( SECTION, |
| 64 | "new Array( ["+TEST_LENGTH+" arguments] ) +''", |
| 65 | ARGUMENTS, |
| 66 | TEST_ARRAY +"" ); |
| 67 | |
| 68 | test(); |