summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-12 10:21:07 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-12 10:21:07 -0800
commitf2aa5fd661cc74326ebc40f80c8854564e386b74 (patch)
tree28dccca66b9fcc647704724485a53e41c11e5d2b /tests
parentf07ce6fead38991697a69a0856eac8a101faa35b (diff)
Fixed/simplified diff output for tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/Tests/Helpers.hs21
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/Tests/Helpers.hs b/tests/Tests/Helpers.hs
index e3148c260..99263cc36 100644
--- a/tests/Tests/Helpers.hs
+++ b/tests/Tests/Helpers.hs
@@ -23,7 +23,6 @@ import Text.Pandoc.Writers.Native (writeNative)
import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Language.Haskell.TH.Syntax (Q, runIO)
import qualified Test.QuickCheck.Property as QP
-import System.Console.ANSI
import Data.Algorithm.Diff
lit :: QuasiQuoter
@@ -54,25 +53,21 @@ test :: (ToString a, ToString b, ToString c)
test fn name (input, expected) =
testCase name $ assertBool msg (actual' == expected')
where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++
- dashes "expected" ++ nl ++ expected'' ++
- dashes "got" ++ nl ++ actual'' ++
+ dashes "result" ++ nl ++
+ unlines (map vividize diff) ++
dashes ""
nl = "\n"
input' = toString input
- actual' = toString $ fn input
- expected' = toString expected
- diff = getDiff (lines expected') (lines actual')
- expected'' = unlines $ map vividize [First x | First x <- diff]
- actual'' = unlines $ map vividize [Second x | Second x <- diff]
+ actual' = lines $ toString $ fn input
+ expected' = lines $ toString expected
+ diff = getDiff expected' actual'
dashes "" = replicate 72 '-'
dashes x = replicate (72 - length x - 5) '-' ++ " " ++ x ++ " ---"
vividize :: Diff String -> String
-vividize (Both s _) = s
-vividize (First s) = s
-vividize (Second s) = setSGRCode [SetColor Background Dull Red
- , SetColor Foreground Vivid White] ++ s
- ++ setSGRCode [Reset]
+vividize (Both s _) = " " ++ s
+vividize (First s) = "- " ++ s
+vividize (Second s) = "+ " ++ s
property :: QP.Testable a => TestName -> a -> Test
property = testProperty