Debian Codegraph @

rhino/testsrc/tests/ecma/Array/15.4.2.1-3.js

raw symbols SCIP
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-3.js';
7
8 /**
9 File Name: 15.4.2.1-3.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 This test stresses the number of arguments presented to
32 the Array constructor. Should support up to Math.pow
33 (2,32) arguments, since that is the maximum length of an
34 ECMAScript array.
35
36 ***Change TEST_LENGTH to Math.pow(2,32) when larger array
37 lengths are supported.
38
39 Author: [email protected]
40 Date: 7 october 1997
41 */
42 var SECTION = "15.4.2.1-3";
43 var VERSION = "ECMA_1";
44 startTest();
45 var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
46
47 writeHeaderToLog( SECTION + " "+ TITLE);
48
49 var TEST_STRING = "new Array(";
50 var ARGUMENTS = ""
51 var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
52
53 for ( var index = 0; index < TEST_LENGTH; index++ ) {
54 ARGUMENTS += index;
55 ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
56 }
57
58 TEST_STRING += ARGUMENTS + ")";
59
60 TEST_ARRAY = eval( TEST_STRING );
61
62 for ( var item = 0; item < TEST_LENGTH; item++ ) {
63 new TestCase( SECTION,
64 "TEST_ARRAY["+item+"]",
65 item,
66 TEST_ARRAY[item] );
67 }
68
69 new TestCase( SECTION,
70 "new Array( ["+TEST_LENGTH+" arguments] ) +''",
71 ARGUMENTS,
72 TEST_ARRAY +"" );
73
74 new TestCase( SECTION,
75 "TEST_ARRAY.toString",
76 Array.prototype.toString,
77 TEST_ARRAY.toString );
78
79 new TestCase( SECTION,
80 "TEST_ARRAY.join",
81 Array.prototype.join,
82 TEST_ARRAY.join );
83
84 new TestCase( SECTION,
85 "TEST_ARRAY.sort",
86 Array.prototype.sort,
87 TEST_ARRAY.sort );
88
89 new TestCase( SECTION,
90 "TEST_ARRAY.reverse",
91 Array.prototype.reverse,
92 TEST_ARRAY.reverse );
93
94 new TestCase( SECTION,
95 "TEST_ARRAY.length",
96 TEST_LENGTH,
97 TEST_ARRAY.length );
98
99 new TestCase( SECTION,
100 "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()",
101 "[object Array]",
102 eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") );
103
104 test();