Debian Codegraph @

rhino/testsrc/tests/ecma/LexicalConventions/7.6.js

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