MyNixOS website logo
Description

LeanCheck support for test-framework.

LeanCheck support for test-framework.

This package can be used to incorporate LeanCheck tests into test-framework test suites.

Please see the Haddock documentation and README for more details.

test-framework-leancheck: LeanCheck support for test-framework

test-framework-leancheck's Build Status test-framework-leancheck on Hackage test-framework-leancheck on Stackage LTS test-framework-leancheck on Stackage Nightly

LeanCheck support for the test-framework test framework.

Installing

$ cabal install test-framework-leancheck

Example

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

import Test.Framework
import Test.Framework.Providers.LeanCheck as LC
import Data.List

main :: IO ()
main = defaultMain tests

tests :: [Test]
tests =
  [ LC.testProperty "sort . sort == sort"
      $ \xs -> sort (sort xs :: [Int]) == sort xs
  , LC.testProperty "sort == id" -- not really, should fail
      $ \xs -> sort (xs :: [Int]) == xs
  ]

And here is the output for the above program:

$ ./eg/test
sort . sort == sort: [OK, passed 100 tests.]
sort == id: [Failed]
*** Failed! Falsifiable (after 7 tests):
[1,0]

         Properties  Total
 Passed  1           1
 Failed  1           1
 Total   2           2

Options

Use -a or --maximum-generated-tests to configure the maximum number of tests for each property.

$ ./eg/test -a5
sort . sort == sort: [OK, passed 5 tests.]
sort == id: [OK, passed 5 tests.]

         Properties  Total      
 Passed  2           2          
 Failed  0           0          
 Total   2           2          

Since LeanCheck is enumerative, you may want to increase the default number of tests (100). Arbitrary rule of thumb:

  • between 200 to 500 on a developer machine;
  • between 1000 and 5000 on the CI.

Your mileage may vary.

Further reading

Metadata

Version

0.0.4

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows