Sometimes, to generate realistic specs, some specs should be more probable than others.
Suggested implementation:
(defmacro weighted-or
"Like [[s/or]], but with weights."
[& weighted-options]
(let [[names specs ws] (apply map vector (partition 3 weighted-options))
sums (reductions + ws)]
`(s/with-gen
(s/or ~@(interleave names specs))
(fn []
(gen/fmap
(fn [count#] (condp < count# ~@(interleave sums specs)))
(gen/choose 1 ~(last sums)))))))
Sometimes, to generate realistic specs, some specs should be more probable than others.
Suggested implementation: