Debian Codegraph @

rhino/testsrc/tests/ecma/Array/15.4.2.1-1.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-1.js';
7
8 /**
9 File Name: 15.4.2.1-1.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 file tests the typeof the newly constructed object.
32
33 Author: [email protected]
34 Date: 7 october 1997
35 */
36
37 var SECTION = "15.4.2.1-1";
38 var VERSION = "ECMA_1";
39 startTest();
40 var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
41
42 writeHeaderToLog( SECTION + " "+ TITLE);
43
44 new TestCase( SECTION,
45 "typeof new Array(1,2)",
46 "object",
47 typeof new Array(1,2) );
48
49 new TestCase( SECTION,
50 "(new Array(1,2)).toString",
51 Array.prototype.toString,
52 (new Array(1,2)).toString );
53
54 new TestCase( SECTION,
55 "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
56 "[object Array]",
57 eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
58
59 new TestCase( SECTION,
60 "(new Array(1,2)).length",
61 2,
62 (new Array(1,2)).length );
63
64 new TestCase( SECTION,
65 "var arr = (new Array(1,2)); arr[0]",
66 1,
67 eval("var arr = (new Array(1,2)); arr[0]") );
68
69 new TestCase( SECTION,
70 "var arr = (new Array(1,2)); arr[1]",
71 2,
72 eval("var arr = (new Array(1,2)); arr[1]") );
73
74 new TestCase( SECTION,
75 "var arr = (new Array(1,2)); String(arr)",
76 "1,2",
77 eval("var arr = (new Array(1,2)); String(arr)") );
78
79 test();