move quickcheck Arbitrary declaration into test suite
So git-annex can build w/o quickcheck installed.
This commit is contained in:
parent
e1bc704a91
commit
3d3abab679
2 changed files with 14 additions and 13 deletions
13
Key.hs
13
Key.hs
|
@ -13,7 +13,6 @@ module Key (
|
|||
prop_idempotent_key_read_show
|
||||
) where
|
||||
|
||||
import Test.QuickCheck
|
||||
import Utility
|
||||
import System.Posix.Types
|
||||
|
||||
|
@ -71,17 +70,5 @@ readKey s = if key == Just stubKey then Nothing else key
|
|||
addfield 'm' k v = Just k { keyMtime = readMaybe v }
|
||||
addfield _ _ _ = Nothing
|
||||
|
||||
-- for quickcheck
|
||||
instance Arbitrary Key where
|
||||
arbitrary = do
|
||||
n <- arbitrary
|
||||
b <- elements ['A'..'Z']
|
||||
return $ Key {
|
||||
keyName = n,
|
||||
keyBackendName = [b],
|
||||
keySize = Nothing,
|
||||
keyMtime = Nothing
|
||||
}
|
||||
|
||||
prop_idempotent_key_read_show :: Key -> Bool
|
||||
prop_idempotent_key_read_show k = Just k == (readKey $ show k)
|
||||
|
|
14
test.hs
14
test.hs
|
@ -7,6 +7,8 @@
|
|||
|
||||
import Test.HUnit
|
||||
import Test.HUnit.Tools
|
||||
import Test.QuickCheck
|
||||
|
||||
import System.Directory
|
||||
import System.Posix.Directory (changeWorkingDirectory)
|
||||
import System.Posix.Files
|
||||
|
@ -42,6 +44,18 @@ import qualified Key
|
|||
import qualified Config
|
||||
import qualified Crypto
|
||||
|
||||
-- for quickcheck
|
||||
instance Arbitrary Key.Key where
|
||||
arbitrary = do
|
||||
n <- arbitrary
|
||||
b <- elements ['A'..'Z']
|
||||
return $ Key.Key {
|
||||
Key.keyName = n,
|
||||
Key.keyBackendName = [b],
|
||||
Key.keySize = Nothing,
|
||||
Key.keyMtime = Nothing
|
||||
}
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
prepare
|
||||
|
|
Loading…
Reference in a new issue