Several Parsoid-specific tests for serializer/parser edge cases.
authorSubramanya Sastry <ssastry@wikimedia.org>
Fri, 29 Mar 2013 18:33:15 +0000 (13:33 -0500)
committerSubramanya Sastry <ssastry@wikimedia.org>
Fri, 29 Mar 2013 21:01:00 +0000 (16:01 -0500)
Added several serializer tests
* For catching future serializer regressions.
* For fixing existing incorrect serialization.

Added couple parser tests
* For testing encap of partially-tpl-generated attribute key
* For testing lists interrupted by comment-lines

Change-Id: Ifbb7da59f65e790b66a621b7964179e4eb1f3fc4

tests/parser/parserTests.txt

index d3bd6a5..0165cb2 100644 (file)
@@ -3497,6 +3497,23 @@ b
 
 !! end
 
+!! test
+Table cell with a single comment
+!! input
+{|
+| <!-- c1 -->
+| a
+|}
+!! result
+<table>
+<tr>
+<td>
+</td>
+<td> a
+</td></tr></table>
+
+!! end
+
 # The expected HTML structure in this test is debatable. The PHP parser does
 # not parse this kind of table at all. The main focus for Parsoid is on
 # round-tripping, so this output is ok for now. TODO: revisit!
@@ -4619,6 +4636,26 @@ Multiple list tags generated by templates
 
 !!end
 
+!!test
+Single-comment whitespace lines dont break lists, but multi-comment whitespace lines do
+!!input
+*a
+<!--This line will NOT split the list-->
+*b
+ <!--This line will NOT split the list either-->
+*c
+ <!--foo--> <!--This line with more than 1 comment will split the list-->
+*d
+!!result
+<ul><li>a
+</li><li>b
+</li><li>c
+</li></ul>
+<ul><li>d
+</li></ul>
+
+!!end
+
 ###
 ### Magic Words
 ###
@@ -6006,6 +6043,15 @@ Templates: HTML Tag: 6. Generation of end piece of HTML attr value
 
 !!end
 
+!!test
+Templates: HTML Tag: 7. Generation of partial attribute key string
+!!input
+<div st{{echo|yle}}="color:red;">foo</div>
+!!result
+<div style="color:red;">foo</div>
+
+!!end
+
 !!test
 Templates: HTML Tables: 1. Generating start of a HTML table
 !!input
@@ -14203,6 +14249,93 @@ Empty table rows go away
 
 !! end
 
+###
+### Parsoid-centric tests for testing RTing of inter-element separators
+### Edge cases not tested by existing parser tests and specific to
+### Parsoid-specific serialization strategies.
+###
+
+!!test
+RT-ed inter-element separators should be valid separators
+!!input
+{|
+|- [[foo]]
+|}
+!!result
+<table>
+
+</table>
+
+!!end
+
+!!test
+Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
+(Parsoid-only since PHP parser relies on Tidy for correct output)
+!!options
+disabled parsoid
+!!input
+{|
+|<small>foo
+bar
+|}
+
+{|
+|<small>foo<small>
+|}
+!!result
+!!end
+
+!!test
+Empty TD followed by TD with tpl-generated attribute
+!!input
+{|
+|-
+|
+|{{echo|style='color:red'}}|foo
+|}
+!!result
+<table>
+
+<tr>
+<td>
+</td>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+Empty TR followed by a template-generated TR
+(Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext)
+!!options
+disabled parsoid
+!!input
+{|
+|-
+{{echo|<tr><td>foo</td></tr>}}
+|}
+!!result
+<table>
+<tbody>
+<tr>
+<td></td></tr>
+<tr>
+<td>foo</td></tr></tbody></table>
+!!end
+
+!!test
+Multi-line image caption generated by templates with/without trailing newlines
+!!options
+parsoid
+!!input
+[[File:foo.jpg|thumb|300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
+[[File:foo.jpg|thumb|300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
+!!result
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Foo.jpg" class="new" title="File:Foo.jpg">File:Foo.jpg</a>  <div class="thumbcaption">foo\nA\nB\nC</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Foo.jpg" class="new" title="File:Foo.jpg">File:Foo.jpg</a>  <div class="thumbcaption">foo\nA\nB\nC\n\n</div></div></div>
+
+!!end
+
 TODO:
 more images
 more tables