From: simonmar Date: Wed, 8 Dec 1999 14:14:32 +0000 (+0000) Subject: [project @ 1999-12-08 14:14:32 by simonmar] X-Git-Tag: Approximately_9120_patches~5399 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=60741e4205e743fc99d50f707c61db93d1372bc8;p=ghc-hetmet.git [project @ 1999-12-08 14:14:32 by simonmar] - add test cases for my URI library - add George Russell's tests for the TimeExts library --- diff --git a/ghc/tests/lib/should_run/Makefile b/ghc/tests/lib/should_run/Makefile index ab0065d..fae5cd2 100644 --- a/ghc/tests/lib/should_run/Makefile +++ b/ghc/tests/lib/should_run/Makefile @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# $Id: Makefile,v 1.14 1999/09/21 09:02:05 sof Exp $ +# $Id: Makefile,v 1.15 1999/12/08 14:14:32 simonmar Exp $ TOP = ../.. include $(TOP)/mk/boilerplate.mk @@ -13,6 +13,8 @@ exceptions001_HC_OPTS = -fglasgow-exts -fno-warn-missing-methods stableptr002_HC_OPTS = -fglasgow-exts stableptr003_HC_OPTS = -fglasgow-exts list001_HC_OPTS = -fglasgow-exts +uri001_HC_OPTS = -syslib lang -syslib net +time001_HC_OPTS = -syslib lang enum01_HC_OPTS = -cpp -fglasgow-exts -H12m enum02_HC_OPTS = -cpp -fglasgow-exts -H12m diff --git a/ghc/tests/lib/should_run/time001.hs b/ghc/tests/lib/should_run/time001.hs new file mode 100644 index 0000000..30c7280 --- /dev/null +++ b/ghc/tests/lib/should_run/time001.hs @@ -0,0 +1,63 @@ +module Main(main) where + +import Time +import TimeExts + +start = toClockTime( + CalendarTime { + ctYear = 1973, + ctMonth = December, + ctDay = 31, + ctHour = 11, + ctMin = 43, + ctSec = 55, + ctPicosec = 123123123123, + ctWDay = Monday, + ctYDay = 0, + ctTZName = "UTC", + ctTZ = 0, + ctIsDST = False + }) + +pClock :: ClockTime -> IO() +pClock c = + do + putStr(calendarTimeToString(toUTCTime c)) + putStr "\n" + +getDiff :: TimeAddable a => ClockTime -> a +getDiff now = diffClock now start + +printSum :: TimeAddable a => a -> IO () +printSum diff = + let + sum = addClock start diff + in + pClock sum + +main = + do + -- now <- getClockTime + -- now fixed so we get reliable output (SDM) + let now = TOD 944662832 34398000000 + putStr "Start: " + pClock start + putStr "End: " + pClock now + putStr "Whole Picos\n" + printSum((getDiff now)::DiffPico) + putStr "Whole Seconds\n" + printSum((getDiff now)::DiffPico) + putStr "Whole Minutes\n" + printSum((getDiff now)::DiffMinute) + putStr "Whole Hours\n" + printSum((getDiff now)::DiffHour) + putStr "Whole Days\n" + printSum((getDiff now)::DiffDay) + putStr "Whole Months\n" + printSum((getDiff now)::DiffMonth) + putStr "Whole Years\n" + printSum((getDiff now)::DiffYear) + + + diff --git a/ghc/tests/lib/should_run/time001.stdout b/ghc/tests/lib/should_run/time001.stdout new file mode 100644 index 0000000..c2e987e --- /dev/null +++ b/ghc/tests/lib/should_run/time001.stdout @@ -0,0 +1,16 @@ +Start: Mon Dec 31 11:43:55 UTC 1973 +End: Wed Dec 8 14:20:32 UTC 1999 +Whole Picos +Wed Dec 8 14:20:32 UTC 1999 +Whole Seconds +Wed Dec 8 14:20:32 UTC 1999 +Whole Minutes +Wed Dec 8 14:19:55 UTC 1999 +Whole Hours +Wed Dec 8 13:43:55 UTC 1999 +Whole Days +Wed Dec 8 11:43:55 UTC 1999 +Whole Months +Wed Dec 1 11:43:55 UTC 1999 +Whole Years +Thu Dec 31 11:43:55 UTC 1998 diff --git a/ghc/tests/lib/should_run/uri001.hs b/ghc/tests/lib/should_run/uri001.hs new file mode 100644 index 0000000..d43b8a5 --- /dev/null +++ b/ghc/tests/lib/should_run/uri001.hs @@ -0,0 +1,56 @@ +module Main where + +import URI +import Maybe +import IOExts + +main = sequence_ (map do_test tests) + +base = fromJust (parseURI "http://a/b/c/d;p?q") + +do_test test = case parseURI test of + Nothing -> error ("no parse: " ++ test) + Just uri -> putStr (show (fromJust (uri `relativeTo` base)) ++ "\n") + +tests = + [ "g:h", + "g", + "./g", + "g/", + "/g", + "//g", + "?y", + "g?y", + "#s", + "g#s", + "g?y#s", + ";x", + "g;x", + "g;x?y#s", + ".", + "./", + "..", + "../", + "../g", + "../..", + "../../", + "../../g", + -- "../../../g" -- should fail + -- "../../../../g" -- should fail + "/./g", + "/../g", + "g.", + ".g", + "g..", + "..g", + "./../g", + "./g/.", + "g/./h", + "g/../h", + "g;x=1/./y", + "g;x=1/../y", + "g?y/./x", + "g?y/../x", + "g#s/./x", + "g#s/../x" + ] diff --git a/ghc/tests/lib/should_run/uri001.stdout b/ghc/tests/lib/should_run/uri001.stdout new file mode 100644 index 0000000..873a906 --- /dev/null +++ b/ghc/tests/lib/should_run/uri001.stdout @@ -0,0 +1,38 @@ +g:h +http://a/b/c/g +http://a/b/c/g +http://a/b/c/g/ +http://a/g +http://g +http://a/b/c/?y +http://a/b/c/g?y +http://a/b/c/#s +http://a/b/c/g#s +http://a/b/c/g?y#s +http://a/b/c/;x +http://a/b/c/g;x +http://a/b/c/g;x?y#s +http://a/b/c/ +http://a/b/c/ +http://a/b/ +http://a/b/ +http://a/b/g +http://a/ +http://a/ +http://a/g +http://a/./g +http://a/../g +http://a/b/c/g. +http://a/b/c/.g +http://a/b/c/g.. +http://a/b/c/..g +http://a/b/g +http://a/b/c/g/ +http://a/b/c/g/h +http://a/b/c/h +http://a/b/c/g;x=1/y +http://a/b/c/y +http://a/b/c/g?y/./x +http://a/b/c/g?y/../x +http://a/b/c/g#s/./x +http://a/b/c/g#s/../x