Debian Codegraph @

rhino/testsrc/tests/ecma/Date/15.9.5.3-2.js

raw symbols SCIP
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 gTestfile = '15.9.5.3-2.js';
7
8 /**
9 File Name: 15.9.5.3-2.js
10 ECMA Section: 15.9.5.3-2 Date.prototype.valueOf
11 Description:
12
13 The valueOf function returns a number, which is this time value.
14
15 The valueOf function is not generic; it generates a runtime error if
16 its this value is not a Date object. Therefore it cannot be transferred
17 to other kinds of objects for use as a method.
18
19 Author: [email protected]
20 Date: 12 november 1997
21 */
22
23 var SECTION = "15.9.5.3-2";
24 var VERSION = "ECMA_1";
25 startTest();
26 var TITLE = "Date.prototype.valueOf";
27
28 writeHeaderToLog( SECTION + " "+ TITLE);
29
30 addTestCase( TIME_NOW );
31 addTestCase( TIME_1970 );
32 addTestCase( TIME_1900 );
33 addTestCase( TIME_2000 );
34 addTestCase( UTC_FEB_29_2000 );
35 addTestCase( UTC_JAN_1_2005 );
36
37 test();
38
39 function addTestCase( t ) {
40 new TestCase( SECTION,
41 "(new Date("+t+").valueOf()",
42 t,
43 (new Date(t)).valueOf() );
44
45 new TestCase( SECTION,
46 "(new Date("+(t+1)+").valueOf()",
47 t+1,
48 (new Date(t+1)).valueOf() );
49
50 new TestCase( SECTION,
51 "(new Date("+(t-1)+").valueOf()",
52 t-1,
53 (new Date(t-1)).valueOf() );
54
55 new TestCase( SECTION,
56 "(new Date("+(t-TZ_ADJUST)+").valueOf()",
57 t-TZ_ADJUST,
58 (new Date(t-TZ_ADJUST)).valueOf() );
59
60 new TestCase( SECTION,
61 "(new Date("+(t+TZ_ADJUST)+").valueOf()",
62 t+TZ_ADJUST,
63 (new Date(t+TZ_ADJUST)).valueOf() );
64 }
65
66 function MyObject( value ) {
67 this.value = value;
68 this.valueOf = Date.prototype.valueOf;
69 this.toString = new Function( "return this+\"\";");
70 return this;
71 }