Debian Codegraph @

rhino/testsrc/tests/ecma/Array/15.4.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.1.1.js';
7
8 /**
9 File Name: 15.4.1.1.js
10 ECMA Section: 15.4.1 Array( item0, item1,... )
11
12 Description: When Array is called as a function rather than as a
13 constructor, it creates and initializes a new array
14 object. Thus, the function call Array(...) is
15 equivalent to the object creation new Array(...) with
16 the same arguments.
17
18 An array is created and returned as if by the expression
19 new Array( item0, item1, ... ).
20
21 Author: [email protected]
22 Date: 7 october 1997
23 */
24 var SECTION = "15.4.1.1";
25 var VERSION = "ECMA_1";
26 startTest();
27 var TITLE = "Array Constructor Called as a Function";
28
29 writeHeaderToLog( SECTION + " "+ TITLE);
30
31 new TestCase( SECTION,
32 "typeof Array(1,2)",
33 "object",
34 typeof Array(1,2) );
35
36 new TestCase( SECTION,
37 "(Array(1,2)).toString",
38 Array.prototype.toString,
39 (Array(1,2)).toString );
40
41 new TestCase( SECTION,
42 "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()",
43 "[object Array]",
44 eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") );
45
46 new TestCase( SECTION,
47 "(Array(1,2)).length",
48 2,
49 (Array(1,2)).length );
50
51 new TestCase( SECTION,
52 "var arr = (Array(1,2)); arr[0]",
53 1,
54 eval("var arr = (Array(1,2)); arr[0]") );
55
56 new TestCase( SECTION,
57 "var arr = (Array(1,2)); arr[1]",
58 2,
59 eval("var arr = (Array(1,2)); arr[1]") );
60
61 new TestCase( SECTION,
62 "var arr = (Array(1,2)); String(arr)",
63 "1,2",
64 eval("var arr = (Array(1,2)); String(arr)") );
65
66 test();
67
68 function ToUint32( n ) {
69 n = Number( n );
70 if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY ||
71 n == Number.NEGATIVE_INFINITY ) {
72 return 0;
73 }
74 var sign = n < 0 ? -1 : 1;
75
76 return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32);
77 }
78