]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Exceptions/date-003.js
3 Corresponds To 15.9.5.3-1.js
4 ECMA Section: 15.9.5.3-1 Date.prototype.valueOf
7 The valueOf function returns a number, which is this time value.
9 The valueOf function is not generic; it generates a runtime error if
10 its this value is not a Date object. Therefore it cannot be transferred
11 to other kinds of objects for use as a method.
13 Author: christine@netscape.com
14 Date: 12 november 1997
16 var SECTION
= "date-003";
17 var VERSION
= "JS1_4";
18 var TITLE
= "Date.prototype.valueOf";
21 writeHeaderToLog( SECTION
+ " "+ TITLE
);
24 var testcases
= new Array();
26 var result
= "Failed";
27 var exception
= "No exception thrown";
28 var expect
= "Passed";
31 var OBJ
= new MyObject( new Date(0) );
32 result
= OBJ
.valueOf();
35 exception
= e
.toString();
38 testcases
[tc
++] = new TestCase(
40 "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" +
41 " (threw " + exception
+")",
47 function MyObject( value
) {
49 this.valueOf
= Date
.prototype.valueOf
;
50 // The following line causes an infinte loop
51 // this.toString = new Function( "return this+\"\";");