michael@0: function testComparisons() michael@0: { michael@0: // All the special values from each of the types in michael@0: // ECMA-262, 3rd ed. section 8 michael@0: var undefinedType, nullType, booleanType, stringType, numberType, objectType; michael@0: michael@0: var types = []; michael@0: types[undefinedType = 0] = "Undefined"; michael@0: types[nullType = 1] = "Null"; michael@0: types[booleanType = 2] = "Boolean"; michael@0: types[stringType = 3] = "String"; michael@0: types[numberType = 4] = "Number"; michael@0: types[objectType = 5] = "Object"; michael@0: michael@0: var JSVAL_INT_MIN = -Math.pow(2, 30); michael@0: var JSVAL_INT_MAX = Math.pow(2, 30) - 1; michael@0: michael@0: // Values from every ES3 type, hitting all the edge-case and special values michael@0: // that can be dreamed up michael@0: var values = michael@0: { michael@0: "undefined": michael@0: { michael@0: value: function() { return undefined; }, michael@0: type: undefinedType michael@0: }, michael@0: "null": michael@0: { michael@0: value: function() { return null; }, michael@0: type: nullType michael@0: }, michael@0: "true": michael@0: { michael@0: value: function() { return true; }, michael@0: type: booleanType michael@0: }, michael@0: "false": michael@0: { michael@0: value: function() { return false; }, michael@0: type: booleanType michael@0: }, michael@0: '""': michael@0: { michael@0: value: function() { return ""; }, michael@0: type: stringType michael@0: }, michael@0: '"a"': michael@0: { michael@0: // a > [, for string-object comparisons michael@0: value: function() { return "a"; }, michael@0: type: stringType michael@0: }, michael@0: '"Z"': michael@0: { michael@0: // Z < [, for string-object comparisons michael@0: value: function() { return "Z"; }, michael@0: type: stringType michael@0: }, michael@0: "0": michael@0: { michael@0: value: function() { return 0; }, michael@0: type: numberType michael@0: }, michael@0: "-0": michael@0: { michael@0: value: function() { return -0; }, michael@0: type: numberType michael@0: }, michael@0: "1": michael@0: { michael@0: value: function() { return 1; }, michael@0: type: numberType michael@0: }, michael@0: "Math.E": michael@0: { michael@0: value: function() { return Math.E; }, michael@0: type: numberType michael@0: }, michael@0: "JSVAL_INT_MIN - 1": michael@0: { michael@0: value: function() { return JSVAL_INT_MIN - 1; }, michael@0: type: numberType michael@0: }, michael@0: "JSVAL_INT_MIN": michael@0: { michael@0: value: function() { return JSVAL_INT_MIN; }, michael@0: type: numberType michael@0: }, michael@0: "JSVAL_INT_MIN + 1": michael@0: { michael@0: value: function() { return JSVAL_INT_MIN + 1; }, michael@0: type: numberType michael@0: }, michael@0: "JSVAL_INT_MAX - 1": michael@0: { michael@0: value: function() { return JSVAL_INT_MAX - 1; }, michael@0: type: numberType michael@0: }, michael@0: "JSVAL_INT_MAX": michael@0: { michael@0: value: function() { return JSVAL_INT_MAX; }, michael@0: type: numberType michael@0: }, michael@0: "JSVAL_INT_MAX + 1": michael@0: { michael@0: value: function() { return JSVAL_INT_MAX + 1; }, michael@0: type: numberType michael@0: }, michael@0: "Infinity": michael@0: { michael@0: value: function() { return Infinity; }, michael@0: type: numberType michael@0: }, michael@0: "-Infinity": michael@0: { michael@0: value: function() { return -Infinity; }, michael@0: type: numberType michael@0: }, michael@0: "NaN": michael@0: { michael@0: value: function() { return NaN; }, michael@0: type: numberType michael@0: }, michael@0: "{}": michael@0: { michael@0: value: function() { return {}; }, michael@0: type: objectType michael@0: }, michael@0: "{ valueOf: undefined }": michael@0: { michael@0: value: function() { return { valueOf: undefined }; }, michael@0: type: objectType michael@0: }, michael@0: "[]": michael@0: { michael@0: value: function() { return []; }, michael@0: type: objectType michael@0: }, michael@0: '[""]': michael@0: { michael@0: value: function() { return [""]; }, michael@0: type: objectType michael@0: }, michael@0: '["a"]': michael@0: { michael@0: value: function() { return ["a"]; }, michael@0: type: objectType michael@0: }, michael@0: "[0]": michael@0: { michael@0: value: function() { return [0]; }, michael@0: type: objectType michael@0: } michael@0: }; michael@0: michael@0: var orderOps = michael@0: { michael@0: "<": function(a, b) { return a < b; }, michael@0: ">": function(a, b) { return a > b; }, michael@0: "<=": function(a, b) { return a <= b; }, michael@0: ">=": function(a, b) { return a >= b; } michael@0: }; michael@0: var eqOps = michael@0: { michael@0: "==": function(a, b) { return a == b; }, michael@0: "!=": function(a, b) { return a != b; }, michael@0: "===": function(a, b) { return a === b; }, michael@0: "!==": function(a, b) { return a !== b; } michael@0: }; michael@0: michael@0: michael@0: var notEqualIncomparable = michael@0: { michael@0: eq: { "==": false, "!=": true, "===": false, "!==": true }, michael@0: order: { "<": false, ">": false, "<=": false, ">=": false } michael@0: }; michael@0: var notEqualLessThan = michael@0: { michael@0: eq: { "==": false, "!=": true, "===": false, "!==": true }, michael@0: order: { "<": true, ">": false, "<=": true, ">=": false } michael@0: }; michael@0: var notEqualGreaterThan = michael@0: { michael@0: eq: { "==": false, "!=": true, "===": false, "!==": true }, michael@0: order: { "<": false, ">": true, "<=": false, ">=": true } michael@0: }; michael@0: var notEqualNorDifferent = michael@0: { michael@0: eq: { "==": false, "!=": true, "===": false, "!==": true }, michael@0: order: { "<": false, ">": false, "<=": true, ">=": true } michael@0: }; michael@0: var strictlyEqual = michael@0: { michael@0: eq: { "==": true, "!=": false, "===": true, "!==": false }, michael@0: order: { "<": false, ">": false, "<=": true, ">=": true } michael@0: }; michael@0: var looselyEqual = michael@0: { michael@0: eq: { "==": true, "!=": false, "===": false, "!==": true }, michael@0: order: { "<": false, ">": false, "<=": true, ">=": true } michael@0: }; michael@0: var looselyEqualNotDifferent = michael@0: { michael@0: eq: { "==": true, "!=": false, "===": false, "!==": true }, michael@0: order: { "<": false, ">": false, "<=": true, ">=": true } michael@0: }; michael@0: var looselyEqualIncomparable = michael@0: { michael@0: eq: { "==": true, "!=": false, "===": false, "!==": true }, michael@0: order: { "<": false, ">": false, "<=": false, ">=": false } michael@0: }; michael@0: var strictlyEqualNotDifferent = michael@0: { michael@0: eq: { "==": true, "!=": false, "===": true, "!==": false }, michael@0: order: { "<": false, ">": false, "<=": true, ">=": true } michael@0: }; michael@0: var strictlyEqualIncomparable = michael@0: { michael@0: eq: { "==": true, "!=": false, "===": true, "!==": false }, michael@0: order: { "<": false, ">": false, "<=": false, ">=": false } michael@0: }; michael@0: michael@0: var comparingZeroToSomething = michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualNorDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": looselyEqual, michael@0: '""': looselyEqualNotDifferent, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": strictlyEqual, michael@0: "-0": strictlyEqual, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": looselyEqual, michael@0: '[""]': looselyEqual, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": looselyEqual michael@0: }; michael@0: michael@0: var comparingObjectOrObjectWithValueUndefined = michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualIncomparable, michael@0: "true": notEqualIncomparable, michael@0: "false": notEqualIncomparable, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualLessThan, michael@0: '"Z"': notEqualGreaterThan, michael@0: "0": notEqualIncomparable, michael@0: "-0": notEqualIncomparable, michael@0: "1": notEqualIncomparable, michael@0: "Math.E": notEqualIncomparable, michael@0: "JSVAL_INT_MIN - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MIN": notEqualIncomparable, michael@0: "JSVAL_INT_MIN + 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX": notEqualIncomparable, michael@0: "JSVAL_INT_MAX + 1": notEqualIncomparable, michael@0: "Infinity": notEqualIncomparable, michael@0: "-Infinity": notEqualIncomparable, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualNorDifferent, michael@0: "{ valueOf: undefined }": notEqualNorDifferent, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualLessThan, michael@0: "[0]": notEqualGreaterThan michael@0: }; michael@0: michael@0: // Constructed expected-value matrix michael@0: var expected = michael@0: { michael@0: "undefined": michael@0: { michael@0: "undefined": strictlyEqualIncomparable, michael@0: "null": looselyEqualIncomparable, michael@0: "true": notEqualIncomparable, michael@0: "false": notEqualIncomparable, michael@0: '""': notEqualIncomparable, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualIncomparable, michael@0: "-0": notEqualIncomparable, michael@0: "1": notEqualIncomparable, michael@0: "Math.E": notEqualIncomparable, michael@0: "JSVAL_INT_MIN - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MIN": notEqualIncomparable, michael@0: "JSVAL_INT_MIN + 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX": notEqualIncomparable, michael@0: "JSVAL_INT_MAX + 1": notEqualIncomparable, michael@0: "Infinity": notEqualIncomparable, michael@0: "-Infinity": notEqualIncomparable, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualIncomparable, michael@0: '[""]': notEqualIncomparable, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualIncomparable michael@0: }, michael@0: "null": michael@0: { michael@0: "undefined": looselyEqualIncomparable, michael@0: "null": strictlyEqualNotDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": notEqualNorDifferent, michael@0: '""': notEqualNorDifferent, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualNorDifferent, michael@0: "-0": notEqualNorDifferent, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualNorDifferent, michael@0: '[""]': notEqualNorDifferent, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualNorDifferent michael@0: }, michael@0: "true": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": strictlyEqual, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": looselyEqual, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "false": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualNorDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": strictlyEqual, michael@0: '""': looselyEqualNotDifferent, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": looselyEqual, michael@0: "-0": looselyEqual, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": looselyEqual, michael@0: '[""]': looselyEqual, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": looselyEqual michael@0: }, michael@0: '""': michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualNorDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": looselyEqual, michael@0: '""': strictlyEqual, michael@0: '"a"': notEqualLessThan, michael@0: '"Z"': notEqualLessThan, michael@0: "0": looselyEqual, michael@0: "-0": looselyEqual, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualLessThan, michael@0: "{ valueOf: undefined }": notEqualLessThan, michael@0: "[]": looselyEqual, michael@0: '[""]': looselyEqual, michael@0: '["a"]': notEqualLessThan, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: '"a"': michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualIncomparable, michael@0: "true": notEqualIncomparable, michael@0: "false": notEqualIncomparable, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': strictlyEqual, michael@0: '"Z"': notEqualGreaterThan, michael@0: "0": notEqualIncomparable, michael@0: "-0": notEqualIncomparable, michael@0: "1": notEqualIncomparable, michael@0: "Math.E": notEqualIncomparable, michael@0: "JSVAL_INT_MIN - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MIN": notEqualIncomparable, michael@0: "JSVAL_INT_MIN + 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX": notEqualIncomparable, michael@0: "JSVAL_INT_MAX + 1": notEqualIncomparable, michael@0: "Infinity": notEqualIncomparable, michael@0: "-Infinity": notEqualIncomparable, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualGreaterThan, michael@0: "{ valueOf: undefined }": notEqualGreaterThan, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': looselyEqualNotDifferent, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: '"Z"': michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualIncomparable, michael@0: "true": notEqualIncomparable, michael@0: "false": notEqualIncomparable, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualLessThan, michael@0: '"Z"': strictlyEqual, michael@0: "0": notEqualIncomparable, michael@0: "-0": notEqualIncomparable, michael@0: "1": notEqualIncomparable, michael@0: "Math.E": notEqualIncomparable, michael@0: "JSVAL_INT_MIN - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MIN": notEqualIncomparable, michael@0: "JSVAL_INT_MIN + 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX": notEqualIncomparable, michael@0: "JSVAL_INT_MAX + 1": notEqualIncomparable, michael@0: "Infinity": notEqualIncomparable, michael@0: "-Infinity": notEqualIncomparable, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualLessThan, michael@0: "{ valueOf: undefined }": notEqualLessThan, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualLessThan, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "0": comparingZeroToSomething, michael@0: "-0": comparingZeroToSomething, michael@0: "1": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": looselyEqual, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": strictlyEqual, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "Math.E": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": notEqualGreaterThan, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": notEqualGreaterThan, michael@0: "Math.E": strictlyEqual, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "JSVAL_INT_MIN - 1": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualLessThan, michael@0: "true": notEqualLessThan, michael@0: "false": notEqualLessThan, michael@0: '""': notEqualLessThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualLessThan, michael@0: "-0": notEqualLessThan, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": strictlyEqual, michael@0: "JSVAL_INT_MIN": notEqualLessThan, michael@0: "JSVAL_INT_MIN + 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualLessThan, michael@0: '[""]': notEqualLessThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: "JSVAL_INT_MIN": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualLessThan, michael@0: "true": notEqualLessThan, michael@0: "false": notEqualLessThan, michael@0: '""': notEqualLessThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualLessThan, michael@0: "-0": notEqualLessThan, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": strictlyEqual, michael@0: "JSVAL_INT_MIN + 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualLessThan, michael@0: '[""]': notEqualLessThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: "JSVAL_INT_MIN + 1": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualLessThan, michael@0: "true": notEqualLessThan, michael@0: "false": notEqualLessThan, michael@0: '""': notEqualLessThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualLessThan, michael@0: "-0": notEqualLessThan, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": strictlyEqual, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualLessThan, michael@0: '[""]': notEqualLessThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: "JSVAL_INT_MAX - 1": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": notEqualGreaterThan, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": notEqualGreaterThan, michael@0: "Math.E": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": strictlyEqual, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "JSVAL_INT_MAX": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": notEqualGreaterThan, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": notEqualGreaterThan, michael@0: "Math.E": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX": strictlyEqual, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "JSVAL_INT_MAX + 1": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": notEqualGreaterThan, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": notEqualGreaterThan, michael@0: "Math.E": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX + 1": strictlyEqual, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "Infinity": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualGreaterThan, michael@0: "true": notEqualGreaterThan, michael@0: "false": notEqualGreaterThan, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualGreaterThan, michael@0: "-0": notEqualGreaterThan, michael@0: "1": notEqualGreaterThan, michael@0: "Math.E": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX + 1": notEqualGreaterThan, michael@0: "Infinity": strictlyEqual, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "-Infinity": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualLessThan, michael@0: "true": notEqualLessThan, michael@0: "false": notEqualLessThan, michael@0: '""': notEqualLessThan, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualLessThan, michael@0: "-0": notEqualLessThan, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualLessThan, michael@0: "JSVAL_INT_MIN": notEqualLessThan, michael@0: "JSVAL_INT_MIN + 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": strictlyEqual, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualLessThan, michael@0: '[""]': notEqualLessThan, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: "NaN": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualIncomparable, michael@0: "true": notEqualIncomparable, michael@0: "false": notEqualIncomparable, michael@0: '""': notEqualIncomparable, michael@0: '"a"': notEqualIncomparable, michael@0: '"Z"': notEqualIncomparable, michael@0: "0": notEqualIncomparable, michael@0: "-0": notEqualIncomparable, michael@0: "1": notEqualIncomparable, michael@0: "Math.E": notEqualIncomparable, michael@0: "JSVAL_INT_MIN - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MIN": notEqualIncomparable, michael@0: "JSVAL_INT_MIN + 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX": notEqualIncomparable, michael@0: "JSVAL_INT_MAX + 1": notEqualIncomparable, michael@0: "Infinity": notEqualIncomparable, michael@0: "-Infinity": notEqualIncomparable, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualIncomparable, michael@0: "{ valueOf: undefined }": notEqualIncomparable, michael@0: "[]": notEqualIncomparable, michael@0: '[""]': notEqualIncomparable, michael@0: '["a"]': notEqualIncomparable, michael@0: "[0]": notEqualIncomparable michael@0: }, michael@0: "{}": comparingObjectOrObjectWithValueUndefined, michael@0: "{ valueOf: undefined }": comparingObjectOrObjectWithValueUndefined, michael@0: "[]": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualNorDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": looselyEqual, michael@0: '""': looselyEqual, michael@0: '"a"': notEqualLessThan, michael@0: '"Z"': notEqualLessThan, michael@0: "0": looselyEqual, michael@0: "-0": looselyEqual, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualLessThan, michael@0: "{ valueOf: undefined }": notEqualLessThan, michael@0: "[]": notEqualNorDifferent, michael@0: '[""]': notEqualNorDifferent, michael@0: '["a"]': notEqualLessThan, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: '[""]': michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualNorDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": looselyEqual, michael@0: '""': looselyEqual, michael@0: '"a"': notEqualLessThan, michael@0: '"Z"': notEqualLessThan, michael@0: "0": looselyEqual, michael@0: "-0": looselyEqual, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualLessThan, michael@0: "{ valueOf: undefined }": notEqualLessThan, michael@0: "[]": notEqualNorDifferent, michael@0: '[""]': notEqualNorDifferent, michael@0: '["a"]': notEqualLessThan, michael@0: "[0]": notEqualLessThan michael@0: }, michael@0: '["a"]': michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualIncomparable, michael@0: "true": notEqualIncomparable, michael@0: "false": notEqualIncomparable, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': looselyEqual, michael@0: '"Z"': notEqualGreaterThan, michael@0: "0": notEqualIncomparable, michael@0: "-0": notEqualIncomparable, michael@0: "1": notEqualIncomparable, michael@0: "Math.E": notEqualIncomparable, michael@0: "JSVAL_INT_MIN - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MIN": notEqualIncomparable, michael@0: "JSVAL_INT_MIN + 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX - 1": notEqualIncomparable, michael@0: "JSVAL_INT_MAX": notEqualIncomparable, michael@0: "JSVAL_INT_MAX + 1": notEqualIncomparable, michael@0: "Infinity": notEqualIncomparable, michael@0: "-Infinity": notEqualIncomparable, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualGreaterThan, michael@0: "{ valueOf: undefined }": notEqualGreaterThan, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualNorDifferent, michael@0: "[0]": notEqualGreaterThan michael@0: }, michael@0: "[0]": michael@0: { michael@0: "undefined": notEqualIncomparable, michael@0: "null": notEqualNorDifferent, michael@0: "true": notEqualLessThan, michael@0: "false": looselyEqual, michael@0: '""': notEqualGreaterThan, michael@0: '"a"': notEqualLessThan, michael@0: '"Z"': notEqualLessThan, michael@0: "0": looselyEqual, michael@0: "-0": looselyEqual, michael@0: "1": notEqualLessThan, michael@0: "Math.E": notEqualLessThan, michael@0: "JSVAL_INT_MIN - 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN": notEqualGreaterThan, michael@0: "JSVAL_INT_MIN + 1": notEqualGreaterThan, michael@0: "JSVAL_INT_MAX - 1": notEqualLessThan, michael@0: "JSVAL_INT_MAX": notEqualLessThan, michael@0: "JSVAL_INT_MAX + 1": notEqualLessThan, michael@0: "Infinity": notEqualLessThan, michael@0: "-Infinity": notEqualGreaterThan, michael@0: "NaN": notEqualIncomparable, michael@0: "{}": notEqualLessThan, michael@0: "{ valueOf: undefined }": notEqualLessThan, michael@0: "[]": notEqualGreaterThan, michael@0: '[""]': notEqualGreaterThan, michael@0: '["a"]': notEqualLessThan, michael@0: "[0]": notEqualNorDifferent michael@0: } michael@0: }; michael@0: michael@0: michael@0: michael@0: var failures = []; michael@0: function fail(a, ta, b, tb, ex, ac, op) michael@0: { michael@0: failures.push("(" + a + " " + op + " " + b + ") wrong: " + michael@0: "expected " + ex + ", got " + ac + michael@0: " (types " + types[ta] + ", " + types[tb] + ")"); michael@0: } michael@0: michael@0: var result = false; michael@0: for (var i in values) michael@0: { michael@0: for (var j in values) michael@0: { michael@0: // Constants, so hoist to help JIT know that michael@0: var vala = values[i], valb = values[j]; michael@0: var a = vala.value(), b = valb.value(); michael@0: michael@0: for (var opname in orderOps) michael@0: { michael@0: var op = orderOps[opname]; michael@0: var expect = expected[i][j].order[opname]; michael@0: var failed = false; michael@0: michael@0: for (var iter = 0; iter < 5; iter++) michael@0: { michael@0: result = op(a, b); michael@0: failed = failed || result !== expect; michael@0: } michael@0: michael@0: if (failed) michael@0: fail(i, vala.type, j, valb.type, expect, result, opname); michael@0: } michael@0: michael@0: for (var opname in eqOps) michael@0: { michael@0: var op = eqOps[opname]; michael@0: var expect = expected[i][j].eq[opname]; michael@0: var failed = false; michael@0: michael@0: for (var iter = 0; iter < 5; iter++) michael@0: { michael@0: result = op(a, b); michael@0: failed = failed || result !== expect; michael@0: } michael@0: michael@0: if (failed) michael@0: fail(i, vala.type, j, valb.type, expect, result, opname); michael@0: } michael@0: } michael@0: } michael@0: michael@0: if (failures.length == 0) michael@0: return "no failures reported!"; michael@0: michael@0: return "\n" + failures.join(",\n"); michael@0: } michael@0: assertEq(testComparisons(), "no failures reported!");