------------------------------------------------------------------------- --- Some definitions added as an appendix to the main test module --- generated by CurryCheck. --- Runs a sequence of property tests. Outputs the messages of the failed tests --- messages and returns exit status 0 if all tests are successful, --- otherwise status 1. If the second argument is `True`, the time --- needed for checking each property is shown. runPropertyTests :: Bool -> Bool -> [IO (Maybe String)] -> IO Int runPropertyTests withcolor withtime props = do failedmsgs <- sequenceIO (if withtime then map showRunTimeFor props else props) >>= return . Maybe.catMaybes if null failedmsgs then return 0 else do putStrLn $ (if withcolor then AnsiCodes.red else id) $ line ++ "\nFAILURES OCCURRED IN SOME TESTS:\n" ++ unlines failedmsgs ++ line return 1 where line = take 78 (repeat '=') --- Prints the run time needed to execute a given IO action. showRunTimeFor :: IO a -> IO a showRunTimeFor action = do t0 <- Profile.getProcessInfos >>= return . maybe 0 id . lookup Profile.RunTime result <- action t1 <- Profile.getProcessInfos >>= return . maybe 0 id . lookup Profile.RunTime putStrLn $ "Run time: " ++ show (t1-t0) ++ " msec." return result -------------------------------------------------------------------------