Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / Date / 15.9.3.8-2.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.8-2.js';
40
41 /**
42    File Name:          15.9.3.8.js
43    ECMA Section:       15.9.3.8 The Date Constructor
44    new Date( value )
45    Description:        The [[Prototype]] property of the newly constructed
46    object is set to the original Date prototype object,
47    the one that is the initial valiue of Date.prototype.
48
49    The [[Class]] property of the newly constructed object is
50    set to "Date".
51
52    The [[Value]] property of the newly constructed object is
53    set as follows:
54
55    1. Call ToPrimitive(value)
56    2. If Type( Result(1) ) is String, then go to step 5.
57    3. Let V be  ToNumber( Result(1) ).
58    4. Set the [[Value]] property of the newly constructed
59    object to TimeClip(V) and return.
60    5. Parse Result(1) as a date, in exactly the same manner
61    as for the parse method.  Let V be the time value for
62    this date.
63    6. Go to step 4.
64
65    Author:             christine@netscape.com
66    Date:               28 october 1997
67    Version:            9706
68
69 */
70
71 var VERSION = "ECMA_1";
72 startTest();
73 var SECTION = "15.9.3.8";
74 var TYPEOF  = "object";
75
76 var TIME        = 0;
77 var UTC_YEAR    = 1;
78 var UTC_MONTH   = 2;
79 var UTC_DATE    = 3;
80 var UTC_DAY     = 4;
81 var UTC_HOURS   = 5;
82 var UTC_MINUTES = 6;
83 var UTC_SECONDS = 7;
84 var UTC_MS      = 8;
85
86 var YEAR        = 9;
87 var MONTH       = 10;
88 var DATE        = 11;
89 var DAY         = 12;
90 var HOURS       = 13;
91 var MINUTES     = 14;
92 var SECONDS     = 15;
93 var MS          = 16;
94
95
96 //  for TCMS, the gTestcases array must be global.
97 var gTc= 0;
98 var TITLE = "Date constructor:  new Date( value )";
99 var SECTION = "15.9.3.8";
100 var VERSION = "ECMA_1";
101 startTest();
102
103 writeHeaderToLog( SECTION +" " + TITLE );
104
105 // all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
106 var TZ_ADJUST =  -TZ_PST * msPerHour;
107
108 addNewTestCase( new Date((new Date(0)).toUTCString()),
109                 "new Date(\""+ (new Date(0)).toUTCString()+"\" )",
110                 [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
111
112 addNewTestCase( new Date((new Date(1)).toString()),
113                 "new Date(\""+ (new Date(1)).toString()+"\" )",
114                 [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
115
116 addNewTestCase( new Date( TZ_ADJUST ),
117                 "new Date(" + TZ_ADJUST+")",
118                 [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
119
120 addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()),
121                 "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")",
122                 [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
123
124
125 addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ),
126                 "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")",
127                 [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
128
129 test();
130
131 function addNewTestCase( DateCase, DateString, ResultArray ) {
132   //adjust hard-coded ResultArray for tester's timezone instead of PST
133   adjustResultArray(ResultArray, 'msMode');
134
135   new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME],       DateCase.getTime() );
136   new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME],       DateCase.valueOf() );
137   new TestCase( SECTION, DateString+".getUTCFullYear()",      ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
138   new TestCase( SECTION, DateString+".getUTCMonth()",         ResultArray[UTC_MONTH],  DateCase.getUTCMonth() );
139   new TestCase( SECTION, DateString+".getUTCDate()",          ResultArray[UTC_DATE],   DateCase.getUTCDate() );
140   new TestCase( SECTION, DateString+".getUTCDay()",           ResultArray[UTC_DAY],    DateCase.getUTCDay() );
141   new TestCase( SECTION, DateString+".getUTCHours()",         ResultArray[UTC_HOURS],  DateCase.getUTCHours() );
142   new TestCase( SECTION, DateString+".getUTCMinutes()",       ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
143   new TestCase( SECTION, DateString+".getUTCSeconds()",       ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
144   new TestCase( SECTION, DateString+".getUTCMilliseconds()",  ResultArray[UTC_MS],     DateCase.getUTCMilliseconds() );
145   new TestCase( SECTION, DateString+".getFullYear()",         ResultArray[YEAR],       DateCase.getFullYear() );
146   new TestCase( SECTION, DateString+".getMonth()",            ResultArray[MONTH],      DateCase.getMonth() );
147   new TestCase( SECTION, DateString+".getDate()",             ResultArray[DATE],       DateCase.getDate() );
148   new TestCase( SECTION, DateString+".getDay()",              ResultArray[DAY],        DateCase.getDay() );
149   new TestCase( SECTION, DateString+".getHours()",            ResultArray[HOURS],      DateCase.getHours() );
150   new TestCase( SECTION, DateString+".getMinutes()",          ResultArray[MINUTES],    DateCase.getMinutes() );
151   new TestCase( SECTION, DateString+".getSeconds()",          ResultArray[SECONDS],    DateCase.getSeconds() );
152   new TestCase( SECTION, DateString+".getMilliseconds()",     ResultArray[MS],         DateCase.getMilliseconds() );
153 }