X-Git-Url: http://nitlanguage.org diff --git a/lib/markdown/test_markdown.nit b/lib/markdown/test_markdown.nit index c470df1..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,37 @@ sit amet, consectetuer adipiscing elit. assert res == exp end - fun test_process_code1 do + fun test_process_list11 is test do + var test = """ +This is a paragraph +* and this is not a list +""" + var exp = """ +This is a paragraph +* and this is not a list
+""" + var proc = new MarkdownProcessor + proc.ext_mode = false + var res = proc.process(test).write_to_string + assert res == exp + end + + fun test_process_list_ext is test do + var test = """ +This is a paragraph +* and this is not a list +""" + var exp = """ +This is a paragraph
+Here is an example of AppleScript:
+tell application "Foo"
+ beep
+end tell
+
+<div class="footer">
+ © 2004 Foo Corporation
+</div>
+
+"""
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ fun test_process_code_ext2 is test do
+ var test = """
+Here is an example of AppleScript:
+```
+tell application "Foo"
+ beep
+end tell
+
+
+```
+"""
+ var exp = """
+Here is an example of AppleScript:
+tell application "Foo"
+ beep
+end tell
+
+<div class="footer">
+ © 2004 Foo Corporation
+</div>
+
+"""
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ fun test_process_code_ext3 is test do
+ var proc = new MarkdownProcessor
+ proc.ext_mode = false
+
+ var test = """
+Here is an example of AppleScript:
+ beep
+"""
+ var exp = """
+Here is an example of AppleScript: +beep
+""" + var res = proc.process(test).write_to_string + assert res == exp + end + + fun test_process_code_ext4 is test do + var test = """ +Here is an example of AppleScript: + beep +""" + var exp = """ +Here is an example of AppleScript:
+beep
+
+"""
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ fun test_process_code_ext5 is test do
+ var test = """
+```nit
+print "Hello World!"
+```
+"""
+ var exp = """
+print "Hello World!"
+
+"""
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ 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.
>
@@ -475,7 +642,7 @@ end tell
assert res == exp
end
- fun test_process_nesting2 do
+ fun test_process_nesting2 is test do
var test = """
* A list item with a blockquote:
@@ -496,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:
@@ -514,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
@@ -536,7 +703,7 @@ inside a list item.
end
# TODO
- # fun test_process_nesting5 do
+ # fun test_process_nesting5 is test do
# var test = """
# * this
#
@@ -558,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*
@@ -577,14 +744,30 @@ __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_xml1 do + fun test_process_emph3 is test do + var proc = new MarkdownProcessor + proc.ext_mode = false + var test = "Con_cat_this" + var exp = "Concatthis
\n" + var res = proc.process(test).write_to_string + assert res == exp + end + + 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 is test do var test = """ This is a regular paragraph. @@ -609,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 imageThis 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.