git.iko.soy/typeable/pandoc
on master help sign in
WIP: tests for RST roles
4e04016Daniel Bergey
tests/Tests/Readers/RST.hs+37−18
@@ -67,26 +67,45 @@ tests = [ "line block with blank line" =:
67 link "http://foo.bar.baz" "" "http://foo.bar.baz" <> ". " <>
67 link "http://foo.bar.baz" "" "http://foo.bar.baz" <> ". " <>
68 link "http://foo.bar/baz_(bam)" "" "http://foo.bar/baz_(bam)"
68 link "http://foo.bar/baz_(bam)" "" "http://foo.bar/baz_(bam)"
69 <> " (" <> link "http://foo.bar" "" "http://foo.bar" <> ")")
69 <> " (" <> link "http://foo.bar" "" "http://foo.bar" <> ")")
70+ , testGroup "literal / line / code blocks"
70− , "indented literal block" =: unlines
71+ [ "indented literal block" =: unlines
71− [ "::"
72+ [ "::"
72− , ""
73+ , ""
73− , " block quotes"
74+ , " block quotes"
74− , ""
75+ , ""
75− , " can go on for many lines"
76+ , " can go on for many lines"
76− , "but must stop here"]
77+ , "but must stop here"]
77− =?> (doc $
78+ =?> (doc $
78− codeBlock "block quotes\n\ncan go on for many lines" <>
79+ codeBlock "block quotes\n\ncan go on for many lines" <>
79− para "but must stop here")
80+ para "but must stop here")
80− , "line block with 3 lines" =: "| a\n| b\n| c"
81+ , "line block with 3 lines" =: "| a\n| b\n| c"
81− =?> para ("a" <> linebreak <> "b" <> linebreak <> "c")
82+ =?> para ("a" <> linebreak <> "b" <> linebreak <> "c")
82 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
83 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
83 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
84 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
84 , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
85 , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
85 =?> codeBlock "| quoted\n| block" <> para "Ordinary paragraph"
86 =?> codeBlock "| quoted\n| block" <> para "Ordinary paragraph"
86− , "class directive with single paragraph" =: ".. class:: special\n\nThis is a \"special\" paragraph."
87+ , "class directive with single paragraph" =: ".. class:: special\n\nThis is a \"special\" paragraph."
87− =?> divWith ("", ["special"], []) (para "This is a \"special\" paragraph.")
88+ =?> divWith ("", ["special"], []) (para "This is a \"special\" paragraph.")
88− , "class directive with two paragraphs" =: ".. class:: exceptional remarkable\n\n First paragraph.\n\n Second paragraph."
89+ , "class directive with two paragraphs" =: ".. class:: exceptional remarkable\n\n First paragraph.\n\n Second paragraph."
89− =?> divWith ("", ["exceptional", "remarkable"], []) (para "First paragraph." <> para "Second paragraph.")
90+ =?> divWith ("", ["exceptional", "remarkable"], []) (para "First paragraph." <> para "Second paragraph.")
90− , "class directive around literal block" =: ".. class:: classy\n\n::\n\n a\n b"
91+ , "class directive around literal block" =: ".. class:: classy\n\n::\n\n a\n b"
91− =?> divWith ("", ["classy"], []) (codeBlock "a\nb")
92+ =?> divWith ("", ["classy"], []) (codeBlock "a\nb")]
93+ , testGroup "interpreted text roles"
94+ [ "literal role prefix" =: ":literal:`a`" =?> para (code "a")
95+ , "literal role postfix" =: "`a`:literal:" =?> para (code "a")
96+ , "literal text" =: "``text``" =?> para (code "text")
97+ , "code role" =: ":code:`a`" =?> para (codeWith ("", ["sourceCode"], []) "a")
98+ , "inherited code role" =: ".. role:: codeLike(code)\n\n:codeLike:`a`"
99+ =?> para (codeWith ("", ["codeLike", "sourceCode"], []) "a")
100+ , "custom code role with language field"
101+ =: ".. role:: lhs(code)\n :language: haskell\n\n:lhs:`a`"
102+ =?> para (codeWith ("", ["sourceCode", "haskell", "lhs"], []) "a")
103+ , "custom role with unspecified parent role"
104+ =: ".. role:: classy\n\n:classy:`text`"
105+ =?> para (spanWith ("", ["classy"], []) "text")
106+ , "role with recursive inheritance"
107+ =: ".. role:: haskell(code)\n.. role:: lhs(haskell)\n\n:lhs:`text`"
108+ =?> para (codeWith ("", ["lhs", "haskell", "sourceCode"], []) "text")
109+ , "unknown role" =: ":unknown:`text`" =?> para (str "text")
110+ ]
92 ]
111 ]
tests/rst-reader.native+2−2
@@ -325,9 +325,9 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
325,Para [Str "And",Space,Str "some",Space,Str "inline",Space,Str "haskell",Space,Code ("",["sourceCode","haskell"],[]) "fmap id [1,2..10]",Str "."]
325,Para [Str "And",Space,Str "some",Space,Str "inline",Space,Str "haskell",Space,Code ("",["sourceCode","haskell"],[]) "fmap id [1,2..10]",Str "."]
326,Null
326,Null
327,Null
327,Null
328−,Para [Str "Indirect",Space,Str "python",Space,Str "role",Space,Code ("",["sourceCode","python"],[]) "[x*x for x in [1,2,3,4,5]]",Str "."]
328+,Para [Str "Indirect",Space,Str "python",Space,Str "role",Space,Code ("",["sourceCode","python","indirect"],[]) "[x*x for x in [1,2,3,4,5]]",Str "."]
329,Null
329,Null
330,Null
330,Null
331−,Para [Str "Different",Space,Str "indirect",Space,Str "C",Space,Code ("",["sourceCode","c"],[]) "int x = 15;",Str "."]
331+,Para [Str "Different",Space,Str "indirect",Space,Str "C",Space,Code ("",["sourceCode","c","different-indirect"],[]) "int x = 15;",Str "."]
332,Header 2 ("literal-symbols",[],[]) [Str "Literal",Space,Str "symbols"]
332,Header 2 ("literal-symbols",[],[]) [Str "Literal",Space,Str "symbols"]
333,Para [Str "2*2",Space,Str "=",Space,Str "4*1"]]
333,Para [Str "2*2",Space,Str "=",Space,Str "4*1"]]