2015-06-30 22:10:25 +00:00
|
|
|
(ns com.rpl.specter.cljs-test-helpers)
|
2015-06-30 22:09:03 +00:00
|
|
|
|
|
|
|
|
;; 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]
|
2016-08-11 14:13:27 +00:00
|
|
|
~@body)))
|