X-Git-Url: http://nitlanguage.org diff --git a/lib/markdown/test_markdown.nit b/lib/markdown/test_markdown.nit index a8d3b9f..b08f5b4 100644 --- a/lib/markdown/test_markdown.nit +++ b/lib/markdown/test_markdown.nit @@ -13,22 +13,21 @@ # limitations under the License. # Test suites for module `markdown` -module test_markdown is test_suite +module test_markdown is test -import test_suite intrude import markdown class TestMarkdownProcessor - super TestSuite + test - fun test_process_empty do + fun test_process_empty is test do var test = "" var exp = "" var res = test.md_to_html.write_to_string assert res == exp end - fun test_process_tabs do + fun test_process_tabs is test do var test = """ some code """ @@ -40,14 +39,14 @@ class TestMarkdownProcessor end - fun test_process_par1 do + fun test_process_par1 is test do var test = "test" var exp = "
test
\n" var res = test.md_to_html.write_to_string assert res == exp end - fun test_process_par2 do + fun test_process_par2 is test do var test = """ line1 line2 @@ -65,7 +64,7 @@ line2 assert res == exp end - fun test_process_par3 do + fun test_process_par3 is test do var test = """ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. @@ -85,7 +84,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_headings_1 do + fun test_process_headings_1 is test do var test = """ This is a H1 ============= @@ -101,7 +100,7 @@ This is a H2 assert res == exp end - fun test_process_headings_2 do + fun test_process_headings_2 is test do var test = """ # This is a H1 @@ -117,7 +116,7 @@ This is a H2 assert res == exp end - fun test_process_headings_3 do + fun test_process_headings_3 is test do var test = """ # This is a H1 # @@ -134,7 +133,7 @@ This is a H2 assert res == exp end - fun test_process_hr do + fun test_process_hr is test do var test = """ * * * @@ -151,7 +150,7 @@ This is a H2 assert res == exp end - fun test_process_bquote1 do + fun test_process_bquote1 is test do var test = """ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. @@ -172,7 +171,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_bquote2 do + fun test_process_bquote2 is test do var test = """ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. @@ -193,7 +192,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_bquote3 do + fun test_process_bquote3 is test do var test = """ > This is the first level of quoting. > @@ -213,7 +212,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list1 do + fun test_process_list1 is test do var test = """ * Red * Green @@ -229,7 +228,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list2 do + fun test_process_list2 is test do var test = """ + Red + Green @@ -245,7 +244,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list3 do + fun test_process_list3 is test do var test = """ - Red - Green @@ -261,7 +260,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list4 do + fun test_process_list4 is test do var test = """ 1. Bird 2. McHale @@ -277,7 +276,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list5 do + fun test_process_list5 is test do var test = """ 3. Bird 1. McHale @@ -293,7 +292,7 @@ id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list6 do + fun test_process_list6 is test do var test = """ * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, @@ -314,7 +313,7 @@ Suspendisse id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list7 do + fun test_process_list7 is test do var test = """ * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, @@ -335,7 +334,7 @@ Suspendisse id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list8 do + fun test_process_list8 is test do var test = """ * Bird @@ -353,7 +352,7 @@ Suspendisse id sem consectetuer libero luctus adipiscing. assert res == exp end - fun test_process_list9 do + fun test_process_list9 is test do var test = """ 1. This is a list item with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit @@ -382,7 +381,7 @@ sit amet velit. assert res == exp end - fun test_process_list10 do + fun test_process_list10 is test do var test = """ * This is a list item with two paragraphs. @@ -407,7 +406,7 @@ sit amet, consectetuer adipiscing elit. assert res == exp end - fun test_process_list11 do + fun test_process_list11 is test do var test = """ This is a paragraph * and this is not a list @@ -422,7 +421,7 @@ This is a paragraph assert res == exp end - fun test_process_list_ext do + fun test_process_list_ext is test do var test = """ This is a paragraph * and this is not a list @@ -437,7 +436,7 @@ This is a paragraph assert res == exp end - fun test_process_code1 do + fun test_process_code1 is test do var test = """ This is a normal paragraph: @@ -451,7 +450,7 @@ This is a normal paragraph: assert res == exp end - fun test_process_code2 do + fun test_process_code2 is test do var test = """ Here is an example of AppleScript: @@ -478,7 +477,7 @@ end tell assert res == exp end - fun test_process_code_ext1 do + fun test_process_code_ext1 is test do var test = """ Here is an example of AppleScript: ~~~ @@ -506,7 +505,7 @@ end tell assert res == exp end - fun test_process_code_ext2 do + fun test_process_code_ext2 is test do var test = """ Here is an example of AppleScript: ``` @@ -534,7 +533,7 @@ end tell assert res == exp end - fun test_process_code_ext3 do + fun test_process_code_ext3 is test do var proc = new MarkdownProcessor proc.ext_mode = false @@ -550,7 +549,7 @@ beep assert res == exp end - fun test_process_code_ext4 do + fun test_process_code_ext4 is test do var test = """ Here is an example of AppleScript: beep @@ -564,7 +563,7 @@ Here is an example of AppleScript: assert res == exp end - fun test_process_code_ext5 do + fun test_process_code_ext5 is test do var test = """ ```nit print "Hello World!" @@ -578,7 +577,45 @@ print "Hello World!" assert res == exp end - fun test_process_nesting1 do + fun test_process_code_ext6 is test do + var test = """ +~~~ +print "Hello" +~~~ +~~~ +print "World" +~~~ +""" + var exp = """ +print "Hello"
+
+print "World"
+
+"""
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ fun test_process_code_ext7 is test do
+ var test = """
+~~~
+print "Hello"
+~~~
+~~~
+print "World"
+~~~
+"""
+ var exp = """
+print "Hello"
+
+print "World"
+
+"""
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ fun test_process_nesting1 is test do
var test = """
> ## This is a header.
>
@@ -605,7 +642,7 @@ print "Hello World!"
assert res == exp
end
- fun test_process_nesting2 do
+ fun test_process_nesting2 is test do
var test = """
* A list item with a blockquote:
@@ -626,7 +663,7 @@ inside a list item.
assert res == exp
end
- fun test_process_nesting3 do
+ fun test_process_nesting3 is test do
var test = """
* A list item with a code block:
@@ -644,7 +681,7 @@ inside a list item.
assert res == exp
end
- fun test_process_nesting4 do
+ fun test_process_nesting4 is test do
var test = """
* Tab
* Tab
@@ -666,7 +703,7 @@ inside a list item.
end
# TODO
- # fun test_process_nesting5 do
+ # fun test_process_nesting5 is test do
# var test = """
# * this
#
@@ -688,7 +725,7 @@ inside a list item.
# assert res == exp
# end
- fun test_process_emph1 do
+ fun test_process_emph1 is test do
var test = """
*single asterisks*
@@ -707,14 +744,14 @@ __double underscores__
assert res == exp
end
- fun test_process_emph2 do
+ fun test_process_emph2 is test do
var test = "un*frigging*believable"
var exp = "unfriggingbelievable
\n" var res = test.md_to_html.write_to_string assert res == exp end - fun test_process_emph3 do + fun test_process_emph3 is test do var proc = new MarkdownProcessor proc.ext_mode = false var test = "Con_cat_this" @@ -723,14 +760,14 @@ __double underscores__ assert res == exp end - fun test_process_emph_ext do + fun test_process_emph_ext is test do var test = "Con_cat_this" var exp = "Con_cat_this
\n" var res = test.md_to_html.write_to_string assert res == exp end - fun test_process_xml1 do + fun test_process_xml1 is test do var test = """ This is a regular paragraph. @@ -755,7 +792,7 @@ This is another regular paragraph. assert res == exp end - fun test_process_xml2 do + fun test_process_xml2 is test do var test = """ This is an image in a regular paragraph. """ @@ -765,7 +802,7 @@ This is an image in a regular paragraph. assert res == exp end - fun test_process_xml3 do + fun test_process_xml3 is test do var test = """ """ @@ -776,21 +813,51 @@ This is an image in a regular paragraph. assert res == exp end - fun test_process_span_code1 do + fun test_process_xml4 is test do + var test = """ +This is an example of a block element that should be escaped.
+Idem for the second paragraph.
+""" + var exp = test + var res = test.md_to_html.write_to_string + assert res == exp + end + + fun test_process_xml5 is test do + var test = """ +# Some more XML tests + +This is an example of a block element that should be escaped.
+Idem for the second paragraph.
+ +With a *md paragraph*! +""" + var exp = """ +This is an example of a block element that should be escaped.
+Idem for the second paragraph.
+With a md paragraph!
+""" + var res = test.md_to_html.write_to_string + print res + assert res == exp + end + + fun test_process_span_code1 is test do var test = "Use the `printf()` function." var exp = "Use the printf()
function.
There is a literal backtick (`) here.