@@ -13,118 +13,127 @@ import System.FilePath ((</>))
13type Options = (WriterOptions, ReaderOptions)
13type Options = (WriterOptions, ReaderOptions)
15compareOutput :: Options
15compareOutput :: Options
16− -> FilePath
16+ -> FilePath
17− -> IO (Pandoc, Pandoc)
18+ -> IO (Pandoc, Pandoc)
18−compareOutput opts nativeFile = do
19+compareOutput opts nativeFileIn nativeFileOut = do
19− nf <- Prelude.readFile nativeFile
20+ nf <- Prelude.readFile nativeFileIn
21+ nf' <- Prelude.readFile nativeFileOut
20 let wopts = fst opts
22 let wopts = fst opts
21 df <- writeDocx wopts{writerUserDataDir = Just (".." </> "data")}
23 df <- writeDocx wopts{writerUserDataDir = Just (".." </> "data")}
22 (handleError $ readNative nf)
24 (handleError $ readNative nf)
23 let (p, _) = handleError $ readDocx (snd opts) df
25 let (p, _) = handleError $ readDocx (snd opts) df
24− return (p, handleError $ readNative nf)
26+ return (p, handleError $ readNative nf')
26−testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test
28+testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO Test
27−testCompareWithOptsIO opts name nativeFile = do
29+testCompareWithOptsIO opts name nativeFileIn nativeFileOut = do
28− (dp, np) <- compareOutput opts nativeFile
30+ (dp, np) <- compareOutput opts nativeFileIn nativeFileOut
29 return $ test id name (dp, np)
31 return $ test id name (dp, np)
31−testCompareWithOpts :: Options -> String -> FilePath -> Test
33+testCompareWithOpts :: Options -> String -> FilePath -> FilePath -> Test
32−testCompareWithOpts opts name nativeFile =
34+testCompareWithOpts opts name nativeFileIn nativeFileOut =
33− buildTest $ testCompareWithOptsIO opts name nativeFile
35+ buildTest $ testCompareWithOptsIO opts name nativeFileIn nativeFileOut
37+roundTripCompareWithOpts :: Options -> String -> FilePath -> Test
38+roundTripCompareWithOpts opts name nativeFile =
39+ testCompareWithOpts opts name nativeFile nativeFile
35−testCompare :: String -> FilePath -> Test
41+testCompare :: String -> FilePath -> FilePath -> Test
36testCompare = testCompareWithOpts def
42testCompare = testCompareWithOpts def
44+roundTripCompare :: String -> FilePath -> Test
45+roundTripCompare = roundTripCompareWithOpts def
38tests :: [Test]
47tests :: [Test]
39tests = [ testGroup "inlines"
48tests = [ testGroup "inlines"
40− [ testCompare
49+ [ roundTripCompare
41 "font formatting"
50 "font formatting"
42 "docx/inline_formatting_writer.native"
51 "docx/inline_formatting_writer.native"
43− , testCompare
52+ , roundTripCompare
44 "font formatting with character styles"
53 "font formatting with character styles"
45 "docx/char_styles.native"
54 "docx/char_styles.native"
46− , testCompare
55+ , roundTripCompare
47 "hyperlinks"
56 "hyperlinks"
48 "docx/links_writer.native"
57 "docx/links_writer.native"
49− , testCompare
58+ , roundTripCompare
50 "inline image"
59 "inline image"
51 "docx/image_no_embed_writer.native"
60 "docx/image_no_embed_writer.native"
52− , testCompare
61+ , roundTripCompare
53 "inline image in links"
62 "inline image in links"
54 "docx/inline_images_writer.native"
63 "docx/inline_images_writer.native"
55− , testCompare
64+ , roundTripCompare
56 "handling unicode input"
65 "handling unicode input"
57 "docx/unicode.native"
66 "docx/unicode.native"
58− , testCompare
67+ , roundTripCompare
59 "literal tabs"
68 "literal tabs"
60 "docx/tabs.native"
69 "docx/tabs.native"
61− , testCompare
70+ , roundTripCompare
62 "normalizing inlines"
71 "normalizing inlines"
63 "docx/normalize.native"
72 "docx/normalize.native"
64− , testCompare
73+ , roundTripCompare
65 "normalizing inlines deep inside blocks"
74 "normalizing inlines deep inside blocks"
66 "docx/deep_normalize.native"
75 "docx/deep_normalize.native"
67− , testCompare
76+ , roundTripCompare
68 "move trailing spaces outside of formatting"
77 "move trailing spaces outside of formatting"
69 "docx/trailing_spaces_in_formatting.native"
78 "docx/trailing_spaces_in_formatting.native"
70− , testCompare
79+ , roundTripCompare
71 "inline code (with VerbatimChar style)"
80 "inline code (with VerbatimChar style)"
72 "docx/inline_code.native"
81 "docx/inline_code.native"
73− , testCompare
82+ , roundTripCompare
74 "inline code in subscript and superscript"
83 "inline code in subscript and superscript"
75 "docx/verbatim_subsuper.native"
84 "docx/verbatim_subsuper.native"
77 , testGroup "blocks"
86 , testGroup "blocks"
78− [ testCompare
87+ [ roundTripCompare
80 "docx/headers.native"
89 "docx/headers.native"
81− , testCompare
90+ , roundTripCompare
82 "headers already having auto identifiers"
91 "headers already having auto identifiers"
83 "docx/already_auto_ident.native"
92 "docx/already_auto_ident.native"
84− , testCompare
93+ , roundTripCompare
85 "numbered headers automatically made into list"
94 "numbered headers automatically made into list"
86 "docx/numbered_header.native"
95 "docx/numbered_header.native"
87− , testCompare
96+ , roundTripCompare
88 "i18n blocks (headers and blockquotes)"
97 "i18n blocks (headers and blockquotes)"
89 "docx/i18n_blocks.native"
98 "docx/i18n_blocks.native"
90 -- Continuation does not survive round-trip
99 -- Continuation does not survive round-trip
91− , testCompare
100+ , roundTripCompare
93 "docx/lists_writer.native"
102 "docx/lists_writer.native"
94− , testCompare
103+ , roundTripCompare
95 "definition lists"
104 "definition lists"
96 "docx/definition_list.native"
105 "docx/definition_list.native"
97− , testCompare
106+ , roundTripCompare
98 "custom defined lists in styles"
107 "custom defined lists in styles"
99 "docx/german_styled_lists.native"
108 "docx/german_styled_lists.native"
100− , testCompare
109+ , roundTripCompare
101 "footnotes and endnotes"
110 "footnotes and endnotes"
102 "docx/notes.native"
111 "docx/notes.native"
103− , testCompare
112+ , roundTripCompare
104 "blockquotes (parsing indent as blockquote)"
113 "blockquotes (parsing indent as blockquote)"
105 "docx/block_quotes_parse_indent.native"
114 "docx/block_quotes_parse_indent.native"
106− , testCompare
115+ , roundTripCompare
107 "hanging indents"
116 "hanging indents"
108 "docx/hanging_indent.native"
117 "docx/hanging_indent.native"
109 -- tables headers do not survive round-trip, should look into that
118 -- tables headers do not survive round-trip, should look into that
110− , testCompare
119+ , roundTripCompare
112 "docx/tables.native"
121 "docx/tables.native"
113− , testCompare
122+ , roundTripCompare
114 "tables with lists in cells"
123 "tables with lists in cells"
115 "docx/table_with_list_cell.native"
124 "docx/table_with_list_cell.native"
116− , testCompare
125+ , roundTripCompare
117 "code block"
126 "code block"
118 "docx/codeblock.native"
127 "docx/codeblock.native"
119− , testCompare
128+ , roundTripCompare
120 "dropcap paragraphs"
129 "dropcap paragraphs"
121 "docx/drop_cap.native"
130 "docx/drop_cap.native"
123 , testGroup "metadata"
132 , testGroup "metadata"
124− [ testCompareWithOpts (def,def{readerStandalone=True})
133+ [ roundTripCompareWithOpts (def,def{readerStandalone=True})
125 "metadata fields"
134 "metadata fields"
126 "docx/metadata.native"
135 "docx/metadata.native"
127− , testCompareWithOpts (def,def{readerStandalone=True})
136+ , roundTripCompareWithOpts (def,def{readerStandalone=True})
128 "stop recording metadata with normal text"
137 "stop recording metadata with normal text"
129 "docx/metadata_after_normal.native"
138 "docx/metadata_after_normal.native"