summaryrefslogtreecommitdiff
path: root/src/Tests
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2011-08-23 00:00:32 +0200
committerJonas Smedegaard <dr@jones.dk>2011-08-23 00:00:32 +0200
commita242ebaf29539d6a9a4eec97e510b5f8e4b59b30 (patch)
treedfc3eab668562da5efbc9cd5577292ee891d9d94 /src/Tests
parent6479926bb9955dcbf0d175d053e2b38c44d59507 (diff)
Imported Upstream version 1.8.2
Diffstat (limited to 'src/Tests')
-rw-r--r--src/Tests/Readers/Markdown.hs33
-rw-r--r--src/Tests/Readers/RST.hs16
-rw-r--r--src/Tests/Writers/Markdown.hs34
3 files changed, 82 insertions, 1 deletions
diff --git a/src/Tests/Readers/Markdown.hs b/src/Tests/Readers/Markdown.hs
index feec8fa65..941762bd0 100644
--- a/src/Tests/Readers/Markdown.hs
+++ b/src/Tests/Readers/Markdown.hs
@@ -8,10 +8,14 @@ import Tests.Arbitrary()
import Text.Pandoc.Builder
-- import Text.Pandoc.Shared ( normalize )
import Text.Pandoc
+import Data.Sequence (singleton)
markdown :: String -> Pandoc
markdown = readMarkdown defaultParserState{ stateStandalone = True }
+markdownSmart :: String -> Pandoc
+markdownSmart = readMarkdown defaultParserState{ stateSmart = True }
+
infix 5 =:
(=:) :: ToString c
=> String -> (String, c) -> Test
@@ -40,6 +44,22 @@ tests = [ testGroup "inline code"
"`*` {.haskell .special x=\"7\"}"
=?> para (codeWith ("",["haskell","special"],[("x","7")]) "*")
]
+ , testGroup "smart punctuation"
+ [ test markdownSmart "quote before ellipses"
+ ("'...hi'"
+ =?> para (singleQuoted (singleton Ellipses +++ "hi")))
+ ]
+ , 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"
@@ -47,6 +67,19 @@ tests = [ testGroup "inline code"
, "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 defaultParserState{stateLiterateHaskell = 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"
diff --git a/src/Tests/Readers/RST.hs b/src/Tests/Readers/RST.hs
index c0f60ff51..4b8c9301b 100644
--- a/src/Tests/Readers/RST.hs
+++ b/src/Tests/Readers/RST.hs
@@ -17,7 +17,10 @@ infix 5 =:
(=:) = test rst
tests :: [Test]
-tests = [ "field list" =:
+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
@@ -32,6 +35,8 @@ tests = [ "field list" =:
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
@@ -41,6 +46,15 @@ tests = [ "field list" =:
, (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" +++ ")")
]
diff --git a/src/Tests/Writers/Markdown.hs b/src/Tests/Writers/Markdown.hs
new file mode 100644
index 000000000..70266a683
--- /dev/null
+++ b/src/Tests/Writers/Markdown.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Writers.Markdown (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+
+markdown :: (ToString a, ToPandoc a) => a -> String
+markdown = writeMarkdown defaultWriterOptions . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test markdown "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test markdown "my test" (X,Y)
+-}
+
+infix 5 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test markdown
+
+tests :: [Test]
+tests = [ "indented code after list"
+ =: (orderedList [ para "one" +++ para "two" ] +++ codeBlock "test")
+ =?> "1. one\n\n two\n\n<!-- -->\n\n test"
+ ]