From f2aa5fd661cc74326ebc40f80c8854564e386b74 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 12 Jan 2013 10:21:07 -0800 Subject: Fixed/simplified diff output for tests. --- tests/Tests/Helpers.hs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'tests/Tests') 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 -- cgit v1.2.3