Last active
September 4, 2018 15:24
-
-
Save samedhi/84a66d3c5a16d6a5e5381179b745e8b8 to your computer and use it in GitHub Desktop.
How do I call with the proper testing library (clojure.test for clj and cljs.test for cljs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; test-utils.cljc | |
(ns inferno.test-utils | |
(:require | |
[clojure.spec.test.alpha :as spec.test] | |
#?(:clj [clojure.test :as test] | |
:cljs [cljs.test :as test :include-macros true]))) | |
(defmacro deftest-fdef [sym] | |
`(test/deftest ~(-> sym name (str "-test") symbol) | |
(let [[res#] (spec.test/check (quote ~sym)) | |
{{result# :result :as ret#} :clojure.spec.test.check/ret} res#] | |
(-> ret# | |
clojure.pprint/pprint | |
println) | |
(test/is (true? result#))))) | |
;; hands_test.cljc | |
(ns inferno.poker.hands-test | |
(:require | |
#?(:clj [clojure.test :as test] | |
:cljs [cljs.test :as test :include-macros true]) | |
[inferno.poker.hands :as hands] | |
#?(:clj [inferno.test-utils :as test-macros] | |
:cljs [inferno.test-utils :include-macros true :as test-macros]))) | |
(test-macros/deftest-fdef inferno.poker.hands/partition-by-rank) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment