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.2.1.2.js michael@0: ECMA Section: 15.2.1.2 The Object Constructor Called as a Function: michael@0: Object(value) michael@0: Description: When Object is called as a function rather than as a michael@0: constructor, the following steps are taken: michael@0: michael@0: 1. If value is null or undefined, create and return a michael@0: new object with no proerties other than internal michael@0: properties exactly as if the object constructor michael@0: had been called on that same value (15.2.2.1). michael@0: 2. Return ToObject (value), whose rules are: michael@0: michael@0: undefined generate a runtime error michael@0: null generate a runtime error michael@0: boolean create a new Boolean object whose default michael@0: value is the value of the boolean. michael@0: number Create a new Number object whose default michael@0: value is the value of the number. michael@0: string Create a new String object whose default michael@0: value is the value of the string. michael@0: object Return the input argument (no conversion). michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 17 july 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.2.1.2"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Object()"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var MYOB = Object(); michael@0: michael@0: new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); michael@0: new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); michael@0: new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); michael@0: michael@0: test();