Добавил коменты
This commit is contained in:
@@ -1,27 +1,33 @@
|
|||||||
import Test.QuickCheck
|
import Test.QuickCheck
|
||||||
import Lib
|
import Lib
|
||||||
|
|
||||||
|
-- Если два числа равны по модулю, то их разность делится на модуль
|
||||||
propCongruentDifference :: Int -> Int -> Int -> Property
|
propCongruentDifference :: Int -> Int -> Int -> Property
|
||||||
propCongruentDifference a b m =
|
propCongruentDifference a b m =
|
||||||
m /= 0 ==> isCongruent a b m == ((a - b) `mod` m == 0)
|
m /= 0 ==> isCongruent a b m == ((a - b) `mod` m == 0)
|
||||||
|
|
||||||
|
-- Равенство по модулю является симметричным
|
||||||
propCongruentSymmetric :: Int -> Int -> Int -> Property
|
propCongruentSymmetric :: Int -> Int -> Int -> Property
|
||||||
propCongruentSymmetric a b m =
|
propCongruentSymmetric a b m =
|
||||||
m /= 0 ==> isCongruent a b m == isCongruent b a m
|
m /= 0 ==> isCongruent a b m == isCongruent b a m
|
||||||
|
|
||||||
|
-- Если одно число равно другому, то они равны по любому модулю
|
||||||
propCongruentEqualNumbers :: Int -> Int -> Property
|
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 Int Bool -> [Int] -> Bool
|
||||||
propFilterByPredicateSatisfiesPredicate (Fun _ predicate) xs =
|
propFilterByPredicateSatisfiesPredicate (Fun _ predicate) xs =
|
||||||
all predicate (filterByPredicate predicate xs)
|
all predicate (filterByPredicate predicate xs)
|
||||||
|
|
||||||
|
-- Длина результата не превышает длину исходного списка
|
||||||
propFilterByPredicateLength :: Fun Int Bool -> [Int] -> Bool
|
propFilterByPredicateLength :: Fun Int Bool -> [Int] -> Bool
|
||||||
propFilterByPredicateLength (Fun _ predicate) xs =
|
propFilterByPredicateLength (Fun _ predicate) xs =
|
||||||
length (filterByPredicate predicate xs) <= length xs
|
length (filterByPredicate predicate xs) <= length xs
|
||||||
|
|
||||||
|
-- Если предикат всегда возвращает True, то результат совпадает с исходным списком
|
||||||
propFilterByPredicateAlwaysTrue :: [Int] -> Bool
|
propFilterByPredicateAlwaysTrue :: [Int] -> Bool
|
||||||
propFilterByPredicateAlwaysTrue xs =
|
propFilterByPredicateAlwaysTrue xs =
|
||||||
filterByPredicate (\_ -> True) xs == xs
|
filterByPredicate (\_ -> True) xs == xs
|
||||||
|
|||||||
Reference in New Issue
Block a user