tasty-leancheck

LeanCheck support for the Tasty test framework.

https://github.com/rudymatela/tasty-leancheck#readme

Version on this page:0.0.1
LTS Haskell 22.37:0.0.2
Stackage Nightly 2024-10-11:0.0.2
Latest on Hackage:0.0.2

See all snapshots tasty-leancheck appears in

BSD-3-Clause licensed and maintained by Rudy Matela
This version can be pinned in stack with:tasty-leancheck-0.0.1@sha256:03407baf9fded4fdc1a4ea06a56c20b2c11725c6034104b486e7f3197d7aee1e,1951

Module documentation for 0.0.1

Depends on 3 packages(full list with versions):

tasty-leancheck: LeanCheck support for Tasty

tasty-leancheck’s Build Status tasty-leancheck on Hackage tasty-leancheck on Stackage LTS tasty-leancheck on Stackage Nightly

LeanCheck support for the Tasty test framework. Tasty and healthy tests.

Installing

$ cabal install tasty-leancheck

Example

(This example is intentionally similar to Tasty’s official example.)

Here’s how your test.hs might look like:

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)
  ]

And here is the output for the above 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)

Options

The tasty-leancheck provider has only one option, --leancheck-tests:

$ ./test --leancheck-tests 10
Test properties checked by LeanCheck
  sort == sort . reverse:  OK
    +++ OK, passed 10 tests.
  Fermat's little theorem: OK
    +++ OK, passed 10 tests.
  Fermat's last theorem:   OK
    +++ OK, passed 10 tests.

All 3 tests passed (0.00s)

Further reading