Тесты для filterByPredicate

This commit is contained in:
2024-11-29 20:00:44 +03:00
parent f05a39da06
commit a3061e6678

View File

@@ -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