~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/ecma/Date/15.9.2.1.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
7
/**
 
8
   File Name:          15.9.2.1.js
 
9
   ECMA Section:       15.9.2.1 Date constructor used as a function
 
10
   Date( year, month, date, hours, minutes, seconds, ms )
 
11
   Description:        The arguments are accepted, but are completely ignored.
 
12
   A string is created and returned as if by the
 
13
   expression (new Date()).toString().
 
14
 
 
15
   Author:             christine@netscape.com
 
16
   Date:               28 october 1997
 
17
 
 
18
*/
 
19
var VERSION =   "ECMA_1";
 
20
startTest();
 
21
var SECTION =   "15.9.2.1";
 
22
var TITLE =     "Date Constructor used as a function";
 
23
var TYPEOF  =   "string";
 
24
var TOLERANCE = 1000;
 
25
 
 
26
writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function:  " +
 
27
                 "Date( year, month, date, hours, minutes, seconds, ms )" );
 
28
 
 
29
// allow up to 1 second difference due to possibility
 
30
// the date may change by 1 second in between calls to Date
 
31
 
 
32
var d1;
 
33
var d2;
 
34
 
 
35
// Dates around 1970
 
36
 
 
37
d1 = new Date();
 
38
d2 = Date.parse(Date(1970,0,1,0,0,0,0));
 
39
new TestCase(SECTION, "Date(1970,0,1,0,0,0,0)", true, d2 - d1 <= 1000);
 
40
 
 
41
d1 = new Date();
 
42
d2 = Date.parse(Date(1969,11,31,15,59,59,999));
 
43
new TestCase(SECTION, "Date(1969,11,31,15,59,59,999)", true, d2 - d1 <= 1000);
 
44
 
 
45
d1 = new Date();
 
46
d2 = Date.parse(Date(1969,11,31,16,0,0,0));
 
47
new TestCase(SECTION, "Date(1969,11,31,16,0,0,0)", true, d2 - d1 <= 1000);
 
48
 
 
49
d1 = new Date();
 
50
d2 = Date.parse(Date(1969,11,31,16,0,0,1));
 
51
new TestCase(SECTION, "Date(1969,11,31,16,0,0,1)", true, d2 - d1 <= 1000);
 
52
 
 
53
// Dates around 2000
 
54
d1 = new Date();
 
55
d2 = Date.parse(Date(1999,11,15,59,59,999));
 
56
new TestCase(SECTION, "Date(1999,11,15,59,59,999)", true, d2 - d1 <= 1000);
 
57
 
 
58
d1 = new Date();
 
59
d2 = Date.parse(Date(1999,11,16,0,0,0,0));
 
60
new TestCase(SECTION, "Date(1999,11,16,0,0,0,0)", true, d2 - d1 <= 1000);
 
61
 
 
62
d1 = new Date();
 
63
d2 = Date.parse(Date(1999,11,31,23,59,59,999));
 
64
new TestCase(SECTION, "Date(1999,11,31,23,59,59,999)", true, d2 - d1 <= 1000);
 
65
 
 
66
d1 = new Date();
 
67
d2 = Date.parse(Date(2000,0,0,0,0,0,0));
 
68
new TestCase(SECTION, "Date(2000,0,1,0,0,0,0)", true, d2 - d1 <= 1000);
 
69
 
 
70
d1 = new Date();
 
71
d2 = Date.parse(Date(2000,0,0,0,0,0,1));
 
72
new TestCase(SECTION, "Date(2000,0,1,0,0,0,1)", true, d2 - d1 <= 1000);
 
73
 
 
74
// Dates around 1900
 
75
 
 
76
d1 = new Date();
 
77
d2 = Date.parse(Date(1899,11,31,23,59,59,999));
 
78
new TestCase(SECTION, "Date(1899,11,31,23,59,59,999)", true, d2 - d1 <= 1000);
 
79
 
 
80
d1 = new Date();
 
81
d2 = Date.parse(Date(1900,0,1,0,0,0,0));
 
82
new TestCase(SECTION, "Date(1900,0,1,0,0,0,0)", true, d2 - d1 <= 1000);
 
83
 
 
84
d1 = new Date();
 
85
d2 = Date.parse(Date(1900,0,1,0,0,0,1));
 
86
new TestCase(SECTION, "Date(1900,0,1,0,0,0,1)", true, d2 - d1 <= 1000);
 
87
 
 
88
d1 = new Date();
 
89
d2 = Date.parse(Date(1899,11,31,16,0,0,0,0));
 
90
new TestCase(SECTION, "Date(1899,11,31,16,0,0,0,0)", true, d2 - d1 <= 1000);
 
91
 
 
92
// Dates around feb 29, 2000
 
93
 
 
94
d1 = new Date();
 
95
d2 = Date.parse(Date(2000,1,29,0,0,0,0));
 
96
new TestCase(SECTION, "Date(2000,1,29,0,0,0,0)", true, d2 - d1 <= 1000);
 
97
 
 
98
d1 = new Date();
 
99
d2 = Date.parse(Date(2000,1,28,23,59,59,999));
 
100
new TestCase(SECTION, "Date(2000,1,28,23,59,59,999)", true, d2 - d1 <= 1000);
 
101
 
 
102
d1 = new Date();
 
103
d2 = Date.parse(Date(2000,1,27,16,0,0,0));
 
104
new TestCase(SECTION, "Date(2000,1,27,16,0,0,0)", true, d2 - d1 <= 1000);
 
105
 
 
106
// Dates around jan 1, 2005
 
107
d1 = new Date();
 
108
d2 = Date.parse(Date(2004,11,31,23,59,59,999));
 
109
new TestCase(SECTION, "Date(2004,11,31,23,59,59,999)",  true, d2 - d1 <= 1000);
 
110
 
 
111
d1 = new Date();
 
112
d2 = Date.parse(Date(2005,0,1,0,0,0,0));
 
113
new TestCase(SECTION, "Date(2005,0,1,0,0,0,0)",  true, d2 - d1 <= 1000);
 
114
 
 
115
d1 = new Date();
 
116
d2 = Date.parse(Date(2005,0,1,0,0,0,1));
 
117
new TestCase(SECTION, "Date(2005,0,1,0,0,0,1)",  true, d2 - d1 <= 1000);
 
118
 
 
119
d1 = new Date();
 
120
d2 = Date.parse(Date(2004,11,31,16,0,0,0,0));
 
121
new TestCase(SECTION, "Date(2004,11,31,16,0,0,0,0)",  true, d2 - d1 <= 1000);
 
122
 
 
123
// Dates around jan 1, 2032
 
124
d1 = new Date();
 
125
d2 = Date.parse(Date(2031,11,31,23,59,59,999));
 
126
new TestCase(SECTION, "Date(2031,11,31,23,59,59,999)",  true, d2 - d1 <= 1000);
 
127
 
 
128
d1 = new Date();
 
129
d2 = Date.parse(Date(2032,0,1,0,0,0,0));
 
130
new TestCase(SECTION, "Date(2032,0,1,0,0,0,0)",  true, d2 - d1 <= 1000);
 
131
 
 
132
d1 = new Date();
 
133
d2 = Date.parse(Date(2032,0,1,0,0,0,1));
 
134
new TestCase(SECTION, "Date(2032,0,1,0,0,0,1)",  true, d2 - d1 <= 1000);
 
135
 
 
136
d1 = new Date();
 
137
d2 = Date.parse(Date(2031,11,31,16,0,0,0,0));
 
138
new TestCase(SECTION, "Date(2031,11,31,16,0,0,0,0)",  true, d2 - d1 <= 1000);
 
139
 
 
140
test();