js/src/tests/ecma/ObjectObjects/15.2.4.3.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:3c27d2893af1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
7 /**
8 File Name: 15.2.4.3.js
9 ECMA Section: 15.2.4.3 Object.prototype.valueOf()
10
11 Description: As a rule, the valueOf method for an object simply
12 returns the object; but if the object is a "wrapper"
13 for a host object, as may perhaps be created by the
14 Object constructor, then the contained host object
15 should be returned.
16
17 This only covers native objects.
18
19 Author: christine@netscape.com
20 Date: 28 october 1997
21
22 */
23 var SECTION = "15.2.4.3";
24 var VERSION = "ECMA_1";
25 startTest();
26 var TITLE = "Object.prototype.valueOf()";
27
28 writeHeaderToLog( SECTION + " "+ TITLE);
29
30
31 var myarray = new Array();
32 myarray.valueOf = Object.prototype.valueOf;
33 var myboolean = new Boolean();
34 myboolean.valueOf = Object.prototype.valueOf;
35 var myfunction = new Function();
36 myfunction.valueOf = Object.prototype.valueOf;
37 var myobject = new Object();
38 myobject.valueOf = Object.prototype.valueOf;
39 var mymath = Math;
40 mymath.valueOf = Object.prototype.valueOf;
41 var mydate = new Date();
42 mydate.valueOf = Object.prototype.valueOf;
43 var mynumber = new Number();
44 mynumber.valueOf = Object.prototype.valueOf;
45 var mystring = new String();
46 mystring.valueOf = Object.prototype.valueOf;
47
48 new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length );
49
50 new TestCase( SECTION,
51 "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()",
52 myarray,
53 myarray.valueOf() );
54 new TestCase( SECTION,
55 "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()",
56 myboolean,
57 myboolean.valueOf() );
58 new TestCase( SECTION,
59 "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()",
60 myfunction,
61 myfunction.valueOf() );
62 new TestCase( SECTION,
63 "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()",
64 myobject,
65 myobject.valueOf() );
66 new TestCase( SECTION,
67 "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()",
68 mymath,
69 mymath.valueOf() );
70 new TestCase( SECTION,
71 "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()",
72 mynumber,
73 mynumber.valueOf() );
74 new TestCase( SECTION,
75 "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()",
76 mystring,
77 mystring.valueOf() );
78 new TestCase( SECTION,
79 "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()",
80 mydate,
81 mydate.valueOf() );
82
83 test();

mercurial