Skip to content

Commit

Permalink
Merge pull request #757 from Golmote/tests-wiki
Browse files Browse the repository at this point in the history
Add tests for Wiki markup
  • Loading branch information
Golmote committed Sep 9, 2015
2 parents 9bdcf2f + 4f1c395 commit 4787349
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 0 deletions.
147 changes: 147 additions & 0 deletions tests/languages/markup+css+wiki/table-tag_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{|
| Foo
| Bar
|-
| Baz
| Foobar
|}

{|
|Foo
bar

baz
|
''Foobar''
|}

{|
| Foo || Bar || Baz
|-
| Baz || Bar || Foo
|}

{|
! style="text-align:left;"| Foo
! Bar
! Baz
|-
| foo
| bar
| baz
|}

{|
! style="color:red;"| Foo !! style="color:blue;"| Bar !! Baz
|-
| foo || style="font-weight:bold;"| bar || baz
|}

----------------------------------------------------

[
["punctuation", "{|"],
["punctuation", "|"], " Foo\r\n",
["punctuation", "|"], " Bar\r\n",
["punctuation", "|-"],
["punctuation", "|"], " Baz\r\n",
["punctuation", "|"], " Foobar\r\n",
["punctuation", "|}"],

["punctuation", "{|"],
["punctuation", "|"], "Foo\r\nbar\r\n\r\nbaz\r\n",
["punctuation", "|"],
["emphasis", [["punctuation", "''"], ["italic", "Foobar"], ["punctuation", "''"]]],
["punctuation", "|}"],

["punctuation", "{|"],
["punctuation", "|"], " Foo ",
["punctuation", "||"], " Bar ",
["punctuation", "||"], " Baz\r\n",
["punctuation", "|-"],
["punctuation", "|"], " Baz ",
["punctuation", "||"], " Bar ",
["punctuation", "||"], " Foo\r\n",
["punctuation", "|}"],

["punctuation", "{|"],
["punctuation", "!"],
["table-tag", [
["style-attr", [
["attr-name", [["attr-name", ["style"]]]],
["punctuation", "=\""],
["attr-value", [
["property", "text-align"],
["punctuation", ":"],
"left",
["punctuation", ";"]
]],
["punctuation", "\""]
]],
["table-bar", "|"]
]], " Foo\r\n",
["punctuation", "!"], " Bar\r\n",
["punctuation", "!"], " Baz\r\n",
["punctuation", "|-"],
["punctuation", "|"], " foo\r\n",
["punctuation", "|"], " bar\r\n",
["punctuation", "|"], " baz\r\n",
["punctuation", "|}"],

["punctuation", "{|"],
["punctuation", "!"],
["table-tag", [
["style-attr", [
["attr-name", [["attr-name", ["style"]]]],
["punctuation", "=\""],
["attr-value", [
["property", "color"],
["punctuation", ":"],
"red",
["punctuation", ";"]
]],
["punctuation", "\""]
]],
["table-bar", "|"]
]], " Foo ",
["punctuation", "!!"],
["table-tag", [
["style-attr", [
["attr-name", [["attr-name", ["style"]]]],
["punctuation", "=\""],
["attr-value", [
["property", "color"],
["punctuation", ":"],
"blue",
["punctuation", ";"]
]],
["punctuation", "\""]
]],
["table-bar", "|"]
]], " Bar ",
["punctuation", "!!"], " Baz\r\n",
["punctuation", "|-"],
["punctuation", "|"], " foo ",
["punctuation", "||"],
["table-tag", [
["style-attr", [
["attr-name", [["attr-name", ["style"]]]],
["punctuation", "=\""],
["attr-value", [
["property", "font-weight"],
["punctuation", ":"],
"bold",
["punctuation", ";"]
]],
["punctuation", "\""]
]],
["table-bar", "|"]
]], " bar ",
["punctuation", "||"], " baz\r\n",
["punctuation", "|}"]
]

----------------------------------------------------

Checks for tables and cell attributes.
Note: Markup is loaded before CSS so that inline styles are added into grammar.
16 changes: 16 additions & 0 deletions tests/languages/wiki/block-comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**/
/* foo */
/* foo
bar */

----------------------------------------------------

[
["block-comment", "/**/"],
["block-comment", "/* foo */"],
["block-comment", "/* foo\r\nbar */"]
]

----------------------------------------------------

Checks for comments.
27 changes: 27 additions & 0 deletions tests/languages/wiki/emphasis_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'''''foo'''''
'''bar'''
''baz''

----------------------------------------------------

