1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/ObjectObjects/15.2.4.3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.2.4.3.js 1.12 + ECMA Section: 15.2.4.3 Object.prototype.valueOf() 1.13 + 1.14 + Description: As a rule, the valueOf method for an object simply 1.15 + returns the object; but if the object is a "wrapper" 1.16 + for a host object, as may perhaps be created by the 1.17 + Object constructor, then the contained host object 1.18 + should be returned. 1.19 + 1.20 + This only covers native objects. 1.21 + 1.22 + Author: christine@netscape.com 1.23 + Date: 28 october 1997 1.24 + 1.25 +*/ 1.26 +var SECTION = "15.2.4.3"; 1.27 +var VERSION = "ECMA_1"; 1.28 +startTest(); 1.29 +var TITLE = "Object.prototype.valueOf()"; 1.30 + 1.31 +writeHeaderToLog( SECTION + " "+ TITLE); 1.32 + 1.33 + 1.34 +var myarray = new Array(); 1.35 +myarray.valueOf = Object.prototype.valueOf; 1.36 +var myboolean = new Boolean(); 1.37 +myboolean.valueOf = Object.prototype.valueOf; 1.38 +var myfunction = new Function(); 1.39 +myfunction.valueOf = Object.prototype.valueOf; 1.40 +var myobject = new Object(); 1.41 +myobject.valueOf = Object.prototype.valueOf; 1.42 +var mymath = Math; 1.43 +mymath.valueOf = Object.prototype.valueOf; 1.44 +var mydate = new Date(); 1.45 +mydate.valueOf = Object.prototype.valueOf; 1.46 +var mynumber = new Number(); 1.47 +mynumber.valueOf = Object.prototype.valueOf; 1.48 +var mystring = new String(); 1.49 +mystring.valueOf = Object.prototype.valueOf; 1.50 + 1.51 +new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); 1.52 + 1.53 +new TestCase( SECTION, 1.54 + "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", 1.55 + myarray, 1.56 + myarray.valueOf() ); 1.57 +new TestCase( SECTION, 1.58 + "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", 1.59 + myboolean, 1.60 + myboolean.valueOf() ); 1.61 +new TestCase( SECTION, 1.62 + "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", 1.63 + myfunction, 1.64 + myfunction.valueOf() ); 1.65 +new TestCase( SECTION, 1.66 + "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", 1.67 + myobject, 1.68 + myobject.valueOf() ); 1.69 +new TestCase( SECTION, 1.70 + "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", 1.71 + mymath, 1.72 + mymath.valueOf() ); 1.73 +new TestCase( SECTION, 1.74 + "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", 1.75 + mynumber, 1.76 + mynumber.valueOf() ); 1.77 +new TestCase( SECTION, 1.78 + "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", 1.79 + mystring, 1.80 + mystring.valueOf() ); 1.81 +new TestCase( SECTION, 1.82 + "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", 1.83 + mydate, 1.84 + mydate.valueOf() ); 1.85 + 1.86 +test();