Commit 60741e42 authored by simonmar's avatar simonmar
Browse files

[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
parent 14a15152
#-----------------------------------------------------------------------------
# $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
......
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)
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
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"
]
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment