git.iko.soy/typeable/pandoc
on master help sign in
Added line numbers to diff output in tests.
commit3ebfcd0ceaccfb7ee0d7c4d2310890e08919e303 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 12 Jan 2011, 08:29 (16 years ago) parenta2f5627
1 file changed+7−6
tests/Old.hs+7−6
tests/Old.hs+7−6
@@ -17,6 +17,7 @@ import Text.Pandoc.Highlighting ( languages )
1717import Prelude hiding ( readFile )
1818import qualified Data.ByteString.Lazy as B
1919import Data.ByteString.Lazy.UTF8 (toString)
20+import Text.Printf
2021
2122readFileUTF8 :: FilePath -> IO String
2223readFileUTF8 f = B.readFile f >>= return . toString
@@ -33,13 +34,13 @@ instance Show TestResult where
3334 show TestPassed = "PASSED"
3435 show (TestError ec) = "ERROR " ++ show ec
3536 show (TestFailed cmd file d) = "\n--- " ++ file ++
36− "\n+++ " ++ cmd ++ "\n" ++ showDiff d
37+ "\n+++ " ++ cmd ++ "\n" ++ showDiff (1,1) d
3738
38−showDiff :: [(DI, String)] -> String
39−showDiff [] = ""
40−showDiff ((F, ln) : ds) = "+ " ++ ln ++ "\n" ++ showDiff ds
41−showDiff ((S, ln) : ds) = "- " ++ ln ++ "\n" ++ showDiff ds
42−showDiff ((B, _ ) : ds) = showDiff ds
39+showDiff :: (Int,Int) -> [(DI, String)] -> String
40+showDiff _ [] = ""
41+showDiff (l,r) ((F, ln) : ds) = printf "%4d +" l ++ ln ++ "\n" ++ showDiff (l+1,r) ds
42+showDiff (l,r) ((S, ln) : ds) = printf "%4d -" r ++ ln ++ "\n" ++ showDiff (l,r+1) ds
43+showDiff (l,r) ((B, _ ) : ds) = showDiff (l+1,r+1) ds
4344
4445tests :: [Test]
4546tests = [ testGroup "markdown" [ testGroup "writer" (writerTests "markdown" ++ lhsWriterTests "markdown")