From 9b22f7bc26f770e339bd9fa6b3542c84bb7723eb Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Mon, 12 Aug 2013 12:50:37 -0400 Subject: [PATCH] Sync up with Parsoid parserTests. This now aligns with Parsoid commit 44d2188ce875a97441e7ffcc40c2824bc52092c8 Change-Id: I6e6e0755e3bd335ba9d34d4a053384cf04847137 --- tests/parser/parserTests.txt | 503 ++++++++++++++++++++++++++++------- 1 file changed, 404 insertions(+), 99 deletions(-) diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 128e25d155..41d49d1e16 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -139,6 +139,12 @@ A?b Weirdo titles! !! endarticle +!!article +Template:Bullet +!!text +* Bar +!!endarticle + ### ### Basic tests ### @@ -1794,6 +1800,20 @@ c !!end +!!test +1d. Indent-Pre and Comments +(Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order) +!!input + a + + b +!!result +
a
+
+
b
+
+!!end + !!test 2a. Indent-Pre and tables !!input @@ -1947,6 +1967,52 @@ b !! end +!! test +6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content +!! input + a + + + b + + c + +d +!! result +
a
+
+b
+
+
c
+
+
+

d +

+!! end + +!! test +7a. Indent-pre and category links +!! options +parsoid=wt2html,wt2wt +!! input + [[Category:foo]] +{{echo| [[Category:foo]]}} +!! result + +!! end + +!! test +7b. Indent-pre and category links +!! options +parsoid=wt2html,wt2wt +!! input + [[Category:foo]] a + [[Category:foo]] {{echo|b}} +!! result +
 a b
+
+!! end + ### ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric) ### @@ -4927,6 +4993,46 @@ parsoid !! end +!! test +Optional colon in #REDIRECT +!! options +# the colon is archaic syntax. we support it for wt2html, but we +# don't care that it roundtrips back to the modern syntax. +parsoid=wt2html,html2html +!! input +#REDIRECT:[[Main Page]] +!! result + +!! end + +!! test +Whitespace in #REDIRECT with optional colon +!! options +# the colon and gratuitous whitespace is archaic syntax. we support +# it for wt2html, but we don't care that it roundtrips back to the +# modern syntax (without extra whitespace) +parsoid=wt2html,html2html +!! input + + #REDIRECT +: +[[Main Page]] +!! result + +!! end + +!! test +Piped link in #REDIRECT +!! options +# content after piped link is ignored. we support this syntax, +# but don't care that the piped link is lost when we roundtrip this. +parsoid=wt2html +!! input +#REDIRECT [[Main Page|bar]] +!! result + +!! end + !! test Redirect to category !! options @@ -4937,6 +5043,16 @@ parsoid=wt2html !! end +!! test +Redirect to category with URL encoding +!! options +parsoid=wt2html +!! input +#REDIRECT [[Category%3AFoo]] +!! result + +!! end + !! test Redirect to category page !! options @@ -4948,7 +5064,7 @@ parsoid=wt2html,html2html !! end !! test -Redirect to image page +Redirect to image page (1) !! options parsoid !! input @@ -4957,6 +5073,16 @@ parsoid !! end +!! test +Redirect to image page (2) +!! options +parsoid +!! input +#REDIRECT [[Image:Wiki.png]] +!! result + +!! end + !! test Redirect to language !! options @@ -4977,6 +5103,17 @@ parsoid !! end +!! test +Non-English #REDIRECT +!! options +parsoid +language=is +!! input +#TILVÍSUN [[Main Page]] +!! result + +!! end + ## ## XHTML tidiness ### @@ -5492,6 +5629,18 @@ parsoid
  1. foo
    1. bar
foo
bar
!! end +!! test +Parsoid: Test of whitespace serialization with Templated bullets +!! options +parsoid +!! input +* {{bullet}} +!! result + +!! end + # ------------------------------------------------------------------------ # The next set of tests are about Parsoid's ability to handle badly nested # tags (parse, minimize scope of fixup, and roundtrip back) @@ -8321,8 +8470,13 @@ Special:Foobar_nonexistent ### ### Images ### +### For Parsoid-specific tests, see +#### http://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images + !! test -Simple image +Simple image (php) +!! options +php !! input [[Image:foobar.jpg]] !! result @@ -8331,16 +8485,20 @@ Simple image !! end !! test -Right-aligned image +Simple image (parsoid) +!! options +parsoid=wt2html !! input -[[Image:foobar.jpg|right]] +[[Image:foobar.jpg]] !! result -
Foobar.jpg
- +

