add cljs test helpers file
This commit is contained in:
parent
9bef1c6528
commit
0a0bab144b
1 changed files with 16 additions and 0 deletions
16
test/com/rpl/specter/cljs_test_helpers.clj
Normal file
16
test/com/rpl/specter/cljs_test_helpers.clj
Normal 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 )))
|
||||||
Loading…
Reference in a new issue