fixed conditions with strings containing "and"/"or"

This commit is contained in:
James MacAulay
2009-09-14 15:01:26 -04:00
parent d1d6febfc1
commit f42ce88456
4 changed files with 23 additions and 8 deletions
+8
View File
@@ -36,6 +36,14 @@ class IfElseTest < Test::Unit::TestCase
assert_template_result('','{% if a == false or b == false %} YES {% endif %}', 'a' => true, 'b' => true)
end
def test_comparison_of_strings_containing_and_or_or
assert_nothing_raised do
awful_markup = "a == 'and' and b == 'or' and c == 'foo and bar' and d == 'bar or baz' and e == 'foo' and foo and bar"
assigns = {'a' => 'and', 'b' => 'or', 'c' => 'foo and bar', 'd' => 'bar or baz', 'e' => 'foo', 'foo' => true, 'bar' => true}
assert_template_result(' YES ',"{% if #{awful_markup} %} YES {% endif %}", assigns)
end
end
def test_if_and
assert_template_result(' YES ','{% if true and true %} YES {% endif %}')
assert_template_result('','{% if false and true %} YES {% endif %}')
+6 -6
View File
@@ -17,31 +17,31 @@ class StatementsTest < Test::Unit::TestCase
assert_equal expected, Template.parse(text).render
end
def test_true_lq_true
def test_zero_gt_zero
text = %| {% if 0 > 0 %} true {% else %} false {% endif %} |
expected = %| false |
assert_equal expected, Template.parse(text).render
end
def test_one_lq_zero
def test_one_gt_zero
text = %| {% if 1 > 0 %} true {% else %} false {% endif %} |
expected = %| true |
assert_equal expected, Template.parse(text).render
end
def test_zero_lq_one
def test_zero_lt_one
text = %| {% if 0 < 1 %} true {% else %} false {% endif %} |
expected = %| true |
assert_equal expected, Template.parse(text).render
end
def test_zero_lq_or_equal_one
def test_zero_lt_or_equal_zero
text = %| {% if 0 <= 0 %} true {% else %} false {% endif %} |
expected = %| true |
assert_equal expected, Template.parse(text).render
end
def test_zero_lq_or_equal_one_involving_nil
def test_zero_lt_or_equal_zero_involving_nil
text = %| {% if null <= 0 %} true {% else %} false {% endif %} |
expected = %| false |
assert_equal expected, Template.parse(text).render
@@ -52,7 +52,7 @@ class StatementsTest < Test::Unit::TestCase
assert_equal expected, Template.parse(text).render
end
def test_zero_lqq_or_equal_one
def test_zero_gt_or_equal_zero
text = %| {% if 0 >= 0 %} true {% else %} false {% endif %} |
expected = %| true |
assert_equal expected, Template.parse(text).render