Skip to content

Instantly share code, notes, and snippets.

@samedhi
Last active September 4, 2018 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samedhi/84a66d3c5a16d6a5e5381179b745e8b8 to your computer and use it in GitHub Desktop.
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)
;; 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