Commit 51d88f6d authored by Guido van Rossum's avatar Guido van Rossum

Update test output to match version 1.0.1 of the code generator.

All test should succeed now (both TAL/test/run.py and TAL/runtest.py).
parent 0f20a2ce
...@@ -138,7 +138,7 @@ class METALGeneratorTestCases(TestCaseBase): ...@@ -138,7 +138,7 @@ class METALGeneratorTestCases(TestCaseBase):
def check_define_macro(self): def check_define_macro(self):
macro = [('startTag', 'p', macro = [('startTag', 'p',
[('metal:define-macro', 'M', 'macroHack')]), [('metal:define-macro', 'M', 'metal')]),
('rawtext', 'booh</p>')] ('rawtext', 'booh</p>')]
program = [ program = [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
...@@ -152,16 +152,18 @@ class METALGeneratorTestCases(TestCaseBase): ...@@ -152,16 +152,18 @@ class METALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('useMacro', ('useMacro',
'M', '$M$', {}, 'M', '$M$', {},
[('rawtext', '<p metal:use-macro="M">booh</p>')]), [('startTag', 'p', [('metal:use-macro', 'M', 'metal')]),
('rawtext', 'booh</p>')]),
]) ])
def check_define_slot(self): def check_define_slot(self):
macro = [ macro = [
('startTag', 'p', [('metal:define-macro', 'M', 'macroHack')]), ('startTag', 'p', [('metal:define-macro', 'M', 'metal')]),
('rawtext', 'foo'), ('rawtext', 'foo'),
('setPosition', (1, 29)), ('setPosition', (1, 29)),
('defineSlot', 'S', ('defineSlot', 'S',
[('rawtext', '<span metal:define-slot="S">spam</span>')]), [('startTag', 'span', [('metal:define-slot', 'S', 'metal')]),
('rawtext', 'spam</span>')]),
('rawtext', 'bar</p>'), ('rawtext', 'bar</p>'),
] ]
program = [('setPosition', (1, 0)), program = [('setPosition', (1, 0)),
...@@ -177,11 +179,14 @@ class METALGeneratorTestCases(TestCaseBase): ...@@ -177,11 +179,14 @@ class METALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('useMacro', ('useMacro',
'M', '$M$', 'M', '$M$',
{'S': [('rawtext', '<span metal:fill-slot="S">spam</span>')]}, {'S': [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]),
[('rawtext', '<p metal:use-macro="M">foo'), ('rawtext', 'spam</span>')]},
[('startTag', 'p', [('metal:use-macro', 'M', 'metal')]),
('rawtext', 'foo'),
('setPosition', (1, 26)), ('setPosition', (1, 26)),
('fillSlot', 'S', ('fillSlot', 'S',
[('rawtext', '<span metal:fill-slot="S">spam</span>')]), [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]),
('rawtext', 'spam</span>')]),
('rawtext', 'bar</p>')]), ('rawtext', 'bar</p>')]),
]) ])
...@@ -196,21 +201,26 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -196,21 +201,26 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('setLocal', 'xyzzy', '$string:spam$'), ('setLocal', 'xyzzy', '$string:spam$'),
('rawtext', '<p tal:define="xyzzy string:spam"></p>'), ('startTag', 'p', [('tal:define', 'xyzzy string:spam', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='local xyzzy string:spam'></p>", [ self._run_check("<p tal:define='local xyzzy string:spam'></p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('setLocal', 'xyzzy', '$string:spam$'), ('setLocal', 'xyzzy', '$string:spam$'),
('rawtext', '<p tal:define="local xyzzy string:spam"></p>'), ('startTag', 'p',
[('tal:define', 'local xyzzy string:spam', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='global xyzzy string:spam'></p>", [ self._run_check("<p tal:define='global xyzzy string:spam'></p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('setGlobal', 'xyzzy', '$string:spam$'), ('setGlobal', 'xyzzy', '$string:spam$'),
('rawtext', '<p tal:define="global xyzzy string:spam"></p>'), ('startTag', 'p',
[('tal:define', 'global xyzzy string:spam', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='x string:spam; y x'></p>", [ self._run_check("<p tal:define='x string:spam; y x'></p>", [
...@@ -218,7 +228,8 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -218,7 +228,8 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope',), ('beginScope',),
('setLocal', 'x', '$string:spam$'), ('setLocal', 'x', '$string:spam$'),
('setLocal', 'y', '$x$'), ('setLocal', 'y', '$x$'),
('rawtext', '<p tal:define="x string:spam; y x"></p>'), ('startTag', 'p', [('tal:define', 'x string:spam; y x', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='x string:;;;;; y x'></p>", [ self._run_check("<p tal:define='x string:;;;;; y x'></p>", [
...@@ -226,7 +237,8 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -226,7 +237,8 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope',), ('beginScope',),
('setLocal', 'x', '$string:;;$'), ('setLocal', 'x', '$string:;;$'),
('setLocal', 'y', '$x$'), ('setLocal', 'y', '$x$'),
('rawtext', '<p tal:define="x string:;;;;; y x"></p>'), ('startTag', 'p', [('tal:define', 'x string:;;;;; y x', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check( self._run_check(
...@@ -236,8 +248,9 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -236,8 +248,9 @@ class TALGeneratorTestCases(TestCaseBase):
('setLocal', 'x', '$string:spam$'), ('setLocal', 'x', '$string:spam$'),
('setGlobal', 'y', '$x$'), ('setGlobal', 'y', '$x$'),
('setLocal', 'z', '$y$'), ('setLocal', 'z', '$y$'),
('rawtext', ('startTag', 'p',
'<p tal:define="x string:spam; global y x; local z y"></p>'), [('tal:define', 'x string:spam; global y x; local z y', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
...@@ -247,27 +260,28 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -247,27 +260,28 @@ class TALGeneratorTestCases(TestCaseBase):
('rawtext', '<p>'), ('rawtext', '<p>'),
('setPosition', (1, 3)), ('setPosition', (1, 3)),
('condition', '$python:1$', ('condition', '$python:1$',
[('rawtext', [('startTag', 'span', [('tal:condition', 'python:1', 'tal')]),
'<span tal:condition="python:1"><b>foo</b></span>')]), ('rawtext', '<b>foo</b></span>')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
def check_content(self): def check_content(self):
self._run_check("<p tal:content='string:foo'>bar</p>", [ self._run_check("<p tal:content='string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('rawtext', '<p tal:content="string:foo">'), ('startTag', 'p', [('tal:content', 'string:foo', 'tal')]),
('insertText', '$string:foo$', [('rawtext', 'bar')]), ('insertText', '$string:foo$', [('rawtext', 'bar')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
self._run_check("<p tal:content='text string:foo'>bar</p>", [ self._run_check("<p tal:content='text string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('rawtext', '<p tal:content="text string:foo">'), ('startTag', 'p', [('tal:content', 'text string:foo', 'tal')]),
('insertText', '$string:foo$', [('rawtext', 'bar')]), ('insertText', '$string:foo$', [('rawtext', 'bar')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
self._run_check("<p tal:content='structure string:<br>'>bar</p>", [ self._run_check("<p tal:content='structure string:<br>'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('rawtext', '<p tal:content="structure string:&lt;br&gt;">'), ('startTag', 'p',
[('tal:content', 'structure string:<br>', 'tal')]),
('insertStructure', '$string:<br>$', {}, [('rawtext', 'bar')]), ('insertStructure', '$string:<br>$', {}, [('rawtext', 'bar')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
...@@ -276,18 +290,21 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -276,18 +290,21 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='string:foo'>bar</p>", [ self._run_check("<p tal:replace='string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertText', '$string:foo$', ('insertText', '$string:foo$',
[('rawtext', '<p tal:replace="string:foo">bar</p>')]), [('startTag', 'p', [('tal:replace', 'string:foo', 'tal')]),
('rawtext', 'bar</p>')]),
]) ])
self._run_check("<p tal:replace='text string:foo'>bar</p>", [ self._run_check("<p tal:replace='text string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertText', '$string:foo$', ('insertText', '$string:foo$',
[('rawtext', '<p tal:replace="text string:foo">bar</p>')]), [('startTag', 'p', [('tal:replace', 'text string:foo', 'tal')]),
('rawtext', 'bar</p>')]),
]) ])
self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [ self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertStructure', '$string:<br>$', {}, ('insertStructure', '$string:<br>$', {},
[('rawtext', [('startTag', 'p',
'<p tal:replace="structure string:&lt;br&gt;">bar</p>')]), [('tal:replace', 'structure string:<br>', 'tal')]),
('rawtext', 'bar</p>')]),
]) ])
def check_repeat(self): def check_repeat(self):
...@@ -296,10 +313,11 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -296,10 +313,11 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('loop', 'x', '$python:(1,2,3)$', ('loop', 'x', '$python:(1,2,3)$',
[('rawtext', '<p tal:repeat="x python:(1,2,3)">'), [('startTag', 'p', [('tal:repeat', 'x python:(1,2,3)', 'tal')]),
('setPosition', (1, 33)), ('setPosition', (1, 33)),
('insertText', '$x$', ('insertText', '$x$',
[('rawtext', '<span tal:replace="x">dummy</span>')]), [('startTag', 'span', [('tal:replace', 'x', 'tal')]),
('rawtext', 'dummy</span>')]),
('rawtext', '</p>')]), ('rawtext', '</p>')]),
('endScope',), ('endScope',),
]) ])
...@@ -313,7 +331,7 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -313,7 +331,7 @@ class TALGeneratorTestCases(TestCaseBase):
[('href', 'foo', 'replace', '$string:http://www.zope.org$'), [('href', 'foo', 'replace', '$string:http://www.zope.org$'),
('name', 'bar'), ('name', 'bar'),
('tal:attributes', ('tal:attributes',
'href string:http://www.zope.org; x string:y'), 'href string:http://www.zope.org; x string:y', 'tal'),
('x', '', 'replace', '$string:y$')]), ('x', '', 'replace', '$string:y$')]),
('rawtext', 'link</a>'), ('rawtext', 'link</a>'),
]) ])
...@@ -322,9 +340,10 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -322,9 +340,10 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertStructure', '$string:<img>$', ('insertStructure', '$string:<img>$',
{'src': '$string:foo.png$'}, {'src': '$string:foo.png$'},
[('rawtext', [('startTag', 'p',
'<p tal:replace="structure string:&lt;img&gt;" ' [('tal:replace', 'structure string:<img>', 'tal'),
'tal:attributes="src string:foo.png">duh</p>')]), ('tal:attributes', 'src string:foo.png', 'tal')]),
('rawtext', 'duh</p>')]),
]) ])
def check_on_error(self): def check_on_error(self):
...@@ -332,12 +351,14 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -332,12 +351,14 @@ class TALGeneratorTestCases(TestCaseBase):
"tal:content='notHere'>okay</p>", [ "tal:content='notHere'>okay</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('onError', ('onError',
[('rawtext', [('startTag', 'p',
'<p tal:on-error="string:error" tal:content="notHere">'), [('tal:on-error', 'string:error', 'tal'),
('tal:content', 'notHere', 'tal')]),
('insertText', '$notHere$', [('rawtext', 'okay')]), ('insertText', '$notHere$', [('rawtext', 'okay')]),
('rawtext', '</p>')], ('rawtext', '</p>')],
[('rawtext', [('startTag', 'p',
'<p tal:on-error="string:error" tal:content="notHere">'), [('tal:on-error', 'string:error', 'tal'),
('tal:content', 'notHere', 'tal')]),
('insertText', '$string:error$', []), ('insertText', '$string:error$', []),
('rawtext', '</p>')]), ('rawtext', '</p>')]),
]) ])
...@@ -346,11 +367,13 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -346,11 +367,13 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('onError', ('onError',
[('insertText', '$notHere$', [('insertText', '$notHere$',
[('rawtext', [('startTag', 'p',
'<p tal:on-error="string:error" ' [('tal:on-error', 'string:error', 'tal'),
'tal:replace="notHere">okay</p>')])], ('tal:replace', 'notHere', 'tal')]),
[('rawtext', ('rawtext', 'okay</p>')])],
'<p tal:on-error="string:error" tal:replace="notHere">'), [('startTag', 'p',
[('tal:on-error', 'string:error', 'tal'),
('tal:replace', 'notHere', 'tal')]),
('insertText', '$string:error$', []), ('insertText', '$string:error$', []),
('rawtext', '</p>')]), ('rawtext', '</p>')]),
]) ])
......
...@@ -138,7 +138,7 @@ class METALGeneratorTestCases(TestCaseBase): ...@@ -138,7 +138,7 @@ class METALGeneratorTestCases(TestCaseBase):
def check_define_macro(self): def check_define_macro(self):
macro = [('startTag', 'p', macro = [('startTag', 'p',
[('metal:define-macro', 'M', 'macroHack')]), [('metal:define-macro', 'M', 'metal')]),
('rawtext', 'booh</p>')] ('rawtext', 'booh</p>')]
program = [ program = [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
...@@ -152,16 +152,18 @@ class METALGeneratorTestCases(TestCaseBase): ...@@ -152,16 +152,18 @@ class METALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('useMacro', ('useMacro',
'M', '$M$', {}, 'M', '$M$', {},
[('rawtext', '<p metal:use-macro="M">booh</p>')]), [('startTag', 'p', [('metal:use-macro', 'M', 'metal')]),
('rawtext', 'booh</p>')]),
]) ])
def check_define_slot(self): def check_define_slot(self):
macro = [ macro = [
('startTag', 'p', [('metal:define-macro', 'M', 'macroHack')]), ('startTag', 'p', [('metal:define-macro', 'M', 'metal')]),
('rawtext', 'foo'), ('rawtext', 'foo'),
('setPosition', (1, 29)), ('setPosition', (1, 29)),
('defineSlot', 'S', ('defineSlot', 'S',
[('rawtext', '<span metal:define-slot="S">spam</span>')]), [('startTag', 'span', [('metal:define-slot', 'S', 'metal')]),
('rawtext', 'spam</span>')]),
('rawtext', 'bar</p>'), ('rawtext', 'bar</p>'),
] ]
program = [('setPosition', (1, 0)), program = [('setPosition', (1, 0)),
...@@ -177,11 +179,14 @@ class METALGeneratorTestCases(TestCaseBase): ...@@ -177,11 +179,14 @@ class METALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('useMacro', ('useMacro',
'M', '$M$', 'M', '$M$',
{'S': [('rawtext', '<span metal:fill-slot="S">spam</span>')]}, {'S': [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]),
[('rawtext', '<p metal:use-macro="M">foo'), ('rawtext', 'spam</span>')]},
[('startTag', 'p', [('metal:use-macro', 'M', 'metal')]),
('rawtext', 'foo'),
('setPosition', (1, 26)), ('setPosition', (1, 26)),
('fillSlot', 'S', ('fillSlot', 'S',
[('rawtext', '<span metal:fill-slot="S">spam</span>')]), [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]),
('rawtext', 'spam</span>')]),
('rawtext', 'bar</p>')]), ('rawtext', 'bar</p>')]),
]) ])
...@@ -196,21 +201,26 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -196,21 +201,26 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('setLocal', 'xyzzy', '$string:spam$'), ('setLocal', 'xyzzy', '$string:spam$'),
('rawtext', '<p tal:define="xyzzy string:spam"></p>'), ('startTag', 'p', [('tal:define', 'xyzzy string:spam', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='local xyzzy string:spam'></p>", [ self._run_check("<p tal:define='local xyzzy string:spam'></p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('setLocal', 'xyzzy', '$string:spam$'), ('setLocal', 'xyzzy', '$string:spam$'),
('rawtext', '<p tal:define="local xyzzy string:spam"></p>'), ('startTag', 'p',
[('tal:define', 'local xyzzy string:spam', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='global xyzzy string:spam'></p>", [ self._run_check("<p tal:define='global xyzzy string:spam'></p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('setGlobal', 'xyzzy', '$string:spam$'), ('setGlobal', 'xyzzy', '$string:spam$'),
('rawtext', '<p tal:define="global xyzzy string:spam"></p>'), ('startTag', 'p',
[('tal:define', 'global xyzzy string:spam', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='x string:spam; y x'></p>", [ self._run_check("<p tal:define='x string:spam; y x'></p>", [
...@@ -218,7 +228,8 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -218,7 +228,8 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope',), ('beginScope',),
('setLocal', 'x', '$string:spam$'), ('setLocal', 'x', '$string:spam$'),
('setLocal', 'y', '$x$'), ('setLocal', 'y', '$x$'),
('rawtext', '<p tal:define="x string:spam; y x"></p>'), ('startTag', 'p', [('tal:define', 'x string:spam; y x', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check("<p tal:define='x string:;;;;; y x'></p>", [ self._run_check("<p tal:define='x string:;;;;; y x'></p>", [
...@@ -226,7 +237,8 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -226,7 +237,8 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope',), ('beginScope',),
('setLocal', 'x', '$string:;;$'), ('setLocal', 'x', '$string:;;$'),
('setLocal', 'y', '$x$'), ('setLocal', 'y', '$x$'),
('rawtext', '<p tal:define="x string:;;;;; y x"></p>'), ('startTag', 'p', [('tal:define', 'x string:;;;;; y x', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
self._run_check( self._run_check(
...@@ -236,8 +248,9 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -236,8 +248,9 @@ class TALGeneratorTestCases(TestCaseBase):
('setLocal', 'x', '$string:spam$'), ('setLocal', 'x', '$string:spam$'),
('setGlobal', 'y', '$x$'), ('setGlobal', 'y', '$x$'),
('setLocal', 'z', '$y$'), ('setLocal', 'z', '$y$'),
('rawtext', ('startTag', 'p',
'<p tal:define="x string:spam; global y x; local z y"></p>'), [('tal:define', 'x string:spam; global y x; local z y', 'tal')]),
('rawtext', '</p>'),
('endScope',), ('endScope',),
]) ])
...@@ -247,27 +260,28 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -247,27 +260,28 @@ class TALGeneratorTestCases(TestCaseBase):
('rawtext', '<p>'), ('rawtext', '<p>'),
('setPosition', (1, 3)), ('setPosition', (1, 3)),
('condition', '$python:1$', ('condition', '$python:1$',
[('rawtext', [('startTag', 'span', [('tal:condition', 'python:1', 'tal')]),
'<span tal:condition="python:1"><b>foo</b></span>')]), ('rawtext', '<b>foo</b></span>')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
def check_content(self): def check_content(self):
self._run_check("<p tal:content='string:foo'>bar</p>", [ self._run_check("<p tal:content='string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('rawtext', '<p tal:content="string:foo">'), ('startTag', 'p', [('tal:content', 'string:foo', 'tal')]),
('insertText', '$string:foo$', [('rawtext', 'bar')]), ('insertText', '$string:foo$', [('rawtext', 'bar')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
self._run_check("<p tal:content='text string:foo'>bar</p>", [ self._run_check("<p tal:content='text string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('rawtext', '<p tal:content="text string:foo">'), ('startTag', 'p', [('tal:content', 'text string:foo', 'tal')]),
('insertText', '$string:foo$', [('rawtext', 'bar')]), ('insertText', '$string:foo$', [('rawtext', 'bar')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
self._run_check("<p tal:content='structure string:<br>'>bar</p>", [ self._run_check("<p tal:content='structure string:<br>'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('rawtext', '<p tal:content="structure string:&lt;br&gt;">'), ('startTag', 'p',
[('tal:content', 'structure string:<br>', 'tal')]),
('insertStructure', '$string:<br>$', {}, [('rawtext', 'bar')]), ('insertStructure', '$string:<br>$', {}, [('rawtext', 'bar')]),
('rawtext', '</p>'), ('rawtext', '</p>'),
]) ])
...@@ -276,18 +290,21 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -276,18 +290,21 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='string:foo'>bar</p>", [ self._run_check("<p tal:replace='string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertText', '$string:foo$', ('insertText', '$string:foo$',
[('rawtext', '<p tal:replace="string:foo">bar</p>')]), [('startTag', 'p', [('tal:replace', 'string:foo', 'tal')]),
('rawtext', 'bar</p>')]),
]) ])
self._run_check("<p tal:replace='text string:foo'>bar</p>", [ self._run_check("<p tal:replace='text string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertText', '$string:foo$', ('insertText', '$string:foo$',
[('rawtext', '<p tal:replace="text string:foo">bar</p>')]), [('startTag', 'p', [('tal:replace', 'text string:foo', 'tal')]),
('rawtext', 'bar</p>')]),
]) ])
self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [ self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertStructure', '$string:<br>$', {}, ('insertStructure', '$string:<br>$', {},
[('rawtext', [('startTag', 'p',
'<p tal:replace="structure string:&lt;br&gt;">bar</p>')]), [('tal:replace', 'structure string:<br>', 'tal')]),
('rawtext', 'bar</p>')]),
]) ])
def check_repeat(self): def check_repeat(self):
...@@ -296,10 +313,11 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -296,10 +313,11 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope',), ('beginScope',),
('loop', 'x', '$python:(1,2,3)$', ('loop', 'x', '$python:(1,2,3)$',
[('rawtext', '<p tal:repeat="x python:(1,2,3)">'), [('startTag', 'p', [('tal:repeat', 'x python:(1,2,3)', 'tal')]),
('setPosition', (1, 33)), ('setPosition', (1, 33)),
('insertText', '$x$', ('insertText', '$x$',
[('rawtext', '<span tal:replace="x">dummy</span>')]), [('startTag', 'span', [('tal:replace', 'x', 'tal')]),
('rawtext', 'dummy</span>')]),
('rawtext', '</p>')]), ('rawtext', '</p>')]),
('endScope',), ('endScope',),
]) ])
...@@ -313,7 +331,7 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -313,7 +331,7 @@ class TALGeneratorTestCases(TestCaseBase):
[('href', 'foo', 'replace', '$string:http://www.zope.org$'), [('href', 'foo', 'replace', '$string:http://www.zope.org$'),
('name', 'bar'), ('name', 'bar'),
('tal:attributes', ('tal:attributes',
'href string:http://www.zope.org; x string:y'), 'href string:http://www.zope.org; x string:y', 'tal'),
('x', '', 'replace', '$string:y$')]), ('x', '', 'replace', '$string:y$')]),
('rawtext', 'link</a>'), ('rawtext', 'link</a>'),
]) ])
...@@ -322,9 +340,10 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -322,9 +340,10 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('insertStructure', '$string:<img>$', ('insertStructure', '$string:<img>$',
{'src': '$string:foo.png$'}, {'src': '$string:foo.png$'},
[('rawtext', [('startTag', 'p',
'<p tal:replace="structure string:&lt;img&gt;" ' [('tal:replace', 'structure string:<img>', 'tal'),
'tal:attributes="src string:foo.png">duh</p>')]), ('tal:attributes', 'src string:foo.png', 'tal')]),
('rawtext', 'duh</p>')]),
]) ])
def check_on_error(self): def check_on_error(self):
...@@ -332,12 +351,14 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -332,12 +351,14 @@ class TALGeneratorTestCases(TestCaseBase):
"tal:content='notHere'>okay</p>", [ "tal:content='notHere'>okay</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('onError', ('onError',
[('rawtext', [('startTag', 'p',
'<p tal:on-error="string:error" tal:content="notHere">'), [('tal:on-error', 'string:error', 'tal'),
('tal:content', 'notHere', 'tal')]),
('insertText', '$notHere$', [('rawtext', 'okay')]), ('insertText', '$notHere$', [('rawtext', 'okay')]),
('rawtext', '</p>')], ('rawtext', '</p>')],
[('rawtext', [('startTag', 'p',
'<p tal:on-error="string:error" tal:content="notHere">'), [('tal:on-error', 'string:error', 'tal'),
('tal:content', 'notHere', 'tal')]),
('insertText', '$string:error$', []), ('insertText', '$string:error$', []),
('rawtext', '</p>')]), ('rawtext', '</p>')]),
]) ])
...@@ -346,11 +367,13 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -346,11 +367,13 @@ class TALGeneratorTestCases(TestCaseBase):
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('onError', ('onError',
[('insertText', '$notHere$', [('insertText', '$notHere$',
[('rawtext', [('startTag', 'p',
'<p tal:on-error="string:error" ' [('tal:on-error', 'string:error', 'tal'),
'tal:replace="notHere">okay</p>')])], ('tal:replace', 'notHere', 'tal')]),
[('rawtext', ('rawtext', 'okay</p>')])],
'<p tal:on-error="string:error" tal:replace="notHere">'), [('startTag', 'p',
[('tal:on-error', 'string:error', 'tal'),
('tal:replace', 'notHere', 'tal')]),
('insertText', '$string:error$', []), ('insertText', '$string:error$', []),
('rawtext', '</p>')]), ('rawtext', '</p>')]),
]) ])
......
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