@@ -1,4 +1,3 @@
1−
21module Tests.Old (tests) where
32
43import Test.Framework (testGroup, Test )
@@ -46,51 +45,62 @@ showDiff (l,r) ((B, _ ) : ds) =
4645 showDiff (l+1,r+1) ds
4746
4847tests :: [Test]
49−tests = [ testGroup "markdown" [ testGroup "writer" (writerTests "markdown" ++ lhsWriterTests "markdown")
50− , testGroup "reader" [ test "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
51− "testsuite.txt" "testsuite.native"
52− , test "tables" ["-r", "markdown", "-w", "native", "--columns=80"]
53− "tables.txt" "tables.native"
54− , test "more" ["-r", "markdown", "-w", "native", "-S"]
55− "markdown-reader-more.txt" "markdown-reader-more.native"
56− , lhsReaderTest "markdown+lhs"
57− ]
58− , testGroup "citations" markdownCitationTests
59− ]
60− , testGroup "rst" [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
61− , testGroup "reader" [ test "basic" ["-r", "rst", "-w", "native", "-s", "-S", "--columns=80"]
62− "rst-reader.rst" "rst-reader.native"
63− , test "tables" ["-r", "rst", "-w", "native", "--columns=80"]
64− "tables.rst" "tables-rstsubset.native"
65− , lhsReaderTest "rst+lhs"
66− ]
67− ]
68− , testGroup "latex" [ testGroup "writer" (writerTests "latex" ++ lhsWriterTests "latex")
69− , testGroup "reader" [ test "basic" ["-r", "latex", "-w", "native", "-s", "-R"]
70− "latex-reader.latex" "latex-reader.native"
71− , lhsReaderTest "latex+lhs"
72− ]
73− , latexCitationTests "biblatex"
74− , latexCitationTests "natbib"
75− ]
76− , testGroup "html" [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
77− , test "reader" ["-r", "html", "-w", "native", "-s"]
78− "html-reader.html" "html-reader.native"
79− ]
80− , testGroup "s5" [ s5WriterTest "basic" ["-s"] "s5"
81− , s5WriterTest "fancy" ["-s","-m","-i"] "s5"
82− , s5WriterTest "fragment" [] "html"
83− , s5WriterTest "inserts" ["-s", "-H", "insert",
84− "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
85− ]
86− , testGroup "textile" [ testGroup "writer" $ writerTests "textile"
87− , test "reader" ["-r", "textile", "-w", "native", "-s"]
88− "textile-reader.textile" "textile-reader.native"
89− ]
90− , testGroup "native" [ testGroup "writer" $ writerTests "native"
91− , test "reader" ["-r", "native", "-w", "native", "-s"]
92− "testsuite.native" "testsuite.native"
93− ]
48+tests = [ testGroup "markdown"
49+ [ testGroup "writer"
50+ $ writerTests "markdown" ++ lhsWriterTests "markdown"
51+ , testGroup "reader"
52+ [ test "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
53+ "testsuite.txt" "testsuite.native"
54+ , test "tables" ["-r", "markdown", "-w", "native", "--columns=80"]
55+ "tables.txt" "tables.native"
56+ , test "more" ["-r", "markdown", "-w", "native", "-S"]
57+ "markdown-reader-more.txt" "markdown-reader-more.native"
58+ , lhsReaderTest "markdown+lhs"
59+ ]
60+ , testGroup "citations" markdownCitationTests
61+ ]
62+ , testGroup "rst"
63+ [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
64+ , testGroup "reader"
65+ [ test "basic" ["-r", "rst", "-w", "native",
66+ "-s", "-S", "--columns=80"] "rst-reader.rst" "rst-reader.native"
67+ , test "tables" ["-r", "rst", "-w", "native", "--columns=80"]
68+ "tables.rst" "tables-rstsubset.native"
69+ , lhsReaderTest "rst+lhs"
70+ ]
71+ ]
72+ , testGroup "latex"
73+ [ testGroup "writer" (writerTests "latex" ++ lhsWriterTests "latex")
74+ , testGroup "reader"
75+ [ test "basic" ["-r", "latex", "-w", "native", "-s", "-R"]
76+ "latex-reader.latex" "latex-reader.native"
77+ , lhsReaderTest "latex+lhs"
78+ ]
79+ , latexCitationTests "biblatex"
80+ , latexCitationTests "natbib"
81+ ]
82+ , testGroup "html"
83+ [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
84+ , test "reader" ["-r", "html", "-w", "native", "-s"]
85+ "html-reader.html" "html-reader.native"
86+ ]
87+ , testGroup "s5"
88+ [ s5WriterTest "basic" ["-s"] "s5"
89+ , s5WriterTest "fancy" ["-s","-m","-i"] "s5"
90+ , s5WriterTest "fragment" [] "html"
91+ , s5WriterTest "inserts" ["-s", "-H", "insert",
92+ "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
93+ ]
94+ , testGroup "textile"
95+ [ testGroup "writer" $ writerTests "textile"
96+ , test "reader" ["-r", "textile", "-w", "native", "-s"]
97+ "textile-reader.textile" "textile-reader.native"
98+ ]
99+ , testGroup "native"
100+ [ testGroup "writer" $ writerTests "native"
101+ , test "reader" ["-r", "native", "-w", "native", "-s"]
102+ "testsuite.native" "testsuite.native"
103+ ]
94104 , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
95105 [ "docbook", "opendocument" , "context" , "texinfo"
96106 , "man" , "plain" , "mediawiki", "rtf", "org"
@@ -108,26 +118,31 @@ lhsWriterTests format
108118 , t "lhs to lhs" (format ++ "+lhs")
109119 ]
110120 where
111− t n f = test n ["--columns=78", "-r", "native", "-s", "-w", f] "lhs-test.native" ("lhs-test" <.> ext f)
121+ t n f = test n ["--columns=78", "-r", "native", "-s", "-w", f]
122+ "lhs-test.native" ("lhs-test" <.> ext f)
112123 ext f = if null languages && format == "html"
113124 then "nohl" <.> f
114125 else f
115126
116127lhsReaderTest :: String -> Test
117128lhsReaderTest format =
118− testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"] ("lhs-test" <.> format) "lhs-test.native"
129+ testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"]
130+ ("lhs-test" <.> format) "lhs-test.native"
119131 where normalizer = writeNative defaultWriterOptions . normalize . read
120132
121133latexCitationTests :: String -> Test
122134latexCitationTests n
123135 = testGroup (n ++ " citations")
124− [ t ("latex reader (" ++ n ++ " citations)") (["-r", "latex", "-w", "markdown", "-s", "--no-wrap"] ++ o)
136+ [ t ("latex reader (" ++ n ++ " citations)")
137+ (["-r", "latex", "-w", "markdown", "-s", "--no-wrap"] ++ o)
125138 f "markdown-citations.txt"
126− , t ("latex writer (" ++ n ++ " citations)") (["-r", "markdown", "-w", "latex", "-s", "--no-wrap"] ++ o)
139+ , t ("latex writer (" ++ n ++ " citations)")
140+ (["-r", "markdown", "-w", "latex", "-s", "--no-wrap"] ++ o)
127141 "markdown-citations.txt" f
128142 ]
129143 where
130− o = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl", "--no-citeproc", "--" ++ n]
144+ o = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl",
145+ "--no-citeproc", "--" ++ n]
131146 f = n ++ "-citations.latex"
132147 normalizer = substitute "\160" " " . substitute "\8211" "-"
133148 t = testWithNormalize normalizer
@@ -142,18 +157,22 @@ writerTests format
142157
143158s5WriterTest :: String -> [String] -> String -> Test
144159s5WriterTest modifier opts format
145− = test (format ++ " writer (" ++ modifier ++ ")") (["-r", "native", "-w", format] ++ opts)
160+ = test (format ++ " writer (" ++ modifier ++ ")")
161+ (["-r", "native", "-w", format] ++ opts)
146162 "s5.native" ("s5." ++ modifier <.> "html")
147163
148164markdownCitationTests :: [Test]
149165markdownCitationTests
150166 = map styleToTest ["chicago-author-date","ieee","mhra"]
151− ++ [test "no-citeproc" wopts "markdown-citations.txt" "markdown-citations.txt"]
167+ ++ [test "no-citeproc" wopts "markdown-citations.txt"
168+ "markdown-citations.txt"]
152169 where
153− ropts = ["-r", "markdown", "-w", "markdown", "--bibliography", "biblio.bib", "--no-wrap"]
170+ ropts = ["-r", "markdown", "-w", "markdown", "--bibliography",
171+ "biblio.bib", "--no-wrap"]
154172 wopts = ropts ++ ["--no-citeproc"]
155173 styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
156− "markdown-citations.txt" ("markdown-citations." ++ style ++ ".txt")
174+ "markdown-citations.txt"
175+ ("markdown-citations." ++ style ++ ".txt")
157176
158177-- | Run a test without normalize function, return True if test passed.
159178test :: String -- ^ Title of test
@@ -177,16 +196,21 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do
177196 let options = ["--data-dir", ".."] ++ [inpPath] ++ opts
178197 let cmd = pandocPath ++ " " ++ unwords options
179198 ph <- runProcess pandocPath options Nothing
180− (Just [("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut) (Just stderr)
199+ (Just [("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut)
200+ (Just stderr)
181201 ec <- waitForProcess ph
182202 result <- if ec == ExitSuccess
183203 then do
184204 -- filter \r so the tests will work on Windows machines
185− outputContents <- readFile' outputPath >>= return . filter (/='\r') . normalizer
186− normContents <- readFile' normPath >>= return . filter (/='\r') . normalizer
205+ outputContents <- readFile' outputPath >>=
206+ return . filter (/='\r') . normalizer
207+ normContents <- readFile' normPath >>=
208+ return . filter (/='\r') . normalizer
187209 if outputContents == normContents
188210 then return TestPassed
189− else return $ TestFailed cmd normPath $ getDiff (lines outputContents) (lines normContents)
211+ else return
212+ $ TestFailed cmd normPath
213+ $ getDiff (lines outputContents) (lines normContents)
190214 else return $ TestError ec
191215 removeFile outputPath
192216 assertBool (show result) (result == TestPassed)