-- |Testing and benchmarking utilities module QuicQuid.Test( runSilentTest,run,tests,t2,t3 ,module Test.HUnit ) where import Test.HUnit import Microbench import Test.BenchPress import qualified Data.Map as M import Test.SmallCheck hiding (test) -- |Create a runnable named test from a set of asserts tests :: (Test.HUnit.Testable b) => String -> (a -> b) -> [a] -> Test tests name chk tsts = name ~: TestList $ map (test.chk) tsts t2 a b = (a,b) t3 a b c = (a,b,c) -- |Run a test reporting errors/failures -- then run it again to measure performance using microbench and benchpress. run :: Test -> IO () run (TestLabel lbl t) = tstL lbl t run t = tstL "unknown" t tstL name t = do putStrLn $ "\n\nTEST " ++ name ++ ":" putStrLn "\nHUnit:" runTestTT t putStrLn "\nmicrobench:" microbench "" $ runSilentTest t >> return () putStrLn "\nbenchpress:" bench 10 $ runSilentTest t -- |Run a test without producing an output runSilentTest :: Test -> IO Counts runSilentTest t = do (counts, 0) <- runTestText (PutText (\m b st -> return st) 0) t return counts instance (Ord a, Serial a, Serial b) => Serial (M.Map a b) where series d = [foldl (\m (k,v) -> M.insert k v m) M.empty $ (series >< series) d] coseries rs = error "coseries"