Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
TCHECK-50: Add gen/generate for single samples
The name `generate` comes from QuickCheck which has a similar function.
  • Loading branch information
gfredericks committed Jun 7, 2015
1 parent 7678112 commit 2d1dc41
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/clojure/clojure/test/check/generators.clj
Expand Up @@ -153,6 +153,16 @@
(take num-samples (sample-seq generator))))


(defn generate
"Returns a single sample value from the generator, using a default
size of 30."
([generator]
(generate generator 30))
([generator size]
(let [rng (random/make-random)]
(rose/root (call-gen generator rng size)))))


;; Internal Helpers
;; ---------------------------------------------------------------------------

Expand Down

0 comments on commit 2d1dc41

Please sign in to comment.