Copyright | (C) 2017 ATS Advanced Telematic Systems GmbH Li-yao Xia |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Stevan Andjelkovic <stevan.andjelkovic@strath.ac.uk> |

Stability | provisional |

Portability | non-portable (GHC extensions) |

Safe Haskell | None |

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 ()
- anyP :: (a -> Property) -> [a] -> Property
- suchThatEither :: forall a. Gen a -> (a -> Bool) -> Gen (Either [a] a)
- collects :: Show a => [a] -> Property -> Property
- data Shrunk a = Shrunk {}
- shrinkS :: Arbitrary a => a -> [Shrunk a]
- shrinkListS :: forall a. (a -> [Shrunk a]) -> [a] -> [Shrunk [a]]
- shrinkListS' :: [a] -> [Shrunk [a]]
- shrinkListS'' :: forall a. (a -> [Shrunk a]) -> [a] -> [Shrunk [a]]
- shrinkPairS :: (a -> [Shrunk a]) -> (b -> [Shrunk b]) -> (a, b) -> [Shrunk (a, b)]
- shrinkPairS' :: (a -> [Shrunk a]) -> (a, a) -> [Shrunk (a, a)]
- pickOneReturnRest :: [a] -> [(a, [a])]
- pickOneReturnRest2 :: ([a], [a]) -> [(a, ([a], [a]))]
- pickOneReturnRestL :: [[a]] -> [(a, [[a]])]
- mkModel :: StateMachine model cmd m resp -> History cmd resp -> model Concrete

# Documentation

liftProperty :: Monad m => Property -> PropertyM m () Source #

Lifts a plain property into a monadic property.

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.

shrinkListS'' :: forall a. (a -> [Shrunk a]) -> [a] -> [Shrunk [a]] Source #

Shrink list by only shrinking elements.

shrinkPairS' :: (a -> [Shrunk a]) -> (a, a) -> [Shrunk (a, a)] Source #

pickOneReturnRest :: [a] -> [(a, [a])] Source #

pickOneReturnRest2 :: ([a], [a]) -> [(a, ([a], [a]))] Source #

pickOneReturnRestL :: [[a]] -> [(a, [[a]])] Source #