[svn] added some more jinja unittests

--HG--
branch : trunk
diff --git a/tests/test_parser.py b/tests/test_parser.py
index d9d75c0..1c8851d 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -40,6 +40,8 @@
     {item}
 {-endfor}'''
 
+BALANCING = '''{{{'foo':'bar'}.foo}}'''
+
 
 def test_no_variable_block():
     env = Environment('{%', '%}', None, None)
@@ -74,3 +76,8 @@
     env = Environment('{', '}', '{', '}', '{*', '*}')
     tmpl = env.from_string(SMARTY_SYNTAX)
     assert tmpl.render(seq=range(5)) == '01234'
+
+
+def test_balancing(env):
+    tmpl = env.from_string(BALANCING)
+    assert tmpl.render() == 'bar'
diff --git a/tests/test_security.py b/tests/test_security.py
index 5e0099d..95d3371 100644
--- a/tests/test_security.py
+++ b/tests/test_security.py
@@ -44,4 +44,8 @@
 Traceback (most recent call last):
     ...
 TemplateSyntaxError: can't assign to expression. (line 1)
+>>> env.from_string("{% for foo, bar.baz in seq %}...{% endfor %}")
+Traceback (most recent call last):
+    ...
+TemplateSyntaxError: can't assign to expression. (line 1)
 '''
diff --git a/tests/test_syntax.py b/tests/test_syntax.py
new file mode 100644
index 0000000..79aaf2f
--- /dev/null
+++ b/tests/test_syntax.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+"""
+    unit test for expression syntax
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    :copyright: 2007 by Armin Ronacher.
+    :license: BSD, see LICENSE for more details.
+"""
+
+CALL = '''{{ foo('a', c='d', e='f', *['b'], **{'g': 'h'}) }}'''
+SLICING = '''{{ [1, 2, 3][:] }}|{{ [1, 2, 3][::-1] }}'''
+ATTR = '''{{ foo.bar }}|{{ foo['bar'] }}'''
+SUBSCRIPT = '''{{ foo[0] }}|{{ foo[-1] }}'''
+KEYATTR = '''{{ {'items': 'foo'}.items }}|{{ {}.items() }}'''
+TUPLE = '''{{ () }}'''
+MATH = '''{{ (1 + 1 * 2) - 3 / 2 }}|{{ 2**3 }}'''
+DIV = '''{{ 3 // 2 }}|{{ 3 / 2 }}|{{ 3 % 2 }}'''
+UNARY = '''{{ +3 }}|{{ -3 }}'''
+COMPARE = '''{{ 1 > 0 }}|{{ 1 >= 1 }}|{{ 2 < 3 }}|{{ 2 == 2 }}|{{ 1 <= 1 }}'''
+LITERALS = '''{{ [] }}|{{ {} }}|{{ '' }}'''
+BOOL = '''{{ true and false }}|{{ false or true }}|{{ not false }}'''
+
+
+def test_call():
+    from jinja import Environment
+    env = Environment()
+    env.globals['foo'] = lambda a, b, c, e, g: a + b + c + e + g
+    tmpl = env.from_string(CALL)
+    assert tmpl.render() == 'abdfh'
+
+
+def test_slicing(env):
+    tmpl = env.from_string(SLICING)
+    assert tmpl.render() == '[1, 2, 3]|[3, 2, 1]'
+
+
+def test_attr(env):
+    tmpl = env.from_string(ATTR)
+    assert tmpl.render(foo={'bar': 42}) == '42|42'
+
+
+def test_subscript(env):
+    tmpl = env.from_string(SUBSCRIPT)
+    assert tmpl.render(foo=[0, 1, 2]) == '0|2'
+
+
+def test_keyattr(env):
+    tmpl = env.from_string(KEYATTR)
+    assert tmpl.render() == 'foo|[]'
+
+
+def test_tuple(env):
+    tmpl = env.from_string(TUPLE)
+    assert tmpl.render() == '[]'
+
+
+def test_math(env):
+    tmpl = env.from_string(MATH)
+    assert tmpl.render() == '1.5|8'
+
+
+def test_div(env):
+    tmpl = env.from_string(DIV)
+    assert tmpl.render() == '1|1.5|1'
+
+
+def test_unary(env):
+    tmpl = env.from_string(UNARY)
+    assert tmpl.render() == '3|-3'
+
+
+def test_compare(env):
+    tmpl = env.from_string(COMPARE)
+    assert tmpl.render() == 'True|True|True|True|True'
+
+
+def test_literals(env):
+    tmpl = env.from_string(LITERALS)
+    assert tmpl.render() == '[]|{}|'
+
+
+def test_bool(env):
+    tmpl = env.from_string(BOOL)
+    assert tmpl.render() == 'False|True|True'
diff --git a/tests/test_various.py b/tests/test_various.py
index 6f449a4..cea56b8 100644
--- a/tests/test_various.py
+++ b/tests/test_various.py
@@ -6,6 +6,7 @@
     :copyright: 2007 by Armin Ronacher.
     :license: BSD, see LICENSE for more details.
 """
+from jinja.exceptions import TemplateSyntaxError
 
 KEYWORDS = '''\
 {{ with }}
@@ -31,7 +32,11 @@
 LIGHTKW = '''{{ call }}'''
 UNPACKING = '''{% for a, b, c in [[1, 2, 3]] %}{{ a }}|{{ b }}|{{ c }}{% endfor %}'''
 RAW = '''{% raw %}{{ FOO }} and {% BAR %}{% endraw %}'''
-CALL = '''{{ foo('a', c='d', e='f', *['b'], **{'g': 'h'}) }}'''
+CONST = '''{{ true }}|{{ false }}|{{ none }}|{{ undefined }}|\
+{{ none is defined }}|{{ undefined is defined }}'''
+CONSTASS1 = '''{% set true = 42 %}'''
+CONSTASS2 = '''{% for undefined in seq %}{% endfor %}'''
+
 
 def test_keywords(env):
     env.from_string(KEYWORDS)
@@ -70,14 +75,6 @@
     assert 'a' in d and 'c' in d and 'd' in d and 'b' not in d
 
 
-def test_call():
-    from jinja import Environment
-    env = Environment()
-    env.globals['foo'] = lambda a, b, c, e, g: a + b + c + e + g
-    tmpl = env.from_string(CALL)
-    assert tmpl.render() == 'abdfh'
-
-
 def test_stringfilter(env):
     from jinja.filters import stringfilter
     f = stringfilter(lambda f, x: f + x)
@@ -88,3 +85,18 @@
     from jinja.filters import simplefilter
     f = simplefilter(lambda f, x: f + x)
     assert f(42)(env, None, 23) == 65
+
+
+def test_const(env):
+    tmpl = env.from_string(CONST)
+    assert tmpl.render() == 'True|False|||True|False'
+
+
+def test_const_assign(env):
+    for tmpl in CONSTASS1, CONSTASS2:
+        try:
+            env.from_string(tmpl)
+        except TemplateSyntaxError:
+            pass
+        else:
+            raise AssertionError('expected syntax error')