Agda-2.3.0: A dependently typed functional programming language and proof assistant

Agda.Utils.TestHelpers

Contents

Description

Some functions and generators suitable for writing QuickCheck properties.

Synopsis

Algebraic properties

associative :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> a -> a -> a -> BoolSource

Is the operator associative?

commutative :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> a -> a -> BoolSource

Is the operator commutative?

isZero :: (Arbitrary a, Eq a, Show a) => a -> (a -> a -> a) -> a -> BoolSource

Is the element a zero for the operator?

identity :: (Arbitrary a, Eq a, Show a) => a -> (a -> a -> a) -> a -> BoolSource

Is the element a unit for the operator?

leftDistributive :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> BoolSource

Does the first operator distribute (from the left) over the second one?

rightDistributive :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> BoolSource

Does the first operator distribute (from the right) over the second one?

Generators

natural :: Integral i => Gen iSource

Generates natural numbers.

positive :: Integral i => Gen iSource

Generates positive numbers.

maybeGen :: Gen a -> Gen (Maybe a)Source

Generates values of Maybe type, using the given generator to generate the contents of the Just constructor.

maybeCoGen :: (a -> Gen b -> Gen b) -> Maybe a -> Gen b -> Gen bSource

Coarbitrary "generator" for Maybe.

listOfElements :: [a] -> Gen [a]Source

Generates a list of elements picked from a given list.

two :: Gen a -> Gen (a, a)Source

Generates two elements.

three :: Gen a -> Gen (a, a, a)Source

Generates three elements.

Test driver.

runTestsSource

Arguments

:: String

A label for the tests. Used for informational purposes.

-> [IO Bool] 
-> IO Bool 

Runs the tests, and returns True if all tests were successful.