diff --git a/test/clojure/core_test/hash_map.cljc b/test/clojure/core_test/hash_map.cljc new file mode 100644 index 0000000..d37fa82 --- /dev/null +++ b/test/clojure/core_test/hash_map.cljc @@ -0,0 +1,17 @@ +(ns clojure.core-test.hash-map + (:require clojure.core + [clojure.test :as t :refer [deftest testing is are]] + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + +(when-var-exists clojure.core/hash-map + (deftest test-hash-map + (testing "common" + (is (= {} (hash-map))) + (is (= {:a 1} (hash-map :a 1))) + (is (= {:a 2} (hash-map :a 1 :a 2))) + (is (= {:a 1 :b "2"} (hash-map :a 1, :b "2"))) + (is (= {"a" 1, [:b :c] "2", \d nil} (hash-map "a" 1, [:b :c] "2", \d nil))) + (is (= {\a {}} (hash-map \a (hash-map)))) + (is (= {:a {:b {:c 1} :d 2}} (hash-map :a (hash-map :b (hash-map :c 1) :d 2)))) + #?@(:clj [(is (thrown? Exception (hash-map :a)))] + :cljs [(is (thrown? js/Error (hash-map :a)))])))) diff --git a/test/clojure/core_test/hash_set.cljc b/test/clojure/core_test/hash_set.cljc new file mode 100644 index 0000000..b85cbeb --- /dev/null +++ b/test/clojure/core_test/hash_set.cljc @@ -0,0 +1,19 @@ +(ns clojure.core-test.hash-set + (:require clojure.core + [clojure.test :as t :refer [deftest testing is are]] + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + +(when-var-exists clojure.core/hash-set + (deftest test-hash-set + (testing "common" + (is (= #{} (hash-set))) + (is (= #{:a} (hash-set :a))) + (is (= #{"a"} (hash-set "a"))) + (is (= #{1} (hash-set 1 1))) + (is (= #{nil} (hash-set nil))) + (is (= #{\space} (hash-set \space))) + (is (= #{'()} (hash-set '()))) + (is (= #{[]} (hash-set []))) + (is (= #{'(1 2 3)} (hash-set '(1 2 3)))) + (is (= #{[1 2 3]} (hash-set [1 2 3]))) + (is (= #{nil #{}} (hash-set nil (hash-set))))))) diff --git a/test/clojure/core_test/set.cljc b/test/clojure/core_test/set.cljc new file mode 100644 index 0000000..774b42a --- /dev/null +++ b/test/clojure/core_test/set.cljc @@ -0,0 +1,24 @@ +(ns clojure.core-test.set + (:require clojure.core + [clojure.test :as t :refer [deftest testing is are]] + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + +(when-var-exists clojure.core/set + (deftest test-set + (testing "common" + (is (= #{} (set nil))) + (is (= #{} (set []))) + (is (= #{} (set '()))) + (is (= #{\a \b \c} (set "abc"))) + (is (= #{} (set #{}))) + (is (= #{:a} (set #{:a}))) + (is (= #{1 2 3} (set [1 1 2 2 3 3 3]))) + (is (= #{:a 1 "a"} (set '(:a 1 "a")))) + (is (= #{:a 1 "a"} (set [:a 1 "a"]))) + (is (= #{:a 1 "a" [\space]} (set [:a 1 "a" [\space]]))) + #?@(:clj [(is (thrown? Exception (set 1))) + (is (thrown? Exception (set \space))) + (is (thrown? Exception (set :a)))] + :cljs [(is (= #{\space} (set \space))) + (is (thrown? js/Error (set 1))) + (is (thrown? js/Error (set :a)))]))))