Test.Properties
- verify :: Show b => a -> [Property (b -> Bool)] -> b -> a
- data Property a = Property String a
- data Properties a b c = Properties {}
- properties :: forall a b c. Properties a b c
- with :: (a -> b) -> a -> b
Documentation
verify :: Show b => a -> [Property (b -> Bool)] -> b -> aSource
Check a list of properties. when a property is violated, a trace error is printed at the end i return the first value, just like (flip trace) must be used as opeator:
expressionverifypropertieswithvalue tuple
Example:
stringProperty=Property"length" (\(x, y)-> length (x++y)== length x + length y) main= do let s= "hello " let s2= "world" print $ s++ s2 `verify` stringProperty `with`(s,s2) print "that's all!"
It is possible to check quickCheck style properties. The same example with a quickCheck style property:
quickCheckProperty x y= length (x++y)== length x + length y
main= do
let s= "hello "
let s2= "world"
print $ s++ s2 `verify` [Property "stringSumLength" $ uncurry quickCheckProperty] `with`(s,s2)
print "that's all!"A labeled property includes a string label and an expression
data Properties a b c Source
Properties is a convenient way to express list of properties with the same arity.
properties :: forall a b c. Properties a b cSource
empty properties: properties= Properties [] [] []