From e450b18e09b90a67dcd8f216216c9fa7c0752038 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Mon, 16 Sep 2013 16:14:20 -0400 Subject: [PATCH] Sync up with Parsoid parserTests. This now aligns with Parsoid commit 8da66db733e02a5a886a62075ab9d9e9c6db6e3a Change-Id: I0b429b4affbacb4ed97718bce8ba9c886d268216 --- tests/parser/parserTests.txt | 535 ++++++++++++++++++++++++++--------- 1 file changed, 404 insertions(+), 131 deletions(-) diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index f841afb6f8..47189fc18d 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -586,7 +586,7 @@ parsoid !! input '''foo''''' !! result -

foo +

foo

!!end @@ -643,7 +643,7 @@ parsoid !! input ''''foo''''' !! result -

'foo +

'foo

!!end @@ -653,26 +653,14 @@ parsoid ### !! test -Italics and bold: 5-quote opening sequence: (5,2) (php) +Italics and bold: 5-quote opening sequence: (5,2) !! options -php !! input '''''foo'' !! result

foo

!!end -# Parsoid reverses the nesting order, compared to the PHP parser -!! test -Italics and bold: 5-quote opening sequence: (5,2) (parsoid) -!! options -parsoid -!! input -'''''foo'' -!! result -

foo -

-!!end !! test @@ -815,32 +803,15 @@ Italics and bold: other quote tests: (3,2,3,2) !!end -# The Parsoid team believes the PHP parser's output on this test is wrong. -# It only checks for convert-to-bold-on-single-character-word when the word -# matches with a bold tag ("'''") that is *odd* in the list of quote tokens. -# This means that the bold token in position 2 (0-indexed) gets converted by -# parsoid, but doesn't get changed by the PHP parser. !! test -Italics and bold: other quote tests: (3,2,3,3) (php) +Italics and bold: other quote tests: (3,2,3,3) !! options -php !! input '''this is about ''foo'''s family''' !! result

'this is about foos family

!!end -# This is the output the Parsoid team believes to be correct. -!! test -Italics and bold: other quote tests: (3,2,3,3) (parsoid) -!! options -parsoid -!! input -'''this is about ''foo'''s family''' -!! result -

this is about foo's family -

-!!end !! test @@ -1042,7 +1013,7 @@ parsoid !! input {{echo|–}} !! result -

+

!! end @@ -1698,6 +1669,62 @@ Templates: Indent-Pre: 1f: Wrapping should be based on expanded content !!end +# TODO / maybe: fix wt2wt for this +!! test +Parsoid: Don't paragraph-wrap fosterable content +!! options +parsoid=wt2html +!! input +{| + + + + + +|} +!! result + + + + + + + + + + +
+!! end + +!! test +Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced +!! options +parsoid=wt2html +!! input +{| + + + + + + +|} +!! result + + + + + + + + + + +
+
+!! end + + #-------------------------------------------------------------------- # Transclusion parameter whitespace stripping tests # Behavior is different for positional and named parameters @@ -1727,7 +1754,6 @@ Templates: Strip leading and trailing whitespace from named-param values !! test Templates: Don't strip whitespace from positional-param values -!! options !! input {{echo|a }} @@ -1771,6 +1797,19 @@ Templates: Don't strip whitespace from positional-param values !! end +!! test +Templates: Handle empty comment-and-ws-only lines correctly +!! input +{{echo|foo + + +bar}} +!! result +

foo +bar +

+!! end + #-------------------------------------------------------------------- # Transclusion parameter escaping tests #-------------------------------------------------------------------- @@ -1782,7 +1821,7 @@ parsoid {{echo|[foo]|{{echo|[bar]}}}} !! result

[foo]

+data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]

