2014-12-23 18:20:11 +03:00
|
|
|
module Main (main) where
|
|
|
|
|
2014-12-23 18:50:25 +03:00
|
|
|
import Control.Monad (when)
|
2014-12-23 18:20:11 +03:00
|
|
|
import Tests.Cases
|
|
|
|
import Tests.Utils
|
|
|
|
import System.Exit (exitFailure, exitSuccess)
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
|
|
|
results <- mapM (runTest True) testCases
|
|
|
|
if and results then exitSuccess else exitFailure
|
|
|
|
|
|
|
|
runTest :: Bool -> Test -> IO Bool
|
|
|
|
runTest verbose (Test {name = name, result = result}) = do
|
|
|
|
res <- result
|
|
|
|
case res of
|
2014-12-23 18:50:25 +03:00
|
|
|
Pass -> when verbose (putStrLn $ "\27[32m[pass]\27[0m " ++ name) >> return True
|
2014-12-23 18:20:11 +03:00
|
|
|
Fail str -> putStrLn ("\27[31m[fail]\27[0m " ++ name ++ ": " ++ str) >> return False
|
|
|
|
Error str -> putStrLn ("\27[35m[error]\27[0m " ++ name ++ ": " ++ str) >> return False
|