testing-feat-0.2: Functional enumeration for systematic and random testing

Safe HaskellSafe-Infered




Functions for accessing the values of enumerations including compatibility with the property based testing frameworks QuickCheck and SmallCheck.


Accessing functions

index :: Enumerate a -> Integer -> aSource

Mainly as a proof of concept we can use the isomorphism between natural numbers and (Part,Index) pairs to index into a type. May not terminate for finite types. Might be slow the first time it is used with a specific enumeration because cardinalities need to be calculated. The computational complexity (after cardinalities are computed) is a polynomial in the size of the resulting value.

values :: Enumerable a => [(Integer, [a])]Source

All values of the enumeration by increasing cost (which is the number of constructors for most types). Also contains the cardinality of each list.

striped :: Enumerable a => Part -> Index -> Integer -> [(Integer, [a])]Source

A generalisation of values that enumerates every nth value of the enumeration from a given starting point. As a special case values = striped 0 0 1.

bounded :: Enumerable a => Integer -> [(Integer, [a])]Source

A version of vales that has a limited number of values in each inner list. If the list corresponds to a Part which is larger than the bound it evenly intersperses the values across the enumeration of the Part.

A simple property tester

ioFeat :: [(Integer, [a])] -> (a -> IO ()) -> IO ()Source

A rather simple but general property testing driver. The property is an (funcurried) IO function that both tests and reports the error. The driver goes on forever or until the list is exhausted, reporting the coverage and the number of tests before each new part.

ioAll :: Enumerable a => (a -> IO ()) -> IO ()Source

Defined as ioAll = ioFeat values

ioBounded :: Enumerable a => Integer -> (a -> IO ()) -> IO ()Source

Defined as ioBounded n = ioFeat (bounded n)



uniform :: Enumerable a => Int -> Gen aSource

Compatibility with QuickCheck. Distribution is uniform generator over values bounded by the given size. Typical use: sized uniform.


toSeries :: Enumerable a => Int -> [a]Source

Compatibility with SmallCheck.

Non-class versions of the access functions

valuesWith :: Enumerate a -> [(Integer, [a])]Source

Non class version of values.

stripedWith :: Enumerate a -> Part -> Index -> Integer -> [(Integer, [a])]Source

Non class version of striped.

boundedWith :: Enumerate a -> Integer -> [(Integer, [a])]Source

Non class version of bounded.

uniformWith :: Enumerate a -> Part -> Gen aSource

Non class version of uniform.

toSeriesWith :: Enumerate a -> Int -> [a]Source

Non class version of toSeries.