Copyright | (c) 2017 Rudy Matela |
---|---|

License | 3-Clause BSD (see the file LICENSE) |

Maintainer | Rudy Matela <rudy@matela.com.br> |

Safe Haskell | None |

Language | Haskell2010 |

This module is part of Extrapolate, a library for generalization of counter-examples.

QuickCheck-like interface.

- check :: Testable a => a -> IO ()
- checkResult :: Testable a => a -> IO Bool
- for :: Testable a => (WithOption a -> b) -> Int -> a -> b
- withInstances :: Testable a => (WithOption a -> b) -> Instances -> a -> b
- withBackground :: Testable a => (WithOption a -> b) -> [Expr] -> a -> b
- withConditionSize :: Testable a => (WithOption a -> b) -> Int -> a -> b

# Documentation

check :: Testable a => a -> IO () Source #

Checks a property printing results on `stdout`

> check $ \xs -> sort (sort xs) == sort (xs::[Int]) +++ OK, passed 360 tests. > check $ \xs ys -> xs `union` ys == ys `union` (xs::[Int]) *** Failed! Falsifiable (after 4 tests): [] [0,0] Generalization: [] (x:x:_)

for :: Testable a => (WithOption a -> b) -> Int -> a -> b Source #

Use

to configure the number of tests performed by `for`

`check`

.

> check `for` 10080 $ \xs -> sort (sort xs) == sort (xs :: [Int]) +++ OK, passed 10080 tests.

Don't forget the dollar (`$`

)!

withInstances :: Testable a => (WithOption a -> b) -> Instances -> a -> b Source #

Allows the user to customize instance information available when generalized. (For advanced users.)

withBackground :: Testable a => (WithOption a -> b) -> [Expr] -> a -> b Source #

Use

to provide additional functions to appear in side-conditions.`withBackground`

check `withBackground` [constant "isSpace" isSpace] $ \xs -> unwords (words xs) == xs *** Failed! Falsifiable (after 4 tests): " " Generalization: ' ':_ Conditional Generalization: c:_ when isSpace c

withConditionSize :: Testable a => (WithOption a -> b) -> Int -> a -> b Source #

Use

to configure the maximum condition size allowed.`withConditionSize`