git.iko.soy/typeable/pandoc
on master help sign in
Include lhs tests in existing testGroup structure.
a2153acNathan Gass
src/test-pandoc.hs+30−41
@@ -52,23 +52,6 @@ showDiff ((F, ln) : ds) = "|TEST| " ++ ln ++ "\n" ++ showDiff ds
52showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds
52showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds
53showDiff ((B, _ ) : ds) = showDiff ds
53showDiff ((B, _ ) : ds) = showDiff ds
54
54
55−lhsWriterFormats :: [String]
56−lhsWriterFormats = [ "markdown"
57− , "markdown+lhs"
58− , "rst"
59− , "rst+lhs"
60− , "latex"
61− , "latex+lhs"
62− , "html"
63− , "html+lhs"
64− ]
65−
66−lhsReaderFormats :: [String]
67−lhsReaderFormats = [ "markdown+lhs"
68− , "rst+lhs"
69− , "latex+lhs"
70− ]
71−
72markdownCitationTest :: Test
55markdownCitationTest :: Test
73markdownCitationTest
56markdownCitationTest
74 = testGroup "citations" $ map styleToTest ["chicago-author-date","ieee","mhra"]
57 = testGroup "citations" $ map styleToTest ["chicago-author-date","ieee","mhra"]
@@ -81,30 +64,34 @@ markdownCitationTest
81
64
82
65
83tests :: [Test]
66tests :: [Test]
84−tests = [ testGroup "markdown" [ runWriterTest "" "markdown"
67+tests = [ testGroup "markdown" [ testGroup "writer" (runWriterTests "markdown" ++ runLhsWriterTests "markdown")
85 , testGroup "reader" [ runTest "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
68 , testGroup "reader" [ runTest "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
86 "testsuite.txt" "testsuite.native"
69 "testsuite.txt" "testsuite.native"
87 , runTest "tables" ["-r", "markdown", "-w", "native"]
70 , runTest "tables" ["-r", "markdown", "-w", "native"]
88 "tables.txt" "tables.native"
71 "tables.txt" "tables.native"
89 , runTest "more" ["-r", "markdown", "-w", "native", "-S"]
72 , runTest "more" ["-r", "markdown", "-w", "native", "-S"]
90 "markdown-reader-more.txt" "markdown-reader-more.native"
73 "markdown-reader-more.txt" "markdown-reader-more.native"
74+ , runLhsReaderTest "markdown+lhs"
91 ]
75 ]
92 , markdownCitationTest
76 , markdownCitationTest
93 ]
77 ]
94− , testGroup "rst" [ runWriterTest "" "rst"
78+ , testGroup "rst" [ testGroup "writer" (runWriterTests "rst" ++ runLhsWriterTests "rst")
95 , testGroup "reader" [ runTest "basic" ["-r", "rst", "-w", "native", "-s", "-S"]
79 , testGroup "reader" [ runTest "basic" ["-r", "rst", "-w", "native", "-s", "-S"]
96 "rst-reader.rst" "rst-reader.native"
80 "rst-reader.rst" "rst-reader.native"
97 , runTest "tables" ["-r", "rst", "-w", "native"]
81 , runTest "tables" ["-r", "rst", "-w", "native"]
98 "tables.rst" "tables-rstsubset.native"
82 "tables.rst" "tables-rstsubset.native"
83+ , runLhsReaderTest "rst+lhs"
99 ]
84 ]
100 ]
85 ]
101− , testGroup "latex" [ runWriterTest "" "latex"
86+ , testGroup "latex" [ testGroup "writer" (runWriterTests "latex" ++ runLhsWriterTests "latex")
102− , runTest "reader" ["-r", "latex", "-w", "native", "-s", "-R"]
87+ , testGroup "reader" [ runTest "basic" ["-r", "latex", "-w", "native", "-s", "-R"]
103− "latex-reader.latex" "latex-reader.native"
88+ "latex-reader.latex" "latex-reader.native"
89+ , runLhsReaderTest "latex+lhs"
90+ ]
104 , runLatexCitationTests "biblatex"
91 , runLatexCitationTests "biblatex"
105 , runLatexCitationTests "natbib"
92 , runLatexCitationTests "natbib"
106 ]
93 ]
107− , testGroup "html" [ runWriterTest "" "html"
94+ , testGroup "html" [ testGroup "writer" (runWriterTests "html" ++ runLhsWriterTests "html")
108 , runTest "reader" ["-r", "html", "-w", "native", "-s"]
95 , runTest "reader" ["-r", "html", "-w", "native", "-s"]
109 "html-reader.html" "html-reader.native"
96 "html-reader.html" "html-reader.native"
110 ]
97 ]
@@ -114,20 +101,18 @@ tests = [ testGroup "markdown" [ runWriterTest "" "markdown"
114 , runS5WriterTest "inserts" ["-s", "-H", "insert",
101 , runS5WriterTest "inserts" ["-s", "-H", "insert",
115 "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
102 "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
116 ]
103 ]
117− , testGroup "textile" [ runWriterTest "" "textile"
104+ , testGroup "textile" [ testGroup "writer" $ runWriterTests "textile"
118 , runTest "reader" ["-r", "textile", "-w", "native", "-s"]
105 , runTest "reader" ["-r", "textile", "-w", "native", "-s"]
119 "textile-reader.textile" "textile-reader.native"
106 "textile-reader.textile" "textile-reader.native"
120 ]
107 ]
121− , testGroup "native" [ runWriterTest "" "native"
108+ , testGroup "native" [ testGroup "writer" $ runWriterTests "native"
122 , runTest "reader" ["-r", "native", "-w", "native", "-s"]
109 , runTest "reader" ["-r", "native", "-w", "native", "-s"]
123 "testsuite.native" "testsuite.native"
110 "testsuite.native" "testsuite.native"
124 ]
111 ]
112+ , testGroup "other writers" $ map (\f -> testGroup f $ runWriterTests f)
125− , testGroup "other writers" $ map (\f -> runWriterTest f f) [ "docbook", "opendocument" , "context" , "texinfo"
113+ [ "docbook", "opendocument" , "context" , "texinfo"
126− , "man" , "plain" , "mediawiki", "rtf", "org"
114+ , "man" , "plain" , "mediawiki", "rtf", "org"
127− ]
128− , testGroup "lhs" [ testGroup "writer" $ map runLhsWriterTest lhsWriterFormats
129− , testGroup "reader" $ map runLhsReaderTest lhsReaderFormats
130− ]
115+ ]
131 ]
116 ]
132
117
133main :: IO ()
118main :: IO ()
@@ -138,13 +123,18 @@ readFile' :: FilePath -> IO String
138readFile' f = do s <- readFileUTF8 f
123readFile' f = do s <- readFileUTF8 f
139 return $! (length s `seq` s)
124 return $! (length s `seq` s)
140
125
141−runLhsWriterTest :: String -> Test
126+runLhsWriterTests :: String -> [Test]
142−runLhsWriterTest format =
127+runLhsWriterTests format
128+ = [ t "lhs to normal" format
129+ , t "lhs to lhs" (format ++ "+lhs")
130+ ]
131+ where
143− runTest format ["--columns=78", "-r", "native", "-s", "-w", format] "lhs-test.native" ("lhs-test" <.> format)
132+ t n f = runTest n ["--columns=78", "-r", "native", "-s", "-w", f]
133+ "lhs-test.native" ("lhs-test" <.> f)
144
134
145runLhsReaderTest :: String -> Test
135runLhsReaderTest :: String -> Test
146runLhsReaderTest format =
136runLhsReaderTest format =
147− runTest format ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
137+ runTest "lhs" ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
148
138
149
139
150runLatexCitationTests :: String -> Test
140runLatexCitationTests :: String -> Test
@@ -161,13 +151,12 @@ runLatexCitationTests n
161 normalize = substitute "\160" " " . substitute "\8211" "-"
151 normalize = substitute "\160" " " . substitute "\8211" "-"
162 rt = runTestWithNormalize normalize
152 rt = runTestWithNormalize normalize
163
153
164−runWriterTest :: String -> String -> Test
154+runWriterTests :: String -> [Test]
165−runWriterTest prefix format
155+runWriterTests format
166− = testGroup name [ runTest "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
156+ = [ runTest "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
167− , runTest "tables" opts "tables.native" ("tables" <.> format)
157+ , runTest "tables" opts "tables.native" ("tables" <.> format)
168− ]
158+ ]
169 where
159 where
170− name = if (null prefix) then "writer" else prefix ++ " writer"
171 opts = ["-r", "native", "-w", format, "--columns=78"]
160 opts = ["-r", "native", "-w", format, "--columns=78"]
172
161
173runS5WriterTest :: String -> [String] -> String -> Test
162runS5WriterTest :: String -> [String] -> String -> Test