aboutsummaryrefslogtreecommitdiff
path: root/src/Tests/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-07-26 08:37:36 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-07-26 08:37:36 -0700
commit45e4c123a45b83d666088967c25b91cf9bb5db72 (patch)
treeb3662354ccacd88b0d9238b3d0c049c4c876abc4 /src/Tests/Readers
parent3053267280bfd7b255f3bf47480e4a8a97ec2915 (diff)
downloadpandoc-45e4c123a45b83d666088967c25b91cf9bb5db72.tar.gz
Moved tests to tests/, modified cabal file so lib isn't recompiled.
Diffstat (limited to 'src/Tests/Readers')
-rw-r--r--src/Tests/Readers/LaTeX.hs169
-rw-r--r--src/Tests/Readers/Markdown.hs107
-rw-r--r--src/Tests/Readers/RST.hs60
3 files changed, 0 insertions, 336 deletions
diff --git a/src/Tests/Readers/LaTeX.hs b/src/Tests/Readers/LaTeX.hs
deleted file mode 100644
index febc91765..000000000
--- a/src/Tests/Readers/LaTeX.hs
+++ /dev/null
@@ -1,169 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-module Tests.Readers.LaTeX (tests) where
-
-import Text.Pandoc.Definition
-import Test.Framework
-import Tests.Helpers
-import Tests.Arbitrary()
-import Text.Pandoc.Builder
-import Text.Pandoc
-
-latex :: String -> Pandoc
-latex = readLaTeX def
-
-infix 4 =:
-(=:) :: ToString c
- => String -> (String, c) -> Test
-(=:) = test latex
-
-tests :: [Test]
-tests = [ testGroup "basic"
- [ "simple" =:
- "word" =?> para "word"
- , "space" =:
- "some text" =?> para ("some text")
- , "emphasized" =:
- "\\emph{emphasized}" =?> para (emph "emphasized")
- ]
-
- , testGroup "headers"
- [ "level 1" =:
- "\\section{header}" =?> header 1 "header"
- , "level 2" =:
- "\\subsection{header}" =?> header 2 "header"
- , "level 3" =:
- "\\subsubsection{header}" =?> header 3 "header"
- , "emph" =:
- "\\section{text \\emph{emph}}" =?>
- header 1 ("text" <> space <> emph "emph")
- , "link" =:
- "\\section{text \\href{/url}{link}}" =?>
- header 1 ("text" <> space <> link "/url" "" "link")
- ]
-
- , testGroup "math"
- [ "escaped $" =:
- "$x=\\$4$" =?> para (math "x=\\$4")
- ]
-
- , testGroup "space and comments"
- [ "blank lines + space at beginning" =:
- "\n \n hi" =?> para "hi"
- , "blank lines + space + comments" =:
- "% my comment\n\n \n % another\n\nhi" =?> para "hi"
- , "comment in paragraph" =:
- "hi % this is a comment\nthere\n" =?> para "hi there"
- ]
-
- , testGroup "citations"
- [ natbibCitations
- , biblatexCitations
- ]
- ]
-
-baseCitation :: Citation
-baseCitation = Citation{ citationId = "item1"
- , citationPrefix = []
- , citationSuffix = []
- , citationMode = AuthorInText
- , citationNoteNum = 0
- , citationHash = 0 }
-
-rt :: String -> Inlines
-rt = rawInline "latex"
-
-natbibCitations :: Test
-natbibCitations = testGroup "natbib"
- [ "citet" =: "\\citet{item1}"
- =?> para (cite [baseCitation] (rt "\\citet{item1}"))
- , "suffix" =: "\\citet[p.~30]{item1}"
- =?> para
- (cite [baseCitation{ citationSuffix = toList $ text ", p.\160\&30" }] (rt "\\citet[p.~30]{item1}"))
- , "suffix long" =: "\\citet[p.~30, with suffix]{item1}"
- =?> para (cite [baseCitation{ citationSuffix =
- toList $ text ", p.\160\&30, with suffix" }] (rt "\\citet[p.~30, with suffix]{item1}"))
- , "multiple" =: "\\citeauthor{item1} \\citetext{\\citeyear{item1}; \\citeyear[p.~30]{item2}; \\citealp[see also][]{item3}}"
- =?> para (cite [baseCitation{ citationMode = AuthorInText }
- ,baseCitation{ citationMode = SuppressAuthor
- , citationSuffix = [Str ",",Space,Str "p.\160\&30"]
- , citationId = "item2" }
- ,baseCitation{ citationId = "item3"
- , citationPrefix = [Str "see",Space,Str "also"]
- , citationMode = NormalCitation }
- ] (rt "\\citetext{\\citeyear{item1}; \\citeyear[p.~30]{item2}; \\citealp[see also][]{item3}}"))
- , "group" =: "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationPrefix = [Str "see"]
- , citationSuffix = [Str ",",Space,Str "p.\160\&34\8211\&35"] }
- ,baseCitation{ citationMode = NormalCitation
- , citationId = "item3"
- , citationPrefix = [Str "also"]
- , citationSuffix = [Str ",",Space,Str "chap.",Space,Str "3"] }
- ] (rt "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"))
- , "suffix and locator" =: "\\citep[pp.~33, 35--37, and nowhere else]{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationSuffix = [Str ",",Space,Str "pp.\160\&33,",Space,Str "35\8211\&37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] (rt "\\citep[pp.~33, 35--37, and nowhere else]{item1}"))
- , "suffix only" =: "\\citep[and nowhere else]{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationSuffix = toList $ text ", and nowhere else" }] (rt "\\citep[and nowhere else]{item1}"))
- , "no author" =: "\\citeyearpar{item1}, and now Doe with a locator \\citeyearpar[p.~44]{item2}"
- =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] (rt "\\citeyearpar{item1}") <>
- text ", and now Doe with a locator " <>
- cite [baseCitation{ citationMode = SuppressAuthor
- , citationSuffix = [Str ",",Space,Str "p.\160\&44"]
- , citationId = "item2" }] (rt "\\citeyearpar[p.~44]{item2}"))
- , "markup" =: "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationPrefix = [Emph [Str "see"]]
- , citationSuffix = [Str ",",Space,Str "p.",Space,
- Strong [Str "32"]] }] (rt "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"))
- ]
-
-biblatexCitations :: Test
-biblatexCitations = testGroup "biblatex"
- [ "textcite" =: "\\textcite{item1}"
- =?> para (cite [baseCitation] (rt "\\textcite{item1}"))
- , "suffix" =: "\\textcite[p.~30]{item1}"
- =?> para
- (cite [baseCitation{ citationSuffix = toList $ text ", p.\160\&30" }] (rt "\\textcite[p.~30]{item1}"))
- , "suffix long" =: "\\textcite[p.~30, with suffix]{item1}"
- =?> para (cite [baseCitation{ citationSuffix =
- toList $ text ", p.\160\&30, with suffix" }] (rt "\\textcite[p.~30, with suffix]{item1}"))
- , "multiple" =: "\\textcites{item1}[p.~30]{item2}[see also][]{item3}"
- =?> para (cite [baseCitation{ citationMode = AuthorInText }
- ,baseCitation{ citationMode = NormalCitation
- , citationSuffix = [Str ",",Space,Str "p.\160\&30"]
- , citationId = "item2" }
- ,baseCitation{ citationId = "item3"
- , citationPrefix = [Str "see",Space,Str "also"]
- , citationMode = NormalCitation }
- ] (rt "\\textcites{item1}[p.~30]{item2}[see also][]{item3}"))
- , "group" =: "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationPrefix = [Str "see"]
- , citationSuffix = [Str ",",Space,Str "p.\160\&34\8211\&35"] }
- ,baseCitation{ citationMode = NormalCitation
- , citationId = "item3"
- , citationPrefix = [Str "also"]
- , citationSuffix = [Str ",",Space,Str "chap.",Space,Str "3"] }
- ] (rt "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"))
- , "suffix and locator" =: "\\autocite[pp.~33, 35--37, and nowhere else]{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationSuffix = [Str ",",Space,Str "pp.\160\&33,",Space,Str "35\8211\&37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] (rt "\\autocite[pp.~33, 35--37, and nowhere else]{item1}"))
- , "suffix only" =: "\\autocite[and nowhere else]{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationSuffix = toList $ text ", and nowhere else" }] (rt "\\autocite[and nowhere else]{item1}"))
- , "no author" =: "\\autocite*{item1}, and now Doe with a locator \\autocite*[p.~44]{item2}"
- =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] (rt "\\autocite*{item1}") <>
- text ", and now Doe with a locator " <>
- cite [baseCitation{ citationMode = SuppressAuthor
- , citationSuffix = [Str ",",Space,Str "p.\160\&44"]
- , citationId = "item2" }] (rt "\\autocite*[p.~44]{item2}"))
- , "markup" =: "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation
- , citationPrefix = [Emph [Str "see"]]
- , citationSuffix = [Str ",",Space,Str "p.",Space,
- Strong [Str "32"]] }] (rt "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}"))
- , "parencite" =: "\\parencite{item1}"
- =?> para (cite [baseCitation{ citationMode = NormalCitation }] (rt "\\parencite{item1}"))
- ]
diff --git a/src/Tests/Readers/Markdown.hs b/src/Tests/Readers/Markdown.hs
deleted file mode 100644
index 543802795..000000000
--- a/src/Tests/Readers/Markdown.hs
+++ /dev/null
@@ -1,107 +0,0 @@
-{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
-module Tests.Readers.Markdown (tests) where
-
-import Text.Pandoc.Definition
-import Test.Framework
-import Tests.Helpers
-import Tests.Arbitrary()
-import Text.Pandoc.Builder
--- import Text.Pandoc.Shared ( normalize )
-import Text.Pandoc
-
-markdown :: String -> Pandoc
-markdown = readMarkdown def
-
-markdownSmart :: String -> Pandoc
-markdownSmart = readMarkdown def { readerSmart = True }
-
-infix 4 =:
-(=:) :: ToString c
- => String -> (String, c) -> Test
-(=:) = test markdown
-
-{-
-p_markdown_round_trip :: Block -> Bool
-p_markdown_round_trip b = matches d' d''
- where d' = normalize $ Pandoc (Meta [] [] []) [b]
- d'' = normalize
- $ readMarkdown def { readerSmart = True }
- $ writeMarkdown defaultWriterOptions d'
- matches (Pandoc _ [Plain []]) (Pandoc _ []) = True
- matches (Pandoc _ [Para []]) (Pandoc _ []) = True
- matches (Pandoc _ [Plain xs]) (Pandoc _ [Para xs']) = xs == xs'
- matches x y = x == y
--}
-
-tests :: [Test]
-tests = [ testGroup "inline code"
- [ "with attribute" =:
- "`document.write(\"Hello\");`{.javascript}"
- =?> para
- (codeWith ("",["javascript"],[]) "document.write(\"Hello\");")
- , "with attribute space" =:
- "`*` {.haskell .special x=\"7\"}"
- =?> para (codeWith ("",["haskell","special"],[("x","7")]) "*")
- ]
- , testGroup "backslash escapes"
- [ "in URL" =:
- "[hi](/there\\))"
- =?> para (link "/there)" "" "hi")
- , "in title" =:
- "[hi](/there \"a\\\"a\")"
- =?> para (link "/there" "a\"a" "hi")
- , "in reference link title" =:
- "[hi]\n\n[hi]: /there (a\\)a)"
- =?> para (link "/there" "a)a" "hi")
- , "in reference link URL" =:
- "[hi]\n\n[hi]: /there\\.0"
- =?> para (link "/there.0" "" "hi")
- ]
- , testGroup "smart punctuation"
- [ test markdownSmart "quote before ellipses"
- ("'...hi'"
- =?> para (singleQuoted ("…hi")))
- , test markdownSmart "apostrophe before emph"
- ("D'oh! A l'*aide*!"
- =?> para ("D’oh! A l’" <> emph "aide" <> "!"))
- , test markdownSmart "apostrophe in French"
- ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
- =?> para ("À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»"))
- ]
- , testGroup "mixed emphasis and strong"
- [ "emph and strong emph alternating" =:
- "*xxx* ***xxx*** xxx\n*xxx* ***xxx*** xxx"
- =?> para (emph "xxx" <> space <> strong (emph "xxx") <>
- space <> "xxx" <> space <>
- emph "xxx" <> space <> strong (emph "xxx") <>
- space <> "xxx")
- , "emph with spaced strong" =:
- "*x **xx** x*"
- =?> para (emph ("x" <> space <> strong "xx" <> space <> "x"))
- ]
- , testGroup "footnotes"
- [ "indent followed by newline and flush-left text" =:
- "[^1]\n\n[^1]: my note\n\n \nnot in note\n"
- =?> para (note (para "my note")) <> para "not in note"
- , "indent followed by newline and indented text" =:
- "[^1]\n\n[^1]: my note\n \n in note\n"
- =?> para (note (para "my note" <> para "in note"))
- , "recursive note" =:
- "[^1]\n\n[^1]: See [^1]\n"
- =?> para (note (para "See [^1]"))
- ]
- , testGroup "lhs"
- [ test (readMarkdown def{ readerLiterateHaskell = True })
- "inverse bird tracks and html" $
- "> a\n\n< b\n\n<div>\n"
- =?> codeBlockWith ("",["sourceCode","literate","haskell"],[]) "a"
- <>
- codeBlockWith ("",["sourceCode","haskell"],[]) "b"
- <>
- rawBlock "html" "<div>\n\n"
- ]
--- the round-trip properties frequently fail
--- , testGroup "round trip"
--- [ property "p_markdown_round_trip" p_markdown_round_trip
--- ]
- ]
diff --git a/src/Tests/Readers/RST.hs b/src/Tests/Readers/RST.hs
deleted file mode 100644
index fdce7c8f6..000000000
--- a/src/Tests/Readers/RST.hs
+++ /dev/null
@@ -1,60 +0,0 @@
-{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
-module Tests.Readers.RST (tests) where
-
-import Text.Pandoc.Definition
-import Test.Framework
-import Tests.Helpers
-import Tests.Arbitrary()
-import Text.Pandoc.Builder
-import Text.Pandoc
-
-rst :: String -> Pandoc
-rst = readRST def
-
-infix 4 =:
-(=:) :: ToString c
- => String -> (String, c) -> Test
-(=:) = test rst
-
-tests :: [Test]
-tests = [ "line block with blank line" =:
- "| a\n|\n| b" =?> para (str "a" <> linebreak <>
- linebreak <> str " " <> str "b")
- , "field list" =:
- [_LIT|
-:Hostname: media08
-:IP address: 10.0.0.19
-:Size: 3ru
-:Date: 2001-08-16
-:Version: 1
-:Authors: - Me
- - Myself
- - I
-:Indentation: Since the field marker may be quite long, the second
- and subsequent lines of the field body do not have to line up
- with the first line, but they must be indented relative to the
- field name marker, and they must line up with each other.
-:Parameter i: integer
-:Final: item
- on two lines
-|] =?> ( setAuthors ["Me","Myself","I"]
- $ setDate "2001-08-16"
- $ doc
- $ definitionList [ (str "Hostname", [para "media08"])
- , (str "IP address", [para "10.0.0.19"])
- , (str "Size", [para "3ru"])
- , (str "Version", [para "1"])
- , (str "Indentation", [para "Since the field marker may be quite long, the second and subsequent lines of the field body do not have to line up with the first line, but they must be indented relative to the field name marker, and they must line up with each other."])
- , (str "Parameter i", [para "integer"])
- , (str "Final", [para "item on two lines"])
- ])
- , "URLs with following punctuation" =:
- ("http://google.com, http://yahoo.com; http://foo.bar.baz.\n" ++
- "http://foo.bar/baz_(bam) (http://foo.bar)") =?>
- para (link "http://google.com" "" "http://google.com" <> ", " <>
- link "http://yahoo.com" "" "http://yahoo.com" <> "; " <>
- link "http://foo.bar.baz" "" "http://foo.bar.baz" <> ". " <>
- link "http://foo.bar/baz_(bam)" "" "http://foo.bar/baz_(bam)"
- <> " (" <> link "http://foo.bar" "" "http://foo.bar" <> ")")
- ]
-