move Arbitrary instances out of Test and into modules that define the types
This is possible now that we build-depend on QuickCheck.
This commit is contained in:
parent
e7b78c2eec
commit
a2f17146fa
5 changed files with 54 additions and 51 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue