Commit 82a76b41 authored by Guido van Rossum's avatar Guido van Rossum

Fix the output after Evan's optimization patch.

parent 8e7cdd11
...@@ -30,86 +30,34 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -30,86 +30,34 @@ class HTMLTALParserTestCases(unittest.TestCase):
def check_code_simple_identity(self): def check_code_simple_identity(self):
self._run_check("""<html a='b' b="c" c=d><title>My Title</html>""", [ self._run_check("""<html a='b' b="c" c=d><title>My Title</html>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<html a="b" b="c" c="d">'
('rawtext', '<html a="b" b="c" c="d">'), '<title>My Title</title></html>'),
('setPosition', (1, 22)),
('rawtext', '<title>My Title</title></html>'),
]) ])
def check_code_implied_list_closings(self): def check_code_implied_list_closings(self):
self._run_check("""<ul><li><p><p><li></ul>""", [ self._run_check("""<ul><li><p><p><li></ul>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<ul><li><p></p><p></p></li><li></li></ul>'),
('rawtext', '<ul>'),
('setPosition', (1, 4)),
('rawtext', '<li>'),
('setPosition', (1, 8)),
('rawtext', '<p></p>'),
('setPosition', (1, 11)),
('rawtext', '<p></p></li>'),
('setPosition', (1, 14)),
('rawtext', '<li></li></ul>'),
]) ])
self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [ self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<dl><dt></dt><dt></dt><dd></dd>'
('rawtext', '<dl>'), '<dd><ol><li></li><li></li></ol></dd></dl>'),
('setPosition', (1, 4)),
('rawtext', '<dt></dt>'),
('setPosition', (1, 8)),
('rawtext', '<dt></dt>'),
('setPosition', (1, 12)),
('rawtext', '<dd></dd>'),
('setPosition', (1, 16)),
('rawtext', '<dd>'),
('setPosition', (1, 20)),
('rawtext', '<ol>'),
('setPosition', (1, 24)),
('rawtext', '<li></li>'),
('setPosition', (1, 28)),
('rawtext', '<li></li></ol></dd></dl>'),
]) ])
def check_code_implied_table_closings(self): def check_code_implied_table_closings(self):
self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t""" self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t"""
"""<table><tr><td>cell \n \t \n<tr>""", [ """<table><tr><td>cell \n \t \n<tr>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<p>text</p> <table><tr><th>head</th>'
('rawtext', '<p>text</p> '), '</tr>\t<tr><td>cell\t<table><tr><td>cell</td>'
('setPosition', (1, 8)), '</tr> \n \t \n<tr></tr></table></td></tr></table>'),
('rawtext', '<table>'),
('setPosition', (1, 15)),
('rawtext', '<tr>'),
('setPosition', (1, 19)),
('rawtext', '<th>head</th></tr>\t'),
('setPosition', (1, 28)),
('rawtext', '<tr>'),
('setPosition', (1, 32)),
('rawtext', '<td>cell\t'),
('setPosition', (1, 41)),
('rawtext', '<table>'),
('setPosition', (1, 48)),
('rawtext', '<tr>'),
('setPosition', (1, 52)),
('rawtext', '<td>cell</td></tr> \n \t \n'),
('setPosition', (3, 0)),
('rawtext', '<tr></tr></table></td></tr></table>'),
]) ])
self._run_check("""<table><tr><td>cell """ self._run_check("""<table><tr><td>cell """
"""<table><tr><td>cell </table></table>""", [ """<table><tr><td>cell </table></table>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<table><tr><td>cell <table><tr><td>cell</td></tr>'
('rawtext', '<table>'), ' </table></td></tr></table>'),
('setPosition', (1, 7)),
('rawtext', '<tr>'),
('setPosition', (1, 11)),
('rawtext', '<td>cell '),
('setPosition', (1, 20)),
('rawtext', '<table>'),
('setPosition', (1, 27)),
('rawtext', '<tr>'),
('setPosition', (1, 31)),
('rawtext', '<td>cell</td></tr> </table></td></tr></table>'),
]) ])
def check_code_bad_nesting(self): def check_code_bad_nesting(self):
...@@ -120,7 +68,6 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -120,7 +68,6 @@ class HTMLTALParserTestCases(unittest.TestCase):
def check_code_attr_syntax(self): def check_code_attr_syntax(self):
output = [ output = [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="v" c="v" d="v" e></a>'), ('rawtext', '<a b="v" c="v" d="v" e></a>'),
] ]
self._run_check("""<a b='v' c="v" d=v e>""", output) self._run_check("""<a b='v' c="v" d=v e>""", output)
...@@ -132,12 +79,10 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -132,12 +79,10 @@ class HTMLTALParserTestCases(unittest.TestCase):
self._run_check( self._run_check(
"""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [ """<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', ('rawtext',
'<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')]) '<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')])
self._run_check("""<a b='' c="" d=>""", [ self._run_check("""<a b='' c="" d=>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="" c="" d=""></a>'), ('rawtext', '<a b="" c="" d=""></a>'),
]) ])
...@@ -145,29 +90,24 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -145,29 +90,24 @@ class HTMLTALParserTestCases(unittest.TestCase):
# we expect entities *not* to be replaced by HTLMParser! # we expect entities *not* to be replaced by HTLMParser!
self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [ self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"></a>'), ('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"></a>'),
]) ])
self._run_check("""<a b='\"'>""", [ self._run_check("""<a b='\"'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', "<a b='\"'></a>"), ('rawtext', "<a b='\"'></a>"),
]) ])
self._run_check("""<a b='&'>""", [ self._run_check("""<a b='&'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="&amp;"></a>'), ('rawtext', '<a b="&amp;"></a>'),
]) ])
self._run_check("""<a b='<'>""", [ self._run_check("""<a b='<'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="&lt;"></a>'), ('rawtext', '<a b="&lt;"></a>'),
]) ])
def check_code_attr_funky_names(self): def check_code_attr_funky_names(self):
self._run_check("""<a a.b='v' c:d=v e-f=v>""", [ self._run_check("""<a a.b='v' c:d=v e-f=v>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a a.b="v" c:d="v" e-f="v"></a>'), ('rawtext', '<a a.b="v" c:d="v" e-f="v"></a>'),
]) ])
...@@ -180,10 +120,7 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -180,10 +120,7 @@ class HTMLTALParserTestCases(unittest.TestCase):
def check_code_short_endtags(self): def check_code_short_endtags(self):
self._run_check("""<html><img/></html>""", [ self._run_check("""<html><img/></html>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<html><img/></html>'),
('rawtext', '<html>'),
('setPosition', (1, 6)),
('rawtext', '<img/></html>'),
]) ])
......
...@@ -30,86 +30,34 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -30,86 +30,34 @@ class HTMLTALParserTestCases(unittest.TestCase):
def check_code_simple_identity(self): def check_code_simple_identity(self):
self._run_check("""<html a='b' b="c" c=d><title>My Title</html>""", [ self._run_check("""<html a='b' b="c" c=d><title>My Title</html>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<html a="b" b="c" c="d">'
('rawtext', '<html a="b" b="c" c="d">'), '<title>My Title</title></html>'),
('setPosition', (1, 22)),
('rawtext', '<title>My Title</title></html>'),
]) ])
def check_code_implied_list_closings(self): def check_code_implied_list_closings(self):
self._run_check("""<ul><li><p><p><li></ul>""", [ self._run_check("""<ul><li><p><p><li></ul>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<ul><li><p></p><p></p></li><li></li></ul>'),
('rawtext', '<ul>'),
('setPosition', (1, 4)),
('rawtext', '<li>'),
('setPosition', (1, 8)),
('rawtext', '<p></p>'),
('setPosition', (1, 11)),
('rawtext', '<p></p></li>'),
('setPosition', (1, 14)),
('rawtext', '<li></li></ul>'),
]) ])
self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [ self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<dl><dt></dt><dt></dt><dd></dd>'
('rawtext', '<dl>'), '<dd><ol><li></li><li></li></ol></dd></dl>'),
('setPosition', (1, 4)),
('rawtext', '<dt></dt>'),
('setPosition', (1, 8)),
('rawtext', '<dt></dt>'),
('setPosition', (1, 12)),
('rawtext', '<dd></dd>'),
('setPosition', (1, 16)),
('rawtext', '<dd>'),
('setPosition', (1, 20)),
('rawtext', '<ol>'),
('setPosition', (1, 24)),
('rawtext', '<li></li>'),
('setPosition', (1, 28)),
('rawtext', '<li></li></ol></dd></dl>'),
]) ])
def check_code_implied_table_closings(self): def check_code_implied_table_closings(self):
self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t""" self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t"""
"""<table><tr><td>cell \n \t \n<tr>""", [ """<table><tr><td>cell \n \t \n<tr>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<p>text</p> <table><tr><th>head</th>'
('rawtext', '<p>text</p> '), '</tr>\t<tr><td>cell\t<table><tr><td>cell</td>'
('setPosition', (1, 8)), '</tr> \n \t \n<tr></tr></table></td></tr></table>'),
('rawtext', '<table>'),
('setPosition', (1, 15)),
('rawtext', '<tr>'),
('setPosition', (1, 19)),
('rawtext', '<th>head</th></tr>\t'),
('setPosition', (1, 28)),
('rawtext', '<tr>'),
('setPosition', (1, 32)),
('rawtext', '<td>cell\t'),
('setPosition', (1, 41)),
('rawtext', '<table>'),
('setPosition', (1, 48)),
('rawtext', '<tr>'),
('setPosition', (1, 52)),
('rawtext', '<td>cell</td></tr> \n \t \n'),
('setPosition', (3, 0)),
('rawtext', '<tr></tr></table></td></tr></table>'),
]) ])
self._run_check("""<table><tr><td>cell """ self._run_check("""<table><tr><td>cell """
"""<table><tr><td>cell </table></table>""", [ """<table><tr><td>cell </table></table>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<table><tr><td>cell <table><tr><td>cell</td></tr>'
('rawtext', '<table>'), ' </table></td></tr></table>'),
('setPosition', (1, 7)),
('rawtext', '<tr>'),
('setPosition', (1, 11)),
('rawtext', '<td>cell '),
('setPosition', (1, 20)),
('rawtext', '<table>'),
('setPosition', (1, 27)),
('rawtext', '<tr>'),
('setPosition', (1, 31)),
('rawtext', '<td>cell</td></tr> </table></td></tr></table>'),
]) ])
def check_code_bad_nesting(self): def check_code_bad_nesting(self):
...@@ -120,7 +68,6 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -120,7 +68,6 @@ class HTMLTALParserTestCases(unittest.TestCase):
def check_code_attr_syntax(self): def check_code_attr_syntax(self):
output = [ output = [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="v" c="v" d="v" e></a>'), ('rawtext', '<a b="v" c="v" d="v" e></a>'),
] ]
self._run_check("""<a b='v' c="v" d=v e>""", output) self._run_check("""<a b='v' c="v" d=v e>""", output)
...@@ -132,12 +79,10 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -132,12 +79,10 @@ class HTMLTALParserTestCases(unittest.TestCase):
self._run_check( self._run_check(
"""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [ """<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', ('rawtext',
'<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')]) '<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')])
self._run_check("""<a b='' c="" d=>""", [ self._run_check("""<a b='' c="" d=>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="" c="" d=""></a>'), ('rawtext', '<a b="" c="" d=""></a>'),
]) ])
...@@ -145,29 +90,24 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -145,29 +90,24 @@ class HTMLTALParserTestCases(unittest.TestCase):
# we expect entities *not* to be replaced by HTLMParser! # we expect entities *not* to be replaced by HTLMParser!
self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [ self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"></a>'), ('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"></a>'),
]) ])
self._run_check("""<a b='\"'>""", [ self._run_check("""<a b='\"'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', "<a b='\"'></a>"), ('rawtext', "<a b='\"'></a>"),
]) ])
self._run_check("""<a b='&'>""", [ self._run_check("""<a b='&'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="&amp;"></a>'), ('rawtext', '<a b="&amp;"></a>'),
]) ])
self._run_check("""<a b='<'>""", [ self._run_check("""<a b='<'>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a b="&lt;"></a>'), ('rawtext', '<a b="&lt;"></a>'),
]) ])
def check_code_attr_funky_names(self): def check_code_attr_funky_names(self):
self._run_check("""<a a.b='v' c:d=v e-f=v>""", [ self._run_check("""<a a.b='v' c:d=v e-f=v>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)),
('rawtext', '<a a.b="v" c:d="v" e-f="v"></a>'), ('rawtext', '<a a.b="v" c:d="v" e-f="v"></a>'),
]) ])
...@@ -180,10 +120,7 @@ class HTMLTALParserTestCases(unittest.TestCase): ...@@ -180,10 +120,7 @@ class HTMLTALParserTestCases(unittest.TestCase):
def check_code_short_endtags(self): def check_code_short_endtags(self):
self._run_check("""<html><img/></html>""", [ self._run_check("""<html><img/></html>""", [
('version', TAL_VERSION), ('version', TAL_VERSION),
('setPosition', (1, 0)), ('rawtext', '<html><img/></html>'),
('rawtext', '<html>'),
('setPosition', (1, 6)),
('rawtext', '<img/></html>'),
]) ])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment