]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/ObjectObjects/15.2.4.3.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.2.4.3.js
24 ECMA Section: 15.2.4.3 Object.prototype.valueOf()
26 Description: As a rule, the valueOf method for an object simply
27 returns the object; but if the object is a "wrapper"
28 for a host object, as may perhaps be created by the
29 Object constructor, then the contained host object
32 This only covers native objects.
34 Author: christine@netscape.com
38 var SECTION
= "15.2.4.3";
39 var VERSION
= "ECMA_1";
41 var TITLE
= "Object.prototype.valueOf()";
43 writeHeaderToLog( SECTION
+ " "+ TITLE
);
45 var testcases
= getTestCases();
48 function getTestCases() {
49 var array
= new Array();
52 var myarray
= new Array();
53 myarray
.valueOf
= Object
.prototype.valueOf
;
54 var myboolean
= new Boolean();
55 myboolean
.valueOf
= Object
.prototype.valueOf
;
56 var myfunction
= new Function();
57 myfunction
.valueOf
= Object
.prototype.valueOf
;
58 var myobject
= new Object();
59 myobject
.valueOf
= Object
.prototype.valueOf
;
61 mymath
.valueOf
= Object
.prototype.valueOf
;
62 var mydate
= new Date();
63 mydate
.valueOf
= Object
.prototype.valueOf
;
64 var mynumber
= new Number();
65 mynumber
.valueOf
= Object
.prototype.valueOf
;
66 var mystring
= new String();
67 mystring
.valueOf
= Object
.prototype.valueOf
;
69 array
[item
++] = new TestCase( SECTION
, "Object.prototype.valueOf.length", 0, Object
.prototype.valueOf
.length
);
71 array
[item
++] = new TestCase( SECTION
,
72 "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()",
75 array
[item
++] = new TestCase( SECTION
,
76 "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()",
78 myboolean
.valueOf() );
79 array
[item
++] = new TestCase( SECTION
,
80 "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()",
82 myfunction
.valueOf() );
83 array
[item
++] = new TestCase( SECTION
,
84 "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()",
87 array
[item
++] = new TestCase( SECTION
,
88 "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()",
91 array
[item
++] = new TestCase( SECTION
,
92 "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()",
95 array
[item
++] = new TestCase( SECTION
,
96 "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()",
99 array
[item
++] = new TestCase( SECTION
,
100 "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()",
106 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
107 testcases
[tc
].passed
= writeTestCaseResult(
108 testcases
[tc
].expect
,
109 testcases
[tc
].actual
,
110 testcases
[tc
].description
+" = "+ testcases
[tc
].actual
);
111 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
114 return ( testcases
);