Debian Codegraph @

js/src/jit-test/tests/basic/testTypeofEq.js

raw
1 var testcases = [
2 [1, "NUMBER"],
3 [1.1, "NUMBER"],
4 [true, "BOOLEAN"],
5 [false, "BOOLEAN"],
6 [null, "OBJECT"],
7 [undefined, "UNDEFINED"],
8 ["foo", "STRING"],
9 [Symbol.iterator, "SYMBOL"],
10 [function f() {}, "FUNCTION"],
11 [{}, "OBJECT"],
12 ];
13
14 function runTest(f) {
15 for (let i = 0; i < 2000; i++) {
16 let testcase = testcases[i % testcases.length];
17 assertEq(f(testcase[0]), testcase[1]);
18 }
19 }
20
21 function loose_left(x) {
22 if (typeof x == "boolean") {
23 return "BOOLEAN";
24 }
25 if (typeof x == "function") {
26 return "FUNCTION";
27 }
28 if (typeof x == "number") {
29 return "NUMBER";
30 }
31 if (typeof x == "object") {
32 return "OBJECT";
33 }
34 if (typeof x == "string") {
35 return "STRING";
36 }
37 if (typeof x == "symbol") {
38 return "SYMBOL";
39 }
40 if (typeof x == "undefined") {
41 return "UNDEFINED";
42 }
43 return "???";
44 }
45
46 function loose_right(x) {
47 if ("boolean" == typeof x) {
48 return "BOOLEAN";
49 }
50 if ("function" == typeof x) {
51 return "FUNCTION";
52 }
53 if ("number" == typeof x) {
54 return "NUMBER";
55 }
56 if ("object" == typeof x) {
57 return "OBJECT";
58 }
59 if ("string" == typeof x) {
60 return "STRING";
61 }
62 if ("symbol" == typeof x) {
63 return "SYMBOL";
64 }
65 if ("undefined" == typeof x) {
66 return "UNDEFINED";
67 }
68 return "???";
69 }
70
71 function strict_left(x) {
72 if (typeof x === "boolean") {
73 return "BOOLEAN";
74 }
75 if (typeof x === "function") {
76 return "FUNCTION";
77 }
78 if (typeof x === "number") {
79 return "NUMBER";
80 }
81 if (typeof x === "object") {
82 return "OBJECT";
83 }
84 if (typeof x === "string") {
85 return "STRING";
86 }
87 if (typeof x === "symbol") {
88 return "SYMBOL";
89 }
90 if (typeof x === "undefined") {
91 return "UNDEFINED";
92 }
93 return "???";
94 }
95
96 function strict_right(x) {
97 if ("boolean" === typeof x) {
98 return "BOOLEAN";
99 }
100 if ("function" === typeof x) {
101 return "FUNCTION";
102 }
103 if ("number" === typeof x) {
104 return "NUMBER";
105 }
106 if ("object" === typeof x) {
107 return "OBJECT";
108 }
109 if ("string" === typeof x) {
110 return "STRING";
111 }
112 if ("symbol" === typeof x) {
113 return "SYMBOL";
114 }
115 if ("undefined" === typeof x) {
116 return "UNDEFINED";
117 }
118 return "???";
119 }
120
121 function loose_left_ne(x) {
122 if (typeof x != "boolean") {
123 } else {
124 return "BOOLEAN";
125 }
126 if (typeof x != "function") {
127 } else {
128 return "FUNCTION";
129 }
130 if (typeof x != "number") {
131 } else {
132 return "NUMBER";
133 }
134 if (typeof x != "object") {
135 } else {
136 return "OBJECT";
137 }
138 if (typeof x != "string") {
139 } else {
140 return "STRING";
141 }
142 if (typeof x != "symbol") {
143 } else {
144 return "SYMBOL";
145 }
146 if (typeof x != "undefined") {
147 } else {
148 return "UNDEFINED";
149 }
150 return "???";
151 }
152
153 function loose_right_ne(x) {
154 if ("boolean" != typeof x) {
155 } else {
156 return "BOOLEAN";
157 }
158 if ("function" != typeof x) {
159 } else {
160 return "FUNCTION";
161 }
162 if ("number" != typeof x) {
163 } else {
164 return "NUMBER";
165 }
166 if ("object" != typeof x) {
167 } else {
168 return "OBJECT";
169 }
170 if ("string" != typeof x) {
171 } else {
172 return "STRING";
173 }
174 if ("symbol" != typeof x) {
175 } else {
176 return "SYMBOL";
177 }
178 if ("undefined" != typeof x) {
179 } else {
180 return "UNDEFINED";
181 }
182 return "???";
183 }
184
185 function strict_left_ne(x) {
186 if (typeof x !== "boolean") {
187 } else {
188 return "BOOLEAN";
189 }
190 if (typeof x !== "function") {
191 } else {
192 return "FUNCTION";
193 }
194 if (typeof x !== "number") {
195 } else {
196 return "NUMBER";
197 }
198 if (typeof x !== "object") {
199 } else {
200 return "OBJECT";
201 }
202 if (typeof x !== "string") {
203 } else {
204 return "STRING";
205 }
206 if (typeof x !== "symbol") {
207 } else {
208 return "SYMBOL";
209 }
210 if (typeof x !== "undefined") {
211 } else {
212 return "UNDEFINED";
213 }
214 return "???";
215 }
216
217 function strict_right_ne(x) {
218 if ("boolean" !== typeof x) {
219 } else {
220 return "BOOLEAN";
221 }
222 if ("function" !== typeof x) {
223 } else {
224 return "FUNCTION";
225 }
226 if ("number" !== typeof x) {
227 } else {
228 return "NUMBER";
229 }
230 if ("object" !== typeof x) {
231 } else {
232 return "OBJECT";
233 }
234 if ("string" !== typeof x) {
235 } else {
236 return "STRING";
237 }
238 if ("symbol" !== typeof x) {
239 } else {
240 return "SYMBOL";
241 }
242 if ("undefined" !== typeof x) {
243 } else {
244 return "UNDEFINED";
245 }
246 return "???";
247 }
248
249 function loose_left_expr(x) {
250 if (typeof (0, x) == "boolean") {
251 return "BOOLEAN";
252 }
253 if (typeof (0, x) == "function") {
254 return "FUNCTION";
255 }
256 if (typeof (0, x) == "number") {
257 return "NUMBER";
258 }
259 if (typeof (0, x) == "object") {
260 return "OBJECT";
261 }
262 if (typeof (0, x) == "string") {
263 return "STRING";
264 }
265 if (typeof (0, x) == "symbol") {
266 return "SYMBOL";
267 }
268 if (typeof (0, x) == "undefined") {
269 return "UNDEFINED";
270 }
271 return "???";
272 }
273
274 function loose_right_expr(x) {
275 if ("boolean" == typeof (0, x)) {
276 return "BOOLEAN";
277 }
278 if ("function" == typeof (0, x)) {
279 return "FUNCTION";
280 }
281 if ("number" == typeof (0, x)) {
282 return "NUMBER";
283 }
284 if ("object" == typeof (0, x)) {
285 return "OBJECT";
286 }
287 if ("string" == typeof (0, x)) {
288 return "STRING";
289 }
290 if ("symbol" == typeof (0, x)) {
291 return "SYMBOL";
292 }
293 if ("undefined" == typeof (0, x)) {
294 return "UNDEFINED";
295 }
296 return "???";
297 }
298
299 function strict_left_expr(x) {
300 if (typeof (0, x) === "boolean") {
301 return "BOOLEAN";
302 }
303 if (typeof (0, x) === "function") {
304 return "FUNCTION";
305 }
306 if (typeof (0, x) === "number") {
307 return "NUMBER";
308 }
309 if (typeof (0, x) === "object") {
310 return "OBJECT";
311 }
312 if (typeof (0, x) === "string") {
313 return "STRING";
314 }
315 if (typeof (0, x) === "symbol") {
316 return "SYMBOL";
317 }
318 if (typeof (0, x) === "undefined") {
319 return "UNDEFINED";
320 }
321 return "???";
322 }
323
324 function strict_right_expr(x) {
325 if ("boolean" === typeof (0, x)) {
326 return "BOOLEAN";
327 }
328 if ("function" === typeof (0, x)) {
329 return "FUNCTION";
330 }
331 if ("number" === typeof (0, x)) {
332 return "NUMBER";
333 }
334 if ("object" === typeof (0, x)) {
335 return "OBJECT";
336 }
337 if ("string" === typeof (0, x)) {
338 return "STRING";
339 }
340 if ("symbol" === typeof (0, x)) {
341 return "SYMBOL";
342 }
343 if ("undefined" === typeof (0, x)) {
344 return "UNDEFINED";
345 }
346 return "???";
347 }
348
349 function loose_left_ne_expr(x) {
350 if (typeof (0, x) != "boolean") {
351 } else {
352 return "BOOLEAN";
353 }
354 if (typeof (0, x) != "function") {
355 } else {
356 return "FUNCTION";
357 }
358 if (typeof (0, x) != "number") {
359 } else {
360 return "NUMBER";
361 }
362 if (typeof (0, x) != "object") {
363 } else {
364 return "OBJECT";
365 }
366 if (typeof (0, x) != "string") {
367 } else {
368 return "STRING";
369 }
370 if (typeof (0, x) != "symbol") {
371 } else {
372 return "SYMBOL";
373 }
374 if (typeof (0, x) != "undefined") {
375 } else {
376 return "UNDEFINED";
377 }
378 return "???";
379 }
380
381 function loose_right_ne_expr(x) {
382 if ("boolean" != typeof (0, x)) {
383 } else {
384 return "BOOLEAN";
385 }
386 if ("function" != typeof (0, x)) {
387 } else {
388 return "FUNCTION";
389 }
390 if ("number" != typeof (0, x)) {
391 } else {
392 return "NUMBER";
393 }
394 if ("object" != typeof (0, x)) {
395 } else {
396 return "OBJECT";
397 }
398 if ("string" != typeof (0, x)) {
399 } else {
400 return "STRING";
401 }
402 if ("symbol" != typeof (0, x)) {
403 } else {
404 return "SYMBOL";
405 }
406 if ("undefined" != typeof (0, x)) {
407 } else {
408 return "UNDEFINED";
409 }
410 return "???";
411 }
412
413 function strict_left_ne_expr(x) {
414 if (typeof (0, x) !== "boolean") {
415 } else {
416 return "BOOLEAN";
417 }
418 if (typeof (0, x) !== "function") {
419 } else {
420 return "FUNCTION";
421 }
422 if (typeof (0, x) !== "number") {
423 } else {
424 return "NUMBER";
425 }
426 if (typeof (0, x) !== "object") {
427 } else {
428 return "OBJECT";
429 }
430 if (typeof (0, x) !== "string") {
431 } else {
432 return "STRING";
433 }
434 if (typeof (0, x) !== "symbol") {
435 } else {
436 return "SYMBOL";
437 }
438 if (typeof (0, x) !== "undefined") {
439 } else {
440 return "UNDEFINED";
441 }
442 return "???";
443 }
444
445 function strict_right_ne_expr(x) {
446 if ("boolean" !== typeof (0, x)) {
447 } else {
448 return "BOOLEAN";
449 }
450 if ("function" !== typeof (0, x)) {
451 } else {
452 return "FUNCTION";
453 }
454 if ("number" !== typeof (0, x)) {
455 } else {
456 return "NUMBER";
457 }
458 if ("object" !== typeof (0, x)) {
459 } else {
460 return "OBJECT";
461 }
462 if ("string" !== typeof (0, x)) {
463 } else {
464 return "STRING";
465 }
466 if ("symbol" !== typeof (0, x)) {
467 } else {
468 return "SYMBOL";
469 }
470 if ("undefined" !== typeof (0, x)) {
471 } else {
472 return "UNDEFINED";
473 }
474 return "???";
475 }
476
477 runTest(loose_left);
478 runTest(loose_right);
479 runTest(strict_left);
480 runTest(strict_right);
481 runTest(loose_left_ne);
482 runTest(loose_right_ne);
483 runTest(strict_left_ne);
484 runTest(strict_right_ne);
485 runTest(loose_left_expr);
486 runTest(loose_right_expr);
487 runTest(strict_left_expr);
488 runTest(strict_right_expr);
489 runTest(loose_left_ne_expr);
490 runTest(loose_right_ne_expr);
491 runTest(strict_left_ne_expr);
492 runTest(strict_right_ne_expr);