(exercise-fn sym)
(exercise-fn sym n)
(exercise-fn sym-or-f n fspec)
exercises the fn named by sym (a symbol) by applying it to
n (default 10) generated samples of its args spec. When fspec is
supplied its arg spec is used, and sym-or-f can be a fn. Returns a
sequence of tuples of [args ret].
Source
(defn exercise-fn
"exercises the fn named by sym (a symbol) by applying it to
n (default 10) generated samples of its args spec. When fspec is
supplied its arg spec is used, and sym-or-f can be a fn. Returns a
sequence of tuples of [args ret]. "
([sym] (exercise-fn sym 10))
([sym n] (exercise-fn sym n (get-spec sym)))
([sym-or-f n fspec]
(let [f (if (symbol? sym-or-f) (resolve sym-or-f) sym-or-f)]
(if-let [arg-spec (c/and fspec (:args fspec))]
(for [args (gen/sample (gen arg-spec) n)]
[args (apply f args)])
(throw (Exception. "No :args spec found, can't generate"))))))