diff --git a/test/clojure/core_test/number_range.cljc b/test/clojure/core_test/number_range.cljc index a3f8881..6c743a7 100644 --- a/test/clojure/core_test/number_range.cljc +++ b/test/clojure/core_test/number_range.cljc @@ -1,15 +1,15 @@ (ns clojure.core-test.number-range) -;; TODO jank support blocked on https://github.com/jank-lang/jank/issues/195 - (def ^:const max-int #?(:clj Long/MAX_VALUE :cljr Int64/MaxValue :cljs js/Number.MAX_SAFE_INTEGER + :jank (cpp/value "std::numeric_limits::max()") :default 0x7FFFFFFFFFFFFFFF)) (def ^:const min-int #?(:clj Long/MIN_VALUE :cljr Int64/MinValue :cljs js/Number.MIN_SAFE_INTEGER + :jank (cpp/value "std::numeric_limits::min()") :default 0x8000000000000000)) (def ^:const all-ones-int #?(:cljs 0xFFFFFFFF @@ -24,10 +24,12 @@ (def ^:const max-double #?(:clj Double/MAX_VALUE :cljr Double/MaxValue :cljs js/Number.MAX_VALUE + :jank (cpp/value "std::numeric_limits::max()") :default 1.7976931348623157e+308)) (def ^:const min-double #?(:clj Double/MIN_VALUE :cljr Double/Epsilon ; NOTE: definitely not Double/MinValue -- ouch! :cljs js/Number.MIN_VALUE + :jank (cpp/value "std::numeric_limits::min()") :default 4.9e-324)) diff --git a/test/clojure/core_test/plus_squote.cljc b/test/clojure/core_test/plus_squote.cljc index 754fbd0..0329235 100644 --- a/test/clojure/core_test/plus_squote.cljc +++ b/test/clojure/core_test/plus_squote.cljc @@ -1,7 +1,7 @@ (ns clojure.core-test.plus-squote (:require [clojure.test :as t :refer [are deftest is]] [clojure.core-test.number-range :as r] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + [clojure.core-test.portability :as p #?(:cljs :refer-macros :default :refer) [when-var-exists]])) (when-var-exists +' (deftest test-+' @@ -70,18 +70,19 @@ 6N 1N 5 6N 1N 5N) - (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' 1 nil))) - (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' nil 1))) + #?(:jank [] + :default [(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' 1 nil))) + (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' nil 1)))]) - (is (instance? clojure.lang.BigInt (+' 0 1N))) - (is (instance? clojure.lang.BigInt (+' 0N 1))) - (is (instance? clojure.lang.BigInt (+' 0N 1N))) - (is (instance? clojure.lang.BigInt (+' 1N 1))) - (is (instance? clojure.lang.BigInt (+' 1 1N))) - (is (instance? clojure.lang.BigInt (+' 1N 1N))) - (is (instance? clojure.lang.BigInt (+' 1 5N))) - (is (instance? clojure.lang.BigInt (+' 1N 5))) - (is (instance? clojure.lang.BigInt (+' 1N 5N))) + (is (p/big-int? (+' 0 1N))) + (is (p/big-int? (+' 0N 1))) + (is (p/big-int? (+' 0N 1N))) + (is (p/big-int? (+' 1N 1))) + (is (p/big-int? (+' 1 1N))) + (is (p/big-int? (+' 1N 1N))) + (is (p/big-int? (+' 1 5N))) + (is (p/big-int? (+' 1N 5))) + (is (p/big-int? (+' 1N 5N))) - (is (instance? clojure.lang.BigInt (+' -1 r/min-int))) - (is (instance? clojure.lang.BigInt (+' r/min-int -1))))) + (is (p/big-int? (+' -1 r/min-int))) + (is (p/big-int? (+' r/min-int -1))))) diff --git a/test/clojure/core_test/portability.cljc b/test/clojure/core_test/portability.cljc index 12e3973..f31fe7a 100644 --- a/test/clojure/core_test/portability.cljc +++ b/test/clojure/core_test/portability.cljc @@ -14,6 +14,7 @@ ;; In CLJS, all numbers are really doubles and integer? and int? ;; return true if the fractional part of the double is zero #?(:cljs (integer? n) + :jank (cpp/jank.runtime.is_big_integer n) :default (and (integer? n) (not (int? n))))) diff --git a/test/clojure/core_test/star_squote.cljc b/test/clojure/core_test/star_squote.cljc index 4c3a151..882f908 100644 --- a/test/clojure/core_test/star_squote.cljc +++ b/test/clojure/core_test/star_squote.cljc @@ -1,7 +1,7 @@ (ns clojure.core-test.star-squote (:require [clojure.test :as t :refer [are deftest is]] [clojure.core-test.number-range :as r] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + [clojure.core-test.portability :as p #?(:cljs :refer-macros :default :refer) [when-var-exists]])) (when-var-exists *' (deftest test-*' @@ -70,20 +70,23 @@ 5 1N 5 5 1N 5N) - (is (thrown? #?(:cljs :default :default Exception) (*' 1 nil))) - (is (thrown? #?(:cljs :default :default Exception) (*' nil 1))) + #?(:jank [] + :default [(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (*' 1 nil))) + (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (*' nil 1)))]) - (is (instance? clojure.lang.BigInt (*' 0 1N))) - (is (instance? clojure.lang.BigInt (*' 0N 1))) - (is (instance? clojure.lang.BigInt (*' 0N 1N))) - (is (instance? clojure.lang.BigInt (*' 1N 1))) - (is (instance? clojure.lang.BigInt (*' 1 1N))) - (is (instance? clojure.lang.BigInt (*' 1N 1N))) - (is (instance? clojure.lang.BigInt (*' 1 5N))) - (is (instance? clojure.lang.BigInt (*' 1N 5))) - (is (instance? clojure.lang.BigInt (*' 1N 5N))) + (is (p/big-int? (*' 0 1N))) + (is (p/big-int? (*' 0N 1))) + (is (p/big-int? (*' 0N 1N))) + (is (p/big-int? (*' 1N 1))) + (is (p/big-int? (*' 1 1N))) + (is (p/big-int? (*' 1N 1N))) + (is (p/big-int? (*' 1 5N))) + (is (p/big-int? (*' 1N 5))) + (is (p/big-int? (*' 1N 5N))) - (is (instance? clojure.lang.BigInt (*' -1 r/min-int))) - (is (instance? clojure.lang.BigInt (*' r/min-int -1))) - (is (instance? clojure.lang.BigInt (*' (long (/ r/min-int 2)) 3))) - (is (instance? clojure.lang.BigInt (*' 3 (long (/ r/min-int 2))))))) + (is (p/big-int? (*' -1 r/min-int))) + (is (p/big-int? (*' r/min-int -1))) + #?(:jank nil ;; Currently `long` hasn't been ported in jank. + :default (is (p/big-int? (*' (long (/ r/min-int 2)) 3)))) + #?(:jank nil + :default (is (p/big-int? (*' 3 (long (/ r/min-int 2))))))))