From d4067bf7f26c68b11e64de48245bd0b6b103fe2f Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 10:47:09 -0700 Subject: [PATCH 01/13] Num take 0 --- project.clj | 5 +- test/clojure/core_test/num.cljc | 104 ++++++++++++++++++++++++++------ 2 files changed, 91 insertions(+), 18 deletions(-) diff --git a/project.clj b/project.clj index 8a948ae5..3e48fde0 100644 --- a/project.clj +++ b/project.clj @@ -3,6 +3,9 @@ :url "https://github.com/jank-lang/clojure-test-suite" :license {:name "MPL 2.0" :url "https://www.mozilla.org/en-US/MPL/2.0/"} + :clr {:main-cmd ["Clojure.Main"] + :compile-cmd ["Clojure.Compile"]} :dependencies [[org.clojure/clojure "1.12.0"] [org.clojure/clojurescript "1.12.42"]] - :plugins [[com.jakemccrary/lein-test-refresh "0.25.0"]]) + :plugins [[com.jakemccrary/lein-test-refresh "0.25.0"] + [lein-clr "0.2.2"]]) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index aab3d2ee..f7275d6b 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -1,26 +1,96 @@ (ns clojure.core-test.num - (:require [clojure.test :as t :refer [deftest is]] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + (:require [clojure.test :as t :refer [are deftest is testing]] + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]) + (:import #?(:cljr [Assigner AssignObject]))) + +(defn f []) + +#?(:clj + (do + (definterface IChecker + (isLong [^long l]) + (isLong [^Object l]) + + (isDouble [^double d]) + (isDouble [^Object d])) + + (deftype Checker [] + IChecker + (isLong [this ^long l] true) + (isLong [this ^Object l] false) + (isDouble [this ^double d] true) + (isDouble [this ^Object d] false)))) (when-var-exists num (deftest test-num + (testing "positive cases" #?@(:cljs [] :clj - ;; The compiler should pass `x` as a primitive to `num`. - [(let [x 1.0] - (is (instance? java.lang.Double (num x)))) - (let [x 1] - (is (instance? java.lang.Long (num x)))) + [(testing "longs" + (let [l (long 1) + L (num l) + checker (Checker.)] + (is (.isLong checker l)) + (is (false? (.isLong checker L))))) + (testing "doubles" + (let [d (double 1.0) + D (num d) + checker (Checker.)] + (is (.isDouble checker d)) + (is (false? (.isDouble checker D))))) ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. (is (instance? clojure.lang.BigInt (num 1N))) (is (instance? java.math.BigDecimal (num 1.0M)))] - :cljr - ;; The compiler should pass `x` as a primitive to `num`. - [(let [x 1.0] - (is (instance? System.Double (num x)))) - (let [x 1] - (is (instance? System.Int64 (num x)))) - ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. - (is (instance? clojure.lang.BigInt (num 1N))) - (is (instance? clojure.lang.BigDecimal (num 1.0M)))] - :default (is false "TODO test num")))) + ;; By default assume that other platforms are no-ops for numeric inputs + :default (are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (short 1) + (byte 1) + (int 1) + (long 1) + (float 1.0) + (double 1.0) + ##NaN + ##Inf)) + (testing "exceptions thrown" + ;; [[num]] is a true no-op in `cljr`, equivalent to [[identity]] + #?@(:cljs + nil + + :cljr + (are [x] (and (= x (num x)) + (= (type x) (type (num x)))) + (fn []) + f + {} + #{} + [] + '() + nil + \1 + \a + "" + "1" + #"" + 'a) + + :default + (are [x] (thrown? Exception (num x)) + (fn []) + f + {} + #{} + [] + '() + nil + \1 + \a + "" + "1" + #"" + 'a)))))) From 0b1aeb9c4c548de002901d92e6fb59e5b12215ca Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 10:49:43 -0700 Subject: [PATCH 02/13] Syntastix --- test/clojure/core_test/num.cljc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index f7275d6b..1c21baa6 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -59,7 +59,7 @@ ##Inf)) (testing "exceptions thrown" ;; [[num]] is a true no-op in `cljr`, equivalent to [[identity]] - #?@(:cljs + #?(:cljs nil :cljr @@ -76,8 +76,8 @@ \a "" "1" - #"" - 'a) + 'a + #"") :default (are [x] (thrown? Exception (num x)) @@ -92,5 +92,5 @@ \a "" "1" - #"" - 'a)))))) + 'a + #"")))))) From 3f0d530c95adeabbc0f5ba6d5d96b9d73714812f Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 10:53:16 -0700 Subject: [PATCH 03/13] nil is always the odd one out --- test/clojure/core_test/num.cljc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 1c21baa6..1bfd9231 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -55,6 +55,7 @@ (long 1) (float 1.0) (double 1.0) + nil ##NaN ##Inf)) (testing "exceptions thrown" @@ -71,7 +72,6 @@ #{} [] '() - nil \1 \a "" @@ -87,7 +87,6 @@ #{} [] '() - nil \1 \a "" From 36c066c54ee8e752f2ef0a8323e1e39336f1b7dd Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 10:56:10 -0700 Subject: [PATCH 04/13] kill dead code --- test/clojure/core_test/num.cljc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 1bfd9231..9b30de8a 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -1,7 +1,7 @@ (ns clojure.core-test.num (:require [clojure.test :as t :refer [are deftest is testing]] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]) - (:import #?(:cljr [Assigner AssignObject]))) + [clojure.core-test.portability + #?(:cljs :refer-macros :default :refer) [when-var-exists]])) (defn f []) From 66e3882f8a9784375a7da65c9e75c5143577eb3c Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 10:59:09 -0700 Subject: [PATCH 05/13] oop --- test/clojure/core_test/num.cljc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 9b30de8a..669b1eab 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -42,22 +42,22 @@ (is (instance? clojure.lang.BigInt (num 1N))) (is (instance? java.math.BigDecimal (num 1.0M)))] ;; By default assume that other platforms are no-ops for numeric inputs - :default (are [n] (and (= n (num n)) - (= (type n) (type (num n)))) - 0 - 0.1 - 1/2 - 1N - 1.0M - (short 1) - (byte 1) - (int 1) - (long 1) - (float 1.0) - (double 1.0) - nil - ##NaN - ##Inf)) + :default [(are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (short 1) + (byte 1) + (int 1) + (long 1) + (float 1.0) + (double 1.0) + nil + ##NaN + ##Inf)]) (testing "exceptions thrown" ;; [[num]] is a true no-op in `cljr`, equivalent to [[identity]] #?(:cljs From b69c305b40eff295803ee3be9c160cedd995b769 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:11:24 -0700 Subject: [PATCH 06/13] cljr does do something! --- test/clojure/core_test/num.cljc | 59 ++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 669b1eab..4ab40577 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -41,8 +41,28 @@ ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. (is (instance? clojure.lang.BigInt (num 1N))) (is (instance? java.math.BigDecimal (num 1.0M)))] + :cljr [(is (= ##NaN (num ##NaN))) + (is (NaN? (num ##NaN))) + (are [n] (and (= n (num n)) + (= (type (num n)) System.Int64)) + (short 1) + (byte 1)) + (are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (long 1) + (float 1.0) + (double 1.0) + nil + ##Inf)] ;; By default assume that other platforms are no-ops for numeric inputs - :default [(are [n] (and (= n (num n)) + :default [(is (= ##NaN (num ##NaN))) + (is (NaN? (num ##NaN))) + (are [n] (and (= n (num n)) (= (type n) (type (num n)))) 0 0.1 @@ -56,17 +76,15 @@ (float 1.0) (double 1.0) nil - ##NaN ##Inf)]) (testing "exceptions thrown" ;; [[num]] is a true no-op in `cljr`, equivalent to [[identity]] - #?(:cljs - nil + #?@(:cljs + [] :cljr - (are [x] (and (= x (num x)) - (= (type x) (type (num x)))) - (fn []) + [(are [x] (and (= x (num x)) + (= (type x) (type (num x)))) f {} #{} @@ -78,18 +96,19 @@ "1" 'a #"") + (is (fn? (num (fn []))))] :default - (are [x] (thrown? Exception (num x)) - (fn []) - f - {} - #{} - [] - '() - \1 - \a - "" - "1" - 'a - #"")))))) + [(are [x] (thrown? Exception (num x)) + (fn []) + f + {} + #{} + [] + '() + \1 + \a + "" + "1" + 'a + #"")]))))) From 4e1d103676da2b289acddd94f7d2d4482c956819 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:16:28 -0700 Subject: [PATCH 07/13] cljr time --- test/clojure/core_test/num.cljc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 4ab40577..c183efc4 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -43,10 +43,12 @@ (is (instance? java.math.BigDecimal (num 1.0M)))] :cljr [(is (= ##NaN (num ##NaN))) (is (NaN? (num ##NaN))) + (is (= (byte 1) (num (byte 1)))) + (is (= System.UInt64 (type (num (byte 1))))) (are [n] (and (= n (num n)) (= (type (num n)) System.Int64)) (short 1) - (byte 1)) + (int 1)) (are [n] (and (= n (num n)) (= (type n) (type (num n)))) 0 @@ -78,7 +80,8 @@ nil ##Inf)]) (testing "exceptions thrown" - ;; [[num]] is a true no-op in `cljr`, equivalent to [[identity]] + ;; [[num]] is *almost* a true no-op in `cljr`, equivalent to [[identity]], + ;; except that it will upcast to System.Int64/System.UInt64 #?@(:cljs [] From fb6d895bc19e2a6ddc13c88867401ced3238e35f Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:20:50 -0700 Subject: [PATCH 08/13] NaN of that --- test/clojure/core_test/num.cljc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index c183efc4..6949cb33 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -41,8 +41,7 @@ ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. (is (instance? clojure.lang.BigInt (num 1N))) (is (instance? java.math.BigDecimal (num 1.0M)))] - :cljr [(is (= ##NaN (num ##NaN))) - (is (NaN? (num ##NaN))) + :cljr [(is (NaN? (num ##NaN))) (is (= (byte 1) (num (byte 1)))) (is (= System.UInt64 (type (num (byte 1))))) (are [n] (and (= n (num n)) From 35c84ac34073a9eb3e9e819040674f45ec3e5e6c Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:24:02 -0700 Subject: [PATCH 09/13] Fix bb --- test/clojure/core_test/num.cljc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 6949cb33..42a7b15a 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -5,7 +5,10 @@ (defn f []) -#?(:clj +#?(:bb + nil + + :clj (do (definterface IChecker (isLong [^long l]) From abd227fe4d1c2530dd8f413e87f041476695154f Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:25:01 -0700 Subject: [PATCH 10/13] underscores!! --- test/clojure/core_test/num.cljc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index 42a7b15a..d60f63e6 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -19,10 +19,10 @@ (deftype Checker [] IChecker - (isLong [this ^long l] true) - (isLong [this ^Object l] false) - (isDouble [this ^double d] true) - (isDouble [this ^Object d] false)))) + (isLong [_this ^long _l] true) + (isLong [_this ^Object _l] false) + (isDouble [_this ^double _d] true) + (isDouble [_this ^Object _d] false)))) (when-var-exists num (deftest test-num From 658230ff7df1e2eb5c433c0b514fc05e237e2beb Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:28:42 -0700 Subject: [PATCH 11/13] Add :bb case --- test/clojure/core_test/num.cljc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index d60f63e6..a326e414 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -27,7 +27,28 @@ (when-var-exists num (deftest test-num (testing "positive cases" - #?@(:cljs [] + #?@(:bb + [(is (= ##NaN (num ##NaN))) + (is (NaN? (num ##NaN))) + (are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (short 1) + (byte 1) + (int 1) + (long 1) + (float 1.0) + (double 1.0) + nil + ##Inf)] + + :cljs + [] + :clj [(testing "longs" (let [l (long 1) @@ -44,6 +65,7 @@ ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. (is (instance? clojure.lang.BigInt (num 1N))) (is (instance? java.math.BigDecimal (num 1.0M)))] + :cljr [(is (NaN? (num ##NaN))) (is (= (byte 1) (num (byte 1)))) (is (= System.UInt64 (type (num (byte 1))))) @@ -63,6 +85,7 @@ (double 1.0) nil ##Inf)] + ;; By default assume that other platforms are no-ops for numeric inputs :default [(is (= ##NaN (num ##NaN))) (is (NaN? (num ##NaN))) From 2bd9447477288ee986e6484b7ebeba1c41e21d55 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:31:57 -0700 Subject: [PATCH 12/13] NaN again --- test/clojure/core_test/num.cljc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index a326e414..c85958a4 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -28,8 +28,7 @@ (deftest test-num (testing "positive cases" #?@(:bb - [(is (= ##NaN (num ##NaN))) - (is (NaN? (num ##NaN))) + [(is (NaN? (num ##NaN))) (are [n] (and (= n (num n)) (= (type n) (type (num n)))) 0 @@ -87,8 +86,7 @@ ##Inf)] ;; By default assume that other platforms are no-ops for numeric inputs - :default [(is (= ##NaN (num ##NaN))) - (is (NaN? (num ##NaN))) + :default [(is (NaN? (num ##NaN))) (are [n] (and (= n (num n)) (= (type n) (type (num n)))) 0 From c411ed86fc14321c1e9c48c6f6e41f08eae4e024 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Wed, 26 Nov 2025 11:38:40 -0700 Subject: [PATCH 13/13] Indentation, all around the nation --- test/clojure/core_test/num.cljc | 210 ++++++++++++++++---------------- 1 file changed, 105 insertions(+), 105 deletions(-) diff --git a/test/clojure/core_test/num.cljc b/test/clojure/core_test/num.cljc index c85958a4..9727c041 100644 --- a/test/clojure/core_test/num.cljc +++ b/test/clojure/core_test/num.cljc @@ -27,114 +27,114 @@ (when-var-exists num (deftest test-num (testing "positive cases" - #?@(:bb - [(is (NaN? (num ##NaN))) - (are [n] (and (= n (num n)) - (= (type n) (type (num n)))) - 0 - 0.1 - 1/2 - 1N - 1.0M - (short 1) - (byte 1) - (int 1) - (long 1) - (float 1.0) - (double 1.0) - nil - ##Inf)] + #?@(:bb + [(is (NaN? (num ##NaN))) + (are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (short 1) + (byte 1) + (int 1) + (long 1) + (float 1.0) + (double 1.0) + nil + ##Inf)] - :cljs - [] - - :clj - [(testing "longs" - (let [l (long 1) - L (num l) - checker (Checker.)] - (is (.isLong checker l)) - (is (false? (.isLong checker L))))) - (testing "doubles" - (let [d (double 1.0) - D (num d) - checker (Checker.)] - (is (.isDouble checker d)) - (is (false? (.isDouble checker D))))) - ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. - (is (instance? clojure.lang.BigInt (num 1N))) - (is (instance? java.math.BigDecimal (num 1.0M)))] + :cljs + [] - :cljr [(is (NaN? (num ##NaN))) - (is (= (byte 1) (num (byte 1)))) - (is (= System.UInt64 (type (num (byte 1))))) - (are [n] (and (= n (num n)) - (= (type (num n)) System.Int64)) - (short 1) - (int 1)) - (are [n] (and (= n (num n)) - (= (type n) (type (num n)))) - 0 - 0.1 - 1/2 - 1N - 1.0M - (long 1) - (float 1.0) - (double 1.0) - nil - ##Inf)] + :clj + [(testing "longs" + (let [l (long 1) + L (num l) + checker (Checker.)] + (is (.isLong checker l)) + (is (false? (.isLong checker L))))) + (testing "doubles" + (let [d (double 1.0) + D (num d) + checker (Checker.)] + (is (.isDouble checker d)) + (is (false? (.isDouble checker D))))) + ;; `BigInt` and `BigDecimal` are always boxed and `num` just returns them as-is. + (is (instance? clojure.lang.BigInt (num 1N))) + (is (instance? java.math.BigDecimal (num 1.0M)))] - ;; By default assume that other platforms are no-ops for numeric inputs - :default [(is (NaN? (num ##NaN))) - (are [n] (and (= n (num n)) - (= (type n) (type (num n)))) - 0 - 0.1 - 1/2 - 1N - 1.0M - (short 1) - (byte 1) - (int 1) - (long 1) - (float 1.0) - (double 1.0) - nil - ##Inf)]) - (testing "exceptions thrown" - ;; [[num]] is *almost* a true no-op in `cljr`, equivalent to [[identity]], - ;; except that it will upcast to System.Int64/System.UInt64 - #?@(:cljs - [] + :cljr [(is (NaN? (num ##NaN))) + (is (= (byte 1) (num (byte 1)))) + (is (= System.UInt64 (type (num (byte 1))))) + (are [n] (and (= n (num n)) + (= (type (num n)) System.Int64)) + (short 1) + (int 1)) + (are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (long 1) + (float 1.0) + (double 1.0) + nil + ##Inf)] - :cljr - [(are [x] (and (= x (num x)) - (= (type x) (type (num x)))) - f - {} - #{} + ;; By default assume that other platforms are no-ops for numeric inputs + :default [(is (NaN? (num ##NaN))) + (are [n] (and (= n (num n)) + (= (type n) (type (num n)))) + 0 + 0.1 + 1/2 + 1N + 1.0M + (short 1) + (byte 1) + (int 1) + (long 1) + (float 1.0) + (double 1.0) + nil + ##Inf)]) + (testing "exceptions thrown" + ;; [[num]] is *almost* a true no-op in `cljr`, equivalent to [[identity]], + ;; except that it will upcast to System.Int64/System.UInt64 + #?@(:cljs [] - '() - \1 - \a - "" - "1" - 'a - #"") - (is (fn? (num (fn []))))] - :default - [(are [x] (thrown? Exception (num x)) - (fn []) - f - {} - #{} - [] - '() - \1 - \a - "" - "1" - 'a - #"")]))))) + :cljr + [(are [x] (and (= x (num x)) + (= (type x) (type (num x)))) + f + {} + #{} + [] + '() + \1 + \a + "" + "1" + 'a + #"") + (is (fn? (num (fn []))))] + + :default + [(are [x] (thrown? Exception (num x)) + (fn []) + f + {} + #{} + [] + '() + \1 + \a + "" + "1" + 'a + #"")])))))