QuickCheck subsumes unit testing

Just to walk the walk, and not just talk the talk, here's a quick unit testing 'diff' driver I hacked up for QuickCheck. When run, it 'diffs' (well, just prints ;-) the incorrect values from the unit test: $ runhaskell T.hs sort unit test : Falsifiable after 0 tests: - [1,2,3] + [1,3,2]
From a normal QC specification like:
prop0 = (sort [3,2,1], [1,3,2]) main = mapM_ (\(s,a) -> printf "%-25s: " s >> a n) tests where n = 100 tests = [("sort unit test", mytest prop0)] The full driver code is attached. It is just proof of concept, but you can see how to extend it to be smarter/prettier. Note that we actually probably want to use SmallCheck here, to prevent bogus repetition of the test. (I.e. 500 tests all passed, for a unit test). Note also, the driver would need further extending, since we've changed the structure of the Testable values. Cheers, Don

On Apr 21, 2007, at 2:54 AM, Donald Bruce Stewart wrote:
Just to walk the walk, and not just talk the talk, here's a quick unit testing 'diff' driver I hacked up for QuickCheck.
Yay! I'll be the first to switch over!
Note that we actually probably want to use SmallCheck here,
I don't have an idea of when to prefer SmallCheck over QuickCheck. An explanation and, possibly, a tutorial would be very welcome! Anyone?
Note also, the driver would need further extending, since we've changed the structure of the Testable values.
Can you elaborate on "further extending"? What direction should I extend it in? Thanks, Joel -- http://wagerlabs.com/
participants (2)
-
dons@cse.unsw.edu.au
-
Joel Reymont