Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@samedhi
Created September 12, 2018 03:03
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/38146521b6e672fba752cf369e2973b5 to your computer and use it in GitHub Desktop.
Save samedhi/38146521b6e672fba752cf369e2973b5 to your computer and use it in GitHub Desktop.
(ns example.silly
(:require
[clojure.spec.alpha :as spec]))
(spec/def ::integer int?)
(defn adder [a b]
(+ a b))
(spec/fdef adder
:args (spec/cat :a ::integer :b ::integer)
:ret ::integer)
(ns example.silly-test
(:require-macros
[inferno.test-utils :refer [deftest-fdef]]))
(deftest-fdef example.silly/adder)
(ns example.test-utils
(:require
[clojure.spec.test.alpha :as spec.test]
[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#)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment