Youtube talk by Reid Draper: https://www.youtube.com/watch?v=JMhNINPo__g
Returns samples from a given generator
(gen/sample gen/boolean)
Generator for vectors of a given element type
(gen/sample
(gen/vector gen/int))
Return a constant value (like constantly)
(gen/sample
(gen/return :foo))
Choose a value from 5 to 10 inclusive
(gen/sample
(gen/choose 5 10))
Choose a random element from a given list of values
(gen/sample
(gen/elements [:clojure :haskell]))
Choose among supplied generators
(gen/sample
(gen/one-of [gen/boolean gen/int]))
Apply a frequency to which generator to choose
(gen/sample
(gen/frequency
[[5 (gen/return :weekday)]
[2 (gen/return :weekend)]]))
Filter the generated values
(gen/sample
(gen/such-that #(not= 0 %) gen/int))
Apply a function to every value generated. i.e. transform the generated value.
(gen/sample
(gen/fmap odd? gen/int))
Take a generated value and create a new generator from it
(gen/sample
(gen/bind
;; generate a value - a non-empty vector of ints
(gen/not-empty (gen/vector gen/int))
;; a new generator that returns a tuple based on the vector value generated
#(gen/tuple (gen/return %)
(gen/elements %))))
Walk the shrink tree as long as the test continues to fail, reducing to the smallest failing value.
(defspec
my-test-property
100 ;; how many iterations to do
(prop/for-all
[a gen/int]
...))