Debian Codegraph @

rhino/testsrc/tests/ecma/Date/15.9.5.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.2.js';
7
8 /**
9 File Name: 15.9.5.2.js
10 ECMA Section: 15.9.5.2 Date.prototype.toString
11 Description:
12 This function returns a string value. The contents of the string are
13 implementation dependent, but are intended to represent the Date in a
14 convenient, human-readable form in the current time zone.
15
16 The toString function is not generic; it generates a runtime error if its
17 this value is not a Date object. Therefore it cannot be transferred to
18 other kinds of objects for use as a method.
19
20 Author: [email protected]
21 Date: 12 november 1997
22 */
23
24 var SECTION = "15.9.5.2";
25 var VERSION = "ECMA_1";
26 startTest();
27 var TITLE = "Date.prototype.toString";
28
29 writeHeaderToLog( SECTION + " "+ TITLE);
30
31 new TestCase( SECTION,
32 "Date.prototype.toString.length",
33 0,
34 Date.prototype.toString.length );
35
36 var now = new Date();
37
38 // can't test the content of the string, but can verify that the string is
39 // parsable by Date.parse
40
41 new TestCase( SECTION,
42 "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000",
43 true,
44 Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 );
45
46 new TestCase( SECTION,
47 "typeof now.toString()",
48 "string",
49 typeof now.toString() );
50 // 1970
51
52 new TestCase( SECTION,
53 "Date.parse( (new Date(0)).toString() )",
54 0,
55 Date.parse( (new Date(0)).toString() ) );
56
57 new TestCase( SECTION,
58 "Date.parse( (new Date("+TZ_ADJUST+")).toString() )",
59 TZ_ADJUST,
60 Date.parse( (new Date(TZ_ADJUST)).toString() ) );
61
62 // 1900
63 new TestCase( SECTION,
64 "Date.parse( (new Date("+TIME_1900+")).toString() )",
65 TIME_1900,
66 Date.parse( (new Date(TIME_1900)).toString() ) );
67
68 new TestCase( SECTION,
69 "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )",
70 TIME_1900 -TZ_ADJUST,
71 Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) );
72
73 // 2000
74 new TestCase( SECTION,
75 "Date.parse( (new Date("+TIME_2000+")).toString() )",
76 TIME_2000,
77 Date.parse( (new Date(TIME_2000)).toString() ) );
78
79 new TestCase( SECTION,
80 "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )",
81 TIME_2000 -TZ_ADJUST,
82 Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) );
83
84 // 29 Feb 2000
85
86 new TestCase( SECTION,
87 "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )",
88 UTC_FEB_29_2000,
89 Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) );
90
91 new TestCase( SECTION,
92 "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )",
93 UTC_FEB_29_2000-1000,
94 Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) );
95
96
97 new TestCase( SECTION,
98 "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )",
99 UTC_FEB_29_2000-TZ_ADJUST,
100 Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) );
101 // 2O05
102
103 new TestCase( SECTION,
104 "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )",
105 UTC_JAN_1_2005,
106 Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) );
107
108 new TestCase( SECTION,
109 "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )",
110 UTC_JAN_1_2005-1000,
111 Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) );
112
113 new TestCase( SECTION,
114 "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )",
115 UTC_JAN_1_2005-TZ_ADJUST,
116 Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) );
117
118 test();