lib/markdown2: import tests from CommonMark spec
[nit.git] / lib / markdown2 / tests / test_commonmark_tabs.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 module test_commonmark_tabs is test
16
17 import test_markdown
18
19 class TestCommonmarkTabs
20 super TestMarkdownHtml
21 test
22
23 fun test1 is test do
24 var md = """\tfoo\tbaz\t\tbim\n"""
25 var html = """<pre><code>foo\tbaz\t\tbim\n</code></pre>\n"""
26 assert md_to_html(md) == html
27 end
28
29 fun test2 is test do
30 var md = """ \tfoo\tbaz\t\tbim\n"""
31 var html = """<pre><code>foo\tbaz\t\tbim\n</code></pre>\n"""
32 assert md_to_html(md) == html
33 end
34
35 fun test3 is test do
36 var md = """ a\ta\n ὐ\ta\n"""
37 var html = """<pre><code>a\ta\nὐ\ta\n</code></pre>\n"""
38 assert md_to_html(md) == html
39 end
40
41 fun test4 is test do
42 var md = """ - foo\n\n\tbar\n"""
43 var html = """<ul>\n<li>\n<p>foo</p>\n<p>bar</p>\n</li>\n</ul>\n"""
44 assert md_to_html(md) == html
45 end
46
47 fun test5 is test do
48 var md = """- foo\n\n\t\tbar\n"""
49 var html = """<ul>\n<li>\n<p>foo</p>\n<pre><code> bar\n</code></pre>\n</li>\n</ul>\n"""
50 assert md_to_html(md) == html
51 end
52
53 fun test6 is test do
54 var md = """>\t\tfoo\n"""
55 var html = """<blockquote>\n<pre><code> foo\n</code></pre>\n</blockquote>\n"""
56 assert md_to_html(md) == html
57 end
58
59 fun test7 is test do
60 var md = """-\t\tfoo\n"""
61 var html = """<ul>\n<li>\n<pre><code> foo\n</code></pre>\n</li>\n</ul>\n"""
62 assert md_to_html(md) == html
63 end
64
65 fun test8 is test do
66 var md = """ foo\n\tbar\n"""
67 var html = """<pre><code>foo\nbar\n</code></pre>\n"""
68 assert md_to_html(md) == html
69 end
70
71 fun test9 is test do
72 var md = """ - foo\n - bar\n\t - baz\n"""
73 var html = """<ul>\n<li>foo\n<ul>\n<li>bar\n<ul>\n<li>baz</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n"""
74 assert md_to_html(md) == html
75 end
76
77 fun test10 is test do
78 var md = """#\tFoo\n"""
79 var html = """<h1>Foo</h1>\n"""
80 assert md_to_html(md) == html
81 end
82
83 fun test11 is test do
84 var md = """*\t*\t*\t\n"""
85 var html = """<hr />\n"""
86 assert md_to_html(md) == html
87 end
88 end