From 4f1c3950b8c9d57829f066ac869e597df5724438 Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 3 Sep 2015 08:28:20 +0200 Subject: [PATCH] Add tests for Wiki markup --- .../markup+css+wiki/table-tag_feature.test | 147 ++++++++++++++++++ .../languages/wiki/block-comment_feature.test | 16 ++ tests/languages/wiki/emphasis_feature.test | 27 ++++ tests/languages/wiki/heading_feature.test | 33 ++++ tests/languages/wiki/hr_feature.test | 13 ++ tests/languages/wiki/nowiki_feature.test | 63 ++++++++ tests/languages/wiki/symbol_feature.test | 17 ++ tests/languages/wiki/url_feature.test | 29 ++++ tests/languages/wiki/variable_feature.test | 19 +++ 9 files changed, 364 insertions(+) create mode 100644 tests/languages/markup+css+wiki/table-tag_feature.test create mode 100644 tests/languages/wiki/block-comment_feature.test create mode 100644 tests/languages/wiki/emphasis_feature.test create mode 100644 tests/languages/wiki/heading_feature.test create mode 100644 tests/languages/wiki/hr_feature.test create mode 100644 tests/languages/wiki/nowiki_feature.test create mode 100644 tests/languages/wiki/symbol_feature.test create mode 100644 tests/languages/wiki/url_feature.test create mode 100644 tests/languages/wiki/variable_feature.test diff --git a/tests/languages/markup+css+wiki/table-tag_feature.test b/tests/languages/markup+css+wiki/table-tag_feature.test new file mode 100644 index 0000000000..e3965f9694 --- /dev/null +++ b/tests/languages/markup+css+wiki/table-tag_feature.test @@ -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. \ No newline at end of file diff --git a/tests/languages/wiki/block-comment_feature.test b/tests/languages/wiki/block-comment_feature.test new file mode 100644 index 0000000000..4d4b87a170 --- /dev/null +++ b/tests/languages/wiki/block-comment_feature.test @@ -0,0 +1,16 @@ +/**/ +/* foo */ +/* foo +bar */ + +---------------------------------------------------- + +[ + ["block-comment", "/**/"], + ["block-comment", "/* foo */"], + ["block-comment", "/* foo\r\nbar */"] +] + +---------------------------------------------------- + +Checks for comments. \ No newline at end of file diff --git a/tests/languages/wiki/emphasis_feature.test b/tests/languages/wiki/emphasis_feature.test new file mode 100644 index 0000000000..952dacbac4 --- /dev/null +++ b/tests/languages/wiki/emphasis_feature.test @@ -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. \ No newline at end of file diff --git a/tests/languages/wiki/heading_feature.test b/tests/languages/wiki/heading_feature.test new file mode 100644 index 0000000000..515dfd83bc --- /dev/null +++ b/tests/languages/wiki/heading_feature.test @@ -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. \ No newline at end of file diff --git a/tests/languages/wiki/hr_feature.test b/tests/languages/wiki/hr_feature.test new file mode 100644 index 0000000000..8b09825ab1 --- /dev/null +++ b/tests/languages/wiki/hr_feature.test @@ -0,0 +1,13 @@ +---- +----- + +---------------------------------------------------- + +[ + ["hr", "----"], + ["hr", "-----"] +] + +---------------------------------------------------- + +Checks for horizontal rows. \ No newline at end of file diff --git a/tests/languages/wiki/nowiki_feature.test b/tests/languages/wiki/nowiki_feature.test new file mode 100644 index 0000000000..0d15443b70 --- /dev/null +++ b/tests/languages/wiki/nowiki_feature.test @@ -0,0 +1,63 @@ +{{foo}} ''bar'' +{{foo}} ''bar'' +
{{foo}} ''bar'' 
+ +---------------------------------------------------- + +[ + ["nowiki", [ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "nowiki" + ]], + ["punctuation", ">"] + ]], + "{{foo}} ''bar'' ", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]] + ]], + ["nowiki", [ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "source" + ]], + ["punctuation", ">"] + ]], + "{{foo}} ''bar'' ", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]] + ]], + ["nowiki", [ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "pre" + ]], + ["punctuation", ">"] + ]], + "{{foo}} ''bar'' ", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]] + ]] +] + +---------------------------------------------------- + +Checks that no highlighting is done inside ,
 and  tags.
\ No newline at end of file
diff --git a/tests/languages/wiki/symbol_feature.test b/tests/languages/wiki/symbol_feature.test
new file mode 100644
index 0000000000..bb051ffcde
--- /dev/null
+++ b/tests/languages/wiki/symbol_feature.test
@@ -0,0 +1,17 @@
+#REDIRECT [[somewhere]]
+~~~
+~~~~
+~~~~~
+
+----------------------------------------------------
+
+[
+	["symbol", "#REDIRECT"], ["url", "[[somewhere]]"],
+	["symbol", "~~~"],
+	["symbol", "~~~~"],
+	["symbol", "~~~~~"]
+]
+
+----------------------------------------------------
+
+Checks for redirects and signatures.
\ No newline at end of file
diff --git a/tests/languages/wiki/url_feature.test b/tests/languages/wiki/url_feature.test
new file mode 100644
index 0000000000..35ce30fbd8
--- /dev/null
+++ b/tests/languages/wiki/url_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/wiki/variable_feature.test b/tests/languages/wiki/variable_feature.test
new file mode 100644
index 0000000000..e78a810326
--- /dev/null
+++ b/tests/languages/wiki/variable_feature.test
@@ -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.
\ No newline at end of file