Created
September 27, 2017 16:43
-
-
Save thejoshwolfe/655728bcbef31bdf60b71a7e61202336 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function assertSameValue(result, expected, resultStr) { | |
if (result === expected) return; | |
$ERROR("Expected (" + resultStr + ") to be " + expected + " but it was " + result); | |
} | |
function compare(a, aStr, b, bStr, cmp) { | |
assertSameValue(a < b, cmp < 0, aStr + " < " + bStr); | |
assertSameValue(a <= b, cmp <= 0, aStr + " <= " + bStr); | |
assertSameValue(a > b, cmp > 0, aStr + " > " + bStr); | |
assertSameValue(a >= b, cmp >= 0, aStr + " >= " + bStr); | |
assertSameValue(b < a, 0 < cmp, aStr + " < " + bStr); | |
assertSameValue(b <= a, 0 <= cmp, aStr + " <= " + bStr); | |
assertSameValue(b > a, 0 > cmp, aStr + " > " + bStr); | |
assertSameValue(b >= a, 0 >= cmp, aStr + " >= " + bStr); | |
} | |
compare(1n, "1n", 0, "0", 1); | |
compare(1n, "1n", 0.999999999999, "0.999999999999", 1); | |
compare(1, "1", 0n, "0n", 1); | |
compare(0.000000000001, "0.000000000001", 0n, "0n", 1); | |
compare(1n, "1n", 1, "1", 0); | |
compare(1, "1", 1n, "1n", 0); | |
compare(0n, "0n", 1, "1", -1); | |
compare(0, "0", 1n, "1n", -1); | |
compare(0, "0", 0n, "0n", 0); | |
compare(0n, "0n", 0, "0", 0); | |
compare(1n, "1n", Number.MAX_VALUE, "Number.MAX_VALUE", -1); | |
compare(Number.MIN_VALUE, "Number.MIN_VALUE", 0n, "0n", -1); | |
compare(-10n, "-10n", Number.MIN_VALUE, "Number.MIN_VALUE", 1); | |
compare(Number.MAX_VALUE, "Number.MAX_VALUE", 10000000000n, "10000000000n", 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uncaught exception: Test262Error: Expected (Number.MIN_VALUE < 0n) to be true but it was false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment