genvalidity-hspec-0.1.0.0: Standard spec's for GenValidity instances

Safe HaskellNone
LanguageHaskell2010

Data.GenValidity.Hspec

Description

These are standard tests that you should add to your hspec test suite if you implemented GenValidity instances for your own data types.

Use them like this:

mySpec :: Spec
mySpec = do
    genspec (proxy :: MyType)
    genspec (proxy :: MyOtherType)

HSpec will take care of the rest.

Synopsis

Documentation

proxy :: a Source #

A value of arbitrary type, used to specify which type to generate a spec for.

genspec :: (Show a, Eq a, Data a, GenValidity a, Arbitrary a) => a -> Spec Source #

A combination of arbitrarySpec and validitySpec

Example usage:

genspec (proxy :: MyData)

arbitrarySpec :: (Typeable a, Show a, Eq a, Data a, GenValidity a, Arbitrary a) => a -> Spec Source #

A Spec that specifies that arbitrary only generates data that satisfy isValid and that shrink only produces data that satisfy isValid.

Example usage:

arbitrarySpec (proxy :: MyData)

validitySpec :: (Typeable a, Show a, Eq a, Data a, GenValidity a, Arbitrary a) => a -> Spec Source #

A Spec that specifies that genValid only generates valid data and that genInvalid only generates invalid data.

In general it is a good idea to add this spec to your test suite if you write a custom implementation of genValid or genInvalid.

Example usage:

validitySpec (proxy :: MyData)