@@ -13,118 +13,127 @@ import System.FilePath ((</>))
1313type Options = (WriterOptions, ReaderOptions)
1414
1515compareOutput :: Options
16− -> FilePath
17− -> IO (Pandoc, Pandoc)
18−compareOutput opts nativeFile = do
19− nf <- Prelude.readFile nativeFile
16+ -> FilePath
17+ -> FilePath
18+ -> IO (Pandoc, Pandoc)
19+compareOutput opts nativeFileIn nativeFileOut = do
20+ nf <- Prelude.readFile nativeFileIn
21+ nf' <- Prelude.readFile nativeFileOut
2022 let wopts = fst opts
2123 df <- writeDocx wopts{writerUserDataDir = Just (".." </> "data")}
2224 (handleError $ readNative nf)
2325 let (p, _) = handleError $ readDocx (snd opts) df
24− return (p, handleError $ readNative nf)
26+ return (p, handleError $ readNative nf')
2527
26−testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test
27−testCompareWithOptsIO opts name nativeFile = do
28− (dp, np) <- compareOutput opts nativeFile
28+testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO Test
29+testCompareWithOptsIO opts name nativeFileIn nativeFileOut = do
30+ (dp, np) <- compareOutput opts nativeFileIn nativeFileOut
2931 return $ test id name (dp, np)
3032
31−testCompareWithOpts :: Options -> String -> FilePath -> Test
32−testCompareWithOpts opts name nativeFile =
33− buildTest $ testCompareWithOptsIO opts name nativeFile
33+testCompareWithOpts :: Options -> String -> FilePath -> FilePath -> Test
34+testCompareWithOpts opts name nativeFileIn nativeFileOut =
35+ buildTest $ testCompareWithOptsIO opts name nativeFileIn nativeFileOut
3436
35−testCompare :: String -> FilePath -> Test
37+roundTripCompareWithOpts :: Options -> String -> FilePath -> Test
38+roundTripCompareWithOpts opts name nativeFile =
39+ testCompareWithOpts opts name nativeFile nativeFile
40+
41+testCompare :: String -> FilePath -> FilePath -> Test
3642testCompare = testCompareWithOpts def
3743
44+roundTripCompare :: String -> FilePath -> Test
45+roundTripCompare = roundTripCompareWithOpts def
46+
3847tests :: [Test]
3948tests = [ testGroup "inlines"
40− [ testCompare
49+ [ roundTripCompare
4150 "font formatting"
4251 "docx/inline_formatting_writer.native"
43− , testCompare
52+ , roundTripCompare
4453 "font formatting with character styles"
4554 "docx/char_styles.native"
46− , testCompare
55+ , roundTripCompare
4756 "hyperlinks"
4857 "docx/links_writer.native"
49− , testCompare
58+ , roundTripCompare
5059 "inline image"
5160 "docx/image_no_embed_writer.native"
52− , testCompare
61+ , roundTripCompare
5362 "inline image in links"
5463 "docx/inline_images_writer.native"
55− , testCompare
64+ , roundTripCompare
5665 "handling unicode input"
5766 "docx/unicode.native"
58− , testCompare
67+ , roundTripCompare
5968 "literal tabs"
6069 "docx/tabs.native"
61− , testCompare
70+ , roundTripCompare
6271 "normalizing inlines"
6372 "docx/normalize.native"
64− , testCompare
73+ , roundTripCompare
6574 "normalizing inlines deep inside blocks"
6675 "docx/deep_normalize.native"
67− , testCompare
76+ , roundTripCompare
6877 "move trailing spaces outside of formatting"
6978 "docx/trailing_spaces_in_formatting.native"
70− , testCompare
79+ , roundTripCompare
7180 "inline code (with VerbatimChar style)"
7281 "docx/inline_code.native"
73− , testCompare
82+ , roundTripCompare
7483 "inline code in subscript and superscript"
7584 "docx/verbatim_subsuper.native"
7685 ]
7786 , testGroup "blocks"
78− [ testCompare
87+ [ roundTripCompare
7988 "headers"
8089 "docx/headers.native"
81− , testCompare
90+ , roundTripCompare
8291 "headers already having auto identifiers"
8392 "docx/already_auto_ident.native"
84− , testCompare
93+ , roundTripCompare
8594 "numbered headers automatically made into list"
8695 "docx/numbered_header.native"
87− , testCompare
96+ , roundTripCompare
8897 "i18n blocks (headers and blockquotes)"
8998 "docx/i18n_blocks.native"
9099 -- Continuation does not survive round-trip
91− , testCompare
100+ , roundTripCompare
92101 "lists"
93102 "docx/lists_writer.native"
94− , testCompare
103+ , roundTripCompare
95104 "definition lists"
96105 "docx/definition_list.native"
97− , testCompare
106+ , roundTripCompare
98107 "custom defined lists in styles"
99108 "docx/german_styled_lists.native"
100− , testCompare
109+ , roundTripCompare
101110 "footnotes and endnotes"
102111 "docx/notes.native"
103− , testCompare
112+ , roundTripCompare
104113 "blockquotes (parsing indent as blockquote)"
105114 "docx/block_quotes_parse_indent.native"
106− , testCompare
115+ , roundTripCompare
107116 "hanging indents"
108117 "docx/hanging_indent.native"
109118 -- tables headers do not survive round-trip, should look into that
110− , testCompare
119+ , roundTripCompare
111120 "tables"
112121 "docx/tables.native"
113− , testCompare
122+ , roundTripCompare
114123 "tables with lists in cells"
115124 "docx/table_with_list_cell.native"
116− , testCompare
125+ , roundTripCompare
117126 "code block"
118127 "docx/codeblock.native"
119− , testCompare
128+ , roundTripCompare
120129 "dropcap paragraphs"
121130 "docx/drop_cap.native"
122131 ]
123132 , testGroup "metadata"
124− [ testCompareWithOpts (def,def{readerStandalone=True})
133+ [ roundTripCompareWithOpts (def,def{readerStandalone=True})
125134 "metadata fields"
126135 "docx/metadata.native"
127− , testCompareWithOpts (def,def{readerStandalone=True})
136+ , roundTripCompareWithOpts (def,def{readerStandalone=True})
128137 "stop recording metadata with normal text"
129138 "docx/metadata_after_normal.native"
130139 ]