]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Date/15.9.2.1.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.9.2.1.js
24 ECMA Section: 15.9.2.1 Date constructor used as a function
25 Date( year, month, date, hours, minutes, seconds, ms )
26 Description: The arguments are accepted, but are completely ignored.
27 A string is created and returned as if by the
28 expression (new Date()).toString().
30 Author: christine@netscape.com
34 var VERSION
= "ECMA_1";
36 var SECTION
= "15.9.2.1";
37 var TITLE
= "Date Constructor used as a function";
38 var TYPEOF
= "string";
40 writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " +
41 "Date( year, month, date, hours, minutes, seconds, ms )" );
43 var testcases
= getTestCases();
45 // all tests must call a function that returns an array of TestCase objects.
48 function getTestCases() {
49 var array
= new Array();
52 var TODAY
= new Date();
54 // allow up to 1 second difference due to possibility
55 // the date may change by 1 second in between calls to Date
63 d2
= Date
.parse(Date(1970,0,1,0,0,0,0));
64 array
[item
++] = new TestCase(SECTION
, "Date(1970,0,1,0,0,0,0)", true, d2
- d1
<= 1000);
67 d2
= Date
.parse(Date(1969,11,31,15,59,59,999));
68 array
[item
++] = new TestCase(SECTION
, "Date(1969,11,31,15,59,59,999)", true, d2
- d1
<= 1000);
71 d2
= Date
.parse(Date(1969,11,31,16,0,0,0));
72 array
[item
++] = new TestCase(SECTION
, "Date(1969,11,31,16,0,0,0)", true, d2
- d1
<= 1000);
75 d2
= Date
.parse(Date(1969,11,31,16,0,0,1));
76 array
[item
++] = new TestCase(SECTION
, "Date(1969,11,31,16,0,0,1)", true, d2
- d1
<= 1000);
80 d2
= Date
.parse(Date(1999,11,15,59,59,999));
81 array
[item
++] = new TestCase(SECTION
, "Date(1999,11,15,59,59,999)", true, d2
- d1
<= 1000);
84 d2
= Date
.parse(Date(1999,11,16,0,0,0,0));
85 array
[item
++] = new TestCase(SECTION
, "Date(1999,11,16,0,0,0,0)", true, d2
- d1
<= 1000);
88 d2
= Date
.parse(Date(1999,11,31,23,59,59,999));
89 array
[item
++] = new TestCase(SECTION
, "Date(1999,11,31,23,59,59,999)", true, d2
- d1
<= 1000);
92 d2
= Date
.parse(Date(2000,0,0,0,0,0,0));
93 array
[item
++] = new TestCase(SECTION
, "Date(2000,0,1,0,0,0,0)", true, d2
- d1
<= 1000);
96 d2
= Date
.parse(Date(2000,0,0,0,0,0,1));
97 array
[item
++] = new TestCase(SECTION
, "Date(2000,0,1,0,0,0,1)", true, d2
- d1
<= 1000);
102 d2
= Date
.parse(Date(1899,11,31,23,59,59,999));
103 array
[item
++] = new TestCase(SECTION
, "Date(1899,11,31,23,59,59,999)", true, d2
- d1
<= 1000);
106 d2
= Date
.parse(Date(1900,0,1,0,0,0,0));
107 array
[item
++] = new TestCase(SECTION
, "Date(1900,0,1,0,0,0,0)", true, d2
- d1
<= 1000);
110 d2
= Date
.parse(Date(1900,0,1,0,0,0,1));
111 array
[item
++] = new TestCase(SECTION
, "Date(1900,0,1,0,0,0,1)", true, d2
- d1
<= 1000);
114 d2
= Date
.parse(Date(1899,11,31,16,0,0,0,0));
115 array
[item
++] = new TestCase(SECTION
, "Date(1899,11,31,16,0,0,0,0)", true, d2
- d1
<= 1000);
117 // Dates around feb 29, 2000
120 d2
= Date
.parse(Date(2000,1,29,0,0,0,0));
121 array
[item
++] = new TestCase(SECTION
, "Date(2000,1,29,0,0,0,0)", true, d2
- d1
<= 1000);
124 d2
= Date
.parse(Date(2000,1,28,23,59,59,999));
125 array
[item
++] = new TestCase(SECTION
, "Date(2000,1,28,23,59,59,999)", true, d2
- d1
<= 1000);
128 d2
= Date
.parse(Date(2000,1,27,16,0,0,0));
129 array
[item
++] = new TestCase(SECTION
, "Date(2000,1,27,16,0,0,0)", true, d2
- d1
<= 1000);
131 // Dates around jan 1, 2005
133 d2
= Date
.parse(Date(2004,11,31,23,59,59,999));
134 array
[item
++] = new TestCase(SECTION
, "Date(2004,11,31,23,59,59,999)", true, d2
- d1
<= 1000);
137 d2
= Date
.parse(Date(2005,0,1,0,0,0,0));
138 array
[item
++] = new TestCase(SECTION
, "Date(2005,0,1,0,0,0,0)", true, d2
- d1
<= 1000);
141 d2
= Date
.parse(Date(2005,0,1,0,0,0,1));
142 array
[item
++] = new TestCase(SECTION
, "Date(2005,0,1,0,0,0,1)", true, d2
- d1
<= 1000);
145 d2
= Date
.parse(Date(2004,11,31,16,0,0,0,0));
146 array
[item
++] = new TestCase(SECTION
, "Date(2004,11,31,16,0,0,0,0)", true, d2
- d1
<= 1000);
148 // Dates around jan 1, 2032
150 d2
= Date
.parse(Date(2031,11,31,23,59,59,999));
151 array
[item
++] = new TestCase(SECTION
, "Date(2031,11,31,23,59,59,999)", true, d2
- d1
<= 1000);
154 d2
= Date
.parse(Date(2032,0,1,0,0,0,0));
155 array
[item
++] = new TestCase(SECTION
, "Date(2032,0,1,0,0,0,0)", true, d2
- d1
<= 1000);
158 d2
= Date
.parse(Date(2032,0,1,0,0,0,1));
159 array
[item
++] = new TestCase(SECTION
, "Date(2032,0,1,0,0,0,1)", true, d2
- d1
<= 1000);
162 d2
= Date
.parse(Date(2031,11,31,16,0,0,0,0));
163 array
[item
++] = new TestCase(SECTION
, "Date(2031,11,31,16,0,0,0,0)", true, d2
- d1
<= 1000);
168 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
169 testcases
[tc
].passed
= writeTestCaseResult(
170 testcases
[tc
].expect
,
171 testcases
[tc
].actual
,
172 testcases
[tc
].description
+" = "+
173 testcases
[tc
].actual
);
175 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
178 return ( testcases
);