diff --git a/test/com/rpl/specter/cljs_test_helpers.clj b/test/com/rpl/specter/cljs_test_helpers.clj new file mode 100644 index 0000000..73cc71c --- /dev/null +++ b/test/com/rpl/specter/cljs_test_helpers.clj @@ -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 )))