[Haskell-cafe] ANN: leancheck-v0.7.4 with providers for Tasty, Hspec and test-framework

Rudy Matela rudy at matela.com.br
Sat Sep 8 23:54:18 UTC 2018


Hello Haskell-Café,

A new version of LeanCheck is out: v0.7.4.  LeanCheck is a property
testing library (like QuickCheck) that tests values enumeratively rather
than at random (unlike QuickCheck).

_Whats new?_  I have created providers to make it easy to incorporate
LeanCheck properties in Tasty, Hspec and test-framework test suites.  This
is optional and provided in separate packages: LeanCheck can still be used
alone.

LeanCheck and its framework providers are available on Hackage.
You can install them with:

$ cabal install leancheck
$ cabal install tasty-leancheck
$ cabal install hspec-leancheck
$ cabal install test-framework-leancheck

Check out the README files for examples of use:

* https://github.com/rudymatela/leancheck
* https://github.com/rudymatela/tasty-leancheck
* https://github.com/rudymatela/hspec-leancheck
* https://github.com/rudymatela/test-framework-leancheck


Here's a sneak peek of LeanCheck+Tasty:


## Test program

    import Test.Tasty
    import Test.Tasty.LeanCheck as LC
    import Data.List

    main :: IO ()
    main = defaultMain tests

    tests :: TestTree
    tests = testGroup "Test properties checked by LeanCheck"
      [ LC.testProperty "sort == sort . reverse" $
          \list -> sort (list :: [Int]) == sort (reverse list)
      , LC.testProperty "Fermat's little theorem" $
          \x -> ((x :: Integer)^7 - x) `mod` 7 == 0
      -- the following property do not hold
      , LC.testProperty "Fermat's last theorem" $
          \x y z n ->
            (n :: Integer) >= 3 LC.==> x^n + y^n /= (z^n :: Integer)
      ]


## Output for the test program

    $ ./test
    Test properties checked by LeanCheck
      sort == sort . reverse:  OK
        +++ OK, passed 200 tests.
      Fermat's little theorem: OK
        +++ OK, passed 200 tests.
      Fermat's last theorem:   FAIL
        *** Failed! Falsifiable (after 71 tests):
        0 0 0 3

    1 out of 3 tests failed (0.00s)

You can't see it here, but Tasty's output is highlighted in colours:
"FAIL" appears in red so you can quickly see which properties failed.


Best Regards,
Rudy


More information about the Haskell-Cafe mailing list