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.RFC733 as RFC733
12 import qualified Data.Time.RFC1123 as RFC1123
14 import Prelude.Unicode
15 import Test.QuickCheck
18 main = mapM_ runTest tests
20 runTest ∷ Property → IO ()
22 = do r ← quickCheckResult prop
24 Success {} → return ()
25 GaveUp {} → exitFailure
26 Failure {} → exitFailure
27 NoExpectedFailure {} → exitFailure
29 instance Arbitrary Day where
30 arbitrary = ModifiedJulianDay <$> arbitrary
32 instance Arbitrary TimeOfDay where
34 = do h ← choose (0, 23)
37 return $ TimeOfDay h m (fromIntegral (s ∷ Int))
39 instance Arbitrary LocalTime where
40 arbitrary = LocalTime <$> arbitrary ⊛ arbitrary
42 instance Eq ZonedTime where
43 a == b = zonedTimeToUTC a ≡ zonedTimeToUTC b
45 instance Arbitrary TimeZone where
47 = do m ← choose (-1439, 1439)
50 return $ TimeZone m s n
52 instance Arbitrary ZonedTime where
53 arbitrary = ZonedTime <$> arbitrary ⊛ arbitrary
57 property ( Asctime.fromAscii "Sun Nov 6 08:49:37 1994"
58 ≡ Right referenceLocalTime )
60 , property ( "Sun Nov 6 08:49:37 1994"
61 ≡ Asctime.toAscii referenceLocalTime )
63 , property $ \lt → Right lt ≡ Asctime.fromAscii (Asctime.toAscii lt)
66 , property ( RFC733.fromAscii "Sunday, 06-Nov-94 08:49:37 GMT"
67 ≡ Right referenceZonedTime )
69 , property ( "Sunday, 06-Nov-1994 08:49:37 GMT"
70 ≡ RFC733.toAscii referenceZonedTime )
72 , property $ \zt → Right zt ≡ RFC733.fromAscii (RFC733.toAscii zt)
75 , property ( RFC1123.fromAscii "Sun, 06 Nov 1994 08:49:37 GMT"
76 ≡ Right referenceZonedTime )
78 , property ( "Sun, 06 Nov 1994 08:49:37 GMT"
79 ≡ RFC1123.toAscii referenceZonedTime )
81 , property $ \zt → Right zt ≡ RFC1123.fromAscii (RFC1123.toAscii zt)
85 = LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)
88 = ZonedTime referenceLocalTime utc