6 module Main (main) where
7 import Control.Applicative
8 import Control.Applicative.Unicode
10 import qualified Data.Time.Asctime as Asctime
11 import qualified Data.Time.RFC1123 as RFC1123
13 import Prelude.Unicode
14 import Test.QuickCheck
17 main = mapM_ runTest tests
19 runTest ∷ Property → IO ()
21 = do r ← quickCheckResult prop
23 Success {} → return ()
24 GaveUp {} → exitFailure
25 Failure {} → exitFailure
26 NoExpectedFailure {} → exitFailure
28 instance Arbitrary Day where
29 arbitrary = ModifiedJulianDay <$> arbitrary
31 instance Arbitrary TimeOfDay where
33 = do h ← choose (0, 23)
36 return $ TimeOfDay h m (fromIntegral (s ∷ Int))
38 instance Arbitrary LocalTime where
39 arbitrary = LocalTime <$> arbitrary ⊛ arbitrary
41 instance Eq ZonedTime where
42 a == b = zonedTimeToUTC a ≡ zonedTimeToUTC b
44 instance Arbitrary TimeZone where
46 = do m ← choose (-1439, 1439)
49 return $ TimeZone m s n
51 instance Arbitrary ZonedTime where
52 arbitrary = ZonedTime <$> arbitrary ⊛ arbitrary
56 property ( Asctime.fromAscii "Sun Nov 6 08:49:37 1994"
57 ≡ Right referenceLocalTime )
59 , property ( "Sun Nov 6 08:49:37 1994"
60 ≡ Asctime.toAscii referenceLocalTime )
62 , property $ \lt → Right lt ≡ Asctime.fromAscii (Asctime.toAscii lt)
65 , property ( RFC1123.fromAscii "Sun, 06 Nov 1994 08:49:37 GMT"
66 ≡ Right referenceZonedTime )
68 , property ( "Sun, 06 Nov 1994 08:49:37 GMT"
69 ≡ RFC1123.toAscii referenceZonedTime )
71 , property $ \zt → Right zt ≡ RFC1123.fromAscii (RFC1123.toAscii zt)
75 = LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)
78 = ZonedTime referenceLocalTime utc