git.iko.soy/typeable/pandoc
on master help sign in
Initial tests for writer
commitae07d5ed490b1d2f8cbb943a8d876a798d57f470 authorNikolay Yakimov <root@livid.pp.ru> dateTue 3 Mar 2015, 14:37 (12 years ago) parent65c8082
9 files changed+145
tests/Tests/Writers/Docx.hs+128 tests/docx/image_no_embed_writer.native+2 tests/docx/inline_formatting_writer.native+5 tests/docx/inline_images_writer.native+2 tests/docx/links_writer.native+6 tests/media/rId25.jpg tests/media/rId26.jpg tests/media/rId27.jpg tests/test-pandoc.hs+2
tests/Tests/Writers/Docx.hsnew file+128
@@ -0,0 +1,128 @@
1+module Tests.Writers.Docx (tests) where
2+
3+import Text.Pandoc.Options
4+import Text.Pandoc.Readers.Native
5+import Text.Pandoc.Definition
6+import Tests.Helpers
7+import Test.Framework
8+import Text.Pandoc.Readers.Docx
9+import Text.Pandoc.Writers.Docx
10+
11+type Options = (WriterOptions, ReaderOptions)
12+
13+compareOutput :: Options
14+ -> FilePath
15+ -> IO (Pandoc, Pandoc)
16+compareOutput opts nativeFile = do
17+ nf <- Prelude.readFile nativeFile
18+ df <- writeDocx (fst opts) (readNative nf)
19+ let (p, _) = readDocx (snd opts) df
20+ return (p, readNative nf)
21+
22+testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test
23+testCompareWithOptsIO opts name nativeFile = do
24+ (dp, np) <- compareOutput opts nativeFile
25+ return $ test id name (dp, np)
26+
27+testCompareWithOpts :: Options -> String -> FilePath -> Test
28+testCompareWithOpts opts name nativeFile =
29+ buildTest $ testCompareWithOptsIO opts name nativeFile
30+
31+testCompare :: String -> FilePath -> Test
32+testCompare = testCompareWithOpts def
33+
34+tests :: [Test]
35+tests = [ testGroup "inlines"
36+ [ testCompare
37+ "font formatting"
38+ "docx/inline_formatting_writer.native"
39+ , testCompare
40+ "font formatting with character styles"
41+ "docx/char_styles.native"
42+ , testCompare
43+ "hyperlinks"
44+ "docx/links_writer.native"
45+ , testCompare
46+ "inline image"
47+ "docx/image_no_embed_writer.native"
48+ , testCompare
49+ "inline image in links"
50+ "docx/inline_images_writer.native"
51+ , testCompare
52+ "handling unicode input"
53+ "docx/unicode.native"
54+ , testCompare
55+ "literal tabs"
56+ "docx/tabs.native"
57+ , testCompare
58+ "normalizing inlines"
59+ "docx/normalize.native"
60+ , testCompare
61+ "normalizing inlines deep inside blocks"
62+ "docx/deep_normalize.native"
63+ , testCompare
64+ "move trailing spaces outside of formatting"
65+ "docx/trailing_spaces_in_formatting.native"
66+ , testCompare
67+ "inline code (with VerbatimChar style)"
68+ "docx/inline_code.native"
69+ , testCompare
70+ "inline code in subscript and superscript"
71+ "docx/verbatim_subsuper.native"
72+ ]
73+ , testGroup "blocks"
74+ [ testCompare
75+ "headers"
76+ "docx/headers.native"
77+ , testCompare
78+ "headers already having auto identifiers"
79+ "docx/already_auto_ident.native"
80+ , testCompare
81+ "numbered headers automatically made into list"
82+ "docx/numbered_header.native"
83+ , testCompare
84+ "i18n blocks (headers and blockquotes)"
85+ "docx/i18n_blocks.native"
86+ -- some level problems, look into that
87+ -- , testCompare
88+ -- "lists"
89+ -- "docx/lists.native"
90+ , testCompare
91+ "definition lists"
92+ "docx/definition_list.native"
93+ , testCompare
94+ "custom defined lists in styles"
95+ "docx/german_styled_lists.native"
96+ , testCompare
97+ "footnotes and endnotes"
98+ "docx/notes.native"
99+ , testCompare
100+ "blockquotes (parsing indent as blockquote)"
101+ "docx/block_quotes_parse_indent.native"
102+ , testCompare
103+ "hanging indents"
104+ "docx/hanging_indent.native"
105+ -- tables headers do not survive round-trip, should look into that
106+ -- , testCompare
107+ -- "tables"
108+ -- "docx/tables.native"
109+ -- , testCompare
110+ -- "tables with lists in cells"
111+ -- "docx/table_with_list_cell.native"
112+ , testCompare
113+ "code block"
114+ "docx/codeblock.native"
115+ , testCompare
116+ "dropcap paragraphs"
117+ "docx/drop_cap.native"
118+ ]
119+ , testGroup "metadata"
120+ [ testCompareWithOpts (def,def{readerStandalone=True})
121+ "metadata fields"
122+ "docx/metadata.native"
123+ , testCompareWithOpts (def,def{readerStandalone=True})
124+ "stop recording metadata with normal text"
125+ "docx/metadata_after_normal.native"
126+ ]
127+
128+ ]
tests/docx/image_no_embed_writer.nativenew file+2
@@ -0,0 +1,2 @@
1+[Para [Str "An",Space,Str "image:"]
2+,Para [Image [] ("media/rId25.jpg","")]]
tests/docx/inline_formatting_writer.nativenew file+5
@@ -0,0 +1,5 @@
1+[Para [Str "Regular",Space,Str "text",Space,Emph [Str "italics"],Space,Strong [Str "bold",Space,Emph [Str "bold",Space,Str "italics"]],Str "."]
2+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "Small",Space,Str "Caps"],Str ",",Space,Str "and",Space,Str "this",Space,Str "is",Space,Strikeout [Str "strikethrough"],Str "."]
3+,Para [Str "Some",Space,Str "people",Space,Str "use",Space,Emph [Str "single",Space,Str "underlines",Space,Str "for",Space,Str "emphasis"],Str "."]
4+,Para [Str "Above",Space,Str "the",Space,Str "line",Space,Str "is",Space,Superscript [Str "superscript"],Space,Str "and",Space,Str "below",Space,Str "the",Space,Str "line",Space,Str "is",Space,Subscript [Str "subscript"],Str "."]
5+,Para [Str "A",Space,Str "line",LineBreak,Str "break."]]
tests/docx/inline_images_writer.nativenew file+2
@@ -0,0 +1,2 @@
1+[Para [Str "This",Space,Str "picture",Space,Image [] ("media/rId26.jpg",""),Space,Str "is",Space,Str "an",Space,Str "identicon."]
2+,Para [Str "Here",Space,Str "is",Space,Link [Str "one",Space,Image [] ("media/rId27.jpg",""),Space,Str "that"] ("http://www.google.com",""),Space,Str "links."]]
tests/docx/links_writer.nativenew file+6
@@ -0,0 +1,6 @@
1+[Header 2 ("an-internal-link-and-an-external-link",[],[]) [Str "An",Space,Str "internal",Space,Str "link",Space,Str "and",Space,Str "an",Space,Str "external",Space,Str "link"]
2+,Para [Str "An",Space,Link [Str "external",Space,Str "link"] ("http://google.com",""),Space,Str "to",Space,Str "a",Space,Str "popular",Space,Str "website."]
3+,Para [Str "An",Space,Link [Str "external",Space,Str "link"] ("http://johnmacfarlane.net/pandoc/README.html#synopsis",""),Space,Str "to",Space,Str "a",Space,Str "website",Space,Str "with",Space,Str "an",Space,Str "anchor."]
4+,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#a-section-for-testing-link-targets",""),Space,Str "to",Space,Str "a",Space,Str "section",Space,Str "header."]
5+,Para [Str "An",Space,Link [Str "internal",Space,Str "link"] ("#my_bookmark",""),Space,Str "to",Space,Str "a",Space,Str "bookmark."]
6+,Header 2 ("a-section-for-testing-link-targets",[],[]) [Str "A",Space,Str "section",Space,Str "for",Space,Str "testing",Space,Str "link",Space,Str "targets"]]
tests/media/rId25.jpgnew file

No changes to the content.

tests/media/rId26.jpgnew file

No changes to the content.

tests/media/rId27.jpgnew file

No changes to the content.

tests/test-pandoc.hs+2
@@ -20,6 +20,7 @@ import qualified Tests.Writers.Native
2020import qualified Tests.Writers.Markdown
2121import qualified Tests.Writers.Plain
2222import qualified Tests.Writers.AsciiDoc
23+import qualified Tests.Writers.Docx
2324import qualified Tests.Shared
2425import qualified Tests.Walk
2526import Text.Pandoc.Shared (inDirectory)
@@ -38,6 +39,7 @@ tests = [ testGroup "Old" Tests.Old.tests
3839 , testGroup "Markdown" Tests.Writers.Markdown.tests
3940 , testGroup "Plain" Tests.Writers.Plain.tests
4041 , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests
42+ , testGroup "Docx" Tests.Writers.Docx.tests
4143 ]
4244 , testGroup "Readers"
4345 [ testGroup "LaTeX" Tests.Readers.LaTeX.tests