Hey Andrew,

Good question. tl;dr, change your test to:

(tc/quick-check 100 prop1 :max-size 50) ;; and that should pass.

Longer explanation:

test.check's generators take two parameters, a random number generator, and an
integer 'size'. During testing, the size starts at 0, and increases up to some 
fixed
maximum. This is used to that the 'size' of the generated data increases as more
and more tests pass. The rationale here is that you don't want your very first 
to 
generate a million-length vector, when, if there is a bug, its more than likely 
also
present with 'smaller' data. As it turns out, with a complex generator like 
gen/any,
a size of 100 (the default maximum) can generate very large, nested 
data-structures.
This is explained in some detail in the documentation [1]. I've tried to make 
all of the
built-in generators have sane defaults, but its appear like gen/any can still 
generate
massive, nested structures with the default values. I'll look into a more sane 
default
sizing strategy for this generator. As I mention in the tl;dr above, you can 
set the
maximum 'size' used during testing.

[1] 
https://github.com/clojure/test.check/blob/master/doc/intro.md#recursive-generators

On Feb 28, 2014, at 3:41 AM, keeds <akee...@gmail.com> wrote:

> Hi Reid,
> This is excellent. Just experimenting and trying to get my head around it. 
> Not sure if I'm doing any wrong or stupid!! If I test a function that relies 
> on Exception handling internally as I reach 100 tests it takes forever and 
> eventually blows the heap.
> 
> Simple contrived example:
> 
> (ns check
>   (:require [clojure.test.check :as tc]
>             [clojure.test.check.generators :as gen]
>             [clojure.test.check.properties :as prop]
>             ))
> 
> (defn format1 [x]
>   (try
>     (->> (double x)
>       (format "%,.0f"))
>     (catch Exception e "")))
> 
> (def prop1
>   (prop/for-all [v gen/any]
>     (string? (format1 v))))
> 
> #_ (tc/quick-check 100 prop1) ;; blows heap
> 
> Thanks,
> Andrew
> 
> On Thursday, 27 February 2014 17:22:44 UTC, Reid Draper wrote:
> I'm happy to announce the first release of the newest Clojure contrib library:
> test.check [1]. Previously named simple-check [1], test.check is a
> property-based testing library, based on QuickCheck. The README has a guide 
> for
> migrating from simple-check, as well as some getting-started documentation. 
> I'm
> happy to answer any questions here as well. Or, stop by my Clojure/West talk 
> in
> March.
> 
> [1] https://github.com/clojure/test.check
> [2] https://github.com/reiddraper/simple-check
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Clojure" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/clojure/EPNoH4JEiVQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to