reorg quickcheck to a separate module
authorJoey Hess <joeyh@joeyh.name>
Tue, 17 Nov 2015 19:49:22 +0000 (15:49 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 17 Nov 2015 19:49:22 +0000 (15:49 -0400)
Test.hs
Utility/Scheduled.hs
Utility/Scheduled/QuickCheck.hs [new file with mode: 0644]

diff --git a/Test.hs b/Test.hs
index 5718b582114f20e21b94174fda33a267b7cbd85e..f4035f60517176b10013c419f50b331df503fc9d 100644 (file)
--- a/Test.hs
+++ b/Test.hs
@@ -83,6 +83,7 @@ import qualified Utility.Matcher
 import qualified Utility.Exception
 import qualified Utility.Hash
 import qualified Utility.Scheduled
+import qualified Utility.Scheduled.QuickCheck
 import qualified Utility.HumanTime
 import qualified Utility.ThreadScheduler
 import qualified Utility.Base64
@@ -157,7 +158,7 @@ properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck"
        , testProperty "prop_parse_show_TrustLog" Logs.Trust.prop_parse_show_TrustLog
        , testProperty "prop_hashes_stable" Utility.Hash.prop_hashes_stable
        , testProperty "prop_mac_stable" Utility.Hash.prop_mac_stable
-       , testProperty "prop_schedule_roundtrips" Utility.Scheduled.prop_schedule_roundtrips
+       , testProperty "prop_schedule_roundtrips" Utility.Scheduled.QuickCheck.prop_schedule_roundtrips
        , testProperty "prop_past_sane" Utility.Scheduled.prop_past_sane
        , testProperty "prop_duration_roundtrips" Utility.HumanTime.prop_duration_roundtrips
        , testProperty "prop_metadata_sane" Types.MetaData.prop_metadata_sane
index 5e813d4a29642d6c5699ba29877dfbaa8b6a3c57..ead8f7716c208ca931b7cf7e252331a5180bd9cb 100644 (file)
@@ -23,12 +23,10 @@ module Utility.Scheduled (
        toRecurrance,
        toSchedule,
        parseSchedule,
-       prop_schedule_roundtrips,
        prop_past_sane,
 ) where
 
 import Utility.Data
-import Utility.QuickCheck
 import Utility.PartialPrelude
 import Utility.Misc
 
@@ -337,41 +335,6 @@ parseSchedule s = do
        recurrance = unwords rws
        scheduledtime = unwords tws
 
-instance Arbitrary Schedule where
-       arbitrary = Schedule <$> arbitrary <*> arbitrary
-
-instance Arbitrary ScheduledTime where
-       arbitrary = oneof
-               [ pure AnyTime
-               , SpecificTime 
-                       <$> choose (0, 23)
-                       <*> choose (1, 59)
-               ]
-
-instance Arbitrary Recurrance where
-       arbitrary = oneof
-               [ pure Daily
-               , Weekly <$> arbday
-               , Monthly <$> arbday
-               , Yearly <$> arbday
-               , Divisible
-                       <$> positive arbitrary
-                       <*> oneof -- no nested Divisibles
-                               [ pure Daily
-                               , Weekly <$> arbday
-                               , Monthly <$> arbday
-                               , Yearly <$> arbday
-                               ]
-               ]
-         where
-               arbday = oneof
-                       [ Just <$> nonNegative arbitrary
-                       , pure Nothing
-                       ]
-
-prop_schedule_roundtrips :: Schedule -> Bool
-prop_schedule_roundtrips s = toSchedule (fromSchedule s) == Just s
-
 prop_past_sane :: Bool
 prop_past_sane = and
        [ all (checksout oneMonthPast) (mplus1 ++ yplus1)
diff --git a/Utility/Scheduled/QuickCheck.hs b/Utility/Scheduled/QuickCheck.hs
new file mode 100644 (file)
index 0000000..a2051cd
--- /dev/null
@@ -0,0 +1,51 @@
+{- quickcheck for scheduled activities
+ - 
+ - Copyright 2013-2014 Joey Hess <id@joeyh.name>
+ -
+ - License: BSD-2-clause
+ -}
+
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Utility.Scheduled.QuickCheck where
+
+import Utility.Scheduled
+import Utility.QuickCheck
+
+import Control.Applicative
+import Prelude
+
+instance Arbitrary Schedule where
+       arbitrary = Schedule <$> arbitrary <*> arbitrary
+
+instance Arbitrary ScheduledTime where
+       arbitrary = oneof
+               [ pure AnyTime
+               , SpecificTime 
+                       <$> choose (0, 23)
+                       <*> choose (1, 59)
+               ]
+
+instance Arbitrary Recurrance where
+       arbitrary = oneof
+               [ pure Daily
+               , Weekly <$> arbday
+               , Monthly <$> arbday
+               , Yearly <$> arbday
+               , Divisible
+                       <$> positive arbitrary
+                       <*> oneof -- no nested Divisibles
+                               [ pure Daily
+                               , Weekly <$> arbday
+                               , Monthly <$> arbday
+                               , Yearly <$> arbday
+                               ]
+               ]
+         where
+               arbday = oneof
+                       [ Just <$> nonNegative arbitrary
+                       , pure Nothing
+                       ]
+
+prop_schedule_roundtrips :: Schedule -> Bool
+prop_schedule_roundtrips s = toSchedule (fromSchedule s) == Just s