summaryrefslogtreecommitdiff
path: root/Logs/Presence.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-27 21:42:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-27 21:42:07 -0400
commitca59b87b11c01c417a7b3b8f0cf15426e6fadcfb (patch)
tree36c342a8ae999986aabf51d6a3371515e9ac1dfd /Logs/Presence.hs
parentf54b34a6e6cb000d3117106fd19c13ef9dc7f38f (diff)
move Arbitrary instances out of Test and into modules that define the types
This is possible now that we build-depend on QuickCheck.
Diffstat (limited to 'Logs/Presence.hs')
-rw-r--r--Logs/Presence.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/Logs/Presence.hs b/Logs/Presence.hs
index 49573df69..83cbe0684 100644
--- a/Logs/Presence.hs
+++ b/Logs/Presence.hs
@@ -29,6 +29,8 @@ import Data.Time.Clock.POSIX
import Data.Time
import System.Locale
import qualified Data.Map as M
+import Test.QuickCheck
+import Utility.QuickCheck ()
import Common.Annex
import qualified Annex.Branch
@@ -74,10 +76,6 @@ showLog = unlines . map genline
genstatus InfoPresent = "1"
genstatus InfoMissing = "0"
--- for quickcheck
-prop_parse_show_log :: [LogLine] -> Bool
-prop_parse_show_log l = parseLog (showLog l) == l
-
{- Generates a new LogLine with the current date. -}
logNow :: LogStatus -> String -> Annex LogLine
logNow s i = do
@@ -113,3 +111,13 @@ mapLog l m
better = maybe True newer $ M.lookup i m
newer l' = date l' <= date l
i = info l
+
+instance Arbitrary LogLine where
+ arbitrary = LogLine
+ <$> arbitrary
+ <*> elements [minBound..maxBound]
+ <*> arbitrary `suchThat` ('\n' `notElem`)
+
+prop_parse_show_log :: [LogLine] -> Bool
+prop_parse_show_log l = parseLog (showLog l) == l
+