38 lines
1.2 KiB
Haskell
38 lines
1.2 KiB
Haskell
import Test.QuickCheck
|
|
import Lib
|
|
|
|
propCongruentDifference :: Int -> Int -> Int -> Property
|
|
propCongruentDifference a b m =
|
|
m /= 0 ==> isCongruent a b m == ((a - b) `mod` m == 0)
|
|
|
|
propCongruentSymmetric :: Int -> Int -> Int -> Property
|
|
propCongruentSymmetric a b m =
|
|
m /= 0 ==> isCongruent a b m == isCongruent b a m
|
|
|
|
propCongruentEqualNumbers :: Int -> Int -> Property
|
|
propCongruentEqualNumbers a m =
|
|
m /= 0 ==> isCongruent a a m == True
|
|
|
|
|
|
propFilterByPredicateSatisfiesPredicate :: Fun Int Bool -> [Int] -> Bool
|
|
propFilterByPredicateSatisfiesPredicate (Fun _ predicate) xs =
|
|
all predicate (filterByPredicate predicate xs)
|
|
|
|
propFilterByPredicateLength :: Fun Int Bool -> [Int] -> Bool
|
|
propFilterByPredicateLength (Fun _ predicate) xs =
|
|
length (filterByPredicate predicate xs) <= length xs
|
|
|
|
propFilterByPredicateAlwaysTrue :: [Int] -> Bool
|
|
propFilterByPredicateAlwaysTrue xs =
|
|
filterByPredicate (\_ -> True) xs == xs
|
|
|
|
main :: IO ()
|
|
main = do
|
|
quickCheck propCongruentDifference
|
|
quickCheck propCongruentSymmetric
|
|
quickCheck propCongruentEqualNumbers
|
|
|
|
quickCheck propFilterByPredicateSatisfiesPredicate
|
|
quickCheck propFilterByPredicateLength
|
|
quickCheck propFilterByPredicateAlwaysTrue
|