diff --git a/test/clojure/core_test/parse_boolean.cljc b/test/clojure/core_test/parse_boolean.cljc new file mode 100644 index 0000000..85d2b81 --- /dev/null +++ b/test/clojure/core_test/parse_boolean.cljc @@ -0,0 +1,47 @@ +(ns clojure.core-test.parse-boolean + (: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/parse-boolean + (deftest test-parse-boolean + (testing "common" + (are [expected x] (= expected (parse-boolean x)) + false "false" + true "true" + nil "0" + nil "1" + nil "" + nil "foo" + nil "False" + nil "FALSE" + nil "True" + nil "TRUE" + nil "ttrue" + nil "truee" + nil "ffalse" + nil "falsee" + nil " true" + nil "tr ue" + nil "true ")) + + (testing "exceptions" + #?(:clj (are [x] (thrown? Exception (parse-boolean x)) + nil + 0 + 0.0 + \a + :key + {} + '() + #{} + [])) + #?(:cljs (are [x] (thrown? js/Error (parse-boolean x)) + nil + 0 + 0.0 + :key + {} + '() + #{} + []))))) diff --git a/test/clojure/core_test/parse_double.cljc b/test/clojure/core_test/parse_double.cljc new file mode 100644 index 0000000..65136c5 --- /dev/null +++ b/test/clojure/core_test/parse_double.cljc @@ -0,0 +1,55 @@ +(ns clojure.core-test.parse-double + (: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/parse-double + (deftest test-parse-double + (testing "common" + (are [expected x] (= expected (parse-double x)) + nil "" + nil "foo" + nil "f00" + nil "7oo" + nil "four" + nil "##Inf" + nil "-##Inf" + nil "+-5.6" + nil "-+5.6" + nil "7.9+6.4" + nil "7.9-6.4" + nil "Infinity7" + nil "-50Infinity7" + nil "8-Infinity7" + nil "InfinityE100" + nil "Infinitye5" + nil "2.6e8E5" + 1.0 "1" + 1.0 "1.0" + 1.0 "1.000" + 5.6 "+5.6" + -8.7 "-8.7" + 90006.0 "9.0006e4" + -105.8 "-1.058e2" + 568.51 "56851e-2" + 568.51 "56851E-2" + ##Inf "Infinity" + ##-Inf "-Infinity")) + (testing "exceptions" + #?(:clj (are [x] (thrown? Exception (parse-double x)) + {} + '() + [] + #{} + \a + :key + 0.0 + 1000)) + #?(:cljs (are [x] (thrown? js/Error (parse-double x)) + {} + '() + [] + #{} + :key + 0.0 + 1000))))) diff --git a/test/clojure/core_test/parse_long.cljc b/test/clojure/core_test/parse_long.cljc new file mode 100644 index 0000000..5c59187 --- /dev/null +++ b/test/clojure/core_test/parse_long.cljc @@ -0,0 +1,51 @@ +(ns clojure.core-test.parse-long + (: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/parse-long + (deftest test-parse-long + (testing "common" + (are [expected x] (= expected (parse-long x)) + nil "" + nil "1L" + nil "foo" + nil "f00" + nil "7oo" + nil "four" + nil "0.0" + nil "+-5" + nil "-+5" + nil "##Inf" + nil "-##Inf" + nil "Infinity" + nil "Infinity7" + nil "-Infinity" + nil "-50Infinity" + nil "NaN" + 0 "0" + 42 "42" + 12 "+12" + -1000 "-1000" + -100000000000 "-100000000000" + #?@(:clj [999999999999999999 "999999999999999999"] + :cljs [nil "999999999999999999" + 999999999999999 "999999999999999"]))) + (testing "exceptions" + #?(:clj (are [x] (thrown? Exception (parse-long x)) + {} + '() + [] + #{} + \a + :key + 0.0 + 1000)) + #?(:cljs (are [x] (thrown? js/Error (parse-long x)) + {} + '() + [] + #{} + :key + 0.0 + 1000))))) diff --git a/test/clojure/core_test/parse_uuid.cljc b/test/clojure/core_test/parse_uuid.cljc new file mode 100644 index 0000000..adbded0 --- /dev/null +++ b/test/clojure/core_test/parse_uuid.cljc @@ -0,0 +1,36 @@ +(ns clojure.core-test.parse-uuid + (: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/parse-uuid + (deftest test-parse-uuid + (testing "common" + (are [expected x] (= expected (parse-uuid x)) + nil "" + nil "0" + nil "df0993" + nil "b6883c0a-0342-4007-9966-bc2dfa6b109eb" + nil "ab6883c0a-0342-4007-9966-bc2dfa6b109e") + (is (= (parse-uuid "b6883c0a-0342-4007-9966-bc2dfa6b109e") (parse-uuid "B6883C0A-0342-4007-9966-BC2dfa6b109E"))) + (when-var-exists clojure.core/instance? + #?(:clj (is (instance? java.util.UUID (parse-uuid "b6883c0a-0342-4007-9966-bc2dfa6b109e")))) + #?(:cljs (is (instance? cljs.core.UUID (parse-uuid "b6883c0a-0342-4007-9966-bc2dfa6b109e")))))) + (testing "exceptions" + #?(:clj (are [x] (thrown? Exception (parse-uuid x)) + {} + '() + [] + #{} + \a + :key + 0.0 + 1000)) + #?(:cljs (are [x] (thrown? js/Error (parse-uuid x)) + {} + '() + [] + #{} + :key + 0.0 + 1000)))))