!! end !! test @@ -1792,7 +1831,7 @@ parsoid !! input {{echo|[{{echo|http://example.com}} link]}} !! result -

link

+

link

!! end !! test @@ -1804,7 +1843,7 @@ parsoid !! result

http://foo.com/a|b

+data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://foo.com/a|b"}},"i":0}}]}'>http://foo.com/a|b

!! end !! test @@ -1816,8 +1855,8 @@ parsoid=html2wt,wt2wt !! result

a|b

+data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"}, +"params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b

!! end !! test @@ -1829,12 +1868,23 @@ parsoid=html2wt,wt2wt {{echo|<div>}} {{echo|}} !! result -

foo|bar -<div> - +

foo|bar +<div> +

!! end +## Bug 52824 +!! test +Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param +!! options +parsoid=html2wt,wt2wt +!! input +{{echo|{{echo|1=bar}}}} +!! result +

bar

+!! end + ### ### Parsoid-centric tests for testing RT edge cases for pre ### @@ -2089,7 +2139,9 @@ parsoid=wt2html,wt2wt [[Category:foo]] {{echo| [[Category:foo]]}} !! result - + + + !! end !! test @@ -2100,8 +2152,10 @@ parsoid=wt2html,wt2wt [[Category:foo]] a [[Category:foo]] {{echo|b}} !! result -
 a b
-
+
+ a
+
+ b
!! end ### @@ -3657,8 +3711,7 @@ Plain ''italic'''s plain !! end # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP # parser strips. The wikitext contains just the first half of the bold -# quote pair. (There's also a case where Parsoid nests and -# differently than the PHP parser.) +# quote pair. !! test Unclosed and unmatched quotes (parsoid) !! options @@ -3686,7 +3739,7 @@ Normal text. Plain ''italic'''s plain !! result

Bold italic text with bold deactivated in between. -

Bold italic text with italic deactivated in between. +

Bold italic text with italic deactivated in between.

Bold text..

..spanning two paragraphs (should not work).

Bold tag left open @@ -4150,11 +4203,14 @@ Template-generated table cell attributes and cell content !! input {| |{{table_attribs}} +| {{table_attribs}} |} !! result +
Foo + Foo
!! end @@ -4404,22 +4460,18 @@ Parsoid: Default to a newline after tables in new content (bug 51219) parsoid=html2wt !! input {| -|- |foo |} bar {| -|- |baz |} '''quux''' !! result - -
foo
bar +foo bar - -
baz
quux +bazquux !! end ### @@ -5058,6 +5110,12 @@ Interwiki link with fragment (bug 2130)

!! end + +### +### Interlanguage links +### Language links (so that searching for '### language' matches..) +### + !! test Interlanguage link !! input @@ -5115,6 +5173,19 @@ language=ln

!! end +!! test +Parsoid bug 53221: Wikilinks should be properly entity-escaped +!! options +parsoid=html2wt +!! input +He&nbsp;llo [[Foo|He&nbsp;llo]] + +He&nbsp;llo [[He&nbsp;llo]] +!!result +

He&nbsp;llo He&nbsp;llo

+

He&nbsp;llo He&nbsp;llo

+!! end + !! test Parsoid: handle constructor well !! options @@ -5130,9 +5201,30 @@ parsoid

constructor:foo

!! end -## -## Redirects, Parsoid-only -## +!! test +Parsoid: recognize interlanguage links without a target page +!! options +parsoid +!! input +[[ko:]] +!! result +

+

+!! end + +!! test +Parsoid: recognize interwiki links without a target page +!! options +parsoid +!! input +[[:ko:]] +!! result +

ko:

+!! end + +### +### Redirects, Parsoid-only +### !! test Simple redirect to page !! options @@ -5775,7 +5867,7 @@ parsoid=wt2html,wt2wt !!result
  • foo
  • li-hack
  • -
  • templated li-hack
  • +
  • templated li-hack
  • li-hack with preceding comments
    @@ -5807,7 +5899,7 @@ parsoid * {{bullet}} !! result
      -
    • Bar
    • +
    • Bar
    !! end @@ -5883,6 +5975,23 @@ parsoid

    !!end +!! test +Table with missing opening tag +!! options +parsoid=wt2html,wt2wt +!! input + + + +
    foo
    +!! result + + + + +
    foo
    +!! end + ### ### Magic Words ### @@ -7265,14 +7374,57 @@ c}}d b}} !! result -ab -
    cd -

    ab

    -
    -

    cd

    -

    a

    -
    -

    b

    +ab +
    cd + + +

    ab

    + +
    + +

    cd

    + + +

    a

    + + +
    + + +

    b

    +!! end + +!! test +Parsoid: Merge double tds (bug 50603) +!! options +parsoid +!! input +{| +|{{echo|{{!}} foo}} +|} +!! result + + +
    foo
    +!! end + +!! test +Parsoid: Merge double tds in nested transclusion content (bug 50603) +!! options +parsoid +!! input +{{echo|
    }} +{| +|{{echo|{{!}} foo}} +|} +{{echo|
    }} +!! result +
    + + +
    foo
    +
    !! end ### @@ -7418,14 +7570,14 @@ bar
    baz
    !!test Templates: P-wrapping: 1d. Template preceded by comment-only line !!options -parsoid=wt2html,wt2wt +parsoid !!input {{echo|Bar}} !!result -

    Bar -

    + +

    Bar

    !!end !!test @@ -7826,24 +7978,24 @@ Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo) Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span) (PHP parser generates misnested html) !! options -parsoid=wt2html,wt2wt +parsoid !!input {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}} !!result -

    abcde

    +

    abcde

    !!end !!test Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div) -(PHP parser generates misnested html) +(PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s) !! options parsoid=wt2html,wt2wt !!input {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}} !!result -
    a
    -
    bcd
    -
    e
    +
    a
    +
    bcd
    +
    e
    !!end !!test @@ -7866,10 +8018,13 @@ parsoid |bar |} !!result - +
    + -
    foo
    bar +foo +bar + !!end !!test @@ -7898,24 +8053,24 @@ parsoid !!result - - - - -
    - - -
    1. foo
    bar 2. baz
    - - - abc - - - - - - xyz - + + + + +
    + + +
    1. foo
    bar 2. baz
    + + + abc + + + + + + xyz + !!end @@ -12882,7 +13037,7 @@ parsoid !! input ''''' !! result -

    +

    !! end !! test @@ -15660,10 +15815,10 @@ A !!result -

    A [1]

    +

    A [1]

    -
      -
    1. ↑ This is a bolded link and this is a transclusion +
        +
      1. ↑ This is a bolded link and this is a transclusion
      !!end @@ -15682,7 +15837,7 @@ A !!result

      A [1]

      -
        +
        1. ↑ foo bar baz @@ -15690,7 +15845,7 @@ A !!end !!test -Ref: 6. No p-wrapping in ref-body +Ref: 7. No p-wrapping in ref-body !!options parsoid !!input @@ -15711,7 +15866,7 @@ booz !!result

          A [1]

          -
            +
            1. ↑ foo bar @@ -15734,9 +15889,9 @@ A foo {{echo| B C}} !!result -

              A [1] B C}}

              +

              A [1] B C}}

              -
                +
                1. ↑ foo {{echo|
                !!end @@ -15751,7 +15906,7 @@ A foo "},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref">[1] B C

                -
                  +
                  1. ↑ foo
                  !!end @@ -15766,7 +15921,7 @@ A foo B C !!result

                  A [1] B C

                  -
                    +
                    1. ↑ foo
                    !!end @@ -15845,7 +16000,7 @@ B1 B2 bar

                    A1 [1] A2 [1] B1 [2] B2 [2]

                    -
                    1. ↑ 1.0 1.1 foo
                    2. ↑ 2.0 2.1 bar
                    +
                    1. ↑ 1.0 1.1 foo
                    2. ↑ 2.0 2.1 bar
                    !!end !!test @@ -15855,7 +16010,7 @@ parsoid !!input !!result -
                      +
                        !!end !!test @@ -15871,7 +16026,7 @@ B bar

                        A [a 1] B [b 1]

                        -
                        1. ↑ foo
                        +
                        1. ↑ foo
                        !!end !!test @@ -15889,11 +16044,11 @@ B bar !!result

                        A [1]

                        -
                        1. ↑ foo
                        +
                        1. ↑ foo

                        B [1]

                        -
                        1. ↑ bar
                        +
                        1. ↑ bar
                        !!end !!test @@ -15913,11 +16068,11 @@ C cfoo

                        A [a 1] B [1]

                        -
                        1. ↑ afoo
                        +
                        1. ↑ afoo

                        C [2]

                        -
                        1. ↑ bfoo
                        2. ↑ cfoo
                        +
                        1. ↑ bfoo
                        2. ↑ cfoo
                        !!end !!test @@ -15936,7 +16091,7 @@ This should just get lost.

                        A [1] B [2]

                        -
                        1. ↑ foo
                        2. ↑ bar
                        +
                        1. ↑ foo
                        2. ↑ bar
                        !!end !!test @@ -15946,7 +16101,7 @@ parsoid !!input {{echo|}} !!result -
                          +
                            !!end !! test @@ -15966,10 +16121,12 @@ B

                            A [1] B [2]

                            -
                            1. ↑ foo bar for a
                            2. ↑
                            - -
                            1. ↑ foo
                            +
                              +
                            1. ↑ foo bar for a
                            2. +
                            3. ↑
                            +
                              +
                            1. ↑ foo
                            !! end #### ---------------------------------------------------------------- @@ -16556,7 +16713,6 @@ Tables: 4a. Escape - parsoid !! input {| -|- !-bar |- |-bar @@ -16574,7 +16730,6 @@ Tables: 4b. Escape + parsoid !! input {| -|- !+bar |- |+bar @@ -16592,7 +16747,6 @@ Tables: 4c. No escaping needed parsoid !! input {| -|- |foo-bar |foo+bar |- @@ -17225,7 +17379,7 @@ Indented table with an empty td Empty TR followed by a template-generated TR (Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext) !!options -parsoid=wt2html,wt2wt +parsoid !!input {| |- @@ -17235,8 +17389,9 @@ parsoid=wt2html,wt2wt - -
                            foo
                            + +foo + !!end ## PHP and parsoid output differ for this, and since this is primarily @@ -17255,10 +17410,10 @@ parsoid !!result + + - - - +
                            !!end @@ -17315,6 +17470,19 @@ plain text plain text !!end +!!test +Ensure fostered text content is wrapped in spans +!!options +parsoid=wt2html +!!input +hi
                            ho
                            +!!result +hi +
                            +ho +
                            +!!end + # ----------------------------------------------------------------- # The following section of tests are primarily to spec requirements # around serialization of new/edited content. @@ -17388,10 +17556,115 @@ Parsoid: Serialize positional parameters with = in them as named parameter parsoid=html2wt !! input {{echo|1 = f=oo}} + +{{echo|1 = f=oo|2 = bar}} + + + +{{echo|f=oo|bar}} !! result

                            foo

                            +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo

                            + +

                            foo

                            + + + +

                            foo

                            +!! end + +!! test +Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes +!! options +parsoid=html2wt +!! input +
                            a +b +
                            +
                            a +b +
                            +
                            +a + +b +
                            +!! result +
                            a

                            b

                            +
                            a +

                            b

                            +
                            +a +

                            b

                            +!! end + +#----------------------------- +# I/B quote minimization tests +#----------------------------- + +!! test +1. I/B qoute minimization: wikitext-only tags should be combined +!! options +parsoid=html2wt +!! input +''AB'' + +'''AB''' + +''A'''B''''' + +'''A''B''''' + +'''A''BC''D''' +!! result +

                            AB

                            +

                            AB

                            +

                            AB

                            +

                            AB

                            +

                            ABCD

                            +!! end + +!! test +2. I/B qoute minimization: wikitext and html tags should not be combined +!! options +parsoid=html2wt +!! input +''A''B + +''A'''''B''' +!! result +

                            AB

                            +

                            AB

                            +!! end + +!! test +3. I/B qoute minimization: templated content stops minimization +!! options +parsoid=html2wt +!! input +''A''{{echo|''B''}} + +''A''{{echo|'''''B'''''}} +!! result +

                            AB +

                            AB +!! end + +!! test +4. I/B qoute minimization: new content should be mimimized with adjacent old content +!! options +parsoid=html2wt +!! input +''AB'' + +'''AB''' + +''A'''B''''' +!! result +

                            AB

                            +

                            AB

                            +

                            AB

                            !! end # ----------------------------------------------------------------- -- 2.20.1