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.4.3.js michael@0: ECMA Section: 15.2.4.3 Object.prototype.valueOf() michael@0: michael@0: Description: As a rule, the valueOf method for an object simply michael@0: returns the object; but if the object is a "wrapper" michael@0: for a host object, as may perhaps be created by the michael@0: Object constructor, then the contained host object michael@0: should be returned. michael@0: michael@0: This only covers native objects. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 28 october 1997 michael@0: michael@0: */ michael@0: var SECTION = "15.2.4.3"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Object.prototype.valueOf()"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: michael@0: var myarray = new Array(); michael@0: myarray.valueOf = Object.prototype.valueOf; michael@0: var myboolean = new Boolean(); michael@0: myboolean.valueOf = Object.prototype.valueOf; michael@0: var myfunction = new Function(); michael@0: myfunction.valueOf = Object.prototype.valueOf; michael@0: var myobject = new Object(); michael@0: myobject.valueOf = Object.prototype.valueOf; michael@0: var mymath = Math; michael@0: mymath.valueOf = Object.prototype.valueOf; michael@0: var mydate = new Date(); michael@0: mydate.valueOf = Object.prototype.valueOf; michael@0: var mynumber = new Number(); michael@0: mynumber.valueOf = Object.prototype.valueOf; michael@0: var mystring = new String(); michael@0: mystring.valueOf = Object.prototype.valueOf; michael@0: michael@0: new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", michael@0: myarray, michael@0: myarray.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", michael@0: myboolean, michael@0: myboolean.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", michael@0: myfunction, michael@0: myfunction.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", michael@0: myobject, michael@0: myobject.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", michael@0: mymath, michael@0: mymath.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", michael@0: mynumber, michael@0: mynumber.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", michael@0: mystring, michael@0: mystring.valueOf() ); michael@0: new TestCase( SECTION, michael@0: "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", michael@0: mydate, michael@0: mydate.valueOf() ); michael@0: michael@0: test();