[ANN] clojure.test.check (previously, simple-check)

404 views
Skip to first unread message

Reid Draper

unread,
Feb 27, 2014, 12:22:44 PM2/27/14
to clo...@googlegroups.com
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.


Ambrose Bonnaire-Sergeant

unread,
Feb 27, 2014, 12:26:21 PM2/27/14
to clojure
Congrats!

Ambrose


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

keeds

unread,
Feb 28, 2014, 4:41:46 AM2/28/14
to clo...@googlegroups.com
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

Peter Taoussanis

unread,
Feb 28, 2014, 5:39:59 AM2/28/14
to clo...@googlegroups.com
Congrats Reid, thanks a lot for all your work on this!

Have only been using simple-check for a little while now, but it's already paid big dividends in production. One of the most concretely useful testing tools I've ever used. For folks that haven't tried it, I'd absolutely recommend taking a look.

Great stuff.

Cheers! :-)

- Peter

Reid Draper

unread,
Feb 28, 2014, 3:01:12 PM2/28/14
to clo...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.

keeds

unread,
Mar 1, 2014, 7:34:43 AM3/1/14
to clo...@googlegroups.com
Reid,
Thank you kindly. That makes sense. Your help is much appreciated, as are your efforts with this library.

Thanks,
Andrew

On Thursday, 27 February 2014 17:22:44 UTC, Reid Draper wrote:

César Bolaños Portilla

unread,
Mar 1, 2014, 2:30:22 PM3/1/14
to clo...@googlegroups.com
NOOOOooo :-(. Now it gets behind the CA + Jira impenetrable wall.

Sean Corfield

unread,
Mar 3, 2014, 5:31:48 PM3/3/14
to clo...@googlegroups.com
On Mar 1, 2014, at 11:30 AM, César Bolaños Portilla <cesar.bola...@gmail.com> wrote:
NOOOOooo :-(. Now it gets behind the CA + Jira impenetrable wall.

Please let's not have this debate again.

Hundreds of people clearly find it less than "impenetrable" and the process is _necessary_ from a legal point of view:


Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



signature.asc
Reply all
Reply to author
Forward
0 new messages