PageRenderTime 42ms CodeModel.GetById 2ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/zpao/v8monkey
JavaScript | 988 lines | 959 code | 21 blank | 8 comment | 14 complexity | efbb2b9b73029da8bc14650285c8260f MD5 | raw file
  1function testComparisons()
  2{
  3  // All the special values from each of the types in
  4  // ECMA-262, 3rd ed. section 8
  5  var undefinedType, nullType, booleanType, stringType, numberType, objectType;
  6
  7  var types = [];
  8  types[undefinedType = 0] = "Undefined";
  9  types[nullType = 1] = "Null";
 10  types[booleanType = 2] = "Boolean";
 11  types[stringType = 3] = "String";
 12  types[numberType = 4] = "Number";
 13  types[objectType = 5] = "Object";
 14
 15  var JSVAL_INT_MIN = -Math.pow(2, 30);
 16  var JSVAL_INT_MAX = Math.pow(2, 30) - 1;
 17
 18  // Values from every ES3 type, hitting all the edge-case and special values
 19  // that can be dreamed up
 20  var values =
 21    {
 22     "undefined":
 23       {
 24         value: function() { return undefined; },
 25         type: undefinedType
 26       },
 27     "null":
 28       {
 29         value: function() { return null; },
 30         type: nullType
 31       },
 32     "true":
 33       {
 34         value: function() { return true; },
 35         type: booleanType
 36       },
 37     "false":
 38       {
 39         value: function() { return false; },
 40         type: booleanType
 41       },
 42     '""':
 43       {
 44         value: function() { return ""; },
 45         type: stringType
 46       },
 47     '"a"':
 48       {
 49         // a > [, for string-object comparisons
 50         value: function() { return "a"; },
 51         type: stringType
 52       },
 53     '"Z"':
 54       {
 55         // Z < [, for string-object comparisons
 56         value: function() { return "Z"; },
 57         type: stringType
 58       },
 59     "0":
 60       {
 61         value: function() { return 0; },
 62         type: numberType
 63       },
 64     "-0":
 65       {
 66         value: function() { return -0; },
 67         type: numberType
 68       },
 69     "1":
 70       {
 71         value: function() { return 1; },
 72         type: numberType
 73       },
 74     "Math.E":
 75       {
 76         value: function() { return Math.E; },
 77         type: numberType
 78       },
 79     "JSVAL_INT_MIN - 1":
 80       {
 81         value: function() { return JSVAL_INT_MIN - 1; },
 82         type: numberType
 83       },
 84     "JSVAL_INT_MIN":
 85       {
 86         value: function() { return JSVAL_INT_MIN; },
 87         type: numberType
 88       },
 89     "JSVAL_INT_MIN + 1":
 90       {
 91         value: function() { return JSVAL_INT_MIN + 1; },
 92         type: numberType
 93       },
 94     "JSVAL_INT_MAX - 1":
 95       {
 96         value: function() { return JSVAL_INT_MAX - 1; },
 97         type: numberType
 98       },
 99     "JSVAL_INT_MAX":
100       {
101         value: function() { return JSVAL_INT_MAX; },
102         type: numberType
103       },
104     "JSVAL_INT_MAX + 1":
105       {
106         value: function() { return JSVAL_INT_MAX + 1; },
107         type: numberType
108       },
109     "Infinity":
110       {
111         value: function() { return Infinity; },
112         type: numberType
113       },
114     "-Infinity":
115       {
116         value: function() { return -Infinity; },
117         type: numberType
118       },
119     "NaN":
120       {
121         value: function() { return NaN; },
122         type: numberType
123       },
124     "{}":
125       {
126         value: function() { return {}; },
127         type: objectType
128       },
129     "{ valueOf: undefined }":
130       {
131         value: function() { return { valueOf: undefined }; },
132         type: objectType
133       },
134     "[]":
135       {
136         value: function() { return []; },
137         type: objectType
138       },
139     '[""]':
140       {
141         value: function() { return [""]; },
142         type: objectType
143       },
144     '["a"]':
145       {
146         value: function() { return ["a"]; },
147         type: objectType
148       },
149     "[0]":
150       {
151         value: function() { return [0]; },
152         type: objectType
153       }
154    };
155
156  var orderOps =
157    {
158     "<": function(a, b) { return a < b; },
159     ">": function(a, b) { return a > b; },
160     "<=": function(a, b) { return a <= b; },
161     ">=": function(a, b) { return a >= b; }
162    };
163  var eqOps =
164    {
165     "==": function(a, b) { return a == b; },
166     "!=": function(a, b) { return a != b; },
167     "===": function(a, b) { return a === b; },
168     "!==": function(a, b) { return a !== b; }
169    };
170
171
172  var notEqualIncomparable =
173    {
174      eq: { "==": false, "!=": true, "===": false, "!==": true },
175      order: { "<": false, ">": false, "<=": false, ">=": false }
176    };
177  var notEqualLessThan =
178    {
179      eq: { "==": false, "!=": true, "===": false, "!==": true },
180      order: { "<": true, ">": false, "<=": true, ">=": false }
181    };
182  var notEqualGreaterThan =
183    {
184      eq: { "==": false, "!=": true, "===": false, "!==": true },
185      order: { "<": false, ">": true, "<=": false, ">=": true }
186    };
187  var notEqualNorDifferent =
188    {
189      eq: { "==": false, "!=": true, "===": false, "!==": true },
190      order: { "<": false, ">": false, "<=": true, ">=": true }
191    };
192  var strictlyEqual =
193    {
194      eq: { "==": true, "!=": false, "===": true, "!==": false },
195      order: { "<": false, ">": false, "<=": true, ">=": true }
196    };
197  var looselyEqual =
198    {
199      eq: { "==": true, "!=": false, "===": false, "!==": true },
200      order: { "<": false, ">": false, "<=": true, ">=": true }
201    };
202  var looselyEqualNotDifferent =
203    {
204      eq: { "==": true, "!=": false, "===": false, "!==": true },
205      order: { "<": false, ">": false, "<=": true, ">=": true }
206    };
207  var looselyEqualIncomparable =
208    {
209      eq: { "==": true, "!=": false, "===": false, "!==": true },
210      order: { "<": false, ">": false, "<=": false, ">=": false }
211    };
212  var strictlyEqualNotDifferent =
213    {
214      eq: { "==": true, "!=": false, "===": true, "!==": false },
215      order: { "<": false, ">": false, "<=": true, ">=": true }
216    };
217  var strictlyEqualIncomparable =
218    {
219      eq: { "==": true, "!=": false, "===": true, "!==": false },
220      order: { "<": false, ">": false, "<=": false, ">=": false }
221    };
222
223  var comparingZeroToSomething =
224    {
225      "undefined": notEqualIncomparable,
226      "null": notEqualNorDifferent,
227      "true": notEqualLessThan,
228      "false": looselyEqual,
229      '""': looselyEqualNotDifferent,
230      '"a"': notEqualIncomparable,
231      '"Z"': notEqualIncomparable,
232      "0": strictlyEqual,
233      "-0": strictlyEqual,
234      "1": notEqualLessThan,
235      "Math.E": notEqualLessThan,
236      "JSVAL_INT_MIN - 1": notEqualGreaterThan,
237      "JSVAL_INT_MIN": notEqualGreaterThan,
238      "JSVAL_INT_MIN + 1": notEqualGreaterThan,
239      "JSVAL_INT_MAX - 1": notEqualLessThan,
240      "JSVAL_INT_MAX": notEqualLessThan,
241      "JSVAL_INT_MAX + 1": notEqualLessThan,
242      "Infinity": notEqualLessThan,
243      "-Infinity": notEqualGreaterThan,
244      "NaN": notEqualIncomparable,
245      "{}": notEqualIncomparable,
246      "{ valueOf: undefined }": notEqualIncomparable,
247      "[]": looselyEqual,
248      '[""]': looselyEqual,
249      '["a"]': notEqualIncomparable,
250      "[0]": looselyEqual
251    };
252
253  var comparingObjectOrObjectWithValueUndefined =
254    {
255      "undefined": notEqualIncomparable,
256      "null": notEqualIncomparable,
257      "true": notEqualIncomparable,
258      "false": notEqualIncomparable,
259      '""': notEqualGreaterThan,
260      '"a"': notEqualLessThan,
261      '"Z"': notEqualGreaterThan,
262      "0": notEqualIncomparable,
263      "-0": notEqualIncomparable,
264      "1": notEqualIncomparable,
265      "Math.E": notEqualIncomparable,
266      "JSVAL_INT_MIN - 1": notEqualIncomparable,
267      "JSVAL_INT_MIN": notEqualIncomparable,
268      "JSVAL_INT_MIN + 1": notEqualIncomparable,
269      "JSVAL_INT_MAX - 1": notEqualIncomparable,
270      "JSVAL_INT_MAX": notEqualIncomparable,
271      "JSVAL_INT_MAX + 1": notEqualIncomparable,
272      "Infinity": notEqualIncomparable,
273      "-Infinity": notEqualIncomparable,
274      "NaN": notEqualIncomparable,
275      "{}": notEqualNorDifferent,
276      "{ valueOf: undefined }": notEqualNorDifferent,
277      "[]": notEqualGreaterThan,
278      '[""]': notEqualGreaterThan,
279      '["a"]': notEqualLessThan,
280      "[0]": notEqualGreaterThan
281    };
282
283  // Constructed expected-value matrix
284  var expected =
285    {
286     "undefined":
287       {
288         "undefined": strictlyEqualIncomparable,
289         "null": looselyEqualIncomparable,
290         "true": notEqualIncomparable,
291         "false": notEqualIncomparable,
292         '""': notEqualIncomparable,
293         '"a"': notEqualIncomparable,
294         '"Z"': notEqualIncomparable,
295         "0": notEqualIncomparable,
296         "-0": notEqualIncomparable,
297         "1": notEqualIncomparable,
298         "Math.E": notEqualIncomparable,
299         "JSVAL_INT_MIN - 1": notEqualIncomparable,
300         "JSVAL_INT_MIN": notEqualIncomparable,
301         "JSVAL_INT_MIN + 1": notEqualIncomparable,
302         "JSVAL_INT_MAX - 1": notEqualIncomparable,
303         "JSVAL_INT_MAX": notEqualIncomparable,
304         "JSVAL_INT_MAX + 1": notEqualIncomparable,
305         "Infinity": notEqualIncomparable,
306         "-Infinity": notEqualIncomparable,
307         "NaN": notEqualIncomparable,
308         "{}": notEqualIncomparable,
309         "{ valueOf: undefined }": notEqualIncomparable,
310         "[]": notEqualIncomparable,
311         '[""]': notEqualIncomparable,
312         '["a"]': notEqualIncomparable,
313         "[0]": notEqualIncomparable
314       },
315     "null":
316       {
317         "undefined": looselyEqualIncomparable,
318         "null": strictlyEqualNotDifferent,
319         "true": notEqualLessThan,
320         "false": notEqualNorDifferent,
321         '""': notEqualNorDifferent,
322         '"a"': notEqualIncomparable,
323         '"Z"': notEqualIncomparable,
324         "0": notEqualNorDifferent,
325         "-0": notEqualNorDifferent,
326         "1": notEqualLessThan,
327         "Math.E": notEqualLessThan,
328         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
329         "JSVAL_INT_MIN": notEqualGreaterThan,
330         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
331         "JSVAL_INT_MAX - 1": notEqualLessThan,
332         "JSVAL_INT_MAX": notEqualLessThan,
333         "JSVAL_INT_MAX + 1": notEqualLessThan,
334         "Infinity": notEqualLessThan,
335         "-Infinity": notEqualGreaterThan,
336         "NaN": notEqualIncomparable,
337         "{}": notEqualIncomparable,
338         "{ valueOf: undefined }": notEqualIncomparable,
339         "[]": notEqualNorDifferent,
340         '[""]': notEqualNorDifferent,
341         '["a"]': notEqualIncomparable,
342         "[0]": notEqualNorDifferent
343       },
344     "true":
345       {
346         "undefined": notEqualIncomparable,
347         "null": notEqualGreaterThan,
348         "true": strictlyEqual,
349         "false": notEqualGreaterThan,
350         '""': notEqualGreaterThan,
351         '"a"': notEqualIncomparable,
352         '"Z"': notEqualIncomparable,
353         "0": notEqualGreaterThan,
354         "-0": notEqualGreaterThan,
355         "1": looselyEqual,
356         "Math.E": notEqualLessThan,
357         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
358         "JSVAL_INT_MIN": notEqualGreaterThan,
359         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
360         "JSVAL_INT_MAX - 1": notEqualLessThan,
361         "JSVAL_INT_MAX": notEqualLessThan,
362         "JSVAL_INT_MAX + 1": notEqualLessThan,
363         "Infinity": notEqualLessThan,
364         "-Infinity": notEqualGreaterThan,
365         "NaN": notEqualIncomparable,
366         "{}": notEqualIncomparable,
367         "{ valueOf: undefined }": notEqualIncomparable,
368         "[]": notEqualGreaterThan,
369         '[""]': notEqualGreaterThan,
370         '["a"]': notEqualIncomparable,
371         "[0]": notEqualGreaterThan
372       },
373     "false":
374       {
375         "undefined": notEqualIncomparable,
376         "null": notEqualNorDifferent,
377         "true": notEqualLessThan,
378         "false": strictlyEqual,
379         '""': looselyEqualNotDifferent,
380         '"a"': notEqualIncomparable,
381         '"Z"': notEqualIncomparable,
382         "0": looselyEqual,
383         "-0": looselyEqual,
384         "1": notEqualLessThan,
385         "Math.E": notEqualLessThan,
386         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
387         "JSVAL_INT_MIN": notEqualGreaterThan,
388         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
389         "JSVAL_INT_MAX - 1": notEqualLessThan,
390         "JSVAL_INT_MAX": notEqualLessThan,
391         "JSVAL_INT_MAX + 1": notEqualLessThan,
392         "Infinity": notEqualLessThan,
393         "-Infinity": notEqualGreaterThan,
394         "NaN": notEqualIncomparable,
395         "{}": notEqualIncomparable,
396         "{ valueOf: undefined }": notEqualIncomparable,
397         "[]": looselyEqual,
398         '[""]': looselyEqual,
399         '["a"]': notEqualIncomparable,
400         "[0]": looselyEqual
401       },
402     '""':
403       {
404         "undefined": notEqualIncomparable,
405         "null": notEqualNorDifferent,
406         "true": notEqualLessThan,
407         "false": looselyEqual,
408         '""': strictlyEqual,
409         '"a"': notEqualLessThan,
410         '"Z"': notEqualLessThan,
411         "0": looselyEqual,
412         "-0": looselyEqual,
413         "1": notEqualLessThan,
414         "Math.E": notEqualLessThan,
415         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
416         "JSVAL_INT_MIN": notEqualGreaterThan,
417         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
418         "JSVAL_INT_MAX - 1": notEqualLessThan,
419         "JSVAL_INT_MAX": notEqualLessThan,
420         "JSVAL_INT_MAX + 1": notEqualLessThan,
421         "Infinity": notEqualLessThan,
422         "-Infinity": notEqualGreaterThan,
423         "NaN": notEqualIncomparable,
424         "{}": notEqualLessThan,
425         "{ valueOf: undefined }": notEqualLessThan,
426         "[]": looselyEqual,
427         '[""]': looselyEqual,
428         '["a"]': notEqualLessThan,
429         "[0]": notEqualLessThan
430       },
431     '"a"':
432       {
433         "undefined": notEqualIncomparable,
434         "null": notEqualIncomparable,
435         "true": notEqualIncomparable,
436         "false": notEqualIncomparable,
437         '""': notEqualGreaterThan,
438         '"a"': strictlyEqual,
439         '"Z"': notEqualGreaterThan,
440         "0": notEqualIncomparable,
441         "-0": notEqualIncomparable,
442         "1": notEqualIncomparable,
443         "Math.E": notEqualIncomparable,
444         "JSVAL_INT_MIN - 1": notEqualIncomparable,
445         "JSVAL_INT_MIN": notEqualIncomparable,
446         "JSVAL_INT_MIN + 1": notEqualIncomparable,
447         "JSVAL_INT_MAX - 1": notEqualIncomparable,
448         "JSVAL_INT_MAX": notEqualIncomparable,
449         "JSVAL_INT_MAX + 1": notEqualIncomparable,
450         "Infinity": notEqualIncomparable,
451         "-Infinity": notEqualIncomparable,
452         "NaN": notEqualIncomparable,
453         "{}": notEqualGreaterThan,
454         "{ valueOf: undefined }": notEqualGreaterThan,
455         "[]": notEqualGreaterThan,
456         '[""]': notEqualGreaterThan,
457         '["a"]': looselyEqualNotDifferent,
458         "[0]": notEqualGreaterThan
459       },
460     '"Z"':
461       {
462         "undefined": notEqualIncomparable,
463         "null": notEqualIncomparable,
464         "true": notEqualIncomparable,
465         "false": notEqualIncomparable,
466         '""': notEqualGreaterThan,
467         '"a"': notEqualLessThan,
468         '"Z"': strictlyEqual,
469         "0": notEqualIncomparable,
470         "-0": notEqualIncomparable,
471         "1": notEqualIncomparable,
472         "Math.E": notEqualIncomparable,
473         "JSVAL_INT_MIN - 1": notEqualIncomparable,
474         "JSVAL_INT_MIN": notEqualIncomparable,
475         "JSVAL_INT_MIN + 1": notEqualIncomparable,
476         "JSVAL_INT_MAX - 1": notEqualIncomparable,
477         "JSVAL_INT_MAX": notEqualIncomparable,
478         "JSVAL_INT_MAX + 1": notEqualIncomparable,
479         "Infinity": notEqualIncomparable,
480         "-Infinity": notEqualIncomparable,
481         "NaN": notEqualIncomparable,
482         "{}": notEqualLessThan,
483         "{ valueOf: undefined }": notEqualLessThan,
484         "[]": notEqualGreaterThan,
485         '[""]': notEqualGreaterThan,
486         '["a"]': notEqualLessThan,
487         "[0]": notEqualGreaterThan
488       },
489     "0": comparingZeroToSomething,
490     "-0": comparingZeroToSomething,
491     "1":
492       {
493         "undefined": notEqualIncomparable,
494         "null": notEqualGreaterThan,
495         "true": looselyEqual,
496         "false": notEqualGreaterThan,
497         '""': notEqualGreaterThan,
498         '"a"': notEqualIncomparable,
499         '"Z"': notEqualIncomparable,
500         "0": notEqualGreaterThan,
501         "-0": notEqualGreaterThan,
502         "1": strictlyEqual,
503         "Math.E": notEqualLessThan,
504         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
505         "JSVAL_INT_MIN": notEqualGreaterThan,
506         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
507         "JSVAL_INT_MAX - 1": notEqualLessThan,
508         "JSVAL_INT_MAX": notEqualLessThan,
509         "JSVAL_INT_MAX + 1": notEqualLessThan,
510         "Infinity": notEqualLessThan,
511         "-Infinity": notEqualGreaterThan,
512         "NaN": notEqualIncomparable,
513         "{}": notEqualIncomparable,
514         "{ valueOf: undefined }": notEqualIncomparable,
515         "[]": notEqualGreaterThan,
516         '[""]': notEqualGreaterThan,
517         '["a"]': notEqualIncomparable,
518         "[0]": notEqualGreaterThan
519       },
520     "Math.E":
521       {
522         "undefined": notEqualIncomparable,
523         "null": notEqualGreaterThan,
524         "true": notEqualGreaterThan,
525         "false": notEqualGreaterThan,
526         '""': notEqualGreaterThan,
527         '"a"': notEqualIncomparable,
528         '"Z"': notEqualIncomparable,
529         "0": notEqualGreaterThan,
530         "-0": notEqualGreaterThan,
531         "1": notEqualGreaterThan,
532         "Math.E": strictlyEqual,
533         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
534         "JSVAL_INT_MIN": notEqualGreaterThan,
535         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
536         "JSVAL_INT_MAX - 1": notEqualLessThan,
537         "JSVAL_INT_MAX": notEqualLessThan,
538         "JSVAL_INT_MAX + 1": notEqualLessThan,
539         "Infinity": notEqualLessThan,
540         "-Infinity": notEqualGreaterThan,
541         "NaN": notEqualIncomparable,
542         "{}": notEqualIncomparable,
543         "{ valueOf: undefined }": notEqualIncomparable,
544         "[]": notEqualGreaterThan,
545         '[""]': notEqualGreaterThan,
546         '["a"]': notEqualIncomparable,
547         "[0]": notEqualGreaterThan
548       },
549     "JSVAL_INT_MIN - 1":
550       {
551         "undefined": notEqualIncomparable,
552         "null": notEqualLessThan,
553         "true": notEqualLessThan,
554         "false": notEqualLessThan,
555         '""': notEqualLessThan,
556         '"a"': notEqualIncomparable,
557         '"Z"': notEqualIncomparable,
558         "0": notEqualLessThan,
559         "-0": notEqualLessThan,
560         "1": notEqualLessThan,
561         "Math.E": notEqualLessThan,
562         "JSVAL_INT_MIN - 1": strictlyEqual,
563         "JSVAL_INT_MIN": notEqualLessThan,
564         "JSVAL_INT_MIN + 1": notEqualLessThan,
565         "JSVAL_INT_MAX - 1": notEqualLessThan,
566         "JSVAL_INT_MAX": notEqualLessThan,
567         "JSVAL_INT_MAX + 1": notEqualLessThan,
568         "Infinity": notEqualLessThan,
569         "-Infinity": notEqualGreaterThan,
570         "NaN": notEqualIncomparable,
571         "{}": notEqualIncomparable,
572         "{ valueOf: undefined }": notEqualIncomparable,
573         "[]": notEqualLessThan,
574         '[""]': notEqualLessThan,
575         '["a"]': notEqualIncomparable,
576         "[0]": notEqualLessThan
577       },
578     "JSVAL_INT_MIN":
579       {
580         "undefined": notEqualIncomparable,
581         "null": notEqualLessThan,
582         "true": notEqualLessThan,
583         "false": notEqualLessThan,
584         '""': notEqualLessThan,
585         '"a"': notEqualIncomparable,
586         '"Z"': notEqualIncomparable,
587         "0": notEqualLessThan,
588         "-0": notEqualLessThan,
589         "1": notEqualLessThan,
590         "Math.E": notEqualLessThan,
591         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
592         "JSVAL_INT_MIN": strictlyEqual,
593         "JSVAL_INT_MIN + 1": notEqualLessThan,
594         "JSVAL_INT_MAX - 1": notEqualLessThan,
595         "JSVAL_INT_MAX": notEqualLessThan,
596         "JSVAL_INT_MAX + 1": notEqualLessThan,
597         "Infinity": notEqualLessThan,
598         "-Infinity": notEqualGreaterThan,
599         "NaN": notEqualIncomparable,
600         "{}": notEqualIncomparable,
601         "{ valueOf: undefined }": notEqualIncomparable,
602         "[]": notEqualLessThan,
603         '[""]': notEqualLessThan,
604         '["a"]': notEqualIncomparable,
605         "[0]": notEqualLessThan
606       },
607     "JSVAL_INT_MIN + 1":
608       {
609         "undefined": notEqualIncomparable,
610         "null": notEqualLessThan,
611         "true": notEqualLessThan,
612         "false": notEqualLessThan,
613         '""': notEqualLessThan,
614         '"a"': notEqualIncomparable,
615         '"Z"': notEqualIncomparable,
616         "0": notEqualLessThan,
617         "-0": notEqualLessThan,
618         "1": notEqualLessThan,
619         "Math.E": notEqualLessThan,
620         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
621         "JSVAL_INT_MIN": notEqualGreaterThan,
622         "JSVAL_INT_MIN + 1": strictlyEqual,
623         "JSVAL_INT_MAX - 1": notEqualLessThan,
624         "JSVAL_INT_MAX": notEqualLessThan,
625         "JSVAL_INT_MAX + 1": notEqualLessThan,
626         "Infinity": notEqualLessThan,
627         "-Infinity": notEqualGreaterThan,
628         "NaN": notEqualIncomparable,
629         "{}": notEqualIncomparable,
630         "{ valueOf: undefined }": notEqualIncomparable,
631         "[]": notEqualLessThan,
632         '[""]': notEqualLessThan,
633         '["a"]': notEqualIncomparable,
634         "[0]": notEqualLessThan
635       },
636     "JSVAL_INT_MAX - 1":
637       {
638         "undefined": notEqualIncomparable,
639         "null": notEqualGreaterThan,
640         "true": notEqualGreaterThan,
641         "false": notEqualGreaterThan,
642         '""': notEqualGreaterThan,
643         '"a"': notEqualIncomparable,
644         '"Z"': notEqualIncomparable,
645         "0": notEqualGreaterThan,
646         "-0": notEqualGreaterThan,
647         "1": notEqualGreaterThan,
648         "Math.E": notEqualGreaterThan,
649         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
650         "JSVAL_INT_MIN": notEqualGreaterThan,
651         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
652         "JSVAL_INT_MAX - 1": strictlyEqual,
653         "JSVAL_INT_MAX": notEqualLessThan,
654         "JSVAL_INT_MAX + 1": notEqualLessThan,
655         "Infinity": notEqualLessThan,
656         "-Infinity": notEqualGreaterThan,
657         "NaN": notEqualIncomparable,
658         "{}": notEqualIncomparable,
659         "{ valueOf: undefined }": notEqualIncomparable,
660         "[]": notEqualGreaterThan,
661         '[""]': notEqualGreaterThan,
662         '["a"]': notEqualIncomparable,
663         "[0]": notEqualGreaterThan
664       },
665     "JSVAL_INT_MAX":
666       {
667         "undefined": notEqualIncomparable,
668         "null": notEqualGreaterThan,
669         "true": notEqualGreaterThan,
670         "false": notEqualGreaterThan,
671         '""': notEqualGreaterThan,
672         '"a"': notEqualIncomparable,
673         '"Z"': notEqualIncomparable,
674         "0": notEqualGreaterThan,
675         "-0": notEqualGreaterThan,
676         "1": notEqualGreaterThan,
677         "Math.E": notEqualGreaterThan,
678         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
679         "JSVAL_INT_MIN": notEqualGreaterThan,
680         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
681         "JSVAL_INT_MAX - 1": notEqualGreaterThan,
682         "JSVAL_INT_MAX": strictlyEqual,
683         "JSVAL_INT_MAX + 1": notEqualLessThan,
684         "Infinity": notEqualLessThan,
685         "-Infinity": notEqualGreaterThan,
686         "NaN": notEqualIncomparable,
687         "{}": notEqualIncomparable,
688         "{ valueOf: undefined }": notEqualIncomparable,
689         "[]": notEqualGreaterThan,
690         '[""]': notEqualGreaterThan,
691         '["a"]': notEqualIncomparable,
692         "[0]": notEqualGreaterThan
693       },
694     "JSVAL_INT_MAX + 1":
695       {
696         "undefined": notEqualIncomparable,
697         "null": notEqualGreaterThan,
698         "true": notEqualGreaterThan,
699         "false": notEqualGreaterThan,
700         '""': notEqualGreaterThan,
701         '"a"': notEqualIncomparable,
702         '"Z"': notEqualIncomparable,
703         "0": notEqualGreaterThan,
704         "-0": notEqualGreaterThan,
705         "1": notEqualGreaterThan,
706         "Math.E": notEqualGreaterThan,
707         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
708         "JSVAL_INT_MIN": notEqualGreaterThan,
709         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
710         "JSVAL_INT_MAX - 1": notEqualGreaterThan,
711         "JSVAL_INT_MAX": notEqualGreaterThan,
712         "JSVAL_INT_MAX + 1": strictlyEqual,
713         "Infinity": notEqualLessThan,
714         "-Infinity": notEqualGreaterThan,
715         "NaN": notEqualIncomparable,
716         "{}": notEqualIncomparable,
717         "{ valueOf: undefined }": notEqualIncomparable,
718         "[]": notEqualGreaterThan,
719         '[""]': notEqualGreaterThan,
720         '["a"]': notEqualIncomparable,
721         "[0]": notEqualGreaterThan
722       },
723     "Infinity":
724       {
725         "undefined": notEqualIncomparable,
726         "null": notEqualGreaterThan,
727         "true": notEqualGreaterThan,
728         "false": notEqualGreaterThan,
729         '""': notEqualGreaterThan,
730         '"a"': notEqualIncomparable,
731         '"Z"': notEqualIncomparable,
732         "0": notEqualGreaterThan,
733         "-0": notEqualGreaterThan,
734         "1": notEqualGreaterThan,
735         "Math.E": notEqualGreaterThan,
736         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
737         "JSVAL_INT_MIN": notEqualGreaterThan,
738         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
739         "JSVAL_INT_MAX - 1": notEqualGreaterThan,
740         "JSVAL_INT_MAX": notEqualGreaterThan,
741         "JSVAL_INT_MAX + 1": notEqualGreaterThan,
742         "Infinity": strictlyEqual,
743         "-Infinity": notEqualGreaterThan,
744         "NaN": notEqualIncomparable,
745         "{}": notEqualIncomparable,
746         "{ valueOf: undefined }": notEqualIncomparable,
747         "[]": notEqualGreaterThan,
748         '[""]': notEqualGreaterThan,
749         '["a"]': notEqualIncomparable,
750         "[0]": notEqualGreaterThan
751       },
752     "-Infinity":
753       {
754         "undefined": notEqualIncomparable,
755         "null": notEqualLessThan,
756         "true": notEqualLessThan,
757         "false": notEqualLessThan,
758         '""': notEqualLessThan,
759         '"a"': notEqualIncomparable,
760         '"Z"': notEqualIncomparable,
761         "0": notEqualLessThan,
762         "-0": notEqualLessThan,
763         "1": notEqualLessThan,
764         "Math.E": notEqualLessThan,
765         "JSVAL_INT_MIN - 1": notEqualLessThan,
766         "JSVAL_INT_MIN": notEqualLessThan,
767         "JSVAL_INT_MIN + 1": notEqualLessThan,
768         "JSVAL_INT_MAX - 1": notEqualLessThan,
769         "JSVAL_INT_MAX": notEqualLessThan,
770         "JSVAL_INT_MAX + 1": notEqualLessThan,
771         "Infinity": notEqualLessThan,
772         "-Infinity": strictlyEqual,
773         "NaN": notEqualIncomparable,
774         "{}": notEqualIncomparable,
775         "{ valueOf: undefined }": notEqualIncomparable,
776         "[]": notEqualLessThan,
777         '[""]': notEqualLessThan,
778         '["a"]': notEqualIncomparable,
779         "[0]": notEqualLessThan
780       },
781     "NaN":
782       {
783         "undefined": notEqualIncomparable,
784         "null": notEqualIncomparable,
785         "true": notEqualIncomparable,
786         "false": notEqualIncomparable,
787         '""': notEqualIncomparable,
788         '"a"': notEqualIncomparable,
789         '"Z"': notEqualIncomparable,
790         "0": notEqualIncomparable,
791         "-0": notEqualIncomparable,
792         "1": notEqualIncomparable,
793         "Math.E": notEqualIncomparable,
794         "JSVAL_INT_MIN - 1": notEqualIncomparable,
795         "JSVAL_INT_MIN": notEqualIncomparable,
796         "JSVAL_INT_MIN + 1": notEqualIncomparable,
797         "JSVAL_INT_MAX - 1": notEqualIncomparable,
798         "JSVAL_INT_MAX": notEqualIncomparable,
799         "JSVAL_INT_MAX + 1": notEqualIncomparable,
800         "Infinity": notEqualIncomparable,
801         "-Infinity": notEqualIncomparable,
802         "NaN": notEqualIncomparable,
803         "{}": notEqualIncomparable,
804         "{ valueOf: undefined }": notEqualIncomparable,
805         "[]": notEqualIncomparable,
806         '[""]': notEqualIncomparable,
807         '["a"]': notEqualIncomparable,
808         "[0]": notEqualIncomparable
809       },
810     "{}": comparingObjectOrObjectWithValueUndefined,
811     "{ valueOf: undefined }": comparingObjectOrObjectWithValueUndefined,
812     "[]":
813       {
814         "undefined": notEqualIncomparable,
815         "null": notEqualNorDifferent,
816         "true": notEqualLessThan,
817         "false": looselyEqual,
818         '""': looselyEqual,
819         '"a"': notEqualLessThan,
820         '"Z"': notEqualLessThan,
821         "0": looselyEqual,
822         "-0": looselyEqual,
823         "1": notEqualLessThan,
824         "Math.E": notEqualLessThan,
825         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
826         "JSVAL_INT_MIN": notEqualGreaterThan,
827         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
828         "JSVAL_INT_MAX - 1": notEqualLessThan,
829         "JSVAL_INT_MAX": notEqualLessThan,
830         "JSVAL_INT_MAX + 1": notEqualLessThan,
831         "Infinity": notEqualLessThan,
832         "-Infinity": notEqualGreaterThan,
833         "NaN": notEqualIncomparable,
834         "{}": notEqualLessThan,
835         "{ valueOf: undefined }": notEqualLessThan,
836         "[]": notEqualNorDifferent,
837         '[""]': notEqualNorDifferent,
838         '["a"]': notEqualLessThan,
839         "[0]": notEqualLessThan
840       },
841     '[""]':
842       {
843         "undefined": notEqualIncomparable,
844         "null": notEqualNorDifferent,
845         "true": notEqualLessThan,
846         "false": looselyEqual,
847         '""': looselyEqual,
848         '"a"': notEqualLessThan,
849         '"Z"': notEqualLessThan,
850         "0": looselyEqual,
851         "-0": looselyEqual,
852         "1": notEqualLessThan,
853         "Math.E": notEqualLessThan,
854         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
855         "JSVAL_INT_MIN": notEqualGreaterThan,
856         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
857         "JSVAL_INT_MAX - 1": notEqualLessThan,
858         "JSVAL_INT_MAX": notEqualLessThan,
859         "JSVAL_INT_MAX + 1": notEqualLessThan,
860         "Infinity": notEqualLessThan,
861         "-Infinity": notEqualGreaterThan,
862         "NaN": notEqualIncomparable,
863         "{}": notEqualLessThan,
864         "{ valueOf: undefined }": notEqualLessThan,
865         "[]": notEqualNorDifferent,
866         '[""]': notEqualNorDifferent,
867         '["a"]': notEqualLessThan,
868         "[0]": notEqualLessThan
869       },
870     '["a"]':
871       {
872         "undefined": notEqualIncomparable,
873         "null": notEqualIncomparable,
874         "true": notEqualIncomparable,
875         "false": notEqualIncomparable,
876         '""': notEqualGreaterThan,
877         '"a"': looselyEqual,
878         '"Z"': notEqualGreaterThan,
879         "0": notEqualIncomparable,
880         "-0": notEqualIncomparable,
881         "1": notEqualIncomparable,
882         "Math.E": notEqualIncomparable,
883         "JSVAL_INT_MIN - 1": notEqualIncomparable,
884         "JSVAL_INT_MIN": notEqualIncomparable,
885         "JSVAL_INT_MIN + 1": notEqualIncomparable,
886         "JSVAL_INT_MAX - 1": notEqualIncomparable,
887         "JSVAL_INT_MAX": notEqualIncomparable,
888         "JSVAL_INT_MAX + 1": notEqualIncomparable,
889         "Infinity": notEqualIncomparable,
890         "-Infinity": notEqualIncomparable,
891         "NaN": notEqualIncomparable,
892         "{}": notEqualGreaterThan,
893         "{ valueOf: undefined }": notEqualGreaterThan,
894         "[]": notEqualGreaterThan,
895         '[""]': notEqualGreaterThan,
896         '["a"]': notEqualNorDifferent,
897         "[0]": notEqualGreaterThan
898       },
899     "[0]":
900       {
901         "undefined": notEqualIncomparable,
902         "null": notEqualNorDifferent,
903         "true": notEqualLessThan,
904         "false": looselyEqual,
905         '""': notEqualGreaterThan,
906         '"a"': notEqualLessThan,
907         '"Z"': notEqualLessThan,
908         "0": looselyEqual,
909         "-0": looselyEqual,
910         "1": notEqualLessThan,
911         "Math.E": notEqualLessThan,
912         "JSVAL_INT_MIN - 1": notEqualGreaterThan,
913         "JSVAL_INT_MIN": notEqualGreaterThan,
914         "JSVAL_INT_MIN + 1": notEqualGreaterThan,
915         "JSVAL_INT_MAX - 1": notEqualLessThan,
916         "JSVAL_INT_MAX": notEqualLessThan,
917         "JSVAL_INT_MAX + 1": notEqualLessThan,
918         "Infinity": notEqualLessThan,
919         "-Infinity": notEqualGreaterThan,
920         "NaN": notEqualIncomparable,
921         "{}": notEqualLessThan,
922         "{ valueOf: undefined }": notEqualLessThan,
923         "[]": notEqualGreaterThan,
924         '[""]': notEqualGreaterThan,
925         '["a"]': notEqualLessThan,
926         "[0]": notEqualNorDifferent
927       }
928    };
929
930
931
932  var failures = [];
933  function fail(a, ta, b, tb, ex, ac, op)
934  {
935    failures.push("(" + a + " " + op + " " + b + ") wrong: " +
936                  "expected " + ex + ", got " + ac +
937                  " (types " + types[ta] + ", " + types[tb] + ")");
938  }
939
940  var result = false;
941  for (var i in values)
942  {
943    for (var j in values)
944    {
945      // Constants, so hoist to help JIT know that
946      var vala = values[i], valb = values[j];
947      var a = vala.value(), b = valb.value();
948
949      for (var opname in orderOps)
950      {
951        var op = orderOps[opname];
952        var expect = expected[i][j].order[opname];
953        var failed = false;
954
955        for (var iter = 0; iter < 5; iter++)
956        {
957          result = op(a, b);
958          failed = failed || result !== expect;
959        }
960
961        if (failed)
962          fail(i, vala.type, j, valb.type, expect, result, opname);
963      }
964
965      for (var opname in eqOps)
966      {
967        var op = eqOps[opname];
968        var expect = expected[i][j].eq[opname];
969        var failed = false;
970
971        for (var iter = 0; iter < 5; iter++)
972        {
973          result = op(a, b);
974          failed = failed || result !== expect;
975        }
976
977        if (failed)
978          fail(i, vala.type, j, valb.type, expect, result, opname);
979      }
980    }
981  }
982
983  if (failures.length == 0)
984    return "no failures reported!";
985
986  return "\n" + failures.join(",\n");
987}
988assertEq(testComparisons(), "no failures reported!");