QuickCheck
For checking properties.
Usage
module MyModule where
import Test.QuickCheck
prop_absolute :: Int -> Int -> Bool
prop_absolute a b = (absolute a) * (absolute b) == absolute (a * b)
> quickCheck prop_absolute
+++ OK, passed 100 tests.
Testing Certain Values
- Implication function:
premise ==> conclusion
prop_absolute :: Int -> Int -> Property
prop_absolute a b = let a' = toInteger a
b' = toInteger b
maxInt = toInteger (maxBound :: Int)
minInt = toInteger (minBound :: Int)
in
(a' * b' < maxInt && a' * b' > minInt)
==> (absolute a) * (absolute b) == absolute (a * b)
-- equals
prop_absolute' :: Int -> Int -> Property
prop_absolute' a b = (a' * b' < maxInt && a' * b' > minInt)
==> (absolute a) * (absolute b) == absolute (a * b)
where
a' = toInteger a
b' = toInteger b
maxInt = toInteger (maxBound :: Int)
minInt = toInteger (minBound :: Int)