Added a testcase for #363. This bug was fixed along the way.
authorArmin Ronacher <armin.ronacher@active-4.com>
Sat, 6 Feb 2010 18:01:58 +0000 (19:01 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sat, 6 Feb 2010 18:01:58 +0000 (19:01 +0100)
--HG--
branch : trunk

Makefile
tests/test_old_bugs.py

index 6cd734ae4b627fa393951783d551779b903bed21..85ed64dea6adbc9cb7983e3b5d24ad8e43b67936 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ test:
        rm -rf py3k
        mkdir py3k
        cp -R jinja2 py3k
-       2to3 jinja2 > py3k/convert.patch
+       cp -R tests py3k
+       2to3 jinja2 tests > py3k/convert.patch
        cd py3k; patch -p0 < convert.patch
 
 .PHONY: test
index 98db1b3b33cbb1cf675bb3f1e011b78c3362d2e7..9ca834467369832645fd9730c426e8d4d429a999 100644 (file)
@@ -140,3 +140,33 @@ def test_empty_if_condition_fails():
     assert_raises(TemplateSyntaxError, Template, '{% if %}....{% endif %}')
     assert_raises(TemplateSyntaxError, Template, '{% if foo %}...{% elif %}...{% endif %}')
     assert_raises(TemplateSyntaxError, Template, '{% for x in %}..{% endfor %}')
+
+
+def test_recursive_loop_bug():
+    tpl1 = Template("""
+    {% for p in foo recursive%}
+        {{p.bar}}
+        {% for f in p.fields recursive%}
+            {{f.baz}}
+            {{p.bar}}
+            {% if f.rec %}
+                {{ loop(f.sub) }}
+            {% endif %}
+        {% endfor %}
+    {% endfor %}
+    """)
+    tpl1.render(ctx)
+
+    tpl2 = Template("""
+    {% for p in foo%}
+        {{p.bar}}
+        {% for f in p.fields recursive%}
+            {{f.baz}}
+            {{p.bar}}
+            {% if f.rec %}
+                {{ loop(f.sub) }}
+            {% endif %}
+        {% endfor %}
+    {% endfor %}
+    """)
+    tpl2.render(ctx)