• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/
5 *
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.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
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
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
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().
29
30    Author:             christine@netscape.com
31    Date:               28 october 1997
32
33*/
34    var VERSION =   "ECMA_1";
35    startTest();
36    var SECTION =   "15.9.2.1";
37    var TITLE =     "Date Constructor used as a function";
38    var TYPEOF  =   "string";
39    var TOLERANCE = 1000;
40
41    writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function:  " +
42                     "Date( year, month, date, hours, minutes, seconds, ms )" );
43    var tc= 0;
44    var testcases = getTestCases();
45
46//  all tests must call a function that returns an array of TestCase objects.
47    test();
48
49function getTestCases() {
50    var array = new Array();
51    var item = 0;
52
53    var TODAY = new Date();
54
55    // Dates around 1970
56
57    array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)",            (new Date()).toString(),    Date(1970,0,1,0,0,0,0) );
58    array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)",     (new Date()).toString(),    Date(1969,11,31,15,59,59,999))
59    array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)",         (new Date()).toString(),    Date(1969,11,31,16,0,0,0))
60    array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)",         (new Date()).toString(),    Date(1969,11,31,16,0,0,1))
61
62    // Dates around 2000
63    array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59,999)",        (new Date()).toString(),    Date(1999,11,15,59,59,999));
64    array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)",          (new Date()).toString(),    Date(1999,11,16,0,0,0,0));
65    array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)",     (new Date()).toString(),    Date(1999,11,31,23,59,59,999) );
66    array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)",            (new Date()).toString(),    Date(2000,0,0,0,0,0,0) );
67    array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)",            (new Date()).toString(),    Date(2000,0,0,0,0,0,1) );
68
69    // Dates around 1900
70
71    array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)",     (new Date()).toString(),    Date(1899,11,31,23,59,59,999));
72    array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)",            (new Date()).toString(),    Date(1900,0,1,0,0,0,0) );
73    array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)",            (new Date()).toString(),    Date(1900,0,1,0,0,0,1) );
74    array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)",       (new Date()).toString(),    Date(1899,11,31,16,0,0,0,0));
75
76    // Dates around feb 29, 2000
77
78    array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)",         (new Date()).toString(),    Date(2000,1,29,0,0,0,0));
79    array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)",    (new Date()).toString(),    Date( 2000,1,28,23,59,59,999));
80    array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)",        (new Date()).toString(),    Date(2000,1,27,16,0,0,0));
81
82    // Dates around jan 1, 2005
83    array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)",     (new Date()).toString(),    Date(2004,11,31,23,59,59,999));
84    array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)",            (new Date()).toString(),    Date(2005,0,1,0,0,0,0) );
85    array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)",            (new Date()).toString(),    Date(2005,0,1,0,0,0,1) );
86    array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)",       (new Date()).toString(),    Date(2004,11,31,16,0,0,0,0));
87
88    // Dates around jan 1, 2032
89    array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)",     (new Date()).toString(),    Date(2031,11,31,23,59,59,999));
90    array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)",            (new Date()).toString(),    Date(2032,0,1,0,0,0,0) );
91    array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)",            (new Date()).toString(),    Date(2032,0,1,0,0,0,1) );
92    array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)",       (new Date()).toString(),    Date(2031,11,31,16,0,0,0,0));
93
94    return ( array );
95}
96function test() {
97    for ( tc=0; tc < testcases.length; tc++ ) {
98        testcases[tc].passed = writeTestCaseResult(
99                            testcases[tc].expect,
100                            testcases[tc].actual,
101                            testcases[tc].description +" = "+
102                            testcases[tc].actual );
103
104        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
105    }
106    stopTest();
107    return ( testcases );
108}
109