michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 15.4.1.js michael@0: ECMA Section: 15.4.1 The Array Constructor Called as a Function michael@0: michael@0: Description: When Array is called as a function rather than as a michael@0: constructor, it creates and initializes a new array michael@0: object. Thus, the function call Array(...) is michael@0: equivalent to the object creationi new Array(...) with michael@0: the same arguments. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 7 october 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.4.1"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "The Array Constructor Called as a Function"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "Array() +''", michael@0: "", michael@0: Array() +"" ); michael@0: michael@0: new TestCase( SECTION, michael@0: "typeof Array()", michael@0: "object", michael@0: typeof Array() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", michael@0: "[object Array]", michael@0: eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var arr = Array(); arr.toString == Array.prototype.toString", michael@0: true, michael@0: eval("var arr = Array(); arr.toString == Array.prototype.toString") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Array().length", michael@0: 0, michael@0: Array().length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Array(1,2,3) +''", michael@0: "1,2,3", michael@0: Array(1,2,3) +"" ); michael@0: michael@0: new TestCase( SECTION, michael@0: "typeof Array(1,2,3)", michael@0: "object", michael@0: typeof Array(1,2,3) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", michael@0: "[object Array]", michael@0: eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", michael@0: true, michael@0: eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Array(1,2,3).length", michael@0: 3, michael@0: Array(1,2,3).length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "typeof Array(12345)", michael@0: "object", michael@0: typeof Array(12345) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", michael@0: "[object Array]", michael@0: eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", michael@0: true, michael@0: eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Array(12345).length", michael@0: 12345, michael@0: Array(12345).length ); michael@0: michael@0: test();