diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/lib/Time | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/lib/Time')
-rw-r--r-- | testsuite/tests/lib/Time/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/time002.hs | 16 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/time002.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/time003.hs | 24 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/time003.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/time004.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/lib/Time/time004.stdout | 1 |
8 files changed, 60 insertions, 0 deletions
diff --git a/testsuite/tests/lib/Time/Makefile b/testsuite/tests/lib/Time/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/lib/Time/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/lib/Time/all.T b/testsuite/tests/lib/Time/all.T new file mode 100644 index 0000000000..25b40820c0 --- /dev/null +++ b/testsuite/tests/lib/Time/all.T @@ -0,0 +1,3 @@ +test('time002', normal, compile_and_run, ['']) +test('time003', normal, compile_and_run, ['']) +test('time004', normal, compile_and_run, ['']) diff --git a/testsuite/tests/lib/Time/time002.hs b/testsuite/tests/lib/Time/time002.hs new file mode 100644 index 0000000000..e2f9bcb7a7 --- /dev/null +++ b/testsuite/tests/lib/Time/time002.hs @@ -0,0 +1,16 @@ +import System.Time + +-- !!! check that we can read the current ClockTime, convert it +-- !!! to CalendarTime and back again, and that all three times when +-- !!! converted to strings compare equal. + +main = do + t <- getClockTime + let clock = show t + c <- toCalendarTime t + let cal = calendarTimeToString c + let t2 = toClockTime c + clock2 = show t2 + if (clock == cal && clock == clock2) + then putStrLn "Ok." + else putStrLn "Failed." diff --git a/testsuite/tests/lib/Time/time002.stdout b/testsuite/tests/lib/Time/time002.stdout new file mode 100644 index 0000000000..587579af91 --- /dev/null +++ b/testsuite/tests/lib/Time/time002.stdout @@ -0,0 +1 @@ +Ok. diff --git a/testsuite/tests/lib/Time/time003.hs b/testsuite/tests/lib/Time/time003.hs new file mode 100644 index 0000000000..4dda0e466f --- /dev/null +++ b/testsuite/tests/lib/Time/time003.hs @@ -0,0 +1,24 @@ +import System.Time + +main :: IO () +main = do + time <- getClockTime + print (plausible (show time)) + let (CalendarTime year month mday hour min sec psec + wday yday timezone gmtoff isdst) = toUTCTime time + time2 = wdays !! fromEnum wday ++ + (' ' : months !! fromEnum month) ++ + (' ' : shows2 mday (' ' : shows2 hour (':' : shows2 min (':' : shows2 sec + (' ' : timezone ++ ' ' : shows year "\n"))))) + print (plausible time2) + + where + wdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] + months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + shows2 x = showString (pad2 x) + pad2 x = case show x of + c@[_] -> '0' : c + cs -> cs + + plausible str = filter (== ':') str == "::"
\ No newline at end of file diff --git a/testsuite/tests/lib/Time/time003.stdout b/testsuite/tests/lib/Time/time003.stdout new file mode 100644 index 0000000000..dbde422651 --- /dev/null +++ b/testsuite/tests/lib/Time/time003.stdout @@ -0,0 +1,2 @@ +True +True diff --git a/testsuite/tests/lib/Time/time004.hs b/testsuite/tests/lib/Time/time004.hs new file mode 100644 index 0000000000..9a281a10da --- /dev/null +++ b/testsuite/tests/lib/Time/time004.hs @@ -0,0 +1,10 @@ +import System.Time + +main :: IO () +main = do + time <- getClockTime + let (CalendarTime year month mday hour min sec psec + wday yday timezone gmtoff isdst) = toUTCTime time + time' = toClockTime (CalendarTime (year - 1) month mday hour min sec psec + wday yday timezone gmtoff isdst) + print (length (show time) == length (show time')) diff --git a/testsuite/tests/lib/Time/time004.stdout b/testsuite/tests/lib/Time/time004.stdout new file mode 100644 index 0000000000..0ca95142bb --- /dev/null +++ b/testsuite/tests/lib/Time/time004.stdout @@ -0,0 +1 @@ +True |