Remove the comment check I added (wasn't necessary); add a way do disable tests.
authorWil Mahan <wmahan@users.mediawiki.org>
Wed, 22 Sep 2004 21:22:51 +0000 (21:22 +0000)
committerWil Mahan <wmahan@users.mediawiki.org>
Wed, 22 Sep 2004 21:22:51 +0000 (21:22 +0000)
Add nowiki, comment, and external links tests (some disabled at the moment).

maintenance/parserTests.php
maintenance/parserTests.txt

index c17f999..3726d65 100644 (file)
@@ -25,13 +25,15 @@ class ParserTest {
                $n = 0;
                while( false !== ($line = fgets( $infile ) ) ) {
                        $n++;
-                       if (is_null($section) && preg_match('/^#/', $line)) {
-                               # skip comment
-                               continue;
-                       }
                        if( preg_match( '/^!!\s*(\w+)/', $line, $matches ) ) {
                                $section = strtolower( $matches[1] );
                                if( $section == 'end' ) {
+                                       if  (isset ($data['disabled'])) {
+                                               # disabled test
+                                               $data = array();
+                                               $section = null;
+                                               continue;
+                                       }
                                        if( !isset( $data['test'] ) ) {
                                                die( "'end' without 'test' at line $n\n" );
                                        }
index d6c8e62..7107def 100644 (file)
@@ -1,3 +1,9 @@
+# MediaWiki Parser test cases
+# see also http://meta.wikimedia.org/wiki/Parser_testing
+
+# At present these assume that $wgUseTidy is false and may break
+# if it is enabled.
+
 !! test
 Blank input
 !! input
@@ -58,3 +64,159 @@ Italics and bold
 </li><li> plain l'<i>italic</i>plain
 </li></ul>
 !! end
+
+###
+### <nowiki> test cases
+###
+
+!! test
+<nowiki> unordered list
+!! input
+<nowiki>* This is not an unordered list item.</nowiki>
+!! result
+<p>* This is not an unordered list item.
+</p>
+!! end
+
+!! test
+<nowiki> spacing
+!! input
+<nowiki>Lorem ipsum dolor
+
+sed abit.
+  sed nullum.
+
+:and a colon
+</nowiki>
+!! result
+<p>Lorem ipsum dolor sed abit. sed nullum. :and a colon</p>
+!! end
+
+!! test
+nowiki 3
+!! input
+:There is not nowiki.
+:There is <nowiki>nowiki</nowiki>.
+
+#There is not nowiki.
+#There is <nowiki>nowiki</nowiki>.
+
+*There is not nowiki.
+*There is <nowiki>nowiki</nowiki>.
+!! result
+<dl><dd>There is not nowiki.
+</dd><dd>There is nowiki.
+</dd></dl>
+<ol><li>There is not nowiki.
+</li><li>There is nowiki.
+</li></ol>
+<ul><li>There is not nowiki.
+</li><li>There is nowiki.
+</li></ul>
+!! end
+
+###
+### comment test cases
+###
+!! test
+comment test 1
+!! input
+<!-- comment 1 --> asdf
+<!-- comment 2 -->
+!! result
+<pre>asdf
+</pre>
+!! end
+
+!! test
+!! disabled
+comment test 2
+!! input
+asdf
+<!-- comment 1 -->
+jkl
+!! result
+<p>asdf jkl
+</p>
+!! end
+
+!! test
+comment test 3
+!! disabled
+!! input
+asdf
+<!-- comment 1 -->
+<!-- comment 2 -->
+jkl
+!! result
+<p>asdf jkl
+</p>
+!! end
+
+!! test
+comment test 4
+!! input
+asdf<!-- comment 1 -->jkl
+!! result
+<p>asdfjkl
+</p>
+!! end
+
+###
+### External links
+###
+!! test
+External links 1
+!! input
+Non-bracketed: http://example.com
+!! result
+<p>Non-bracketed: <a href="http://example.com" class='external' title="http://example.com">http://example.com</a>
+</p>
+!! end
+
+!! test
+!! disabled
+External links
+!! input
+Numbered: [http://example.com]
+Specified text: [http://example.com link]
+Trail (not sure if this is meant to work): [http://example.com link]s
+Unrecognised characters (for no good reason): http://example.com/1$2345  [http://example.com/1$2345]
+External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
+External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
+Link to non-http image, no img tag: ftp://example.com/test.jpg
+Terminating separator: http://example.com/thing,
+Intervening separator: http://example.com/1,2,3
+Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
+And again with mixed protocols: [ftp://example.com?url=http://example.com link]
+URL in text: [http://example.com http://example.com]
+ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
+Old &amp; use: http://x&y
+Escaping without &amp;: http://x&y
+!! result
+<p>Numbered: <a href='http://example.com' class='external'>[2]</a> <span class=
+'urlexpansion'>(<i>http://example.com</i>)</span></p>
+<p>Specified text: <a href='http://example.com' class='external'>link</a> <span class=
+'urlexpansion'>(<i>http://example.com</i>)</span></p>
+<p>Trail (not sure if this is meant to work): <a href='http://example.com' class='external'>link</a> <span class=
+'urlexpansion'>(<i>http://example.com</i>)</span>s</p>
+<p>Unrecognised characters (for no good reason): <a href="http://example.com/1" class='external'>http://example.com/1</a>$2345
+[http://example.com/1$2345]</p>
+<p>External image: <img src="http://example.com/test.jpg" alt="test.jpg" /></p>
+<p>External image from https: <img src="https://example.com/test.jpg" alt="test.jpg" /></p>
+<p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external'>ftp://example.com/test.jpg</a></p>
+<p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,</p>
+<p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a></p>
+<p>Old bug with URL in query: [http://example.com/thing?url=<a href="http://example.com" class='external'>http://example.com</a>
+link]</p>
+<p>And again with mixed protocols: [ftp://example.com?url=<a href="http://example.com" class='external'>http://example.com</a>
+link]</p>
+<p>URL in text: <a href='http://example.com' class='external'></a><a href="http://example.com" class=
+'external'>http://example.com</a> <span class='urlexpansion'>(<i>http://example.com</i>)</span></p>
+<p>ja-style clickable images: <a href='http://example.com' class='external'><img src=
+"http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a> <span class=
+'urlexpansion'>(<i>http://example.com</i>)</span></p>
+<p>Old &amp; use: <a href="http://x&y" class='external'>http://x&y</a></p>
+<p>Escaping without &amp;: <a href="http://x&y" class='external'>http://x&y</a></p>
+!! end
+