+

!! end !! test -Simple image (using File: namespace, now canonical) +Simple image (using File: namespace, now canonical) (php) +!! options +php !! input [[File:foobar.jpg]] !! result @@ -8349,38 +8507,108 @@ Simple image (using File: namespace, now canonical) !! end !! test -Image with caption +Simple image (using File: namespace, now canonical) (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|right|Caption text]] +[[File:Foobar.jpg]] +!! result +

+

+!! end + +!! test +Right-aligned image (php) +!! options +php +!! input +[[Image:foobar.jpg|right]] +!! result +
Foobar.jpg
+ +!! end + +!! test +Right-aligned image (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|right]] +!! result +
+!! end + +!! test +Image with caption (php) +!! options +php +!! input +[[File:Foobar.jpg|right|Caption text]] !! result
Caption text
!! end !! test -Image with empty attribute +Image with caption (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|right|Caption text]] +!! result +
Caption text
+!! end + +!! test +Image with empty attribute (php) +!! options +php !! input -[[Image:foobar.jpg|right||Caption text]] +[[File:Foobar.jpg|right||Caption text]] !! result
Caption text
!! end !! test -Image with attributes from template. +Image with empty attribute (parsoid) +!! options +parsoid=wt2html !! input -[[Image:foobar.jpg|{{image_attribs}}]] +[[File:Foobar.jpg|right||Caption text]] +!! result +
Caption text
+!! end + +!! test +Image with attributes from template (php) +!! options +php +!! input +[[File:Foobar.jpg|{{image_attribs}}]] !! result
Caption text
!! end !! test -Image with link tails +Image with attributes from template (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|{{image_attribs}}]] +!! result +
Caption text
+!! end + +!! test +Image with link tails (php) +!! options +php !! input -123[[Image:foobar.jpg]]456 -123[[Image:foobar.jpg|right]]456 -123[[Image:foobar.jpg|thumb]]456 +123[[File:Foobar.jpg]]456 +123[[File:Foobar.jpg|right]]456 +123[[File:Foobar.jpg|thumb]]456 !! result

123Foobar.jpg456

@@ -8390,20 +8618,48 @@ Image with link tails !! end !! test -Image with multiple captions -- only last one is accepted +Image with link tails (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] +123[[File:Foobar.jpg]]456 +123[[File:Foobar.jpg|right]]456 +123[[File:Foobar.jpg|thumb]]456 +!! result +

123456

+123
456 +123
456 +!! end + +!! test +Image with multiple captions -- only last one is accepted (php) +!! options +php +!! input +[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] !! result
Caption3 - accepted
!! end !! test -Image with width attribute at different positions +Image with multiple captions -- only last one is accepted (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] +!! result +
Caption3 - accepted
+!! end + +!! test +Image with width attribute at different positions (php) +!! options +php !! input -[[Image:foobar.jpg|200px|right|Caption]] -[[Image:foobar.jpg|right|200px|Caption]] -[[Image:foobar.jpg|right|Caption|200px]] +[[File:Foobar.jpg|200px|right|Caption]] +[[File:Foobar.jpg|right|200px|Caption]] +[[File:Foobar.jpg|right|Caption|200px]] !! result
Caption
Caption
@@ -8412,23 +8668,84 @@ Image with width attribute at different positions !! end !! test -Image with link parameter, wiki target +Image with width attribute at different positions (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|link=Target page]] +[[File:Foobar.jpg|200px|right|Caption]] +[[File:Foobar.jpg|right|200px|Caption]] +[[File:Foobar.jpg|right|Caption|200px]] !! result -

Foobar.jpg +

Caption
+
Caption
+
Caption
+!! end + +!! test +Image with link parameter, wiki target (php) +!! options +php +!! input +[[File:Foobar.jpg|link=Main Page]] +!! result +

Foobar.jpg

