Thanks Eugene and wren.<div><br></div><div>Serves me right, actually. The one chapter I skipped in RWH was the 11th one called &quot;Testing and Quality Assurance&quot; thinking it is too boring.</div><div> <br><br><div class="gmail_quote">
On Fri, May 29, 2009 at 12:44 PM, wren ng thornton <span dir="ltr">&lt;<a href="mailto:wren@freegeek.org">wren@freegeek.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Eugene Kirpichov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Use QuickCheck.<br>
</blockquote>
<br>
Also use SmallCheck or lazy SmallCheck.<br>
<br>
All of these are automatic tools that allow you to specify laws[1] and automatically generate values for testing the law. QuickCheck generates values randomly, which can be useful but is very often insufficient. Both versions of SmallCheck do exhaustive search of all values down to a bounded &quot;depth&quot; (lazy SmallCheck can often search deeper and faster).<br>

<br>
If you want to have decent assurances of correctness then use (lazy) SmallCheck. If you&#39;re dealing with a really branchy type which makes it prohibitive to search to any reasonable depth, then use QuickCheck in addition. Occasionally QuickCheck can be good for ferreting out really obscure corner cases, but SmallCheck is much better about guaranteeing you get all the basic cases.<br>

<br>
<br>
[1] e.g.<br>
<br>
prop_compare a b =<br>
    compare a b == negateOrdering (compare b a)<br>
    where<br>
    negateOrdering LT = GT<br>
    negateOrdering EQ = EQ<br>
    negateOrdering GT = LT<br>
<br>
-- <br>
Live well,<br><font color="#888888">
~wren</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>