summaryrefslogtreecommitdiff
path: root/Utility/InodeCache.hs
diff options
context:
space:
mode:
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