QML_RUNTIME_TESTING should be disabled by default.
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / Expressions / 11.4.7-01.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 = '11.4.7-01.js';
40
41 /**
42    File Name:          11.4.7-01.js
43    ECMA Section:       11.4.7 Unary - Operator
44    Description:        convert operand to Number type and change sign
45    Author:             christine@netscape.com
46    Date:               7 july 1997
47 */
48
49 var SECTION = "11.4.7";
50 var VERSION = "ECMA_1";
51 var BUGNUMBER="77391";
52
53 startTest();
54
55 writeHeaderToLog( SECTION + " Unary + operator");
56
57 new TestCase( SECTION,  "-('')",           -0,      -("") );
58 new TestCase( SECTION,  "-(' ')",          -0,      -(" ") );
59 new TestCase( SECTION,  "-(\\t)",          -0,      -("\t") );
60 new TestCase( SECTION,  "-(\\n)",          -0,      -("\n") );
61 new TestCase( SECTION,  "-(\\r)",          -0,      -("\r") );
62 new TestCase( SECTION,  "-(\\f)",          -0,      -("\f") );
63
64 new TestCase( SECTION,  "-(String.fromCharCode(0x0009)",   -0,  -(String.fromCharCode(0x0009)) );
65 new TestCase( SECTION,  "-(String.fromCharCode(0x0020)",   -0,  -(String.fromCharCode(0x0020)) );
66 new TestCase( SECTION,  "-(String.fromCharCode(0x000C)",   -0,  -(String.fromCharCode(0x000C)) );
67 new TestCase( SECTION,  "-(String.fromCharCode(0x000B)",   -0,  -(String.fromCharCode(0x000B)) );
68 new TestCase( SECTION,  "-(String.fromCharCode(0x000D)",   -0,  -(String.fromCharCode(0x000D)) );
69 new TestCase( SECTION,  "-(String.fromCharCode(0x000A)",   -0,  -(String.fromCharCode(0x000A)) );
70
71 //  a StringNumericLiteral may be preceeded or followed by whitespace and/or
72 //  line terminators
73
74 new TestCase( SECTION,  "-( '   ' +  999 )",        -999,    -( '   '+999) );
75 new TestCase( SECTION,  "-( '\\n'  + 999 )",       -999,    -( '\n' +999) );
76 new TestCase( SECTION,  "-( '\\r'  + 999 )",       -999,    -( '\r' +999) );
77 new TestCase( SECTION,  "-( '\\t'  + 999 )",       -999,    -( '\t' +999) );
78 new TestCase( SECTION,  "-( '\\f'  + 999 )",       -999,    -( '\f' +999) );
79
80 new TestCase( SECTION,  "-( 999 + '   ' )",        -999,    -( 999+'   ') );
81 new TestCase( SECTION,  "-( 999 + '\\n' )",        -999,    -( 999+'\n' ) );
82 new TestCase( SECTION,  "-( 999 + '\\r' )",        -999,    -( 999+'\r' ) );
83 new TestCase( SECTION,  "-( 999 + '\\t' )",        -999,    -( 999+'\t' ) );
84 new TestCase( SECTION,  "-( 999 + '\\f' )",        -999,    -( 999+'\f' ) );
85
86 new TestCase( SECTION,  "-( '\\n'  + 999 + '\\n' )",         -999,    -( '\n' +999+'\n' ) );
87 new TestCase( SECTION,  "-( '\\r'  + 999 + '\\r' )",         -999,    -( '\r' +999+'\r' ) );
88 new TestCase( SECTION,  "-( '\\t'  + 999 + '\\t' )",         -999,    -( '\t' +999+'\t' ) );
89 new TestCase( SECTION,  "-( '\\f'  + 999 + '\\f' )",         -999,    -( '\f' +999+'\f' ) );
90
91 new TestCase( SECTION,  "-( '   ' +  '999' )",     -999,    -( '   '+'999') );
92 new TestCase( SECTION,  "-( '\\n'  + '999' )",       -999,    -( '\n' +'999') );
93 new TestCase( SECTION,  "-( '\\r'  + '999' )",       -999,    -( '\r' +'999') );
94 new TestCase( SECTION,  "-( '\\t'  + '999' )",       -999,    -( '\t' +'999') );
95 new TestCase( SECTION,  "-( '\\f'  + '999' )",       -999,    -( '\f' +'999') );
96
97 new TestCase( SECTION,  "-( '999' + '   ' )",        -999,    -( '999'+'   ') );
98 new TestCase( SECTION,  "-( '999' + '\\n' )",        -999,    -( '999'+'\n' ) );
99 new TestCase( SECTION,  "-( '999' + '\\r' )",        -999,    -( '999'+'\r' ) );
100 new TestCase( SECTION,  "-( '999' + '\\t' )",        -999,    -( '999'+'\t' ) );
101 new TestCase( SECTION,  "-( '999' + '\\f' )",        -999,    -( '999'+'\f' ) );
102
103 new TestCase( SECTION,  "-( '\\n'  + '999' + '\\n' )",         -999,    -( '\n' +'999'+'\n' ) );
104 new TestCase( SECTION,  "-( '\\r'  + '999' + '\\r' )",         -999,    -( '\r' +'999'+'\r' ) );
105 new TestCase( SECTION,  "-( '\\t'  + '999' + '\\t' )",         -999,    -( '\t' +'999'+'\t' ) );
106 new TestCase( SECTION,  "-( '\\f'  + '999' + '\\f' )",         -999,    -( '\f' +'999'+'\f' ) );
107
108 new TestCase( SECTION,  "-( String.fromCharCode(0x0009) +  '99' )",    -99,     -( String.fromCharCode(0x0009) +  '99' ) );
109 new TestCase( SECTION,  "-( String.fromCharCode(0x0020) +  '99' )",    -99,     -( String.fromCharCode(0x0020) +  '99' ) );
110 new TestCase( SECTION,  "-( String.fromCharCode(0x000C) +  '99' )",    -99,     -( String.fromCharCode(0x000C) +  '99' ) );
111 new TestCase( SECTION,  "-( String.fromCharCode(0x000B) +  '99' )",    -99,     -( String.fromCharCode(0x000B) +  '99' ) );
112 new TestCase( SECTION,  "-( String.fromCharCode(0x000D) +  '99' )",    -99,     -( String.fromCharCode(0x000D) +  '99' ) );
113 new TestCase( SECTION,  "-( String.fromCharCode(0x000A) +  '99' )",    -99,     -( String.fromCharCode(0x000A) +  '99' ) );
114
115 new TestCase( SECTION,  "-( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x0009)",    -99,     -( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x0009)) );
116 new TestCase( SECTION,  "-( String.fromCharCode(0x0020) +  '99' + String.fromCharCode(0x0020)",    -99,     -( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x0020)) );
117 new TestCase( SECTION,  "-( String.fromCharCode(0x000C) +  '99' + String.fromCharCode(0x000C)",    -99,     -( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x000C)) );
118 new TestCase( SECTION,  "-( String.fromCharCode(0x000D) +  '99' + String.fromCharCode(0x000D)",    -99,     -( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x000D)) );
119 new TestCase( SECTION,  "-( String.fromCharCode(0x000B) +  '99' + String.fromCharCode(0x000B)",    -99,     -( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x000B)) );
120 new TestCase( SECTION,  "-( String.fromCharCode(0x000A) +  '99' + String.fromCharCode(0x000A)",    -99,     -( String.fromCharCode(0x0009) +  '99' + String.fromCharCode(0x000A)) );
121
122 new TestCase( SECTION,  "-( '99' + String.fromCharCode(0x0009)",    -99,     -( '99' + String.fromCharCode(0x0009)) );
123 new TestCase( SECTION,  "-( '99' + String.fromCharCode(0x0020)",    -99,     -( '99' + String.fromCharCode(0x0020)) );
124 new TestCase( SECTION,  "-( '99' + String.fromCharCode(0x000C)",    -99,     -( '99' + String.fromCharCode(0x000C)) );
125 new TestCase( SECTION,  "-( '99' + String.fromCharCode(0x000D)",    -99,     -( '99' + String.fromCharCode(0x000D)) );
126 new TestCase( SECTION,  "-( '99' + String.fromCharCode(0x000B)",    -99,     -( '99' + String.fromCharCode(0x000B)) );
127 new TestCase( SECTION,  "-( '99' + String.fromCharCode(0x000A)",    -99,     -( '99' + String.fromCharCode(0x000A)) );
128
129 new TestCase( SECTION,  "-( String.fromCharCode(0x0009) +  99 )",    -99,     -( String.fromCharCode(0x0009) +  99 ) );
130 new TestCase( SECTION,  "-( String.fromCharCode(0x0020) +  99 )",    -99,     -( String.fromCharCode(0x0020) +  99 ) );
131 new TestCase( SECTION,  "-( String.fromCharCode(0x000C) +  99 )",    -99,     -( String.fromCharCode(0x000C) +  99 ) );
132 new TestCase( SECTION,  "-( String.fromCharCode(0x000B) +  99 )",    -99,     -( String.fromCharCode(0x000B) +  99 ) );
133 new TestCase( SECTION,  "-( String.fromCharCode(0x000D) +  99 )",    -99,     -( String.fromCharCode(0x000D) +  99 ) );
134 new TestCase( SECTION,  "-( String.fromCharCode(0x000A) +  99 )",    -99,     -( String.fromCharCode(0x000A) +  99 ) );
135
136 new TestCase( SECTION,  "-( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x0009)",    -99,     -( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x0009)) );
137 new TestCase( SECTION,  "-( String.fromCharCode(0x0020) +  99 + String.fromCharCode(0x0020)",    -99,     -( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x0020)) );
138 new TestCase( SECTION,  "-( String.fromCharCode(0x000C) +  99 + String.fromCharCode(0x000C)",    -99,     -( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x000C)) );
139 new TestCase( SECTION,  "-( String.fromCharCode(0x000D) +  99 + String.fromCharCode(0x000D)",    -99,     -( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x000D)) );
140 new TestCase( SECTION,  "-( String.fromCharCode(0x000B) +  99 + String.fromCharCode(0x000B)",    -99,     -( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x000B)) );
141 new TestCase( SECTION,  "-( String.fromCharCode(0x000A) +  99 + String.fromCharCode(0x000A)",    -99,     -( String.fromCharCode(0x0009) +  99 + String.fromCharCode(0x000A)) );
142
143 new TestCase( SECTION,  "-( 99 + String.fromCharCode(0x0009)",    -99,     -( 99 + String.fromCharCode(0x0009)) );
144 new TestCase( SECTION,  "-( 99 + String.fromCharCode(0x0020)",    -99,     -( 99 + String.fromCharCode(0x0020)) );
145 new TestCase( SECTION,  "-( 99 + String.fromCharCode(0x000C)",    -99,     -( 99 + String.fromCharCode(0x000C)) );
146 new TestCase( SECTION,  "-( 99 + String.fromCharCode(0x000D)",    -99,     -( 99 + String.fromCharCode(0x000D)) );
147 new TestCase( SECTION,  "-( 99 + String.fromCharCode(0x000B)",    -99,     -( 99 + String.fromCharCode(0x000B)) );
148 new TestCase( SECTION,  "-( 99 + String.fromCharCode(0x000A)",    -99,     -( 99 + String.fromCharCode(0x000A)) );
149
150
151 // StrNumericLiteral:::StrDecimalLiteral:::Infinity
152
153 new TestCase( SECTION,  "-('Infinity')",   -Math.pow(10,10000),   -("Infinity") );
154 new TestCase( SECTION,  "-('-Infinity')", +Math.pow(10,10000),   -("-Infinity") );
155 new TestCase( SECTION,  "-('+Infinity')",  -Math.pow(10,10000),   -("+Infinity") );
156
157 // StrNumericLiteral:::   StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt
158
159 new TestCase( SECTION,  "-('0')",          -0,          -("0") );
160 new TestCase( SECTION,  "-('-0')",         +0,         -("-0") );
161 new TestCase( SECTION,  "-('+0')",          -0,         -("+0") );
162
163 new TestCase( SECTION,  "-('1')",          -1,          -("1") );
164 new TestCase( SECTION,  "-('-1')",         +1,         -("-1") );
165 new TestCase( SECTION,  "-('+1')",          -1,         -("+1") );
166
167 new TestCase( SECTION,  "-('2')",          -2,          -("2") );
168 new TestCase( SECTION,  "-('-2')",         +2,         -("-2") );
169 new TestCase( SECTION,  "-('+2')",          -2,         -("+2") );
170
171 new TestCase( SECTION,  "-('3')",          -3,          -("3") );
172 new TestCase( SECTION,  "-('-3')",         +3,         -("-3") );
173 new TestCase( SECTION,  "-('+3')",          -3,         -("+3") );
174
175 new TestCase( SECTION,  "-('4')",          -4,          -("4") );
176 new TestCase( SECTION,  "-('-4')",         +4,         -("-4") );
177 new TestCase( SECTION,  "-('+4')",          -4,         -("+4") );
178
179 new TestCase( SECTION,  "-('5')",          -5,          -("5") );
180 new TestCase( SECTION,  "-('-5')",         +5,         -("-5") );
181 new TestCase( SECTION,  "-('+5')",          -5,         -("+5") );
182
183 new TestCase( SECTION,  "-('6')",          -6,          -("6") );
184 new TestCase( SECTION,  "-('-6')",         +6,         -("-6") );
185 new TestCase( SECTION,  "-('+6')",          -6,         -("+6") );
186
187 new TestCase( SECTION,  "-('7')",          -7,          -("7") );
188 new TestCase( SECTION,  "-('-7')",         +7,         -("-7") );
189 new TestCase( SECTION,  "-('+7')",          -7,         -("+7") );
190
191 new TestCase( SECTION,  "-('8')",          -8,          -("8") );
192 new TestCase( SECTION,  "-('-8')",         +8,         -("-8") );
193 new TestCase( SECTION,  "-('+8')",          -8,         -("+8") );
194
195 new TestCase( SECTION,  "-('9')",          -9,          -("9") );
196 new TestCase( SECTION,  "-('-9')",         +9,         -("-9") );
197 new TestCase( SECTION,  "-('+9')",          -9,         -("+9") );
198
199 new TestCase( SECTION,  "-('3.14159')",    -3.14159,    -("3.14159") );
200 new TestCase( SECTION,  "-('-3.14159')",   +3.14159,   -("-3.14159") );
201 new TestCase( SECTION,  "-('+3.14159')",   -3.14159,    -("+3.14159") );
202
203 new TestCase( SECTION,  "-('3.')",         -3,          -("3.") );
204 new TestCase( SECTION,  "-('-3.')",        +3,         -("-3.") );
205 new TestCase( SECTION,  "-('+3.')",        -3,          -("+3.") );
206
207 new TestCase( SECTION,  "-('3.e1')",       -30,         -("3.e1") );
208 new TestCase( SECTION,  "-('-3.e1')",      +30,        -("-3.e1") );
209 new TestCase( SECTION,  "-('+3.e1')",      -30,         -("+3.e1") );
210
211 new TestCase( SECTION,  "-('3.e+1')",       -30,         -("3.e+1") );
212 new TestCase( SECTION,  "-('-3.e+1')",      +30,        -("-3.e+1") );
213 new TestCase( SECTION,  "-('+3.e+1')",      -30,         -("+3.e+1") );
214
215 new TestCase( SECTION,  "-('3.e-1')",       -.30,         -("3.e-1") );
216 new TestCase( SECTION,  "-('-3.e-1')",      +.30,        -("-3.e-1") );
217 new TestCase( SECTION,  "-('+3.e-1')",      -.30,         -("+3.e-1") );
218
219 // StrDecimalLiteral:::  .DecimalDigits ExponentPart opt
220
221 new TestCase( SECTION,  "-('.00001')",     -0.00001,    -(".00001") );
222 new TestCase( SECTION,  "-('+.00001')",    -0.00001,    -("+.00001") );
223 new TestCase( SECTION,  "-('-0.0001')",    +0.00001,   -("-.00001") );
224
225 new TestCase( SECTION,  "-('.01e2')",      -1,          -(".01e2") );
226 new TestCase( SECTION,  "-('+.01e2')",     -1,          -("+.01e2") );
227 new TestCase( SECTION,  "-('-.01e2')",     +1,         -("-.01e2") );
228
229 new TestCase( SECTION,  "-('.01e+2')",      -1,         -(".01e+2") );
230 new TestCase( SECTION,  "-('+.01e+2')",     -1,         -("+.01e+2") );
231 new TestCase( SECTION,  "-('-.01e+2')",     +1,        -("-.01e+2") );
232
233 new TestCase( SECTION,  "-('.01e-2')",      -0.0001,    -(".01e-2") );
234 new TestCase( SECTION,  "-('+.01e-2')",     -0.0001,    -("+.01e-2") );
235 new TestCase( SECTION,  "-('-.01e-2')",     +0.0001,   -("-.01e-2") );
236
237 //  StrDecimalLiteral:::    DecimalDigits ExponentPart opt
238
239 new TestCase( SECTION,  "-('1234e5')",     -123400000,  -("1234e5") );
240 new TestCase( SECTION,  "-('+1234e5')",    -123400000,  -("+1234e5") );
241 new TestCase( SECTION,  "-('-1234e5')",    +123400000, -("-1234e5") );
242
243 new TestCase( SECTION,  "-('1234e+5')",    -123400000,  -("1234e+5") );
244 new TestCase( SECTION,  "-('+1234e+5')",   -123400000,  -("+1234e+5") );
245 new TestCase( SECTION,  "-('-1234e+5')",   +123400000, -("-1234e+5") );
246
247 new TestCase( SECTION,  "-('1234e-5')",     -0.01234,  -("1234e-5") );
248 new TestCase( SECTION,  "-('+1234e-5')",    -0.01234,  -("+1234e-5") );
249 new TestCase( SECTION,  "-('-1234e-5')",    +0.01234, -("-1234e-5") );
250
251 // StrNumericLiteral::: HexIntegerLiteral
252
253 new TestCase( SECTION,  "-('0x0')",        -0,          -("0x0"));
254 new TestCase( SECTION,  "-('0x1')",        -1,          -("0x1"));
255 new TestCase( SECTION,  "-('0x2')",        -2,          -("0x2"));
256 new TestCase( SECTION,  "-('0x3')",        -3,          -("0x3"));
257 new TestCase( SECTION,  "-('0x4')",        -4,          -("0x4"));
258 new TestCase( SECTION,  "-('0x5')",        -5,          -("0x5"));
259 new TestCase( SECTION,  "-('0x6')",        -6,          -("0x6"));
260 new TestCase( SECTION,  "-('0x7')",        -7,          -("0x7"));
261 new TestCase( SECTION,  "-('0x8')",        -8,          -("0x8"));
262 new TestCase( SECTION,  "-('0x9')",        -9,          -("0x9"));
263 new TestCase( SECTION,  "-('0xa')",        -10,         -("0xa"));
264 new TestCase( SECTION,  "-('0xb')",        -11,         -("0xb"));
265 new TestCase( SECTION,  "-('0xc')",        -12,         -("0xc"));
266 new TestCase( SECTION,  "-('0xd')",        -13,         -("0xd"));
267 new TestCase( SECTION,  "-('0xe')",        -14,         -("0xe"));
268 new TestCase( SECTION,  "-('0xf')",        -15,         -("0xf"));
269 new TestCase( SECTION,  "-('0xA')",        -10,         -("0xA"));
270 new TestCase( SECTION,  "-('0xB')",        -11,         -("0xB"));
271 new TestCase( SECTION,  "-('0xC')",        -12,         -("0xC"));
272 new TestCase( SECTION,  "-('0xD')",        -13,         -("0xD"));
273 new TestCase( SECTION,  "-('0xE')",        -14,         -("0xE"));
274 new TestCase( SECTION,  "-('0xF')",        -15,         -("0xF"));
275
276 new TestCase( SECTION,  "-('0X0')",        -0,          -("0X0"));
277 new TestCase( SECTION,  "-('0X1')",        -1,          -("0X1"));
278 new TestCase( SECTION,  "-('0X2')",        -2,          -("0X2"));
279 new TestCase( SECTION,  "-('0X3')",        -3,          -("0X3"));
280 new TestCase( SECTION,  "-('0X4')",        -4,          -("0X4"));
281 new TestCase( SECTION,  "-('0X5')",        -5,          -("0X5"));
282 new TestCase( SECTION,  "-('0X6')",        -6,          -("0X6"));
283 new TestCase( SECTION,  "-('0X7')",        -7,          -("0X7"));
284 new TestCase( SECTION,  "-('0X8')",        -8,          -("0X8"));
285 new TestCase( SECTION,  "-('0X9')",        -9,          -("0X9"));
286 new TestCase( SECTION,  "-('0Xa')",        -10,         -("0Xa"));
287 new TestCase( SECTION,  "-('0Xb')",        -11,         -("0Xb"));
288 new TestCase( SECTION,  "-('0Xc')",        -12,         -("0Xc"));
289 new TestCase( SECTION,  "-('0Xd')",        -13,         -("0Xd"));
290 new TestCase( SECTION,  "-('0Xe')",        -14,         -("0Xe"));
291 new TestCase( SECTION,  "-('0Xf')",        -15,         -("0Xf"));
292 new TestCase( SECTION,  "-('0XA')",        -10,         -("0XA"));
293 new TestCase( SECTION,  "-('0XB')",        -11,         -("0XB"));
294 new TestCase( SECTION,  "-('0XC')",        -12,         -("0XC"));
295 new TestCase( SECTION,  "-('0XD')",        -13,         -("0XD"));
296 new TestCase( SECTION,  "-('0XE')",        -14,         -("0XE"));
297 new TestCase( SECTION,  "-('0XF')",        -15,         -("0XF"));
298
299 test();