diff --git a/test/clojure/core_test/reverse.cljc b/test/clojure/core_test/reverse.cljc new file mode 100644 index 0000000..4324a55 --- /dev/null +++ b/test/clojure/core_test/reverse.cljc @@ -0,0 +1,21 @@ +(ns clojure.core-test.reverse + (:require [clojure.test :as t :refer [deftest testing is are]] + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + +(when-var-exists reverse + (deftest test-reverse + (testing "common" + (is (= '() (reverse nil))) + (is (= '() (reverse '()))) + (is (= '() (reverse []))) + (is (= '(3 2 1) (reverse '(1 2 3)))) + (is (= '(3 2 1) (reverse [1 2 3]))) + (is (= '([4 5] 3 2 1) (reverse [1 2 3 [4 5]]))) + (is (= '(\c \b \a) (reverse "abc"))) + (is (= '([:a :b]) (reverse {:a :b}))) + #?@(:cljs [(is (= '(\a) (reverse \a))) + (is (thrown? js/Error (reverse 0))) + (is (thrown? js/Error (reverse 0.0)))] + :default [(is (thrown? Exception (reverse \a))) + (is (thrown? Exception (reverse 0))) + (is (thrown? Exception (reverse 0.0)))]))))