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. --- Types/Key.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Types') diff --git a/Types/Key.hs b/Types/Key.hs index ecdf7b842..e955725c7 100644 --- a/Types/Key.hs +++ b/Types/Key.hs @@ -17,6 +17,8 @@ module Types.Key ( ) where import System.Posix.Types +import Test.QuickCheck +import Utility.QuickCheck () import Common @@ -74,5 +76,12 @@ file2key s = if key == Just stubKey then Nothing else key addfield 'm' k v = Just k { keyMtime = readish v } addfield _ _ _ = Nothing +instance Arbitrary Key where + arbitrary = Key + <$> arbitrary + <*> (listOf1 $ elements ['A'..'Z']) -- BACKEND + <*> ((abs <$>) <$> arbitrary) -- size cannot be negative + <*> arbitrary + prop_idempotent_key_encode :: Key -> Bool prop_idempotent_key_encode k = Just k == (file2key . key2file) k -- cgit v1.2.3