3 import Test.QuickCheck.Batch hiding (runTests)
5 import System.Environment
7 import HeaderInfoTests as HI
9 runUnitTests :: Bool -> IO ()
10 runUnitTests debug = exitWith =<< performTests debug
12 performTests :: Bool -> IO ExitCode
14 do e1 <- exeTests "HeaderInfo" opts
15 [ run HI.prop_optionsIdentity
16 , run HI.prop_languageParse
17 , run HI.prop_languageError ]
18 return (foldr1 cat [e1])
19 where opts = TestOptions 100 10 debug
20 cat (e@(ExitFailure _)) _ = e
23 exeTests :: String -> TestOptions -> [TestOptions -> IO TestResult] -> IO ExitCode
24 exeTests name scale actions =
25 do putStr (rjustify 25 name ++ " : ")
26 tr 1 actions [] 0 False
28 rjustify n s = replicate (max 0 (n - length s)) ' ' ++ s
30 putStr (rjustify (max 0 (35-n)) " (" ++ show c ++ ")\n")
33 then return (ExitFailure 1)
34 else return ExitSuccess
35 tr n (action:actions) others c e =
40 tr (n+1) actions others (c+m) e }
43 tr (n+1) actions others (c+m) e }
47 tr (n+1) actions others c True }
50 tr (n+1) actions ((f,n,num):others) (c+num) True }
51 fa :: ([String],Int,Int) -> IO ()
58 ++ " failed with the binding(s)\n")
59 sequence_ [putStr (" ** " ++ v ++ "\n")