
Now that ghc 9.0.2 is the oldest supported version. Eg cruft from https://web.archive.org/web/20190424185034/https://prime.haskell.org/wiki/Libraries/Proposals/SemigroupMonoid Sponsored-by: Jack Hill
48 lines
1 KiB
Haskell
48 lines
1 KiB
Haskell
{- 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 (prop_schedule_roundtrips) where
|
|
|
|
import Utility.Scheduled
|
|
import Utility.QuickCheck
|
|
|
|
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 Recurrence 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
|