more quickcheck fun
This commit is contained in:
parent
bf71d42681
commit
ddb0adb998
3 changed files with 30 additions and 13 deletions
|
@ -17,7 +17,8 @@ module Annex.Content.Direct (
|
||||||
removeCache,
|
removeCache,
|
||||||
genCache,
|
genCache,
|
||||||
toCache,
|
toCache,
|
||||||
Cache
|
Cache(..),
|
||||||
|
prop_read_show_direct
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -123,6 +124,10 @@ readCache s = case words s of
|
||||||
<*> readish mtime
|
<*> readish mtime
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
|
-- for quickcheck
|
||||||
|
prop_read_show_direct :: Cache -> Bool
|
||||||
|
prop_read_show_direct c = readCache (showCache c) == Just c
|
||||||
|
|
||||||
genCache :: FilePath -> IO (Maybe Cache)
|
genCache :: FilePath -> IO (Maybe Cache)
|
||||||
genCache f = catchDefaultIO Nothing $ toCache <$> getFileStatus f
|
genCache f = catchDefaultIO Nothing $ toCache <$> getFileStatus f
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import qualified Annex
|
||||||
import qualified Annex.Branch
|
import qualified Annex.Branch
|
||||||
import qualified Annex.Queue
|
import qualified Annex.Queue
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Content.Direct
|
|
||||||
import Annex.Direct
|
import Annex.Direct
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
import qualified Git.Command
|
import qualified Git.Command
|
||||||
|
|
35
test.hs
35
test.hs
|
@ -51,21 +51,18 @@ import qualified Utility.Format
|
||||||
import qualified Utility.Verifiable
|
import qualified Utility.Verifiable
|
||||||
import qualified Utility.Process
|
import qualified Utility.Process
|
||||||
import qualified Utility.Misc
|
import qualified Utility.Misc
|
||||||
|
import qualified Annex.Content.Direct
|
||||||
|
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
|
|
||||||
-- instances for quickcheck
|
-- instances for quickcheck
|
||||||
instance Arbitrary Types.Key.Key where
|
instance Arbitrary Types.Key.Key where
|
||||||
arbitrary = do
|
arbitrary = Types.Key.Key
|
||||||
n <- arbitrary
|
<$> arbitrary
|
||||||
b <- elements ['A'..'Z']
|
<*> ((\b -> [b]) <$> elements ['A'..'Z']) -- BACKEND
|
||||||
return Types.Key.Key {
|
<*> ((abs <$>) <$> arbitrary) -- size cannot be negative
|
||||||
Types.Key.keyName = n,
|
<*> arbitrary
|
||||||
Types.Key.keyBackendName = [b],
|
|
||||||
Types.Key.keySize = Nothing,
|
|
||||||
Types.Key.keyMtime = Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
instance Arbitrary Logs.Transfer.TransferInfo where
|
instance Arbitrary Logs.Transfer.TransferInfo where
|
||||||
arbitrary = Logs.Transfer.TransferInfo
|
arbitrary = Logs.Transfer.TransferInfo
|
||||||
|
@ -78,10 +75,25 @@ instance Arbitrary Logs.Transfer.TransferInfo where
|
||||||
<*> arbitrary
|
<*> arbitrary
|
||||||
|
|
||||||
instance Arbitrary POSIXTime where
|
instance Arbitrary POSIXTime where
|
||||||
arbitrary = arbitrarySizedIntegral
|
arbitrary = abs <$> arbitrarySizedIntegral
|
||||||
|
|
||||||
instance Arbitrary ProcessID where
|
instance Arbitrary ProcessID where
|
||||||
arbitrary = arbitraryBoundedIntegral
|
arbitrary = abs <$> arbitraryBoundedIntegral
|
||||||
|
|
||||||
|
instance Arbitrary Annex.Content.Direct.Cache where
|
||||||
|
arbitrary = Annex.Content.Direct.Cache
|
||||||
|
<$> arbitrary
|
||||||
|
<*> arbitrary
|
||||||
|
<*> arbitrary
|
||||||
|
|
||||||
|
instance Arbitrary EpochTime where
|
||||||
|
arbitrary = abs <$> arbitrarySizedIntegral
|
||||||
|
|
||||||
|
instance Arbitrary FileID where
|
||||||
|
arbitrary = abs <$> arbitrarySizedIntegral
|
||||||
|
|
||||||
|
instance Arbitrary FileOffset where
|
||||||
|
arbitrary = abs <$> arbitrarySizedIntegral
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
@ -115,6 +127,7 @@ quickcheck = TestLabel "quickcheck" $ TestList
|
||||||
, qctest "prop_verifiable_sane" Utility.Verifiable.prop_verifiable_sane
|
, qctest "prop_verifiable_sane" Utility.Verifiable.prop_verifiable_sane
|
||||||
, qctest "prop_segment_regressionTest" Utility.Misc.prop_segment_regressionTest
|
, qctest "prop_segment_regressionTest" Utility.Misc.prop_segment_regressionTest
|
||||||
, qctest "prop_read_write_transferinfo" Logs.Transfer.prop_read_write_transferinfo
|
, qctest "prop_read_write_transferinfo" Logs.Transfer.prop_read_write_transferinfo
|
||||||
|
, qctest "prop_read_show_direct" Annex.Content.Direct.prop_read_show_direct
|
||||||
]
|
]
|
||||||
|
|
||||||
blackbox :: Test
|
blackbox :: Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue