lazysmallcheck-0.1: benchmarks/Benchmark.hs
import System
import Data.List
main :: IO ()
main = do args <- getArgs
case args of
[checker, file] -> benchmark checker file
_ -> error usage
usage = "Usage: runhugs Benchmark.hs "
++ "[SmallCheck|LazySmallCheck|LazySmallCheck.Generic] FILE"
benchmark checker file =
do extra <-
case checker of
"SmallCheck" -> return ""
"LazySmallCheck" -> return ""
"LazySmallCheck.Generic" -> return "import Data.Generics\n"
_ -> error usage
if '.' `elem` file then error "Filename should not contain '.'"
else return ()
contents <- readFile (file ++ ".hs")
let props = nub $ filter ("prop_" `isPrefixOf`) (words contents)
writeFile (file ++ "2.hs") $ extra
++ "import System\n"
++ "import " ++ checker ++ "\n\n"
++ contents ++ "\n\n"
++ "main = do { [p, d] <- getArgs"
++ " ; case p of { "
++ concatMap propAlt props
++ "_ -> error \"Unknown property\"}}"
system $ "ghc -fglasgow-exts -O2 --make " ++ file ++ "2.hs -o " ++ file
return ()
propAlt p = "\"" ++ p ++ "\" -> " ++ "depthCheck (read d) " ++ p ++ ";"