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
- minFailures :: Testable a => (WithOption a -> b) -> Ratio Int -> a -> b
- maxSpeculateSize :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b
- conditionBound :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b
- constantBound :: Testable a => (WithOption a -> b) -> Maybe Int -> a -> b
- depthBound :: Testable a => (WithOption a -> b) -> Maybe 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`

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

Use

to configure the minimum number of failures for a
conditional generalization in function of the maximum number of tests.`minFailures`

To set that conditional generalizations should fail for 10% of cases:
> check `minFailures`

(`div`

10) $ prop

To set that conditional generalizations should fail for 5% of cases:
> check `minFailures`

(`div`

20) $ prop

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

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

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

Configures a bound on the number of constants allowed in expressions that are considered when testing for equality in Speculate.

Defaults to 2.

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

Configures a bound on the depth of expressions that are considered when testing for equality in Speculate.

Default to 3.