!! end !! test -Image with link parameter, URL target +Image with link parameter, wiki target (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|link=http://example.com/]] +[[File:Foobar.jpg|link=Main Page]] +!! result +

+!! end + +!! test +Image with link parameter, URL target (php) +!! options +php +!! input +[[File:Foobar.jpg|link=http://example.com/]] !! result

Foobar.jpg

!! end +# parsoid bug 49293 (part 1) +!! test +Image with link parameter, URL target (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=http://example.com/]] +!! result +

+!! end + +!! test +Image with link parameter, protocol-less URL target (php) +!! options +php +!! input +[[File:Foobar.jpg|link=//example.com/]] +!! result +

Foobar.jpg +

+!! end + +# parsoid bug 49293 (part 2) +!! test +Image with link parameter, protocol-less URL target (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=//example.com/]] +!! result +

+!! end + !! test Image with link parameter, wgExternalLinkTarget !! input @@ -8474,32 +8791,68 @@ wgExternalLinkTarget='foobar' !! end !! test -Image with empty link parameter +Image with empty link parameter (php) +!! options +php !! input -[[Image:foobar.jpg|link=]] +[[File:Foobar.jpg|link=]] !! result

Foobar.jpg

!! end !! test -Image with link parameter (wiki target) and unnamed parameter +Image with empty link parameter (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|link=Target page|Title]] +[[File:Foobar.jpg|link=]] !! result -

Title +

+!! end + +!! test +Image with link parameter (wiki target) and unnamed parameter (php) +!! options +php +!! input +[[File:Foobar.jpg|link=Main Page|Title]] +!! result +

Title

!! end !! test -Image with link parameter (URL target) and unnamed parameter +Image with link parameter (wiki target) and unnamed parameter (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=Main Page|Title]] +!! result +

+!! end + +!! test +Image with link parameter (URL target) and unnamed parameter (php) +!! options +php !! input -[[Image:foobar.jpg|link=http://example.com/|Title]] +[[File:Foobar.jpg|link=http://example.com/|Title]] !! result

Title

!! end +!! test +Image with link parameter (URL target) and unnamed parameter (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=http://example.com/|Title]] +!! result +

+!! end + !! test Thumbnail image with link parameter !! options @@ -8878,54 +9231,8 @@ wgEnableUploads=0 # http://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images # Currently imperfect due to a flaw in the Parsoid testrunner # Work in progress - -!! test -Parsoid-specific image handling - simple image -!! options -parsoid -!! input -[[Image:Foobar.jpg]] -!! result -

- - - - - -

-!! end - -!! test -Parsoid-specific image handling - simple image without link -!! options -parsoid -!! input -[[Image:Foobar.jpg|link=]] -!! result -

- - - - - -

-!! end - -!! test -Parsoid-specific image handling - simple image with specific link -!! options -parsoid -!! input -[[Image:Foobar.jpg|link=Main Page]] -!! result -

- - - - - -

-!! end +# THESE TESTS SHOULD BE MOVED UP and merged with the php-specific +# image tests. !! test Parsoid-specific image handling - simple image with size and middle alignment @@ -8937,7 +9244,7 @@ parsoid

- +

@@ -8953,7 +9260,7 @@ parsoid

- +

@@ -8969,7 +9276,7 @@ parsoid

- +

@@ -8984,7 +9291,7 @@ parsoid !! result
- +
caption content
@@ -8999,7 +9306,7 @@ parsoid !! result
- +
caption
@@ -9014,7 +9321,7 @@ parsoid !! result
- +
caption
@@ -9029,7 +9336,7 @@ parsoid !! result
- +
caption
@@ -9045,7 +9352,7 @@ parsoid

- +

!! end @@ -9060,7 +9367,7 @@ parsoid #

# # -#Foobar.jpg +#Foobar.jpg # #abc # @@ -13675,12 +13982,6 @@ language=sr

!!end -!!article -Template:Bullet -!!text -* Bar -!!endarticle - !! test Bug 529: Uncovered bullet !! input @@ -15353,7 +15654,7 @@ parsoid !!result -[1] +

[1]

  1. ↑ foo <ref>bar</ref> baz
@@ -16858,6 +17159,10 @@ parsoid=html2wt

123

456

!!end +# Wacky -- the leading newline in input is required because +# that is what the serializer emits. To be fixed. Not fixing +# the test because this test is required to test serialization of +# new content and preferred whitespace style. !! test Lists: Add space after bullets !! options -- 2.20.1