Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / Date / 15.9.5.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.5.2.js';
40
41 /**
42    File Name:          15.9.5.2.js
43    ECMA Section:       15.9.5.2 Date.prototype.toString
44    Description:
45    This function returns a string value. The contents of the string are
46    implementation dependent, but are intended to represent the Date in a
47    convenient, human-readable form in the current time zone.
48
49    The toString function is not generic; it generates a runtime error if its
50    this value is not a Date object. Therefore it cannot be transferred to
51    other kinds of objects for use as a method.
52
53    Author:             christine@netscape.com
54    Date:               12 november 1997
55 */
56
57 var SECTION = "15.9.5.2";
58 var VERSION = "ECMA_1";
59 startTest();
60 var TITLE   = "Date.prototype.toString";
61
62 writeHeaderToLog( SECTION + " "+ TITLE);
63
64 new TestCase( SECTION,
65               "Date.prototype.toString.length",
66               0,
67               Date.prototype.toString.length );
68
69 var now = new Date();
70
71 // can't test the content of the string, but can verify that the string is
72 // parsable by Date.parse
73
74 new TestCase( SECTION,
75               "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000",
76               true,
77               Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 );
78
79 new TestCase( SECTION,
80               "typeof now.toString()",
81               "string",
82               typeof now.toString() );
83 // 1970
84
85 new TestCase( SECTION,
86               "Date.parse( (new Date(0)).toString() )",
87               0,
88               Date.parse( (new Date(0)).toString() ) );
89
90 new TestCase( SECTION,
91               "Date.parse( (new Date("+TZ_ADJUST+")).toString() )",
92               TZ_ADJUST,
93               Date.parse( (new Date(TZ_ADJUST)).toString() ) );
94
95 // 1900
96 new TestCase( SECTION,
97               "Date.parse( (new Date("+TIME_1900+")).toString() )",
98               TIME_1900,
99               Date.parse( (new Date(TIME_1900)).toString() ) );
100
101 new TestCase( SECTION,
102               "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )",
103               TIME_1900 -TZ_ADJUST,
104               Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) );
105
106 // 2000
107 new TestCase( SECTION,
108               "Date.parse( (new Date("+TIME_2000+")).toString() )",
109               TIME_2000,
110               Date.parse( (new Date(TIME_2000)).toString() ) );
111
112 new TestCase( SECTION,
113               "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )",
114               TIME_2000 -TZ_ADJUST,
115               Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) );
116
117 // 29 Feb 2000
118
119 new TestCase( SECTION,
120               "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )",
121               UTC_FEB_29_2000,
122               Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) );
123
124 new TestCase( SECTION,
125               "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )",
126               UTC_FEB_29_2000-1000,
127               Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) );
128
129
130 new TestCase( SECTION,
131               "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )",
132               UTC_FEB_29_2000-TZ_ADJUST,
133               Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) );
134 // 2O05
135
136 new TestCase( SECTION,
137               "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )",
138               UTC_JAN_1_2005,
139               Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) );
140
141 new TestCase( SECTION,
142               "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )",
143               UTC_JAN_1_2005-1000,
144               Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) );
145
146 new TestCase( SECTION,
147               "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )",
148               UTC_JAN_1_2005-TZ_ADJUST,
149               Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) );
150
151 test();