diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-07-23 22:57:05 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-07-23 22:57:05 +0000 |
commit | 79feae0a6b9d5edb86faea9d22d1af7111538cae (patch) | |
tree | 9d78bd0008acf78334cfcbfc91efd39a68dc3cf7 /test/lexer.py | |
parent | 6280701b755e3173ad8d9c2c6d66f53415828000 (diff) | |
download | external_python_mako-79feae0a6b9d5edb86faea9d22d1af7111538cae.tar.gz external_python_mako-79feae0a6b9d5edb86faea9d22d1af7111538cae.tar.bz2 external_python_mako-79feae0a6b9d5edb86faea9d22d1af7111538cae.zip |
- comments can be placed at the end of control lines,
i.e. if foo: # a comment, [ticket:53], thanks to
Paul Colomiets
Diffstat (limited to 'test/lexer.py')
-rw-r--r-- | test/lexer.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/lexer.py b/test/lexer.py index e088a50..a8fbb8a 100644 --- a/test/lexer.py +++ b/test/lexer.py @@ -380,6 +380,17 @@ text text la la """ nodes = Lexer(template).parse() assert repr(nodes) == r"""TemplateNode({}, [NamespaceTag(u'namespace', {u'name': u'foo', u'file': u'somefile.html'}, (1, 1), []), Text(u'\n', (1, 46)), Comment(u'inherit from foobar.html', (2, 1)), InheritTag(u'inherit', {u'file': u'foobar.html'}, (3, 1), []), Text(u'\n\n', (3, 31)), DefTag(u'def', {u'name': u'header()'}, (5, 1), ["Text(u'\\n <div>header</div>\\n', (5, 23))"]), Text(u'\n', (7, 8)), DefTag(u'def', {u'name': u'footer()'}, (8, 1), ["Text(u'\\n <div> footer</div>\\n', (8, 23))"]), Text(u'\n\n<table>\n', (10, 8)), ControlLine(u'for', u'for j in data():', False, (13, 1)), Text(u' <tr>\n', (14, 1)), ControlLine(u'for', u'for x in j:', False, (15, 1)), Text(u' <td>Hello ', (16, 1)), Expression(u'x', ['h'], (16, 23)), Text(u'</td>\n', (16, 30)), ControlLine(u'for', u'endfor', True, (17, 1)), Text(u' </tr>\n', (18, 1)), ControlLine(u'for', u'endfor', True, (19, 1)), Text(u'</table>\n', (20, 1))])""" + + def test_comment_after_statement(self): + template = """ + % if x: #comment + hi + % else: #next + hi + % endif #end +""" + nodes = Lexer(template).parse() + assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n', (1, 1)), ControlLine(u'if', u'if x: #comment', False, (2, 1)), Text(u' hi\n', (3, 1)), ControlLine(u'else', u'else: #next', False, (4, 1)), Text(u' hi\n', (5, 1)), ControlLine(u'if', u'endif #end', True, (6, 1))])""" def test_crlf(self): template = file("./test_htdocs/crlf.html").read() |