Skip to content

Instantly share code, notes, and snippets.

@m0smith
Last active November 15, 2019 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m0smith/6a9f4ed261c985f06549f3ee5b0a7179 to your computer and use it in GitHub Desktop.
Save m0smith/6a9f4ed261c985f06549f3ee5b0a7179 to your computer and use it in GitHub Desktop.
(require '[clojure.test.check.random :as random]
'[clojure.test.check.generators :as gen]
'[clojure.test.check.rose-tree :as rt])
(defn shrinks
"Shows how a generator will shrink"
([g] (shrinks g 10 10))
([g size] (shrinks g size 10))
([g size sample] (take sample (distinct (map rt/root
(tree-seq (fn [_] true) rt/children (gen/call-gen g (random/make-random) size)))))))
(def g (gen/vector gen/int))
(shrinks g)
(shrinks g 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment