Copyright | (C) 2017 ATS Advanced Telematic Systems GmbH Li-yao Xia |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Stevan Andjelkovic <stevan.andjelkovic@here.com> |
Stability | provisional |
Portability | non-portable (GHC extensions) |
Safe Haskell | Safe |
Language | Haskell2010 |
This module exports some QuickCheck utility functions. Some of these should perhaps be upstreamed.
Synopsis
- liftProperty :: Monad m => Property -> PropertyM m ()
- whenFailM :: Monad m => IO () -> Property -> PropertyM m ()
- forAllShrinkShow :: Testable prop => Gen a -> (a -> [a]) -> (a -> String) -> (a -> prop) -> Property
- anyP :: (a -> Property) -> [a] -> Property
- shrinkPair :: (a -> [a]) -> (a, a) -> [(a, a)]
- shrinkPair' :: (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
- suchThatOneOf :: [(Int, Gen a)] -> (a -> Bool) -> Gen (Maybe a)
- oldCover :: Testable prop => Bool -> Int -> String -> prop -> Property
- data Shrunk a = Shrunk {}
- shrinkS :: Arbitrary a => a -> [Shrunk a]
- shrinkListS :: forall a. (a -> [Shrunk a]) -> [a] -> [Shrunk [a]]
- shrinkListS' :: [a] -> [Shrunk [a]]
- shrinkPairS :: (a -> [Shrunk a]) -> (b -> [Shrunk b]) -> (a, b) -> [Shrunk (a, b)]
- shrinkPairS' :: (a -> [Shrunk a]) -> (a, a) -> [Shrunk (a, a)]
Documentation
liftProperty :: Monad m => Property -> PropertyM m () Source #
Lifts a plain property into a monadic property.
forAllShrinkShow :: Testable prop => Gen a -> (a -> [a]) -> (a -> String) -> (a -> prop) -> Property Source #
A variant of forAllShrink
with an
explicit show function.
shrinkPair :: (a -> [a]) -> (a, a) -> [(a, a)] Source #
Same above, but for homogeneous pairs.
shrinkPair' :: (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)] Source #
Given shrinkers for the components of a pair we can shrink the pair.
More permissive notion of shrinking where a value can shrink to itself
For example
shrink 3 == [0, 2] -- standard QuickCheck shrink shrinkS 3 == [Shrunk True 0, Shrunk True 2, Shrunk False 3]
This is primarily useful when shrinking composite structures: the combinators here keep track of whether something was shrunk somewhere in the structure. For example, we have
shrinkListS (shrinkPairS shrinkS shrinkS) [(1,3),(2,4)] == [ Shrunk True [] -- removed all elements of the list , Shrunk True [(2,4)] -- removed the first , Shrunk True [(1,3)] -- removed the second , Shrunk True [(0,3),(2,4)] -- shrinking the '1' , Shrunk True [(1,0),(2,4)] -- shrinking the '3' , Shrunk True [(1,2),(2,4)] -- .. , Shrunk True [(1,3),(0,4)] -- shrinking the '2' , Shrunk True [(1,3),(1,4)] -- .. , Shrunk True [(1,3),(2,0)] -- shrinking the '4' , Shrunk True [(1,3),(2,2)] -- .. , Shrunk True [(1,3),(2,3)] -- .. , Shrunk False [(1,3),(2,4)] -- the original unchanged list ]
shrinkListS :: forall a. (a -> [Shrunk a]) -> [a] -> [Shrunk [a]] Source #
shrinkListS' :: [a] -> [Shrunk [a]] Source #
Shrink list without shrinking elements
shrinkPairS' :: (a -> [Shrunk a]) -> (a, a) -> [Shrunk (a, a)] Source #