• 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.2.js
24    ECMA Section:       15.9.2.2 Date constructor used as a function
25                        Date( year, month, date, hours, minutes, seconds )
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    Version:            9706
33
34*/
35    var VERSION = 9706;
36    startTest();
37    var SECTION = "15.9.2.2";
38    var TOLERANCE = 100;
39    var TITLE = "The Date Constructor Called as a Function";
40
41    writeHeaderToLog(SECTION+" "+TITLE );
42    var tc= 0;
43    var testcases = getTestCases();
44
45//  all tests must call a function that returns an array of TestCase objects.
46    test();
47
48function getTestCases() {
49    var array = new Array();
50    var item = 0;
51
52    // Dates around 1970
53
54    array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0)",          (new Date()).toString(),    Date(1970,0,1,0,0,0) );
55    array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59)",     (new Date()).toString(),    Date(1969,11,31,15,59,59))
56    array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0)",       (new Date()).toString(),    Date(1969,11,31,16,0,0))
57    array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,1)",       (new Date()).toString(),    Date(1969,11,31,16,0,1))
58/*
59    // Dates around 2000
60    array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)",        (new Date()).toString(),    Date(1999,11,15,59,59));
61    array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)",        (new Date()).toString(),    Date(1999,11,16,0,0,0));
62    array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)",     (new Date()).toString(),    Date(1999,11,31,23,59,59) );
63    array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)",          (new Date()).toString(),    Date(2000,0,0,0,0,0) );
64    array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)",          (new Date()).toString(),    Date(2000,0,0,0,0,1) );
65
66    // Dates around 1900
67
68    array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)",     (new Date()).toString(),    Date(1899,11,31,23,59,59));
69    array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)",          (new Date()).toString(),    Date(1900,0,1,0,0,0) );
70    array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)",          (new Date()).toString(),    Date(1900,0,1,0,0,1) );
71    array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)",     (new Date()).toString(),    Date(1899,11,31,16,0,0,0));
72
73    // Dates around feb 29, 2000
74
75    array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)",        (new Date()).toString(),    Date(2000,1,29,0,0,0));
76    array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)",     (new Date()).toString(),    Date( 2000,1,28,23,59,59));
77    array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)",       (new Date()).toString(),    Date(2000,1,27,16,0,0));
78
79    // Dates around jan 1, 2005
80    array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)",     (new Date()).toString(),    Date(2004,11,31,23,59,59));
81    array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)",          (new Date()).toString(),    Date(2005,0,1,0,0,0) );
82    array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)",          (new Date()).toString(),    Date(2005,0,1,0,0,1) );
83    array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)",     (new Date()).toString(),    Date(2004,11,31,16,0,0,0));
84
85    // Dates around jan 1, 2032
86    array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)",     (new Date()).toString(),    Date(2031,11,31,23,59,59));
87    array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)",          (new Date()).toString(),    Date(2032,0,1,0,0,0) );
88    array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)",          (new Date()).toString(),    Date(2032,0,1,0,0,1) );
89    array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)",     (new Date()).toString(),    Date(2031,11,31,16,0,0,0));
90*/
91    return ( array );
92}
93function test() {
94    for ( tc=0; tc < testcases.length; tc++ ) {
95        testcases[tc].passed = writeTestCaseResult(
96                            testcases[tc].expect,
97                            testcases[tc].actual,
98                            testcases[tc].description +" = "+
99                            testcases[tc].actual );
100
101        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
102    }
103    stopTest();
104    return ( testcases );
105}
106