diff --git a/lab4/test/Spec.hs b/lab4/test/Spec.hs index 360ec28..ab58924 100644 --- a/lab4/test/Spec.hs +++ b/lab4/test/Spec.hs @@ -1,5 +1,5 @@ import Test.QuickCheck -import Lib (isCongruent) +import Lib propCongruentDifference :: Int -> Int -> Int -> Property propCongruentDifference a b m = @@ -13,8 +13,25 @@ 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