packages feed

relative-date 0.0.0 → 0.0.1

raw patch · 2 files changed

+16/−5 lines, 2 filesdep ~concatenative

Dependency ranges changed: concatenative

Files

relative-date.cabal view
@@ -1,5 +1,5 @@ name:                relative-date-version:             0.0.0+version:             0.0.1 synopsis:            Durations and generalized time parsing description:         Relative-date provides two modules.  Data.Duration gives 					 functions for the creation of durations of time, represented@@ -14,5 +14,5 @@ author:              Sam Anklesaria maintainer:          amsay@amsay.net build-type:          Simple-Build-Depends:		 base >= 3 && < 5, mtl >=1.1 && <1.2, concatenative == 0.0, datetime == 0.2, parsec >= 3.0 && <= 3.1.0, time >= 1.1.2.2 && <1.2+Build-Depends:		 base >= 3 && < 5, mtl >=1.1 && <1.2, concatenative == 0.0.0, datetime == 0.2, parsec >= 3.0 && <= 3.1.0, time >= 1.1.2.2 && <1.2 Exposed-Modules:	 Data.DateTime.Parser, Data.Duration
tests.hs view
@@ -11,6 +11,10 @@ import Data.DateTime.Parser import Data.DateTime +newtype PosInt = PosInt Int deriving (Eq, Show)+instance Arbitrary PosInt where+    arbitrary = liftM PosInt (choose (0,50))+ testParser p i = runReader (runPT p () "" i) (US,fromSeconds 1293840000) -- the year I graduate  formatProperty :: DateTime -> [String] -> QC.Result@@ -23,8 +27,8 @@             getUTC (Right (a:_)) = Right a             getUTC (Left a) = (Left (a,Just i))     toResult (Right a) = succeeded-    toResult (Left (a,Just b)) = failed {QC.reason = show a ++ " parsing string " ++ b }-    toResult (Left (a,Nothing)) = failed {QC.reason = show a }+    toResult (Left (a,Just b)) = failed result {QC.reason = show a ++ " parsing string " ++ b }+    toResult (Left (a,Nothing)) = failed result {QC.reason = show a }  formatDateProperty d = formatProperty (fixDate d) ["%A %B %e, %Y", "%B %e, %Y", "%D"] where     fixDate d = let (y,m,i) = toGregorian' d in fromGregorian' (2000 + (y`mod`100)) m i@@ -32,4 +36,11 @@ formatTimeProperty d = formatProperty (fixTime d) ["%A %B %e, %Y %I:%M %p", "%B %e, %Y %I:%M %p"] where     fixTime = fromSeconds . bi id (`mod`60) (-) . toSeconds -main = mapM (quickCheckWith (Args Nothing 1000 1000 1000)) [formatDateProperty, formatTimeProperty]+repeatProperty (PosInt n) =+    case testParser expr ("every day for " ++ (show n) ++ " weeks") of+        (Left _) -> False+        (Right a) -> length a == (n*7+1)++main = do+    mapM quickCheck [formatDateProperty, formatTimeProperty]+    quickCheck repeatProperty