[commit: packages/time] master, wip/travis: get "runhaskell Setup.hs test" to work (ab61764)

git at git.haskell.org git at git.haskell.org
Sat May 7 06:44:34 UTC 2016


Repository : ssh://git@git.haskell.org/time

On branches: master,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/ab6176494357c23ad1bd6b4a79bc5cbeae76c4b6

>---------------------------------------------------------------

commit ab6176494357c23ad1bd6b4a79bc5cbeae76c4b6
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Fri Dec 22 18:26:02 2006 -0800

    get "runhaskell Setup.hs test" to work
    
    darcs-hash:20061223022602-ac6dd-8a16b100b94134574f8368cb1a521ea0d55ff64f


>---------------------------------------------------------------

ab6176494357c23ad1bd6b4a79bc5cbeae76c4b6
 test/Makefile         | 36 +++++++++++++++++++-----------------
 test/TestParseTime.hs | 23 ++++++++++++++++-------
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/test/Makefile b/test/Makefile
index ff2454b..ecfaa96 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,55 +1,57 @@
 GHC = ghc
-GHCFLAGS = -i../dist/build
-LIBS = ../dist/build/libHStime-1.0.a
+GHCFLAGS = -package time
 
-default: CurrentTime.run ShowDST.run test
+default:
+	cd ..; runhaskell Setup.hs register --user --inplace
+	make CurrentTime.run ShowDST.run test
+	cd ..; runhaskell Setup.hs unregister --user
 
-TestMonthDay: TestMonthDay.o $(LIBS)
+TestMonthDay: TestMonthDay.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-ConvertBack: ConvertBack.o $(LIBS)
+ConvertBack: ConvertBack.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-TestCalendars: TestCalendars.o $(LIBS)
+TestCalendars: TestCalendars.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-TestTime: TestTime.o $(LIBS)
+TestTime: TestTime.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-LongWeekYears: LongWeekYears.o $(LIBS)
+LongWeekYears: LongWeekYears.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-ClipDates: ClipDates.o $(LIBS)
+ClipDates: ClipDates.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-AddDays: AddDays.o $(LIBS)
+AddDays: AddDays.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-TestFormat: TestFormat.o TestFormatStuff.o $(LIBS)
+TestFormat: TestFormat.o TestFormatStuff.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
 TestFormatStuff.o: TestFormatStuff.c TestFormatStuff.h
 	gcc -o $@ -c $<
 
-TestParseDAT: TestParseDAT.o $(LIBS)
+TestParseDAT: TestParseDAT.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-TestEaster: TestEaster.o $(LIBS)
+TestEaster: TestEaster.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-CurrentTime: CurrentTime.o $(LIBS)
+CurrentTime: CurrentTime.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-ShowDST: ShowDST.o $(LIBS)
+ShowDST: ShowDST.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
-TimeZone: TimeZone.o $(LIBS)
+TimeZone: TimeZone.o
 	$(GHC) $(GHCFLAGS) $^ -o $@
 
 TimeZone.ref: FORCE
 	date +%z > $@
 
-TestParseTime: TestParseTime.o $(LIBS)
+TestParseTime: TestParseTime.o
 	$(GHC) $(GHCFLAGS) -package QuickCheck $^ -o $@
 
 test:	\
diff --git a/test/TestParseTime.hs b/test/TestParseTime.hs
index 91d76b0..ad0c1c5 100644
--- a/test/TestParseTime.hs
+++ b/test/TestParseTime.hs
@@ -1,3 +1,5 @@
+{-# OPTIONS -Wall -Werror -fno-warn-type-defaults -fno-warn-unused-binds #-}
+
 import Control.Monad
 import Data.Char
 import Data.Ratio
@@ -10,6 +12,7 @@ import System.Locale
 import Test.QuickCheck
 
 
+ntest :: Int
 ntest = 1000
 
 main :: IO ()
@@ -26,10 +29,13 @@ checkOne :: Config -> NamedProperty -> IO ()
 checkOne config (n,p) = 
     do putStr (rpad 65 ' ' n)
        check config p
-  where rpad n c xs = xs ++ replicate (n - length xs) c
+  where rpad n' c xs = xs ++ replicate (n' - length xs) c
+
 
+parse :: ParseTime t => String -> String -> Maybe t
 parse f t = parseTime defaultTimeLocale f t
 
+format :: (FormatTime t) => String -> t -> String
 format f t = formatTime defaultTimeLocale f t
 
 
@@ -39,12 +45,12 @@ instance Arbitrary Day where
 
 instance Arbitrary DiffTime where
     arbitrary = oneof [intSecs, fracSecs] -- up to 1 leap second
-        where intSecs = liftM secondsToDiffTime $ choose (0, 86400) 
-              fracSecs = liftM picosecondsToDiffTime $ choose (0, 86400 * 10^12) 
-              secondsToDiffTime :: Integer -> DiffTime
-              secondsToDiffTime = fromInteger
-              picosecondsToDiffTime :: Integer -> DiffTime
-              picosecondsToDiffTime x = fromRational (x % 10^12)
+        where intSecs = liftM secondsToDiffTime' $ choose (0, 86400)
+              fracSecs = liftM picosecondsToDiffTime' $ choose (0, 86400 * 10^12)
+              secondsToDiffTime' :: Integer -> DiffTime
+              secondsToDiffTime' = fromInteger
+              picosecondsToDiffTime' :: Integer -> DiffTime
+              picosecondsToDiffTime' x = fromRational (x % 10^12)
     coarbitrary t = coarbitrary (fromEnum t)
 
 instance Arbitrary TimeOfDay where
@@ -75,6 +81,7 @@ instance Eq ZonedTime where
 -- * tests for dbugging failing cases
 --
 
+test_parse_format :: (FormatTime t,ParseTime t,Show t) => String -> t -> (String,String,Maybe t)
 test_parse_format f t = let s = format f t in (show t, s, parse f s `asTypeOf` Just t)
 
 --
@@ -101,11 +108,13 @@ prop_parse_showOrdinalDate d = parse "%Y-%j" (showOrdinalDate d) == Just d
 -- * fromMondayStartWeek and fromSundayStartWeek
 --
 
+prop_fromMondayStartWeek :: Day -> Bool
 prop_fromMondayStartWeek d = 
     let (w,wd)  = mondayStartWeek d
         (y,_,_) = toGregorian d
      in fromMondayStartWeek y w wd == d
 
+prop_fromSundayStartWeek :: Day -> Bool
 prop_fromSundayStartWeek d = 
     let (w,wd)  = sundayStartWeek d
         (y,_,_) = toGregorian d



More information about the ghc-commits mailing list