Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
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/. */
7 /**
8 File Name: 15.4.1.1.js
9 ECMA Section: 15.4.1 Array( item0, item1,... )
11 Description: When Array is called as a function rather than as a
12 constructor, it creates and initializes a new array
13 object. Thus, the function call Array(...) is
14 equivalent to the object creation new Array(...) with
15 the same arguments.
17 An array is created and returned as if by the expression
18 new Array( item0, item1, ... ).
20 Author: christine@netscape.com
21 Date: 7 october 1997
22 */
23 var SECTION = "15.4.1.1";
24 var VERSION = "ECMA_1";
25 startTest();
26 var TITLE = "Array Constructor Called as a Function";
28 writeHeaderToLog( SECTION + " "+ TITLE);
30 new TestCase( SECTION,
31 "typeof Array(1,2)",
32 "object",
33 typeof Array(1,2) );
35 new TestCase( SECTION,
36 "(Array(1,2)).toString",
37 Array.prototype.toString,
38 (Array(1,2)).toString );
40 new TestCase( SECTION,
41 "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()",
42 "[object Array]",
43 eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") );
45 new TestCase( SECTION,
46 "(Array(1,2)).length",
47 2,
48 (Array(1,2)).length );
50 new TestCase( SECTION,
51 "var arr = (Array(1,2)); arr[0]",
52 1,
53 eval("var arr = (Array(1,2)); arr[0]") );
55 new TestCase( SECTION,
56 "var arr = (Array(1,2)); arr[1]",
57 2,
58 eval("var arr = (Array(1,2)); arr[1]") );
60 new TestCase( SECTION,
61 "var arr = (Array(1,2)); String(arr)",
62 "1,2",
63 eval("var arr = (Array(1,2)); String(arr)") );
65 test();
67 function ToUint32( n ) {
68 n = Number( n );
69 if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY ||
70 n == Number.NEGATIVE_INFINITY ) {
71 return 0;
72 }
73 var sign = n < 0 ? -1 : 1;
75 return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32);
76 }