add cljs test helpers file

This commit is contained in:
Nathan Marz 2015-06-30 18:09:03 -04:00
parent 9bef1c6528
commit 0a0bab144b

View file

@ -0,0 +1,16 @@
(ns com.rpl.specter.cljs-test-helpers
(:require [clojure.test.check
[generators :as gen]
[properties :as prop]]))
;; it seems like gen/bind and gen/return are a monad (hence the names)
(defmacro for-all+ [bindings & body]
(let [parts (partition 2 bindings)
vars (vec (map first parts))
genned (reduce
(fn [curr [v code]]
`(cljs.test.check.generators/bind ~code (fn [~v] ~curr)))
`(cljs.test.check.generators/return ~vars)
(reverse parts))]
`(cljs.test.check.properties/for-all [~vars ~genned]
~@body )))