[
["emphasis", [
["punctuation", "'''''"],
["bold italic", "foo"],
["punctuation", "'''''"]
]],
["emphasis", [
["punctuation", "'''"],
["bold", "bar"],
["punctuation", "'''"]
]],
["emphasis", [
["punctuation", "''"],
["italic", "baz"],
["punctuation", "''"]
]]
]

----------------------------------------------------

Checks for bold and italic.
33 changes: 33 additions & 0 deletions tests/languages/wiki/heading_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
= Header 1 =
== Header 2 ==
=== Header 3 ===
==== Header 4 ====
===== Header 5 =====
====== Header 6 ======

----------------------------------------------------

[
["heading", [
["punctuation", "="], ["important", " Header 1 "], ["punctuation", "="]
]],
["heading", [
["punctuation", "=="], ["important", " Header 2 "], ["punctuation", "=="]
]],
["heading", [
["punctuation", "==="], ["important", " Header 3 "], ["punctuation", "==="]
]],
["heading", [
["punctuation", "===="], ["important", " Header 4 "], ["punctuation", "===="]
]],
["heading", [
["punctuation", "====="], ["important", " Header 5 "], ["punctuation", "====="]
]],
["heading", [
["punctuation", "======"], ["important", " Header 6 "], ["punctuation", "======"]
]]
]

----------------------------------------------------

Checks for titles.
13 changes: 13 additions & 0 deletions tests/languages/wiki/hr_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
----
-----

----------------------------------------------------

[
["hr", "----"],
["hr", "-----"]
]

----------------------------------------------------

Checks for horizontal rows.
63 changes: 63 additions & 0 deletions tests/languages/wiki/nowiki_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<nowiki>{{foo}} ''bar'' <baz></nowiki>
<source>{{foo}} ''bar'' <baz></source>
<pre>{{foo}} ''bar'' <baz></pre>

----------------------------------------------------

[
["nowiki", [
["tag", [
["tag", [
["punctuation", "<"],
"nowiki"
]],
["punctuation", ">"]
]],
"{{foo}} ''bar'' <baz>",
["tag", [
["tag", [
["punctuation", "</"],
"nowiki"
]],
["punctuation", ">"]
]]
]],
["nowiki", [
["tag", [
["tag", [
["punctuation", "<"],
"source"
]],
["punctuation", ">"]
]],
"{{foo}} ''bar'' <baz>",
["tag", [
["tag", [
["punctuation", "</"],
"source"
]],
["punctuation", ">"]
]]
]],
["nowiki", [
["tag", [
["tag", [
["punctuation", "<"],
"pre"
]],
["punctuation", ">"]
]],
"{{foo}} ''bar'' <baz>",
["tag", [
["tag", [
["punctuation", "</"],
"pre"
]],
["punctuation", ">"]
]]
]]
]

----------------------------------------------------

Checks that no highlighting is done inside <nowiki>, <pre> and <source> tags.
17 changes: 17 additions & 0 deletions tests/languages/wiki/symbol_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#REDIRECT [[somewhere]]
~~~
~~~~
~~~~~

----------------------------------------------------

[
["symbol", "#REDIRECT"], ["url", "[[somewhere]]"],
["symbol", "~~~"],
["symbol", "~~~~"],
["symbol", "~~~~~"]
]

----------------------------------------------------

Checks for redirects and signatures.
29 changes: 29 additions & 0 deletions tests/languages/wiki/url_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[[w:en:Formal_grammar|Formal grammar]]
[http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html EBNF help]

ISBN 1234567890
ISBN 123456789x
ISBN 1 2 3-4-5 6789 X
ISBN 978-9999999999

RFC 822
PMID 822

----------------------------------------------------

[
["url", "[[w:en:Formal_grammar|Formal grammar]]"],
["url", "[http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html EBNF help]"],

["url", "ISBN 1234567890"],
["url", "ISBN 123456789x"],
["url", "ISBN 1 2 3-4-5 6789 X"],
["url", "ISBN 978-9999999999"],

["url", "RFC 822"],
["url", "PMID 822"]
]

----------------------------------------------------

Checks for links, ISBN, RFC and PMID.
19 changes: 19 additions & 0 deletions tests/languages/wiki/variable_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
__NOTOC__
{{{1}}}
{{!}}
{{SITENAME}}
{{#ifexists:foo}}

----------------------------------------------------

[
["variable", "__NOTOC__"],
["variable", "{{{1}}}"],
["variable", "{{!}}"],
["variable", "{{SITENAME}}"],
["variable", "{{#ifexists:foo}}"]
]

----------------------------------------------------

Checks for variables and magic words.

0 comments on commit 4787349

Please sign in to comment.