Safe Haskell | None |
---|---|
Language | Haskell2010 |
- module Data.GenValidity
- proxy :: a
- genspec :: (Show a, Eq a, Data a, GenValidity a, Arbitrary a) => a -> Spec
- arbitrarySpec :: (Typeable a, Show a, Eq a, Data a, GenValidity a, Arbitrary a) => a -> Spec
- validitySpec :: (Typeable a, Show a, Eq a, Data a, GenValidity a, Arbitrary a) => a -> Spec
- producesValidsOnGen :: (Show a, Show b, Validity b) => (a -> b) -> Gen a -> Property
- alwaysProducesValid :: (Show a, Show b, GenValidity a, Validity b) => (a -> b) -> Property
- producesValidsOnValids :: (Show a, Show b, GenValidity a, Validity b) => (a -> b) -> Property
- producesValidsOnGens2 :: (Show a, Show b, Show c, Validity c) => (a -> b -> c) -> Gen a -> Gen b -> Property
- alwaysProducesValid2 :: (Show a, Show b, Show c, GenValidity a, GenValidity b, Validity c) => (a -> b -> c) -> Property
- producesValidsOnValids2 :: (Show a, Show b, Show c, GenValidity a, GenValidity b, Validity c) => (a -> b -> c) -> Property
- class CanFail f where
- succeedsOnGen :: (Show a, Show b, Show (f b), CanFail f) => (a -> f b) -> Gen a -> Property
- succeedsOnValidInput :: (Show a, Show b, Show (f b), GenValidity a, CanFail f) => (a -> f b) -> Property
- failsOnGen :: (Show a, Show b, Show (f b), CanFail f) => (a -> f b) -> Gen a -> Property
- failsOnInvalidInput :: (Show a, Show b, Show (f b), GenValidity a, CanFail f) => (a -> f b) -> Property
- validIfSucceedsOnGen :: (Show a, Show b, Show (f b), Validity b, CanFail f) => (a -> f b) -> Gen a -> Property
- validIfSucceeds :: (Show a, Show b, Show (f b), GenValidity a, Validity b, CanFail f) => (a -> f b) -> Property
Documentation
module Data.GenValidity
Tests for GenValidity instances
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 #
alwaysProducesValid2 :: (Show a, Show b, Show c, GenValidity a, GenValidity b, Validity c) => (a -> b -> c) -> Property Source #
producesValidsOnValids2 :: (Show a, Show b, Show c, GenValidity a, GenValidity b, Validity c) => (a -> b -> c) -> 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.
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
.