[Haskell-cafe] ANN: leancheck-v0.7.2, enumerative QuickCheck-like testing
Rudy Matela
rudy at matela.com.br
Wed Aug 22 22:06:03 UTC 2018
Hello Haskell-Café,
LeanCheck is a simple enumerative property-based testing library for
Haskell. It is highly portable, and even works on Hugs98 (v2006-09).
It does not pull any dependencies other than what's bundled with GHC.
Check it out on Hackage and GitHub:
https://hackage.haskell.org/package/leancheck
https://github.com/rudymatela/leancheck
A simple example follows:
> import Test.LeanCheck
> import Data.List (sort, union)
> check $ \xs -> sort (sort xs) == sort (xs::[Int])
+++ OK, passed 200 tests.
> check $ \xs ys -> xs `union` ys == ys `union` (xs::[Int])
*** Failed! Falsifiable (after 4 tests):
[] [0,0]
LeanCheck works on all types that are instances of the Listable typeclass.
A TH automatic deriver is provided with LeanCheck so you don't need to
learn LeanCheck's DSL to test with your types.
I recently released 0.7.2, there are several additions since last
announcement here. Notable changes include:
* minor fixes for loading on Hugs98;
* functions to compute statistics about generated values; and
* a family of functions to test invariants of typeclass instances:
> data MyTy = ...
> instance ... MyTy where ...
> import Test.LeanCheck.Utils
> check $ (okEqOrd :: MyTy -> MyTy -> MyTy -> Bool)
+++ OK, passed 200 tests.
> check $ (okNum :: MyTy -> MyTy -> MyTy -> Bool)
+++ OK, passed 200 tests.
LeanCheck is available on Hackage or Stackage, and can be installed using:
$ cabal install leancheck
As far as I am aware, there are no bindings to use LeanCheck with tasty,
test-framework or hspec yet, but contributions are welcome. I may create
bindings for those if I ever get the time.
Best Regards,
Rudy
More information about the Haskell-Cafe
mailing list