1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-17 00:37:39 +00:00

Actually got the comparisons working for s64 (still need to fix u64)

This commit is contained in:
Mike Beller
2020-06-04 18:27:48 -04:00
parent 01837f2bb6
commit 3e423722c6
2 changed files with 20 additions and 8 deletions

View File

@@ -389,7 +389,7 @@
# test polymorphic compare with int/u64 and int/s64
(def MAX_INT_64_STRING "9223372036854775807")
(def MAX_UINT_64_STRING "18446744073709551615")
(def MAX_INT_IN_DBL_STRING "9007199254740992")
(def MAX_INT_IN_DBL_STRING "9007199254740991")
(assert (= 0 (compare (int/u64 3) 3)) "compare number to int/u64")
(assert (= -1 (compare (int/u64 3) 4)) "compare number to int/u64 less")
(assert (= 0 (compare 3 (int/u64 3))) "compare number to int/u64")
@@ -410,10 +410,7 @@
(assert (= -1 (compare (int/s64 MAX_INT_64_STRING) (int/u64 MAX_UINT_64_STRING))) "compare big ints")
(assert (= 0 (compare (int/s64 MAX_INT_IN_DBL_STRING) (scan-number MAX_INT_IN_DBL_STRING))) "compare max int in double (1)")
(assert (= 0 (compare (int/u64 MAX_INT_IN_DBL_STRING) (scan-number MAX_INT_IN_DBL_STRING))) "compare max int in double (2)")
(assert (= 1 (compare (+ 2 (int/u64 MAX_INT_IN_DBL_STRING)) (scan-number MAX_INT_IN_DBL_STRING))) "compare max int in double (3)")
# Beware: This is a horrible effect of comparing doubles to integers
# int/64(MAX+1) should compare greater than the double, (but doesn't due to precision)
(assert (= 0 (compare (+ 1 (int/u64 MAX_INT_IN_DBL_STRING)) (scan-number MAX_INT_IN_DBL_STRING))) "compare max int in double (3)")
(assert (= 1 (compare (+ 1 (int/u64 MAX_INT_IN_DBL_STRING)) (scan-number MAX_INT_IN_DBL_STRING))) "compare max int in double (3)")
(end-suite)