more unittests and updated documentation for extensions.  Fixed bug in optimizer that caused blocks to be optimized away under some circumstances.

--HG--
branch : trunk
diff --git a/tests/test_ext.py b/tests/test_ext.py
index 5a487cf..f91b0f7 100644
--- a/tests/test_ext.py
+++ b/tests/test_ext.py
@@ -6,7 +6,32 @@
     :copyright: 2008 by Armin Ronacher.
     :license: BSD, see LICENSE for more details.
 """
-from jinja2 import Environment
+from jinja2 import Environment, nodes
+from jinja2.ext import Extension
+
+
+importable_object = 23
+
+
+class TestExtension(Extension):
+    tags = set(['test'])
+    ext_attr = 42
+
+    def parse(self, parser):
+        return nodes.Output([self.call_method('_dump', [
+            nodes.EnvironmentAttribute('sandboxed'),
+            self.attr('ext_attr'),
+            nodes.ImportedName(__name__ + '.importable_object'),
+            nodes.ContextReference()
+        ])]).set_lineno(parser.stream.next().lineno)
+
+    def _dump(self, sandboxed, ext_attr, imported_object, context):
+        return '%s|%s|%s|%s' % (
+            sandboxed,
+            ext_attr,
+            imported_object,
+            context.blocks
+        )
 
 
 def test_loop_controls():
@@ -35,3 +60,9 @@
             {%- do items.append(loop.index0 ~ char) %}
         {%- endfor %}{{ items|join(', ') }}''')
     assert tmpl.render() == '0f, 1o, 2o'
+
+
+def test_extension_nodes():
+    env = Environment(extensions=[TestExtension])
+    tmpl = env.from_string('{% test %}')
+    assert tmpl.render() == 'False|42|23|{}'