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

Safe HaskellNone
LanguageHaskell2010

Data.GenValidity.Hspec

Contents

Synopsis

Documentation

Tests for GenValidity instances

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)

Standard tests involving validity

producesValidsOnGen :: (Show a, Show b, Validity b) => (a -> b) -> Gen a -> Property Source #

The function produces valid output when the input is generated as specified by the given generator.

alwaysProducesValid :: (Show a, Show b, GenValidity a, Validity b) => (a -> b) -> Property Source #

The function produces valid output when the input is generated by genUnchecked

producesValidsOnValids :: (Show a, Show b, GenValidity a, Validity b) => (a -> b) -> Property Source #

The function produces valid output when the input is generated by genValid

producesValidsOnGens2 :: (Show a, Show b, Show c, Validity c) => (a -> b -> c) -> Gen a -> Gen b -> Property Source #

Standard tests involving functions that can fail

class CanFail f where Source #

A class of types that are the result of functions that can fail

You should not use this class yourself.

Minimal complete definition

hasFailed, resultIfSucceeded

Methods

hasFailed :: f a -> Bool Source #

resultIfSucceeded :: f a -> Maybe a Source #

succeedsOnGen :: (Show a, Show b, Show (f b), CanFail f) => (a -> f b) -> Gen a -> Property Source #

The function succeeds if the input is generated by the given generator

succeedsOnValidInput :: (Show a, Show b, Show (f b), GenValidity a, CanFail f) => (a -> f b) -> Property Source #

The function succeeds if the input is generated by genValid

failsOnGen :: (Show a, Show b, Show (f b), CanFail f) => (a -> f b) -> Gen a -> Property Source #

The function fails if the input is generated by the given generator

failsOnInvalidInput :: (Show a, Show b, Show (f b), GenValidity a, CanFail f) => (a -> f b) -> Property Source #

The function fails if the input is generated by genInvalid

validIfSucceedsOnGen :: (Show a, Show b, Show (f b), Validity b, CanFail f) => (a -> f b) -> Gen a -> Property Source #

The function produces output that satisfies isValid if it is given input that is generated by the given generator.

validIfSucceeds :: (Show a, Show b, Show (f b), GenValidity a, Validity b, CanFail f) => (a -> f b) -> Property Source #

The function produces output that satisfies isValid if it is given input that is generated by genUnchecked.