Тесты для filterByPredicate
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import Test.QuickCheck
|
import Test.QuickCheck
|
||||||
import Lib (isCongruent)
|
import Lib
|
||||||
|
|
||||||
propCongruentDifference :: Int -> Int -> Int -> Property
|
propCongruentDifference :: Int -> Int -> Int -> Property
|
||||||
propCongruentDifference a b m =
|
propCongruentDifference a b m =
|
||||||
@@ -13,8 +13,25 @@ propCongruentEqualNumbers :: Int -> Int -> Property
|
|||||||
propCongruentEqualNumbers a m =
|
propCongruentEqualNumbers a m =
|
||||||
m /= 0 ==> isCongruent a a m == True
|
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 :: IO ()
|
||||||
main = do
|
main = do
|
||||||
quickCheck propCongruentDifference
|
quickCheck propCongruentDifference
|
||||||
quickCheck propCongruentSymmetric
|
quickCheck propCongruentSymmetric
|
||||||
quickCheck propCongruentEqualNumbers
|
quickCheck propCongruentEqualNumbers
|
||||||
|
|
||||||
|
quickCheck propFilterByPredicateSatisfiesPredicate
|
||||||
|
quickCheck propFilterByPredicateLength
|
||||||
|
quickCheck propFilterByPredicateAlwaysTrue
|
||||||
|
|||||||
Reference in New Issue
Block a user