5 module Main (main) where
6 import Control.Applicative
7 import Control.Applicative.Unicode
9 import qualified Data.Time.Asctime as Asctime
10 import qualified Data.Time.HTTP as HTTP
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
55 instance Arbitrary DiffTime where
56 arbitrary = secondsToDiffTime <$> choose (0, 86400)
58 instance Arbitrary UTCTime where
59 arbitrary = UTCTime <$> arbitrary ⊛ arbitrary
63 property ( Asctime.fromAscii "Sun Nov 6 08:49:37 1994"
64 ≡ Right referenceLocalTime )
66 , property ( "Sun Nov 6 08:49:37 1994"
67 ≡ Asctime.toAscii referenceLocalTime )
69 , property $ \lt → Right lt ≡ Asctime.fromAscii (Asctime.toAscii lt)
72 , property ( RFC733.fromAscii "Sunday, 06-Nov-94 08:49:37 GMT"
73 ≡ Right referenceZonedTime )
75 , property ( "Sunday, 06-Nov-1994 08:49:37 GMT"
76 ≡ RFC733.toAscii referenceZonedTime )
78 , property $ \zt → Right zt ≡ RFC733.fromAscii (RFC733.toAscii zt)
81 , property ( RFC1123.fromAscii "Sun, 06 Nov 1994 08:49:37 GMT"
82 ≡ Right referenceZonedTime )
84 , property ( "Sun, 06 Nov 1994 08:49:37 GMT"
85 ≡ RFC1123.toAscii referenceZonedTime )
87 , property $ \zt → Right zt ≡ RFC1123.fromAscii (RFC1123.toAscii zt)
90 , property $ \ut → Right ut ≡ HTTP.fromAscii (HTTP.toAscii ut )
91 , property $ \ut → Right ut ≡ HTTP.fromAscii (Asctime.toAscii (ut2lt ut))
92 , property $ \ut → Right ut ≡ HTTP.fromAscii (RFC733.toAscii (ut2zt ut))
93 , property $ \ut → Right ut ≡ HTTP.fromAscii (RFC1123.toAscii (ut2zt ut))
97 = LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)
100 = ZonedTime referenceLocalTime utc
102 ut2lt = utcToLocalTime utc
104 ut2zt = utcToZonedTime utc