From 076c2d4698e78b84615b1bad417e64333fcdee4f Mon Sep 17 00:00:00 2001 From: David Miller Date: Fri, 5 Sep 2025 14:34:24 -0400 Subject: [PATCH 1/9] Additional edits for ClojureCLR tests --- deps-clr.edn | 11 +++++ test/clojure/core_test/byte.cljc | 44 ++++++++++++------- test/clojure/core_test/double.cljc | 7 ++- test/clojure/core_test/int.cljc | 33 +++++++++----- test/clojure/core_test/shuffle.cljc | 12 +++-- test/clojure/core_test/str.cljc | 15 ++++++- test/clojure/core_test/with_out_str.cljc | 18 +++++++- test/clojure/string_test/blank_qmark.cljc | 4 +- test/clojure/string_test/capitalize.cljc | 4 ++ test/clojure/string_test/ends_with_qmark.cljc | 28 +++++++++--- test/clojure/string_test/lower_case.cljc | 3 ++ .../string_test/starts_with_qmark.cljc | 43 +++++++++++------- test/clojure/string_test/upper_case.cljc | 4 ++ 13 files changed, 168 insertions(+), 58 deletions(-) create mode 100644 deps-clr.edn diff --git a/deps-clr.edn b/deps-clr.edn new file mode 100644 index 0000000..f5e87f7 --- /dev/null +++ b/deps-clr.edn @@ -0,0 +1,11 @@ +{:deps {} + + :aliases + {:test + {:extra-paths ["test"] + :extra-deps {io.github.dmiller/test-runner {:git/sha "c055ea13d19c6a9b9632aa2370fcc2215c8043c3"}} + ;; :main-opts {"-m" "cognitect.test-runner" "-d" "test"} + :exec-fn cognitect.test-runner.api/test + :exec-args {:dirs ["test"] + :patterns [".*test.*"]}}} + } \ No newline at end of file diff --git a/test/clojure/core_test/byte.cljc b/test/clojure/core_test/byte.cljc index 4987998..98a1960 100644 --- a/test/clojure/core_test/byte.cljc +++ b/test/clojure/core_test/byte.cljc @@ -13,16 +13,17 @@ :cljr (is (instance? System.Byte (byte 0)))) ;; Check conversions and rounding from other numeric types + ;; In ClojureCLR, Byte is unsigned, so we have to wipe all tests of negative values (are [expected x] (= expected (byte x)) - -128 -128 + #?@(:cljr [] :default [-128 -128]) 0 0 127 127 1 1N 0 0N - -1 -1N + #?@(:cljr [] :default [-1 -1N]) 1 1.0M 0 0.0M - -1 -1.0M + #?@(:cljr [] :default [-1 -1.0M]) ;; Clojurescript `byte` is a "dummy cast" which doesn't do ;; anything (no-op). Thus, there is no conversion, no truncation ;; of decimal values, etc. @@ -34,14 +35,14 @@ -1.1 -1.1M] :default [1 1.1 - -1 -1.1 + #?@(:cljr [] :default [-1 -1.1]) 1 1.9 1 3/2 - -1 -3/2 + #?@(:cljr [] :default [-1 -3/2]) 0 1/10 - 0 -1/10 + #?@(:cljr [] :default [0 -1/10]) 1 1.1M - -1 -1.1M])) + #?@(:cljr [] :default [-1 -1.1M])])) #?@(:cljs [ ;; ClojureScript `byte` just returns its argument @@ -53,15 +54,26 @@ (is (= :0 (byte :0))) (is (= [0] (byte [0]))) (is (= nil (byte nil)))] - :bb [] ;; byte constructions goes via boxed argument + :cljr + [ ;; `byte` throws outside the range of 127 ... -128. + (is (thrown? Exception (byte -128.000001))) + (is (thrown? Exception (byte -129))) + (is (= 128 (byte 128))) + (is (= 127(byte 127.000001))) + ;; Check handling of other types + (is (= 0 (byte "0"))) + (is (thrown? Exception (byte :0))) + (is (thrown? Exception (byte [0]))) + (is (thrown? Exception (byte nil)))] + :bb [] ;; byte constructions goes via boxed argument :default [ ;; `byte` throws outside the range of 127 ... -128. - (is (thrown? #?(:clj Exception :cljr Exception) (byte -128.000001))) - (is (thrown? #?(:clj Exception :cljr Exception) (byte -129))) - (is (thrown? #?(:clj Exception :cljr Exception) (byte 128))) - (is (thrown? #?(:clj Exception :cljr Exception) (byte 127.000001))) + (is (thrown? Exception (byte -128.000001))) + (is (thrown? Exception (byte -129))) + (is (thrown? Exception (byte 128))) + (is (thrown? Exception (byte 127.000001))) ;; Check handling of other types - (is (thrown? #?(:clj Exception :cljr Exception) (byte "0"))) - (is (thrown? #?(:clj Exception :cljr Exception) (byte :0))) - (is (thrown? #?(:clj Exception :cljr Exception) (byte [0]))) - (is (thrown? #?(:clj Exception :cljr Exception) (byte nil)))]))) + (is (thrown? Exception (byte "0"))) + (is (thrown? Exception (byte :0))) + (is (thrown? Exception (byte [0]))) + (is (thrown? Exception (byte nil)))]))) diff --git a/test/clojure/core_test/double.cljc b/test/clojure/core_test/double.cljc index e554032..65f51f0 100644 --- a/test/clojure/core_test/double.cljc +++ b/test/clojure/core_test/double.cljc @@ -23,9 +23,12 @@ ;; In cljs, `double` is just returns the argument unchanged (dummy fn) [(is (= "0" (double "0"))) (is (= :0 (double :0)))] + :cljr + [(is (= 0.0 (double "0"))) + (is (thrown? Exception (double :0)))] :default - [(is (thrown? #?(:clj Exception :cljr Exception) (double "0"))) - (is (thrown? #?(:clj Exception :cljr Exception) (double :0)))]) + [(is (thrown? Exception (double "0"))) + (is (thrown? Exception (double :0)))]) #?@(:clj [(is (instance? java.lang.Double (double 0))) diff --git a/test/clojure/core_test/int.cljc b/test/clojure/core_test/int.cljc index cc1e8c9..d8928e9 100644 --- a/test/clojure/core_test/int.cljc +++ b/test/clojure/core_test/int.cljc @@ -11,7 +11,8 @@ ;; predicate for it. Here, we just test whether it's a fixed-length ;; integer of some sort. (is (int? (int 0))) - #?(:clj (is (instance? java.lang.Integer (int 0)))) + #?(:clj (is (instance? java.lang.Integer (int 0))) + :cljr (is (instance? System.Int32 (int 0)))) ;; Check conversions and rounding from other numeric types (are [expected x] (= expected (int x)) @@ -40,16 +41,28 @@ 0 -1/10])) #?@(:cljs [] - :bb [] + :bb [] + :cljr + [ ;; `int` throws outside the range of 32767 ... -32768. + (is (thrown? Exception (int -2147483648.000001))) + (is (thrown? Exception (int -2147483649))) + (is (thrown? Exception (int 2147483648))) + (is (thrown? Exception (int 2147483647.000001))) + + ;; Check handling of other types + (is (= 0 (int "0"))) + (is (thrown? Exception (int :0))) + (is (thrown? Exception (int [0]))) + (is (thrown? Exception (int nil)))] :default [ ;; `int` throws outside the range of 32767 ... -32768. - (is (thrown? #?(:clj Exception :cljr Exception) (int -2147483648.000001))) - (is (thrown? #?(:clj Exception :cljr Exception) (int -2147483649))) - (is (thrown? #?(:clj Exception :cljr Exception) (int 2147483648))) - (is (thrown? #?(:clj Exception :cljr Exception) (int 2147483647.000001))) + (is (thrown? Exception (int -2147483648.000001))) + (is (thrown? Exception (int -2147483649))) + (is (thrown? Exception (int 2147483648))) + (is (thrown? Exception (int 2147483647.000001))) ;; Check handling of other types - (is (thrown? #?(:clj Exception :cljr Exception) (int "0"))) - (is (thrown? #?(:clj Exception :cljr Exception) (int :0))) - (is (thrown? #?(:clj Exception :cljr Exception) (int [0]))) - (is (thrown? #?(:clj Exception :cljr Exception) (int nil)))]))) + (is (thrown? Exception (int "0"))) + (is (thrown? Exception (int :0))) + (is (thrown? Exception (int [0]))) + (is (thrown? Exception (int nil)))]))) diff --git a/test/clojure/core_test/shuffle.cljc b/test/clojure/core_test/shuffle.cljc index c266698..3029e2d 100644 --- a/test/clojure/core_test/shuffle.cljc +++ b/test/clojure/core_test/shuffle.cljc @@ -23,11 +23,15 @@ (is (vector? actual)) (is (= (count x) (count actual)))))) (testing "negative cases" - (is (thrown? #?(:cljs :default, :default Exception) (shuffle 1))) + (is (thrown? Exception (shuffle 1))) #?@(:cljs [(is (= [] (shuffle nil))) (is [] (shuffle {}))] + :cljr + [(is (thrown? Exception (shuffle nil))) + (is (thrown? Exception (shuffle "abc"))) + (is (= [](shuffle {})))] :default - [(is (thrown? #?(:cljs :default, :default Exception) (shuffle nil))) - (is (thrown? #?(:cljs :default, :default Exception) (shuffle "abc"))) - (is (thrown? #?(:cljs :default, :default Exception) (shuffle {})))])))) + [(is (thrown? Exception (shuffle nil))) + (is (thrown? Exception (shuffle "abc"))) + (is (thrown? Exception (shuffle {})))])))) diff --git a/test/clojure/core_test/str.cljc b/test/clojure/core_test/str.cljc index d7b1363..87179a6 100644 --- a/test/clojure/core_test/str.cljc +++ b/test/clojure/core_test/str.cljc @@ -19,6 +19,17 @@ "0" (double 0.0) "1" (double 1.0) "-1" (double -1.0)] + :cljr + ["0" 0.0 + "1" 1.0 + "-1" -1.0 + "0" 0.00000 + "0" (float 0.0) + "1" (float 1.0) + "-1" (float -1.0) + "0" (double 0.0) + "1" (double 1.0) + "-1" (double -1.0)] :default ["0.0" 0.0 "1.0" 1.0 @@ -49,8 +60,8 @@ "-1.0" -1.0M]) "" nil - "true" true - "false" false + #?(:cljr "True" :default "true") true + #?(:cljr "False" :default "false") false "a string" "a string" "0" "0" "1" "1" diff --git a/test/clojure/core_test/with_out_str.cljc b/test/clojure/core_test/with_out_str.cljc index 3d9bc5c..6bc26fb 100644 --- a/test/clojure/core_test/with_out_str.cljc +++ b/test/clojure/core_test/with_out_str.cljc @@ -2,10 +2,24 @@ (:require [clojure.test :as t :refer [deftest testing is are]] [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) +;; This is part of clojure.test-helpers, but I couldn't figure out how to :require or :use that library. +;; Copied here for now + +#?(:cljr + (let [nl Environment/NewLine] ;;; (System/getProperty "line.separator")] + (defn platform-newlines [s] (.Replace ^String s "\n" nl))) ;;; .replace, add type hint + :clj + (let [nl (System/getProperty "line.separator")] + (defn platform-newlines [s] (.replace s "\n" nl))) + :default ;; does ClojureScript have its own version? + (defn platform-newlines [s] s)) + + + (when-var-exists clojure.core/with-out-str (deftest test-with-out-str - (is (= (str "some sample :text here" \newline - "[:a :b] {:c :d} #{:e} (:f)" \newline) + (is (= (platform-newlines (str "some sample :text here" \newline + "[:a :b] {:c :d} #{:e} (:f)" \newline)) (with-out-str (println "some" "sample" :text 'here) (prn [:a :b] {:c :d} #{:e} '(:f))))))) diff --git a/test/clojure/string_test/blank_qmark.cljc b/test/clojure/string_test/blank_qmark.cljc index 085320f..6d10240 100644 --- a/test/clojure/string_test/blank_qmark.cljc +++ b/test/clojure/string_test/blank_qmark.cljc @@ -9,8 +9,8 @@ (is (true? (str/blank? nil))) (is (false? (str/blank? "֎"))) (testing "U+2007" - (is (#?(:cljs true? :cljr true :default false?) (str/blank? " "))) - (is (#?(:cljs true? :cljr true :default false?) (str/blank? "\u2007")))) + (is (#?(:cljs true? :cljr true? :default false?) (str/blank? " "))) + (is (#?(:cljs true? :cljr true? :default false?) (str/blank? "\u2007")))) (is (true? (str/blank? " "))) (is (true? (str/blank? " \t "))) #?(:cljs (do (is (true? (str/blank? (symbol "")))) diff --git a/test/clojure/string_test/capitalize.cljc b/test/clojure/string_test/capitalize.cljc index b5496e1..0332c60 100644 --- a/test/clojure/string_test/capitalize.cljc +++ b/test/clojure/string_test/capitalize.cljc @@ -11,6 +11,10 @@ (is (thrown? :default (str/capitalize 'a/a))) (is (thrown? :default (str/capitalize :a))) (is (thrown? :default (str/capitalize :a/a)))) + :cljr (do (is (thrown? Exception (str/capitalize 1))) + (is (thrown? Exception (str/capitalize 'Asdf))) + (is (thrown? Exception (str/capitalize 'asDf/aSdf))) + (is (thrown? Exception (str/capitalize :asDf/aSdf)))) :default (do (is (= "1" (str/capitalize 1))) (is (= "Asdf" (str/capitalize 'Asdf))) (is (= "Asdf/asdf" (str/capitalize 'asDf/aSdf))) diff --git a/test/clojure/string_test/ends_with_qmark.cljc b/test/clojure/string_test/ends_with_qmark.cljc index fdb1a65..4b9e4a9 100644 --- a/test/clojure/string_test/ends_with_qmark.cljc +++ b/test/clojure/string_test/ends_with_qmark.cljc @@ -7,16 +7,34 @@ (deftest test-ends-with? (is (true? (str/ends-with? "" ""))) (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (str/ends-with? "" nil))) - (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (str/ends-with? nil ""))) + + #?(:cljs (is (thrown? :default (str/ends-with? nil ""))) + :cljr (is (true? (str/ends-with? nil ""))) + :default (is (thrown? :default (str/ends-with? nil "")))) + #?(:cljs (do (is (false? (str/ends-with? "ab" :b))) (is (false? (str/ends-with? "ab" :a)))) :default (is (thrown? #?(:clj Exception :cljr Exception) (str/ends-with? "ab" :b)))) + #?(:cljs (is (false? (str/ends-with? "ab" 'b))) :default (is (thrown? #?(:clj Exception :cljr Exception) (str/ends-with? "ab" 'b)))) - (is (#?(:cljs false? :default true?) (str/ends-with? 'ab "b"))) - (is (false? (str/ends-with? 'ab "a"))) - (is (#?(:cljs false? :default true?) (str/ends-with? :ab "b"))) - (is (false? (str/ends-with? :ab "a"))) + + #?@(:cljs + [(is (false? (str/ends-with? 'ab "b"))) + (is (false? (str/ends-with? 'ab "a"))) + (is (false? (str/ends-with? :ab "b"))) + (is (false? (str/ends-with? :ab "a")))] + :cljr + [(is (thrown? Exception (str/ends-with? 'ab "b"))) + (is (thrown? Exception (str/ends-with? 'ab "a"))) + (is (thrown? Exception (str/ends-with? :ab "b"))) + (is (thrown? Exception (str/ends-with? :ab "b")))] + :default + [(is (true? (str/ends-with? 'ab "b"))) + (is (false? (str/ends-with? 'ab "a"))) + (is (true? (str/ends-with? :ab "b"))) + (is (false? (str/ends-with? :ab "a")))]) + (is (false? (str/ends-with? "" "a"))) (is (true? (str/ends-with? "a-test" ""))) (is (true? (str/ends-with? "a-test֎" "֎"))) diff --git a/test/clojure/string_test/lower_case.cljc b/test/clojure/string_test/lower_case.cljc index 99421f1..a5dad62 100644 --- a/test/clojure/string_test/lower_case.cljc +++ b/test/clojure/string_test/lower_case.cljc @@ -14,8 +14,11 @@ (is (= "asdf" (str/lower-case "ASDF"))) (is (= "ASDF" s) "original string mutated")) #?(:cljs (is (thrown? :default (str/lower-case :ASDF))) + :cljr :cljs (is (thrown? Exception (str/lower-case :ASDF))) :default (is (= ":asdf" (str/lower-case :ASDF)))) #?(:cljs (is (thrown? :default (str/lower-case :ASDF/ASDF))) + :cljr (is (thrown? Exception (str/lower-case :ASDF/ASDF))) :default (is (= ":asdf/asdf" (str/lower-case :ASDF/ASDF)))) #?(:cljs (is (thrown? :default (str/lower-case 'ASDF))) + :cljr (is (thrown? Exception (str/lower-case 'ASDF))) :default (is (= "asdf" (str/lower-case 'ASDF)))))) diff --git a/test/clojure/string_test/starts_with_qmark.cljc b/test/clojure/string_test/starts_with_qmark.cljc index 5563b6e..ca27b1c 100644 --- a/test/clojure/string_test/starts_with_qmark.cljc +++ b/test/clojure/string_test/starts_with_qmark.cljc @@ -8,13 +8,18 @@ (is (true? (str/starts-with? "" ""))) #?(:cljs (is (false? (str/starts-with? "" nil))) :default (is (thrown? #?(:clj Exception :cljr Exception) (str/starts-with? "" nil)))) - (is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (str/starts-with? nil ""))) + + #?(:cljs (is (thrown? :default (str/starts-with? nil ""))) + :cljr (is (true? (str/starts-with? nil ""))) + :default (is (thrown? :default (str/starts-with? nil "")))) + #?(:cljs (do (is (false? (str/starts-with? "ab" :a))) (is (true? (str/starts-with? ":ab" :a))) (is (false? (str/starts-with? "ab" :b)))) :default (is (thrown? #?(:clj Exception :cljr Exception) (str/starts-with? "ab" :a)))) #?(:cljs (is (true? (str/starts-with? "ab" 'a))) :default (is (thrown? #?(:clj Exception :cljr Exception) (str/starts-with? "a" 'a)))) + (is (false? (str/starts-with? "" "a"))) (is (true? (str/starts-with? "a-test" ""))) (is (true? (str/starts-with? "֎a-test" "֎"))) @@ -22,17 +27,25 @@ (is (true? (str/starts-with? "a-test" "a-test"))) (is (false? (str/starts-with? "a-test" "-"))) (is (false? (str/starts-with? "a-test" "t"))) - #?(:cljs (is (thrown? :default (str/starts-with? 'ab ":a"))) - :default (do (is (false? (str/starts-with? 'ab "b"))) - (is (true? (str/starts-with? 'ab "a"))))) - #?(:cljs (is (thrown? :default (str/starts-with? :ab ":a"))) - :default (do (is (false? (str/starts-with? :ab "b"))) - (is (false? (str/starts-with? :ab "a"))) - (is (true? (str/starts-with? :ab ":a"))))) - #?(:cljs (is (thrown? :default (str/starts-with? 'a/b ":a"))) - :default (do (is (false? (str/starts-with? 'a/b "b"))) - (is (true? (str/starts-with? 'a/b "a"))))) - #?(:cljs (is (thrown? :default (str/starts-with? :a/b ":a"))) - :default (do (is (false? (str/starts-with? :a/b "b"))) - (is (false? (str/starts-with? :a/b "a"))) - (is (true? (str/starts-with? :a/b ":a"))))))) + + #?@(:cljs + [(is (thrown? :default (str/starts-with? 'ab ":a"))) + (is (thrown? :default (str/starts-with? :ab ":a"))) + (is (thrown? :default (str/starts-with? 'a/b ":a"))) + (is (thrown? :default (str/starts-with? :a/b ":a")))] + :cljr + [(is (thrown? Exception (str/starts-with? 'ab ":a"))) + (is (thrown? Exception (str/starts-with? :ab ":a"))) + (is (thrown? Exception (str/starts-with? 'a/b ":a"))) + (is (thrown? Exception (str/starts-with? :a/b ":a")))] + :default + [(is (false? (str/starts-with? 'ab "b"))) + (is (true? (str/starts-with? 'ab "a"))) + (is (false? (str/starts-with? :ab "b"))) + (is (false? (str/starts-with? :ab "a"))) + (is (true? (str/starts-with? :ab ":a"))) + (is (false? (str/starts-with? 'a/b "b"))) + (is (true? (str/starts-with? 'a/b "a"))) + (is (false? (str/starts-with? :a/b "b"))) + (is (false? (str/starts-with? :a/b "a"))) + (is (true? (str/starts-with? :a/b ":a")))]))) \ No newline at end of file diff --git a/test/clojure/string_test/upper_case.cljc b/test/clojure/string_test/upper_case.cljc index 8bad599..16c6ab2 100644 --- a/test/clojure/string_test/upper_case.cljc +++ b/test/clojure/string_test/upper_case.cljc @@ -14,10 +14,14 @@ (is (= "ASDF" (str/upper-case "asdf"))) (is (= "asdf" s) "original string mutated")) #?(:cljs (is (thrown? :default (str/upper-case :asdf))) + :cljr (is (thrown? Exception (str/upper-case :asdf))) :default (is (= ":ASDF" (str/upper-case :asdf)))) #?(:cljs (is (thrown? :default (str/upper-case :asdf/asdf))) + :cljr (is (thrown? Exception (str/upper-case :asdf/asdf))) :default (is (= ":ASDF/ASDF" (str/upper-case :asdf/asdf)))) #?(:cljs (is (thrown? :default (str/upper-case 'asdf))) + :cljr (is (thrown? Exception (str/upper-case 'asdf))) :default (is (= "ASDF" (str/upper-case 'asdf)))) #?(:cljs (is (thrown? :default (str/upper-case 'asdf/asdf))) + :cljr (is (thrown? Exception (str/upper-case 'asdf/asdf))) :default (is (= "ASDF/ASDF" (str/upper-case 'asdf/asdf)))))) From 66957f7aa7777e490decaea188e4cb2ffe5da1b2 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Fri, 5 Sep 2025 21:17:47 -0600 Subject: [PATCH 2/9] Fix formatting --- deps-clr.edn | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/deps-clr.edn b/deps-clr.edn index f5e87f7..d8bcb98 100644 --- a/deps-clr.edn +++ b/deps-clr.edn @@ -1,11 +1,8 @@ {:deps {} - - :aliases - {:test - {:extra-paths ["test"] - :extra-deps {io.github.dmiller/test-runner {:git/sha "c055ea13d19c6a9b9632aa2370fcc2215c8043c3"}} - ;; :main-opts {"-m" "cognitect.test-runner" "-d" "test"} - :exec-fn cognitect.test-runner.api/test - :exec-args {:dirs ["test"] - :patterns [".*test.*"]}}} - } \ No newline at end of file + :aliases + {:test + {:extra-paths ["test"] + :extra-deps {io.github.dmiller/test-runner {:git/sha "c055ea13d19c6a9b9632aa2370fcc2215c8043c3"}} + :exec-fn cognitect.test-runner.api/test + :exec-args {:dirs ["test"] + :patterns [".*test.*"]}}}} From 029111cb5500f90daeb8373ef03dab284e68e06f Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Sat, 6 Sep 2025 13:30:13 -0600 Subject: [PATCH 3/9] Cleanup with-out-str --- test/clojure/core_test/with_out_str.cljc | 32 +++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/test/clojure/core_test/with_out_str.cljc b/test/clojure/core_test/with_out_str.cljc index 6bc26fb..801a02b 100644 --- a/test/clojure/core_test/with_out_str.cljc +++ b/test/clojure/core_test/with_out_str.cljc @@ -1,25 +1,27 @@ (ns clojure.core-test.with-out-str - (:require [clojure.test :as t :refer [deftest testing is are]] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + (:require [clojure.test :as t :refer [deftest is]] + [clojure.core-test.portability + #?(:cljs :refer-macros :default :refer) [when-var-exists]])) -;; This is part of clojure.test-helpers, but I couldn't figure out how to :require or :use that library. +;; This is part of clojure.test-helpers, but I couldn't figure out how to +;; :require or :use that library. ;; Copied here for now - -#?(:cljr - (let [nl Environment/NewLine] ;;; (System/getProperty "line.separator")] - (defn platform-newlines [s] (.Replace ^String s "\n" nl))) ;;; .replace, add type hint - :clj - (let [nl (System/getProperty "line.separator")] - (defn platform-newlines [s] (.replace s "\n" nl))) - :default ;; does ClojureScript have its own version? - (defn platform-newlines [s] s)) - +(defn platform-newlines [s] + #?(:clj + (let [nl (System/getProperty "line.separator")] + (.replace s "\n" nl)) + :cljr + (let [nl Environment/NewLine] ;;; (System/getProperty "line.separator")] + (.Replace ^String s "\n" nl)) ;;; .replace, add type hint + :default + s)) (when-var-exists clojure.core/with-out-str (deftest test-with-out-str - (is (= (platform-newlines (str "some sample :text here" \newline - "[:a :b] {:c :d} #{:e} (:f)" \newline)) + (is (= (platform-newlines + (str "some sample :text here" \newline + "[:a :b] {:c :d} #{:e} (:f)" \newline)) (with-out-str (println "some" "sample" :text 'here) (prn [:a :b] {:c :d} #{:e} '(:f))))))) From 23711b3d9c4cda7abba0b4b358b1f4f36397025d Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Sat, 6 Sep 2025 13:33:11 -0600 Subject: [PATCH 4/9] Cleanup blank_qmark --- test/clojure/string_test/blank_qmark.cljc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/clojure/string_test/blank_qmark.cljc b/test/clojure/string_test/blank_qmark.cljc index 6d10240..fbf9444 100644 --- a/test/clojure/string_test/blank_qmark.cljc +++ b/test/clojure/string_test/blank_qmark.cljc @@ -1,7 +1,8 @@ (ns clojure.string-test.blank-qmark (:require [clojure.string :as str] - [clojure.test :as t :refer [deftest testing is are]] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + [clojure.test :as t :refer [deftest testing is]] + [clojure.core-test.portability + #?(:cljs :refer-macros :default :refer) [when-var-exists]])) (when-var-exists str/blank? (deftest test-blank? @@ -10,7 +11,7 @@ (is (false? (str/blank? "֎"))) (testing "U+2007" (is (#?(:cljs true? :cljr true? :default false?) (str/blank? " "))) - (is (#?(:cljs true? :cljr true? :default false?) (str/blank? "\u2007")))) + (is (#?(:cljs true? :cljr true? :default false?) (str/blank? "\u2007")))) (is (true? (str/blank? " "))) (is (true? (str/blank? " \t "))) #?(:cljs (do (is (true? (str/blank? (symbol "")))) From e1bd5e179d921160bf53b146a74ba8f9aaf7080d Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Sat, 6 Sep 2025 13:34:50 -0600 Subject: [PATCH 5/9] Cleanup byte --- test/clojure/core_test/byte.cljc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/clojure/core_test/byte.cljc b/test/clojure/core_test/byte.cljc index 98a1960..eff992a 100644 --- a/test/clojure/core_test/byte.cljc +++ b/test/clojure/core_test/byte.cljc @@ -1,6 +1,7 @@ (ns clojure.core-test.byte - (:require [clojure.test :as t :refer [deftest testing is are]] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + (:require [clojure.test :as t :refer [deftest is are]] + [clojure.core-test.portability + #?(:cljs :refer-macros :default :refer) [when-var-exists]])) (when-var-exists clojure.core/byte (deftest test-byte @@ -10,7 +11,7 @@ ;; test whether it's a fixed-length integer of some sort. (is (int? (byte 0))) #?(:clj (is (instance? java.lang.Byte (byte 0))) - :cljr (is (instance? System.Byte (byte 0)))) + :cljr (is (instance? System.Byte (byte 0)))) ;; Check conversions and rounding from other numeric types ;; In ClojureCLR, Byte is unsigned, so we have to wipe all tests of negative values @@ -20,10 +21,10 @@ 127 127 1 1N 0 0N - #?@(:cljr [] :default [-1 -1N]) + #?@(:cljr [] :default [-1 -1N]) 1 1.0M 0 0.0M - #?@(:cljr [] :default [-1 -1.0M]) + #?@(:cljr [] :default [-1 -1.0M]) ;; Clojurescript `byte` is a "dummy cast" which doesn't do ;; anything (no-op). Thus, there is no conversion, no truncation ;; of decimal values, etc. @@ -35,14 +36,14 @@ -1.1 -1.1M] :default [1 1.1 - #?@(:cljr [] :default [-1 -1.1]) + #?@(:cljr [] :default [-1 -1.1]) 1 1.9 1 3/2 - #?@(:cljr [] :default [-1 -3/2]) + #?@(:cljr [] :default [-1 -3/2]) 0 1/10 - #?@(:cljr [] :default [0 -1/10]) + #?@(:cljr [] :default [0 -1/10]) 1 1.1M - #?@(:cljr [] :default [-1 -1.1M])])) + #?@(:cljr [] :default [-1 -1.1M])])) #?@(:cljs [ ;; ClojureScript `byte` just returns its argument From 98e1f59a4623fc903e2bf956dc89ab6d070e7bc9 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Sat, 6 Sep 2025 13:36:19 -0600 Subject: [PATCH 6/9] Cleanup 2 --- test/clojure/core_test/byte.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/clojure/core_test/byte.cljc b/test/clojure/core_test/byte.cljc index eff992a..8b105f3 100644 --- a/test/clojure/core_test/byte.cljc +++ b/test/clojure/core_test/byte.cljc @@ -1,7 +1,7 @@ (ns clojure.core-test.byte (:require [clojure.test :as t :refer [deftest is are]] [clojure.core-test.portability - #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + #?(:cljs :refer-macros :default :refer) [when-var-exists]])) (when-var-exists clojure.core/byte (deftest test-byte From d33f41fa84b26550dc1e460f3e10cd2acdc6ec47 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Mon, 8 Sep 2025 09:39:44 -0600 Subject: [PATCH 7/9] Fix whitespace --- test/clojure/core_test/byte.cljc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/clojure/core_test/byte.cljc b/test/clojure/core_test/byte.cljc index 8b105f3..d788df1 100644 --- a/test/clojure/core_test/byte.cljc +++ b/test/clojure/core_test/byte.cljc @@ -14,7 +14,8 @@ :cljr (is (instance? System.Byte (byte 0)))) ;; Check conversions and rounding from other numeric types - ;; In ClojureCLR, Byte is unsigned, so we have to wipe all tests of negative values + ;; In ClojureCLR, Byte is unsigned, so we have to wipe all tests + ;; of negative values (are [expected x] (= expected (byte x)) #?@(:cljr [] :default [-128 -128]) 0 0 From 1b6759fb2a073b5b774de4b9e431d00cbdb9c1c8 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Mon, 8 Sep 2025 22:50:28 -0600 Subject: [PATCH 8/9] Fix cljs shuffle --- package-lock.json | 4 ++-- test/clojure/core_test/shuffle.cljc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4559627..2a47cbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "clojure.core-test", + "name": "io.github.jank-lang/clojure-test-suite", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "clojure.core-test", + "name": "io.github.jank-lang/clojure-test-suite", "version": "1.0.0", "license": "MPL 2.0", "devDependencies": { diff --git a/test/clojure/core_test/shuffle.cljc b/test/clojure/core_test/shuffle.cljc index 3029e2d..9699533 100644 --- a/test/clojure/core_test/shuffle.cljc +++ b/test/clojure/core_test/shuffle.cljc @@ -23,14 +23,14 @@ (is (vector? actual)) (is (= (count x) (count actual)))))) (testing "negative cases" - (is (thrown? Exception (shuffle 1))) + (is (thrown? #?(:cljs js/Error :default Exception) (shuffle 1))) #?@(:cljs [(is (= [] (shuffle nil))) - (is [] (shuffle {}))] + (is (= [] (shuffle {})))] :cljr [(is (thrown? Exception (shuffle nil))) (is (thrown? Exception (shuffle "abc"))) - (is (= [](shuffle {})))] + (is (= [] (shuffle {})))] :default [(is (thrown? Exception (shuffle nil))) (is (thrown? Exception (shuffle "abc"))) From 45d72954c8991f0b48e462995b494b6fad7ab710 Mon Sep 17 00:00:00 2001 From: Emma Griffin Date: Mon, 8 Sep 2025 23:29:20 -0600 Subject: [PATCH 9/9] Fix clj --- test/clojure/core_test/shuffle.cljc | 3 +- test/clojure/core_test/with_precision.cljc | 4 +-- test/clojure/string_test/ends_with_qmark.cljc | 2 +- test/clojure/string_test/lower_case.cljc | 6 ++-- .../string_test/starts_with_qmark.cljc | 32 +++++++++---------- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/test/clojure/core_test/shuffle.cljc b/test/clojure/core_test/shuffle.cljc index 9699533..6a9b424 100644 --- a/test/clojure/core_test/shuffle.cljc +++ b/test/clojure/core_test/shuffle.cljc @@ -23,7 +23,8 @@ (is (vector? actual)) (is (= (count x) (count actual)))))) (testing "negative cases" - (is (thrown? #?(:cljs js/Error :default Exception) (shuffle 1))) + #?(:cljs (is (thrown? js/Error (shuffle 1))) + :default (is (thrown? Exception (shuffle 1)))) #?@(:cljs [(is (= [] (shuffle nil))) (is (= [] (shuffle {})))] diff --git a/test/clojure/core_test/with_precision.cljc b/test/clojure/core_test/with_precision.cljc index a2a288e..5061c08 100644 --- a/test/clojure/core_test/with_precision.cljc +++ b/test/clojure/core_test/with_precision.cljc @@ -1,8 +1,8 @@ (ns clojure.core-test.with-precision (:require [clojure.test :as t :refer [deftest testing is are]] - [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) -(when-var-exists clojure.core/with-precision +(when-var-exists with-precision (deftest test-with-precision ;; tests copied from https://clojuredocs.org/clojure.core/with-precision (is (= 2M (with-precision 1 :rounding UP (* 1.1M 1M)))) diff --git a/test/clojure/string_test/ends_with_qmark.cljc b/test/clojure/string_test/ends_with_qmark.cljc index 4b9e4a9..b62422b 100644 --- a/test/clojure/string_test/ends_with_qmark.cljc +++ b/test/clojure/string_test/ends_with_qmark.cljc @@ -10,7 +10,7 @@ #?(:cljs (is (thrown? :default (str/ends-with? nil ""))) :cljr (is (true? (str/ends-with? nil ""))) - :default (is (thrown? :default (str/ends-with? nil "")))) + :default (is (thrown? Exception (str/ends-with? nil "")))) #?(:cljs (do (is (false? (str/ends-with? "ab" :b))) (is (false? (str/ends-with? "ab" :a)))) diff --git a/test/clojure/string_test/lower_case.cljc b/test/clojure/string_test/lower_case.cljc index a5dad62..db30f60 100644 --- a/test/clojure/string_test/lower_case.cljc +++ b/test/clojure/string_test/lower_case.cljc @@ -14,11 +14,11 @@ (is (= "asdf" (str/lower-case "ASDF"))) (is (= "ASDF" s) "original string mutated")) #?(:cljs (is (thrown? :default (str/lower-case :ASDF))) - :cljr :cljs (is (thrown? Exception (str/lower-case :ASDF))) + :cljr (is (thrown? Exception (str/lower-case :ASDF))) :default (is (= ":asdf" (str/lower-case :ASDF)))) #?(:cljs (is (thrown? :default (str/lower-case :ASDF/ASDF))) - :cljr (is (thrown? Exception (str/lower-case :ASDF/ASDF))) + :cljr (is (thrown? Exception (str/lower-case :ASDF/ASDF))) :default (is (= ":asdf/asdf" (str/lower-case :ASDF/ASDF)))) #?(:cljs (is (thrown? :default (str/lower-case 'ASDF))) - :cljr (is (thrown? Exception (str/lower-case 'ASDF))) + :cljr (is (thrown? Exception (str/lower-case 'ASDF))) :default (is (= "asdf" (str/lower-case 'ASDF)))))) diff --git a/test/clojure/string_test/starts_with_qmark.cljc b/test/clojure/string_test/starts_with_qmark.cljc index ca27b1c..907d685 100644 --- a/test/clojure/string_test/starts_with_qmark.cljc +++ b/test/clojure/string_test/starts_with_qmark.cljc @@ -11,7 +11,7 @@ #?(:cljs (is (thrown? :default (str/starts-with? nil ""))) :cljr (is (true? (str/starts-with? nil ""))) - :default (is (thrown? :default (str/starts-with? nil "")))) + :default (is (thrown? Exception (str/starts-with? nil "")))) #?(:cljs (do (is (false? (str/starts-with? "ab" :a))) (is (true? (str/starts-with? ":ab" :a))) @@ -30,22 +30,22 @@ #?@(:cljs [(is (thrown? :default (str/starts-with? 'ab ":a"))) - (is (thrown? :default (str/starts-with? :ab ":a"))) - (is (thrown? :default (str/starts-with? 'a/b ":a"))) - (is (thrown? :default (str/starts-with? :a/b ":a")))] + (is (thrown? :default (str/starts-with? :ab ":a"))) + (is (thrown? :default (str/starts-with? 'a/b ":a"))) + (is (thrown? :default (str/starts-with? :a/b ":a")))] :cljr [(is (thrown? Exception (str/starts-with? 'ab ":a"))) - (is (thrown? Exception (str/starts-with? :ab ":a"))) - (is (thrown? Exception (str/starts-with? 'a/b ":a"))) - (is (thrown? Exception (str/starts-with? :a/b ":a")))] + (is (thrown? Exception (str/starts-with? :ab ":a"))) + (is (thrown? Exception (str/starts-with? 'a/b ":a"))) + (is (thrown? Exception (str/starts-with? :a/b ":a")))] :default [(is (false? (str/starts-with? 'ab "b"))) - (is (true? (str/starts-with? 'ab "a"))) - (is (false? (str/starts-with? :ab "b"))) - (is (false? (str/starts-with? :ab "a"))) - (is (true? (str/starts-with? :ab ":a"))) - (is (false? (str/starts-with? 'a/b "b"))) - (is (true? (str/starts-with? 'a/b "a"))) - (is (false? (str/starts-with? :a/b "b"))) - (is (false? (str/starts-with? :a/b "a"))) - (is (true? (str/starts-with? :a/b ":a")))]))) \ No newline at end of file + (is (true? (str/starts-with? 'ab "a"))) + (is (false? (str/starts-with? :ab "b"))) + (is (false? (str/starts-with? :ab "a"))) + (is (true? (str/starts-with? :ab ":a"))) + (is (false? (str/starts-with? 'a/b "b"))) + (is (true? (str/starts-with? 'a/b "a"))) + (is (false? (str/starts-with? :a/b "b"))) + (is (false? (str/starts-with? :a/b "a"))) + (is (true? (str/starts-with? :a/b ":a")))])))