compiler: handle multi-iterators
[nit.git] / lib / markdown / test_markdown.nit
index e4bd177..53c355f 100644 (file)
@@ -578,6 +578,44 @@ print "Hello World!"
                assert res == exp
        end
 
+       fun test_process_code_ext6 do
+               var test = """
+~~~
+print "Hello"
+~~~
+~~~
+print "World"
+~~~
+"""
+               var exp = """
+<pre><code>print "Hello"
+</code></pre>
+<pre><code>print "World"
+</code></pre>
+"""
+               var res = test.md_to_html.write_to_string
+               assert res == exp
+       end
+
+       fun test_process_code_ext7 do
+               var test = """
+~~~
+print "Hello"
+~~~
+~~~
+print "World"
+~~~
+"""
+               var exp = """
+<pre><code>print "Hello"
+</code></pre>
+<pre><code>print "World"
+</code></pre>
+"""
+               var res = test.md_to_html.write_to_string
+               assert res == exp
+       end
+
        fun test_process_nesting1 do
                var test = """
 > ## This is a header.
@@ -776,6 +814,36 @@ This is an image <img src="foo/bar" alt="baz"/> in a regular paragraph.
                assert res == exp
        end
 
+       fun test_process_xml4 do
+               var test = """
+<p>This is an example of a block element that should be escaped.</p>
+<p>Idem for the second paragraph.</p>
+"""
+               var exp = test
+               var res = test.md_to_html.write_to_string
+               assert res == exp
+       end
+
+       fun test_process_xml5 do
+               var test = """
+# Some more XML tests
+
+<p>This is an example of a block element that should be escaped.</p>
+<p>Idem for the second paragraph.</p>
+
+With a *md paragraph*!
+"""
+               var exp = """
+<h1 id="Some_more_XML_tests">Some more XML tests</h1>
+<p>This is an example of a block element that should be escaped.</p>
+<p>Idem for the second paragraph.</p>
+<p>With a <em>md paragraph</em>!</p>
+"""
+               var res = test.md_to_html.write_to_string
+               print res
+               assert res == exp
+       end
+
        fun test_process_span_code1 do
                var test = "Use the `printf()` function."
                var exp = "<p>Use the <code>printf()</code> function.</p>\n"
@@ -2619,6 +2687,8 @@ class TestLine
                assert v.line_kind(subject) isa LineFence
                subject = new MDLine(loc, "  ```")
                assert v.line_kind(subject) isa LineFence
+               subject = new MDLine(loc, "~~~raw")
+               assert v.line_kind(subject) isa LineFence
        end
 
        fun test_count_chars do
@@ -2730,6 +2800,26 @@ class TestTokenLocation
                        "TokenLink at 4,1--4,1"]
                (new TestTokenProcessor(stack)).process(string)
        end
+
+       fun test_token_location4 do
+               var string = "**Hello**\n\n`World`"
+               var stack =  [
+                       "TokenStrongStar at 1,1--1,1",
+                       "TokenStrongStar at 1,8--1,8",
+                       "TokenCodeSingle at 3,1--3,1",
+                       "TokenCodeSingle at 3,7--3,7"]
+               (new TestTokenProcessor(stack)).process(string)
+       end
+
+       fun test_token_location5 do
+               var string = "# *Title1*\n\n# *Title2*"
+               var stack =  [
+                       "TokenEmStar at 1,3--1,3",
+                       "TokenEmStar at 1,10--1,10",
+                       "TokenEmStar at 3,3--3,3",
+                       "TokenEmStar at 3,10--3,10"]
+               (new TestTokenProcessor(stack)).process(string)
+       end
 end
 
 class TestTokenProcessor
@@ -2741,8 +2831,10 @@ class TestTokenProcessor
                var token = super
                if token isa TokenNone then return token
                var res = "{token.class_name} at {token.location}"
-               print res
                var exp = test_stack.shift
+               print ""
+               print "EXP {exp}"
+               print "RES {res}"
                assert exp == res
                return token
        end
@@ -2782,6 +2874,15 @@ some code
                proc.emitter.decorator = new TestBlockDecorator(stack)
                proc.process(string)
        end
+
+       fun test_block_location3 do
+               var stack = [
+                       "BlockHeadline: 1,1--1,8",
+                       "BlockHeadline: 3,1--3,10"]
+               var string ="""# Title\n\n## Title 2"""
+               proc.emitter.decorator = new TestBlockDecorator(stack)
+               proc.process(string)
+       end
 end
 
 class TestBlockDecorator