091c74d7db5f65a781a40aac9f7ab58428de4f4d
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / parserstress / tests / ecma / LexicalConventions / 7.6.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 = '7.6.js';
40
41 /**
42    File Name:          7.6.js
43    ECMA Section:       Punctuators
44    Description:
45
46    This tests verifies that all ECMA punctutors are recognized as a
47    token separator, but does not attempt to verify the functionality
48    of any punctuator.
49
50    Author:             christine@netscape.com
51    Date:               12 november 1997
52 */
53
54 var SECTION = "7.6";
55 var VERSION = "ECMA_1";
56 startTest();
57 var TITLE   = "Punctuators";
58
59 writeHeaderToLog( SECTION + " "+ TITLE);
60
61 // ==
62 new TestCase( SECTION,
63               "var c,d;c==d",
64               true,
65               eval("var c,d;c==d") );
66
67 // =
68
69 new TestCase( SECTION,
70               "var a=true;a",
71               true,
72               eval("var a=true;a") );
73
74 // >
75 new TestCase( SECTION,
76               "var a=true,b=false;a>b",
77               true,
78               eval("var a=true,b=false;a>b") );
79
80 // <
81 new TestCase( SECTION,
82               "var a=true,b=false;a<b",
83               false,
84               eval("var a=true,b=false;a<b") );
85
86 // <=
87 new TestCase( SECTION,
88               "var a=0xFFFF,b=0X0FFF;a<=b",
89               false,
90               eval("var a=0xFFFF,b=0X0FFF;a<=b") );
91
92 // >=
93 new TestCase( SECTION,
94               "var a=0xFFFF,b=0XFFFE;a>=b",
95               true,
96               eval("var a=0xFFFF,b=0XFFFE;a>=b") );
97
98 // !=
99 new TestCase( SECTION,
100               "var a=true,b=false;a!=b",
101               true,
102               eval("var a=true,b=false;a!=b") );
103
104 new TestCase( SECTION,
105               "var a=false,b=false;a!=b",
106               false,
107               eval("var a=false,b=false;a!=b") );
108 // ,
109 new TestCase( SECTION,
110               "var a=true,b=false;a,b",
111               false,
112               eval("var a=true,b=false;a,b") );
113 // !
114 new TestCase( SECTION,
115               "var a=true,b=false;!a",
116               false,
117               eval("var a=true,b=false;!a") );
118
119 // ~
120 new TestCase( SECTION,
121               "var a=true;~a",
122               -2,
123               eval("var a=true;~a") );
124 // ?
125 new TestCase( SECTION,
126               "var a=true; (a ? 'PASS' : '')",
127               "PASS",
128               eval("var a=true; (a ? 'PASS' : '')") );
129
130 // :
131
132 new TestCase( SECTION,
133               "var a=false; (a ? 'FAIL' : 'PASS')",
134               "PASS",
135               eval("var a=false; (a ? 'FAIL' : 'PASS')") );
136 // .
137
138 new TestCase( SECTION,
139               "var a=Number;a.NaN",
140               NaN,
141               eval("var a=Number;a.NaN") );
142
143 // &&
144 new TestCase( SECTION,
145               "var a=true,b=true;if(a&&b)'PASS';else'FAIL'",
146               "PASS",
147               eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") );
148
149 // ||
150 new TestCase( SECTION,
151               "var a=false,b=false;if(a||b)'FAIL';else'PASS'",
152               "PASS",
153               eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") );
154 // ++
155 new TestCase( SECTION,
156               "var a=false,b=false;++a",
157               1,
158               eval("var a=false,b=false;++a") );
159 // --
160 new TestCase( SECTION,
161               "var a=true,b=false--a",
162               0,
163               eval("var a=true,b=false;--a") );
164 // +
165
166 new TestCase( SECTION,
167               "var a=true,b=true;a+b",
168               2,
169               eval("var a=true,b=true;a+b") );
170 // -
171 new TestCase( SECTION,
172               "var a=true,b=true;a-b",
173               0,
174               eval("var a=true,b=true;a-b") );
175 // *
176 new TestCase( SECTION,
177               "var a=true,b=true;a*b",
178               1,
179               eval("var a=true,b=true;a*b") );
180 // /
181 new TestCase( SECTION,
182               "var a=true,b=true;a/b",
183               1,
184               eval("var a=true,b=true;a/b") );
185 // &
186 new TestCase( SECTION,
187               "var a=3,b=2;a&b",
188               2,
189               eval("var a=3,b=2;a&b") );
190 // |
191 new TestCase( SECTION,
192               "var a=4,b=3;a|b",
193               7,
194               eval("var a=4,b=3;a|b") );
195
196 // |
197 new TestCase( SECTION,
198               "var a=4,b=3;a^b",
199               7,
200               eval("var a=4,b=3;a^b") );
201
202 // %
203 new TestCase( SECTION,
204               "var a=4,b=3;a|b",
205               1,
206               eval("var a=4,b=3;a%b") );
207
208 // <<
209 new TestCase( SECTION,
210               "var a=4,b=3;a<<b",
211               32,
212               eval("var a=4,b=3;a<<b") );
213
214 //  >>
215 new TestCase( SECTION,
216               "var a=4,b=1;a>>b",
217               2,
218               eval("var a=4,b=1;a>>b") );
219
220 //  >>>
221 new TestCase( SECTION,
222               "var a=1,b=1;a>>>b",
223               0,
224               eval("var a=1,b=1;a>>>b") );
225 //  +=
226 new TestCase( SECTION,
227               "var a=4,b=3;a+=b;a",
228               7,
229               eval("var a=4,b=3;a+=b;a") );
230
231 //  -=
232 new TestCase( SECTION,
233               "var a=4,b=3;a-=b;a",
234               1,
235               eval("var a=4,b=3;a-=b;a") );
236 //  *=
237 new TestCase( SECTION,
238               "var a=4,b=3;a*=b;a",
239               12,
240               eval("var a=4,b=3;a*=b;a") );
241 //  +=
242 new TestCase( SECTION,
243               "var a=4,b=3;a+=b;a",
244               7,
245               eval("var a=4,b=3;a+=b;a") );
246 //  /=
247 new TestCase( SECTION,
248               "var a=12,b=3;a/=b;a",
249               4,
250               eval("var a=12,b=3;a/=b;a") );
251
252 //  &=
253 new TestCase( SECTION,
254               "var a=4,b=5;a&=b;a",
255               4,
256               eval("var a=4,b=5;a&=b;a") );
257
258 // |=
259 new TestCase( SECTION,
260               "var a=4,b=5;a&=b;a",
261               5,
262               eval("var a=4,b=5;a|=b;a") );
263 //  ^=
264 new TestCase( SECTION,
265               "var a=4,b=5;a^=b;a",
266               1,
267               eval("var a=4,b=5;a^=b;a") );
268 // %=
269 new TestCase( SECTION,
270               "var a=12,b=5;a%=b;a",
271               2,
272               eval("var a=12,b=5;a%=b;a") );
273 // <<=
274 new TestCase( SECTION,
275               "var a=4,b=3;a<<=b;a",
276               32,
277               eval("var a=4,b=3;a<<=b;a") );
278
279 //  >>
280 new TestCase( SECTION,
281               "var a=4,b=1;a>>=b;a",
282               2,
283               eval("var a=4,b=1;a>>=b;a") );
284
285 //  >>>
286 new TestCase( SECTION,
287               "var a=1,b=1;a>>>=b;a",
288               0,
289               eval("var a=1,b=1;a>>>=b;a") );
290
291 // ()
292 new TestCase( SECTION,
293               "var a=4,b=3;(a)",
294               4,
295               eval("var a=4,b=3;(a)") );
296 // {}
297 new TestCase( SECTION,
298               "var a=4,b=3;{b}",
299               3,
300               eval("var a=4,b=3;{b}") );
301
302 // []
303 new TestCase( SECTION,
304               "var a=new Array('hi');a[0]",
305               "hi",
306               eval("var a=new Array('hi');a[0]") );
307 // []
308 new TestCase( SECTION,
309               ";",
310               void 0,
311               eval(";") );
312 test();
313