summaryrefslogtreecommitdiff
path: root/Utility/InodeCache.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 /Utility/InodeCache.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 'Utility/InodeCache.hs')
-rw-r--r--Utility/InodeCache.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/Utility/InodeCache.hs b/Utility/InodeCache.hs
index 321125bf4..fdcbf3ef2 100644
--- a/Utility/InodeCache.hs
+++ b/Utility/InodeCache.hs
@@ -9,6 +9,8 @@ module Utility.InodeCache where
import Common
import System.Posix.Types
+import Test.QuickCheck
+import Utility.QuickCheck ()
data InodeCache = InodeCache FileID FileOffset EpochTime
deriving (Eq, Show)
@@ -35,10 +37,6 @@ readInodeCache s = case words s of
<*> readish mtime
_ -> Nothing
--- for quickcheck
-prop_read_show_inodecache :: InodeCache -> Bool
-prop_read_show_inodecache c = readInodeCache (showInodeCache c) == Just c
-
genInodeCache :: FilePath -> IO (Maybe InodeCache)
genInodeCache f = catchDefaultIO Nothing $ toInodeCache <$> getFileStatus f
@@ -49,3 +47,12 @@ toInodeCache s
(fileSize s)
(modificationTime s)
| otherwise = Nothing
+
+instance Arbitrary InodeCache where
+ arbitrary = InodeCache
+ <$> arbitrary
+ <*> arbitrary
+ <*> arbitrary
+
+prop_read_show_inodecache :: InodeCache -> Bool
+prop_read_show_inodecache c = readInodeCache (showInodeCache c) == Just c