SmallCheck is a testing library that allows to verify properties for all test cases up to some depth. The test cases are generated automatically by SmallCheck.
SmallCheck is a testing library that allows to verify properties for all test cases up to some depth. The test cases are generated automatically by SmallCheck.
Test.SmallCheck
This module exports the main pieces of SmallCheck functionality.
To generate test cases for your own types, refer to Test.SmallCheck.Series.
For pointers to other sources of information about SmallCheck, please refer to the README at https://github.com/feuerbach/smallcheck/blob/master/README.md
Constructing tests
The simplest kind of test is a function (possibly of many arguments) returning Bool. The function arguments are interpreted as being universally, existentially or uniquely quantified, depending on the quantification context.
The default quantification context is universal (forAll).
forAll, exists and existsUnique functions set the quantification context for function arguments. Depending on the quantification context, the test \x y -> p x y
may be equivalent to:
∀ x, y. p x y (forAll)
∃ x, y: p x y (exists)
∃! x, y: p x y (existsUnique)
The quantification context affects all the variables immediately following the quantification operator, also extending past over, changeDepth and changeDepth1 functions.
However, it doesn't extend past other functions, like monadic, and doesn't affect the operands of ==>. Such functions start a fresh default quantification context.
Examples
\x y -> p x y means ∀ x, y. p x y
exists $ \x y -> p x y means ∃ x, y: p x y
exists $ \x -> forAll $ \y -> p x y means ∃ x: ∀ y. p x y
existsUnique $ \x y -> p x y means ∃! (x, y): p x y
existsUnique $ \x -> over s $ \y -> p x y means ∃! (x, y): y ∈ s && p x y
existsUnique $ \x -> monadic $ \y -> p x y means ∃! x: ∀ y. [p x y]
existsUnique $ \x -> existsUnique $ \y -> p x y means ∃! x: ∃! y: p x y
exists $ \x -> (\y -> p y) ==> (\z -> q z) means ∃ x: (∀ y. p y) => (∀ z. p z)