leancheck-1.0.0: Enumerative property-based testing
Copyright(c) 2015-2020 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.LeanCheck.IO

Description

This module is part of LeanCheck, a simple enumerative property-based testing library.

QuickCheck-like interface to Test.LeanCheck

Synopsis

Documentation

check :: Testable a => a -> IO () Source #

Checks a property printing results on stdout

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

checkFor :: Testable a => Int -> a -> IO () Source #

Check a property for a given number of tests printing results on stdout

> checkFor 1000 $ \xs -> sort (sort xs) == sort (xs::[Int])
+++ OK, passed 1000 tests.

Test exhaustion is reported when the configured number of tests is larger than the number of available test values:

> checkFor 3 $ \p -> p == not (not p)
+++ OK, passed 2 tests (exhausted).

checkResult :: Testable a => a -> IO Bool Source #

Check a property printing results on stdout and returning True on success.

> p <- checkResult $ \xs -> sort (sort xs) == sort (xs::[Int])
+++ OK, passed 200 tests.

> q <- checkResult $ \xs ys -> xs `union` ys == ys `union` (xs::[Int])
*** Failed! Falsifiable (after 4 tests):
[] [0,0]

> p && q
False

There is no option to silence this function: for silence, you should use holds.

checkResultFor :: Testable a => Int -> a -> IO Bool Source #

Check a property for a given number of tests printing results on stdout and returning True on success.

> checkResultFor 1000 $ \xs -> sort (sort xs) == sort (xs::[Int])
+++ OK, passed 1000 tests.
True

There is no option to silence this function: for silence, you should use holds.