Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / Date / 15.9.3.1-1.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39 gTestfile = '15.9.3.1-1.js';
40
41 /**
42    File Name:          15.9.3.1.js
43    ECMA Section:       15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
44    Description:        The [[Prototype]] property of the newly constructed
45    object is set to the original Date prototype object,
46    the one that is the initial value of Date.prototype.
47
48    The [[Class]] property of the newly constructed object
49    is set as follows:
50    1. Call ToNumber(year)
51    2. Call ToNumber(month)
52    3. Call ToNumber(date)
53    4. Call ToNumber(hours)
54    5. Call ToNumber(minutes)
55    6. Call ToNumber(seconds)
56    7. Call ToNumber(ms)
57    8.  If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
58    99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
59    Result(8) is Result(1)
60    9.  Compute MakeDay(Result(8), Result(2), Result(3)
61    10. Compute MakeTime(Result(4), Result(5), Result(6),
62    Result(7)
63    11. Compute MakeDate(Result(9), Result(10))
64    12. Set the [[Value]] property of the newly constructed
65    object to TimeClip(UTC(Result(11))).
66
67
68    This tests the returned value of a newly constructed
69    Date object.
70
71    Author:             christine@netscape.com
72    Date:               7 july 1997
73 */
74
75 var SECTION = "15.9.3.1";
76 var VERSION = "ECMA_1";
77 startTest();
78 var TITLE   = "new Date( year, month, date, hours, minutes, seconds, ms )";
79
80 var TIME        = 0;
81 var UTC_YEAR    = 1;
82 var UTC_MONTH   = 2;
83 var UTC_DATE    = 3;
84 var UTC_DAY     = 4;
85 var UTC_HOURS   = 5;
86 var UTC_MINUTES = 6;
87 var UTC_SECONDS = 7;
88 var UTC_MS      = 8;
89
90 var YEAR        = 9;
91 var MONTH       = 10;
92 var DATE        = 11;
93 var DAY         = 12;
94 var HOURS       = 13;
95 var MINUTES     = 14;
96 var SECONDS     = 15;
97 var MS          = 16;
98
99 writeHeaderToLog( SECTION + " "+ TITLE);
100
101 // Dates around 1970
102
103 addNewTestCase( new Date( 1969,11,31,15,59,59,999),
104                 "new Date( 1969,11,31,15,59,59,999)",
105                 [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] );
106
107 addNewTestCase( new Date( 1969,11,31,23,59,59,999),
108                 "new Date( 1969,11,31,23,59,59,999)",
109                 [TIME_1970-PST_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] );
110
111 addNewTestCase( new Date( 1970,0,1,0,0,0,0),
112                 "new Date( 1970,0,1,0,0,0,0)",
113                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
114
115 addNewTestCase( new Date( 1969,11,31,16,0,0,0),
116                 "new Date( 1969,11,31,16,0,0,0)",
117                 [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
118
119 addNewTestCase( new Date(1969,12,1,0,0,0,0),
120                 "new Date(1969,12,1,0,0,0,0)",
121                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
122
123 addNewTestCase( new Date(1969,11,32,0,0,0,0),
124                 "new Date(1969,11,32,0,0,0,0)",
125                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
126
127 addNewTestCase( new Date(1969,11,31,24,0,0,0),
128                 "new Date(1969,11,31,24,0,0,0)",
129                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
130
131 addNewTestCase( new Date(1969,11,31,23,60,0,0),
132                 "new Date(1969,11,31,23,60,0,0)",
133                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
134
135 addNewTestCase( new Date(1969,11,31,23,59,60,0),
136                 "new Date(1969,11,31,23,59,60,0)",
137                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
138
139 addNewTestCase( new Date(1969,11,31,23,59,59,1000),
140                 "new Date(1969,11,31,23,59,59,1000)",
141                 [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
142
143 // Dates around 2000
144
145 addNewTestCase( new Date( 1999,11,31,15,59,59,999),
146                 "new Date( 1999,11,31,15,59,59,999)",
147                 [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
148
149 addNewTestCase( new Date( 1999,11,31,16,0,0,0),
150                 "new Date( 1999,11,31,16,0,0,0)",
151                 [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
152
153 addNewTestCase( new Date( 1999,11,31,23,59,59,999),
154                 "new Date( 1999,11,31,23,59,59,999)",
155                 [TIME_2000-PST_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
156
157 addNewTestCase( new Date( 2000,0,1,0,0,0,0),
158                 "new Date( 2000,0,1,0,0,0,0)",
159                 [TIME_2000-PST_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
160
161 addNewTestCase( new Date( 2000,0,1,0,0,0,1),
162                 "new Date( 2000,0,1,0,0,0,1)",
163                 [TIME_2000-PST_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] );
164
165 // Dates around 29 Feb 2000
166
167 addNewTestCase( new Date(2000,1,28,16,0,0,0),
168                 "new Date(2000,1,28,16,0,0,0)",
169                 [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
170
171 addNewTestCase( new Date(2000,1,29,0,0,0,0),
172                 "new Date(2000,1,29,0,0,0,0)",
173                 [UTC_FEB_29_2000-PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
174
175 addNewTestCase( new Date(2000,1,28,24,0,0,0),
176                 "new Date(2000,1,28,24,0,0,0)",
177                 [UTC_FEB_29_2000-PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
178
179 // Dates around 1900
180
181 addNewTestCase( new Date(1899,11,31,16,0,0,0),
182                 "new Date(1899,11,31,16,0,0,0)",
183                 [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
184
185 addNewTestCase( new Date(1899,11,31,15,59,59,999),
186                 "new Date(1899,11,31,15,59,59,999)",
187                 [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
188
189 addNewTestCase( new Date(1899,11,31,23,59,59,999),
190                 "new Date(1899,11,31,23,59,59,999)",
191                 [TIME_1900-PST_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] );
192
193 addNewTestCase( new Date(1900,0,1,0,0,0,0),
194                 "new Date(1900,0,1,0,0,0,0)",
195                 [TIME_1900-PST_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
196
197 addNewTestCase( new Date(1900,0,1,0,0,0,1),
198                 "new Date(1900,0,1,0,0,0,1)",
199                 [TIME_1900-PST_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
200
201 // Dates around 2005
202
203 addNewTestCase( new Date(2005,0,1,0,0,0,0),
204                 "new Date(2005,0,1,0,0,0,0)",
205                 [UTC_JAN_1_2005-PST_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
206
207 addNewTestCase( new Date(2004,11,31,16,0,0,0),
208                 "new Date(2004,11,31,16,0,0,0)",
209                 [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
210
211 test();
212
213
214 function addNewTestCase( DateCase, DateString, ResultArray ) {
215   //adjust hard-coded ResultArray for tester's timezone instead of PST
216   adjustResultArray(ResultArray);
217
218   new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME],       DateCase.getTime() );
219   new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME],       DateCase.valueOf() );
220
221   new TestCase( SECTION, DateString+".getUTCFullYear()",      ResultArray[UTC_YEAR],  DateCase.getUTCFullYear() );
222   new TestCase( SECTION, DateString+".getUTCMonth()",         ResultArray[UTC_MONTH],  DateCase.getUTCMonth() );
223   new TestCase( SECTION, DateString+".getUTCDate()",          ResultArray[UTC_DATE],   DateCase.getUTCDate() );
224   new TestCase( SECTION, DateString+".getUTCDay()",           ResultArray[UTC_DAY],    DateCase.getUTCDay() );
225   new TestCase( SECTION, DateString+".getUTCHours()",         ResultArray[UTC_HOURS],  DateCase.getUTCHours() );
226   new TestCase( SECTION, DateString+".getUTCMinutes()",       ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
227   new TestCase( SECTION, DateString+".getUTCSeconds()",       ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
228   new TestCase( SECTION, DateString+".getUTCMilliseconds()",  ResultArray[UTC_MS],     DateCase.getUTCMilliseconds() );
229
230   new TestCase( SECTION, DateString+".getFullYear()",         ResultArray[YEAR],       DateCase.getFullYear() );
231   new TestCase( SECTION, DateString+".getMonth()",            ResultArray[MONTH],      DateCase.getMonth() );
232   new TestCase( SECTION, DateString+".getDate()",             ResultArray[DATE],       DateCase.getDate() );
233   new TestCase( SECTION, DateString+".getDay()",              ResultArray[DAY],        DateCase.getDay() );
234   new TestCase( SECTION, DateString+".getHours()",            ResultArray[HOURS],      DateCase.getHours() );
235   new TestCase( SECTION, DateString+".getMinutes()",          ResultArray[MINUTES],    DateCase.getMinutes() );
236   new TestCase( SECTION, DateString+".getSeconds()",          ResultArray[SECONDS],    DateCase.getSeconds() );
237   new TestCase( SECTION, DateString+".getMilliseconds()",     ResultArray[MS],         DateCase.getMilliseconds() );
238 }
239