Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 File Name: 7.6.js
9 ECMA Section: Punctuators
10 Description:
12 This tests verifies that all ECMA punctutors are recognized as a
13 token separator, but does not attempt to verify the functionality
14 of any punctuator.
16 Author: christine@netscape.com
17 Date: 12 november 1997
18 */
20 var SECTION = "7.6";
21 var VERSION = "ECMA_1";
22 startTest();
23 var TITLE = "Punctuators";
25 writeHeaderToLog( SECTION + " "+ TITLE);
27 // ==
28 new TestCase( SECTION,
29 "var c,d;c==d",
30 true,
31 eval("var c,d;c==d") );
33 // =
35 new TestCase( SECTION,
36 "var a=true;a",
37 true,
38 eval("var a=true;a") );
40 // >
41 new TestCase( SECTION,
42 "var a=true,b=false;a>b",
43 true,
44 eval("var a=true,b=false;a>b") );
46 // <
47 new TestCase( SECTION,
48 "var a=true,b=false;a<b",
49 false,
50 eval("var a=true,b=false;a<b") );
52 // <=
53 new TestCase( SECTION,
54 "var a=0xFFFF,b=0X0FFF;a<=b",
55 false,
56 eval("var a=0xFFFF,b=0X0FFF;a<=b") );
58 // >=
59 new TestCase( SECTION,
60 "var a=0xFFFF,b=0XFFFE;a>=b",
61 true,
62 eval("var a=0xFFFF,b=0XFFFE;a>=b") );
64 // !=
65 new TestCase( SECTION,
66 "var a=true,b=false;a!=b",
67 true,
68 eval("var a=true,b=false;a!=b") );
70 new TestCase( SECTION,
71 "var a=false,b=false;a!=b",
72 false,
73 eval("var a=false,b=false;a!=b") );
74 // ,
75 new TestCase( SECTION,
76 "var a=true,b=false;a,b",
77 false,
78 eval("var a=true,b=false;a,b") );
79 // !
80 new TestCase( SECTION,
81 "var a=true,b=false;!a",
82 false,
83 eval("var a=true,b=false;!a") );
85 // ~
86 new TestCase( SECTION,
87 "var a=true;~a",
88 -2,
89 eval("var a=true;~a") );
90 // ?
91 new TestCase( SECTION,
92 "var a=true; (a ? 'PASS' : '')",
93 "PASS",
94 eval("var a=true; (a ? 'PASS' : '')") );
96 // :
98 new TestCase( SECTION,
99 "var a=false; (a ? 'FAIL' : 'PASS')",
100 "PASS",
101 eval("var a=false; (a ? 'FAIL' : 'PASS')") );
102 // .
104 new TestCase( SECTION,
105 "var a=Number;a.NaN",
106 NaN,
107 eval("var a=Number;a.NaN") );
109 // &&
110 new TestCase( SECTION,
111 "var a=true,b=true;if(a&&b)'PASS';else'FAIL'",
112 "PASS",
113 eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") );
115 // ||
116 new TestCase( SECTION,
117 "var a=false,b=false;if(a||b)'FAIL';else'PASS'",
118 "PASS",
119 eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") );
120 // ++
121 new TestCase( SECTION,
122 "var a=false,b=false;++a",
123 1,
124 eval("var a=false,b=false;++a") );
125 // --
126 new TestCase( SECTION,
127 "var a=true,b=false--a",
128 0,
129 eval("var a=true,b=false;--a") );
130 // +
132 new TestCase( SECTION,
133 "var a=true,b=true;a+b",
134 2,
135 eval("var a=true,b=true;a+b") );
136 // -
137 new TestCase( SECTION,
138 "var a=true,b=true;a-b",
139 0,
140 eval("var a=true,b=true;a-b") );
141 // *
142 new TestCase( SECTION,
143 "var a=true,b=true;a*b",
144 1,
145 eval("var a=true,b=true;a*b") );
146 // /
147 new TestCase( SECTION,
148 "var a=true,b=true;a/b",
149 1,
150 eval("var a=true,b=true;a/b") );
151 // &
152 new TestCase( SECTION,
153 "var a=3,b=2;a&b",
154 2,
155 eval("var a=3,b=2;a&b") );
156 // |
157 new TestCase( SECTION,
158 "var a=4,b=3;a|b",
159 7,
160 eval("var a=4,b=3;a|b") );
162 // |
163 new TestCase( SECTION,
164 "var a=4,b=3;a^b",
165 7,
166 eval("var a=4,b=3;a^b") );
168 // %
169 new TestCase( SECTION,
170 "var a=4,b=3;a|b",
171 1,
172 eval("var a=4,b=3;a%b") );
174 // <<
175 new TestCase( SECTION,
176 "var a=4,b=3;a<<b",
177 32,
178 eval("var a=4,b=3;a<<b") );
180 // >>
181 new TestCase( SECTION,
182 "var a=4,b=1;a>>b",
183 2,
184 eval("var a=4,b=1;a>>b") );
186 // >>>
187 new TestCase( SECTION,
188 "var a=1,b=1;a>>>b",
189 0,
190 eval("var a=1,b=1;a>>>b") );
191 // +=
192 new TestCase( SECTION,
193 "var a=4,b=3;a+=b;a",
194 7,
195 eval("var a=4,b=3;a+=b;a") );
197 // -=
198 new TestCase( SECTION,
199 "var a=4,b=3;a-=b;a",
200 1,
201 eval("var a=4,b=3;a-=b;a") );
202 // *=
203 new TestCase( SECTION,
204 "var a=4,b=3;a*=b;a",
205 12,
206 eval("var a=4,b=3;a*=b;a") );
207 // +=
208 new TestCase( SECTION,
209 "var a=4,b=3;a+=b;a",
210 7,
211 eval("var a=4,b=3;a+=b;a") );
212 // /=
213 new TestCase( SECTION,
214 "var a=12,b=3;a/=b;a",
215 4,
216 eval("var a=12,b=3;a/=b;a") );
218 // &=
219 new TestCase( SECTION,
220 "var a=4,b=5;a&=b;a",
221 4,
222 eval("var a=4,b=5;a&=b;a") );
224 // |=
225 new TestCase( SECTION,
226 "var a=4,b=5;a&=b;a",
227 5,
228 eval("var a=4,b=5;a|=b;a") );
229 // ^=
230 new TestCase( SECTION,
231 "var a=4,b=5;a^=b;a",
232 1,
233 eval("var a=4,b=5;a^=b;a") );
234 // %=
235 new TestCase( SECTION,
236 "var a=12,b=5;a%=b;a",
237 2,
238 eval("var a=12,b=5;a%=b;a") );
239 // <<=
240 new TestCase( SECTION,
241 "var a=4,b=3;a<<=b;a",
242 32,
243 eval("var a=4,b=3;a<<=b;a") );
245 // >>
246 new TestCase( SECTION,
247 "var a=4,b=1;a>>=b;a",
248 2,
249 eval("var a=4,b=1;a>>=b;a") );
251 // >>>
252 new TestCase( SECTION,
253 "var a=1,b=1;a>>>=b;a",
254 0,
255 eval("var a=1,b=1;a>>>=b;a") );
257 // ()
258 new TestCase( SECTION,
259 "var a=4,b=3;(a)",
260 4,
261 eval("var a=4,b=3;(a)") );
262 // {}
263 new TestCase( SECTION,
264 "var a=4,b=3;{b}",
265 3,
266 eval("var a=4,b=3;{b}") );
268 // []
269 new TestCase( SECTION,
270 "var a=new Array('hi');a[0]",
271 "hi",
272 eval("var a=new Array('hi');a[0]") );
273 // []
274 new TestCase( SECTION,
275 ";",
276 void 0,
277 eval(";") );
278 test();