From 7ccdb8346efcd434e0492dcf6e98136643ccd443 Mon Sep 17 00:00:00 2001 From: Arity-T Date: Fri, 29 Nov 2024 19:26:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=B9=20=D1=84=D1=83?= =?UTF-8?q?=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab4/lab4.cabal | 3 ++- lab4/package.yaml | 1 + lab4/test/Spec.hs | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lab4/lab4.cabal b/lab4/lab4.cabal index d953ad5..12e5dde 100644 --- a/lab4/lab4.cabal +++ b/lab4/lab4.cabal @@ -62,6 +62,7 @@ test-suite lab4-test test ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: - base >=4.7 && <5 + QuickCheck + , base >=4.7 && <5 , lab4 default-language: Haskell2010 diff --git a/lab4/package.yaml b/lab4/package.yaml index 7484a48..2429c0f 100644 --- a/lab4/package.yaml +++ b/lab4/package.yaml @@ -57,3 +57,4 @@ tests: - -with-rtsopts=-N dependencies: - lab4 + - QuickCheck diff --git a/lab4/test/Spec.hs b/lab4/test/Spec.hs index cd4753f..360ec28 100644 --- a/lab4/test/Spec.hs +++ b/lab4/test/Spec.hs @@ -1,2 +1,20 @@ +import Test.QuickCheck +import Lib (isCongruent) + +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 + main :: IO () -main = putStrLn "Test suite not yet implemented" +main = do + quickCheck propCongruentDifference + quickCheck propCongruentSymmetric + quickCheck propCongruentEqualNumbers