diff --git a/.gitignore b/.gitignore index bdc11d7..f76eb49 100644 --- a/.gitignore +++ b/.gitignore @@ -9,11 +9,14 @@ pom.xml.asc /checkouts/ /node_modules .eastwood +.clj-kondo/ .lein-deps-sum .lein-repl-history .lein-plugins/ .lein-failures .nrepl-port +.java-version +.lsp/ .rebel_readline_history .DS_Store .#* diff --git a/src/same/platform.cljc b/src/same/platform.cljc index c97aa9b..4b576df 100644 --- a/src/same/platform.cljc +++ b/src/same/platform.cljc @@ -5,7 +5,7 @@ (def max-value "The largest representable non-infinite Double." - #?(:clj (Double/MAX_VALUE) + #?(:clj Double/MAX_VALUE :cljs (.-MAX_VALUE js/Number))) (defn is-array? diff --git a/test/same/core_test.cljc b/test/same/core_test.cljc index 60a969b..3bb5280 100644 --- a/test/same/core_test.cljc +++ b/test/same/core_test.cljc @@ -5,7 +5,8 @@ [same.core :refer [ish? zeroish? not-zeroish? set-comparator! with-comparator]] [same.ish :as ish] [same.platform :as p] - [same.test-helpers :refer [about infinity #?@(:clj [java-map java-set])]])) + [same.test-helpers :refer [about infinity]]) + #?(:clj (:import [java.util HashSet HashMap]))) (deftest scalar-test (is (ish? 1.0 1.0)) @@ -64,12 +65,12 @@ (is (not (ish? #{1.0 2 \b "c" :d} #{1.01 2 \b "c" :d})))) #?(:clj (testing "Java sets" - (is (ish? (java-set 1.0 2 \b "c" :d) - (java-set 1.0 2 \b "c" :d))) - (is (ish? (java-set 1.0 2 \b "c" :d) - (java-set (about 1) 2 \b "c" :d))) - (is (not (ish? (java-set 1.0 2 \b "c" :d) - (java-set 1.01 2 \b "c" :d))))))) + (is (ish? (HashSet. [1.0 2 \b "c" :d]) + (HashSet. [1.0 2 \b "c" :d]))) + (is (ish? (HashSet. [1.0 2 \b "c" :d]) + (HashSet. [(about 1) 2 \b "c" :d]))) + (is (not (ish? (HashSet. [1.0 2 \b "c" :d]) + (HashSet. [1.01 2 \b "c" :d]))))))) (deftest map-test (testing "Maps of keyword-double" @@ -86,12 +87,12 @@ (is (not (ish? {1.0 2 :a "b"} {1.01 2 :a "b"})))) #?(:clj (testing "Java maps" - (is (ish? (java-map 1.0 2 :a "b") - (java-map 1.0 2 :a "b"))) - (is (ish? (java-map 1.0 2 :a "b") - (java-map (about 1) 2 :a "b"))) - (is (not (ish? (java-map 1.0 2 :a "b") - (java-map 1.01 2 :a "b"))))))) + (is (ish? (HashMap. {1.0 2 :a "b"}) + (HashMap. {1.0 2 :a "b"}))) + (is (ish? (HashMap. {1.0 2 :a "b"}) + (HashMap. {(about 1) 2 :a "b"}))) + (is (not (ish? (HashMap. {1.0 2 :a "b"}) + (HashMap. {1.01 2 :a "b"}))))))) (deftest array-test (testing "Arrays of doubles" diff --git a/test/same/test_helpers.cljc b/test/same/test_helpers.cljc index 72f112d..9ca3986 100644 --- a/test/same/test_helpers.cljc +++ b/test/same/test_helpers.cljc @@ -19,11 +19,3 @@ (def nan #?(:clj Double/NaN :cljs js/NaN)) - -(defn java-set - [& coll] - (java.util.HashSet. ^java.util.Collection coll)) - -(defn java-map - [& {:as map}] - (java.util.HashMap. ^java.util.Map map))