|
7 | 7 |
|
8 | 8 | import Prelude
|
9 | 9 |
|
| 10 | +#if !MIN_VERSION_base(4,8,0) |
| 11 | +import Control.Applicative |
| 12 | +#endif |
10 | 13 | import Control.Arrow
|
11 | 14 | import Control.Lens
|
12 | 15 | import qualified Data.Attoparsec.ByteString.Char8 as P
|
@@ -51,16 +54,24 @@ prop_toOrdinalDate :: Day -> Bool
|
51 | 54 | prop_toOrdinalDate day =
|
52 | 55 | fromIntegral `first` toOrdinalDate day == T.toOrdinalDate (thyme # day)
|
53 | 56 |
|
54 |
| -newtype AcUTCTime = AcUTCTime { getAc :: UTCTime } deriving (Show) |
| 57 | +newtype AcUTCTime = AcUTCTime UTCTime deriving (Show) |
55 | 58 | instance Arbitrary AcUTCTime where
|
56 | 59 | arbitrary = AcUTCTime <$> (arbitrary `suchThat` (\d -> d >= year1 && d < yearMax))
|
57 | 60 | where
|
58 |
| - year1 = UTCTime (fromGregorian 1 1 1) 0 |
59 |
| - yearMax = UTCTime (fromGregorian 10000 1 1) 0 |
| 61 | + year1 = view (from utcTime) $ UTCView (fromGregorian 1 1 1) 0 |
| 62 | + yearMax = view (from utcTime) $ UTCView (fromGregorian 10000 1 1) 0 |
60 | 63 | shrink (AcUTCTime a) = map AcUTCTime (shrink a)
|
61 | 64 |
|
62 |
| -prop_aeson :: AcUTCTime -> Bool |
63 |
| -prop_aeson a = AE.decode (AE.encode (getAc a)) == Just (getAc a) |
| 65 | +prop_aeson :: AcUTCTime -> Property |
| 66 | +prop_aeson (AcUTCTime t') = |
| 67 | +#if MIN_VERSION_QuickCheck(2,7,0) |
| 68 | + counterexample desc (t == Just [t']) |
| 69 | +#else |
| 70 | + printTestCase desc (t == Just [t']) |
| 71 | +#endif |
| 72 | + where |
| 73 | + t = AE.decode (AE.encode [t']) |
| 74 | + desc = "Orig: " ++ show t' ++ ", Aeson: " ++ show (AE.encode t') ++ ", BackOrig: " ++ show t |
64 | 75 |
|
65 | 76 | prop_formatTime :: Spec -> RecentTime -> Property
|
66 | 77 | prop_formatTime (Spec spec) (RecentTime t@(review thyme -> t'))
|
|
0 commit comments