[Haskell-cafe] ANN: leancheck-v0.7.2, enumerative QuickCheck-like testing

Rudy Matela rudy at matela.com.br
Sun Sep 9 00:42:36 UTC 2018


Hi,

On Fri, 31 Aug 2018 16:44:17 -0300, Rodrigo Stevaux wrote:
> Hi, nice to see a fellow Brazilian.

:-)

> How does your work differ from QuickCheck?

In summary, LeanCheck _enumerates_ test values whereas QuickCheck
generates values _randomly_.  For example consider:

	prop_double :: Int -> Bool
	prop_double x  =  x + x == 2 * x

From the surface, QuickCheck and LeanCheck look very similar, in the
following case even providing the same output:

	> import Test.QuickCheck
	> quickCheck . withMaxSuccess 10 $ prop_double
	+++ OK, passed 10 tests.

	> import Test.LeanCheck
	> checkFor 10 prop_double
	+++ OK, passed 10 tests.

However, the 10 test values used by each tool differ quite a bit:

	> import Test.QuickCheck
	> sample' arbitrary :: IO [Int]
	[0,-2,-2,-4,-7,-4,-11,13,-3,-10,2]
	> sample' arbitrary :: IO [Int]
	[0,0,-2,4,-5,-1,-9,13,-12,-7,-12]

	> import Test.LeanCheck
	> take 10 list :: [Int]
	[0,1,-1,2,-2,3,-3,4,-4,5]
	> take 10 list :: [Int]
	[0,1,-1,2,-2,3,-3,4,-4,5]

Since QuickCheck is random, each run tests different values, in this case,
random integers.  Since LeanCheck is enumerative, each run tests the same
set of values, in this case integers of increasing magnitude.  In both
cases, if you increase the number of tests you'll be more likely to find a
bug.

Whether one wants enumerative or random test cases is a matter of debate.
If in doubt, you can always use both...  :-)  The bindings for Tasty,
test-framework and Hspec for LeanCheck and QuickCheck are very similar and
can help in this regard.

There are other differences in the library interface: I tried to keep
LeanCheck's very simple.   The default number of tests is different (LC:
200, QC: 100).  But again, the main difference is the method of test data
generation as explained above.

Best Regards,
Rudy

PS: sorry for the delay in replying, I read haskell-café in a monthly
digest and since I wasn't cc'ed, I only saw your e-mail now.


More information about the Haskell-Cafe mailing list