Permalink
Browse files

Merge branch 'pr/283'

  • Loading branch information...
2 parents d47b4d7 + 40367c4 commit 510fb489d63ad69c5a0cc9057926a0ed3f03f4c3 @mitsuhiko mitsuhiko committed Dec 12, 2013
Showing with 22 additions and 0 deletions.
  1. +11 −0 jinja2/tests.py
  2. +11 −0 jinja2/testsuite/tests.py
View
@@ -102,6 +102,16 @@ def test_sequence(value):
return False
return True
+def test_equalto(value, other):
+ """Check if an object has the same value as another object:
+
+ .. sourcecode:: jinja
+
+ {% if foo.expression is equalto 42 %}
+ the foo attribute evaluates to the constant 42
+ {% endif %}
+ """
+ return value == other
def test_sameas(value, other):
"""Check if an object points to the same memory address than another
@@ -146,5 +156,6 @@ def test_escaped(value):
'iterable': test_iterable,
'callable': test_callable,
'sameas': test_sameas,
+ 'equalto': test_equalto,
'escaped': test_escaped
}
View
@@ -72,6 +72,17 @@ def test_upper(self):
tmpl = env.from_string('{{ "FOO" is upper }}|{{ "foo" is upper }}')
assert tmpl.render() == 'True|False'
+ def test_equalto(self):
+ tmpl = env.from_string('{{ foo is equalto 12 }}|'
+ '{{ foo is equalto 0 }}|'
+ '{{ foo is equalto (3 * 4) }}|'
+ '{{ bar is equalto "baz" }}|'
+ '{{ bar is equalto "zab" }}|'
+ '{{ bar is equalto ("ba" + "z") }}|'
+ '{{ bar is equalto bar }}|'
+ '{{ bar is equalto foo }}')
+ assert tmpl.render(foo=12, bar="baz") == 'True|False|True|True|False|True|True|False'
+
def test_sameas(self):
tmpl = env.from_string('{{ foo is sameas false }}|'
'{{ 0 is sameas false }}')

0 comments on commit 510fb48

Please sign in to comment.