Skip to content

Instantly share code, notes, and snippets.

@nskeip
Created April 21, 2018 05:10
Show Gist options
  • Save nskeip/f7e91cb4379d3c15873c65edfc3af637 to your computer and use it in GitHub Desktop.
Save nskeip/f7e91cb4379d3c15873c65edfc3af637 to your computer and use it in GitHub Desktop.
Green OKs and red FAILs test helper :)
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Lib
import GHC.List (take)
import Data.Text as T
import System.Console.ANSI
import System.Exit (exitFailure)
assert :: String -> Bool -> IO Bool
assert
testTitle
test =
do
let printColorfulResult txt col = do
putStr "["
setSGR [SetColor Foreground Vivid col]
putStr txt
setSGR [Reset]
putStr "] "
if test
then printColorfulResult " OK " Green
else printColorfulResult "FAIL" Red
putStrLn testTitle
return test
main :: IO ()
main = do
putStrLn ""
putStrLn "------------------------------"
putStrLn "Running tests now..."
result <-
sequence [
(assert "Success example" True),
(assert "Fail example" False)
]
putStrLn "------------------------------"
if and $ result
then putStrLn "Success!"
else exitFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment