From ca59b87b11c01c417a7b3b8f0cf15426e6fadcfb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 Feb 2013 21:42:07 -0400 Subject: move Arbitrary instances out of Test and into modules that define the types This is possible now that we build-depend on QuickCheck. --- Utility/InodeCache.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Utility') 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 -- cgit v1.2.3