From 0835bc3a4eabaa601a28381251e22f152f69d651 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 2 Aug 2016 07:17:57 +0200 Subject: [PATCH] more tests --- test/Spec.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Spec.hs b/test/Spec.hs index a1324ca..82c6959 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -57,10 +57,22 @@ main = hspec $ do precision testMatchFun ['a', 'b', 'c'] [0, 1, 2, 3, 4, 5] `shouldBeAlmost` 0.3333333333333333 recall testMatchFun ['a', 'b', 'c'] [0, 1, 2, 3, 4, 5] `shouldBeAlmost` 0.66666666666666666 f1Measure testMatchFun ['a', 'b', 'c'] [0, 1, 2, 3, 4, 5] `shouldBeAlmost` 0.444444444444444 + it "perfect result" $ do + precision alwaysMatch ['a', 'b', 'c'] [0, 1, 2] `shouldBeAlmost` 1.0 + recall alwaysMatch ['a', 'b', 'c'] [0, 1, 2] `shouldBeAlmost` 1.0 + f1Measure alwaysMatch ['a', 'b', 'c'] [0, 1, 2] `shouldBeAlmost` 1.0 + it "full match" $ do + precision alwaysMatch ['a', 'b', 'c'] [0, 1, 2, 3, 4, 5] `shouldBeAlmost` 0.5 + recall alwaysMatch ['a', 'b', 'c'] [0, 1, 2, 3, 4, 5] `shouldBeAlmost` 1.0 + f1Measure alwaysMatch ['a', 'b', 'c'] [0, 1, 2, 3 , 4, 5] `shouldBeAlmost` 0.66666666666666 + neverMatch :: Char -> Int -> Bool neverMatch _ _ = False +alwaysMatch :: Char -> Int -> Bool +alwaysMatch _ _ = True + testMatchFun :: Char -> Int -> Bool testMatchFun 'a' 1 = True testMatchFun 'a' 2 = True