Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / Date / 15.9.5.28-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.5.28-1.js';
40
41 /**
42    File Name:          15.9.5.28-1.js
43    ECMA Section:       15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] )
44    Description:
45    If sec is not specified, this behaves as if sec were specified with the
46    value getSeconds ( ).
47
48    If ms is not specified, this behaves as if ms were specified with the
49    value getMilliseconds( ).
50
51    1.  Let t be the result of LocalTime(this time value).
52    2.  Call ToNumber(min).
53    3.  If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec).
54    4.  If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms).
55    5.  Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)).
56    6.  Compute UTC(MakeDate(Day(t), Result(5))).
57    7.  Set the [[Value]] property of the this value to TimeClip(Result(6)).
58    8.  Return the value of the [[Value]] property of the this value.
59
60    Author:             christine@netscape.com
61    Date:               12 november 1997
62 */
63 var SECTION = "15.9.5.28-1";
64 var VERSION = "ECMA_1";
65 startTest();
66
67 writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )");
68
69 addNewTestCase( 0, 0, void 0, void 0,
70                 "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE",
71                 UTCDateFromTime(SetMinutes(0,0,0,0)),
72                 LocalDateFromTime(SetMinutes(0,0,0,0)) );
73
74 addNewTestCase( 28800000, 59, 59, void 0,
75                 "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE",
76                 UTCDateFromTime(SetMinutes(28800000,59,59)),
77                 LocalDateFromTime(SetMinutes(28800000,59,59)) );
78
79 addNewTestCase( 28800000, 59, 59, 999,
80                 "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE",
81                 UTCDateFromTime(SetMinutes(28800000,59,59,999)),
82                 LocalDateFromTime(SetMinutes(28800000,59,59,999)) );
83
84 addNewTestCase( 28800000, 59, void 0, void 0,
85                 "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE",
86                 UTCDateFromTime(SetMinutes(28800000,59,0)),
87                 LocalDateFromTime(SetMinutes(28800000,59,0)) );
88
89 addNewTestCase( 28800000, -480, void 0, void 0,
90                 "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE",
91                 UTCDateFromTime(SetMinutes(28800000,-480)),
92                 LocalDateFromTime(SetMinutes(28800000,-480)) );
93
94 addNewTestCase( 946684800000, 1234567, void 0, void 0,
95                 "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE",
96                 UTCDateFromTime(SetMinutes(946684800000,1234567)),
97                 LocalDateFromTime(SetMinutes(946684800000,1234567)) );
98
99 addNewTestCase( -2208988800000,59, 59, void 0,
100                 "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE",
101                 UTCDateFromTime(SetMinutes(-2208988800000,59,59)),
102                 LocalDateFromTime(SetMinutes(-2208988800000,59,59)) );
103
104 addNewTestCase( -2208988800000, 59, 59, 999,
105                 "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE",
106                 UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)),
107                 LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) );
108
109 test();
110
111 function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) {
112   DateCase = new Date( time );
113
114   if ( sec == void 0 ) {
115     DateCase.setMinutes( min );
116   } else {
117     if ( ms == void 0 ) {
118       DateCase.setMinutes( min, sec );
119     } else {
120       DateCase.setMinutes( min, sec, ms );
121     }
122   }
123
124   new TestCase( SECTION, DateString+".getTime()",             UTCDate.value,       DateCase.getTime() );
125   new TestCase( SECTION, DateString+".valueOf()",             UTCDate.value,       DateCase.valueOf() );
126
127   new TestCase( SECTION, DateString+".getUTCFullYear()",      UTCDate.year,    DateCase.getUTCFullYear() );
128   new TestCase( SECTION, DateString+".getUTCMonth()",         UTCDate.month,  DateCase.getUTCMonth() );
129   new TestCase( SECTION, DateString+".getUTCDate()",          UTCDate.date,   DateCase.getUTCDate() );
130
131   new TestCase( SECTION, DateString+".getUTCHours()",         UTCDate.hours,  DateCase.getUTCHours() );
132   new TestCase( SECTION, DateString+".getUTCMinutes()",       UTCDate.minutes,DateCase.getUTCMinutes() );
133   new TestCase( SECTION, DateString+".getUTCSeconds()",       UTCDate.seconds,DateCase.getUTCSeconds() );
134   new TestCase( SECTION, DateString+".getUTCMilliseconds()",  UTCDate.ms,     DateCase.getUTCMilliseconds() );
135
136   new TestCase( SECTION, DateString+".getFullYear()",         LocalDate.year,       DateCase.getFullYear() );
137   new TestCase( SECTION, DateString+".getMonth()",            LocalDate.month,      DateCase.getMonth() );
138   new TestCase( SECTION, DateString+".getDate()",             LocalDate.date,       DateCase.getDate() );
139
140   new TestCase( SECTION, DateString+".getHours()",            LocalDate.hours,      DateCase.getHours() );
141   new TestCase( SECTION, DateString+".getMinutes()",          LocalDate.minutes,    DateCase.getMinutes() );
142   new TestCase( SECTION, DateString+".getSeconds()",          LocalDate.seconds,    DateCase.getSeconds() );
143   new TestCase( SECTION, DateString+".getMilliseconds()",     LocalDate.ms,         DateCase.getMilliseconds() );
144
145   DateCase.toString = Object.prototype.toString;
146
147   new TestCase( SECTION,
148                 DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
149                 "[object Date]",
150                 DateCase.toString() );
151 }
152
153 function MyDate() {
154   this.year = 0;
155   this.month = 0;
156   this.date = 0;
157   this.hours = 0;
158   this.minutes = 0;
159   this.seconds = 0;
160   this.ms = 0;
161 }
162 function LocalDateFromTime(t) {
163   t = LocalTime(t);
164   return ( MyDateFromTime(t) );
165 }
166 function UTCDateFromTime(t) {
167   return ( MyDateFromTime(t) );
168 }
169 function MyDateFromTime( t ) {
170   var d = new MyDate();
171   d.year = YearFromTime(t);
172   d.month = MonthFromTime(t);
173   d.date = DateFromTime(t);
174   d.hours = HourFromTime(t);
175   d.minutes = MinFromTime(t);
176   d.seconds = SecFromTime(t);
177   d.ms = msFromTime(t);
178
179   d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
180   d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
181   d.day = WeekDay( d.value );
182
183   return (d);
184 }
185
186 function SetMinutes( t, min, sec, ms ) {
187   var TIME = LocalTime(t);
188   var MIN =  Number(min);
189   var SEC  = ( sec == void 0) ? SecFromTime(TIME) : Number(sec);
190   var MS   = ( ms == void 0 ) ? msFromTime(TIME)  : Number(ms);
191   var RESULT5 = MakeTime( HourFromTime( TIME ),
192                           MIN,
193                           SEC,
194                           MS );
195   return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) );
196 }