Initial options passing

This commit is contained in:
Tristan Hume
2013-07-30 14:44:41 -04:00
parent 1458396733
commit 84f0c1bef8
8 changed files with 31 additions and 37 deletions
+5 -7
View File
@@ -70,13 +70,11 @@ class ErrorHandlingTest < Test::Unit::TestCase
end
def test_lax_unrecognized_operator
with_lax_parsing do
assert_nothing_raised do
template = Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ')
assert_equal ' Liquid error: Unknown operator =! ', template.render
assert_equal 1, template.errors.size
assert_equal Liquid::ArgumentError, template.errors.first.class
end
assert_nothing_raised do
template = Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', :error_mode => :lax)
assert_equal ' Liquid error: Unknown operator =! ', template.render
assert_equal 1, template.errors.size
assert_equal Liquid::ArgumentError, template.errors.first.class
end
end
+4 -9
View File
@@ -30,7 +30,6 @@ class ParsingQuirksTest < Test::Unit::TestCase
end
def test_error_on_empty_filter
Template.error_mode = :strict
assert_nothing_raised do
Template.parse("{{test}}")
Template.parse("{{|test}}")
@@ -41,7 +40,6 @@ class ParsingQuirksTest < Test::Unit::TestCase
end
def test_meaningless_parens_error
Template.error_mode = :strict
assert_raise(SyntaxError) do
markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false"
Template.parse("{% if #{markup} %} YES {% endif %}")
@@ -49,7 +47,6 @@ class ParsingQuirksTest < Test::Unit::TestCase
end
def test_unexpected_characters_syntax_error
Template.error_mode = :strict
assert_raise(SyntaxError) do
markup = "true && false"
Template.parse("{% if #{markup} %} YES {% endif %}")
@@ -61,12 +58,10 @@ class ParsingQuirksTest < Test::Unit::TestCase
end
def test_no_error_on_lax_empty_filter
with_lax_parsing do
assert_nothing_raised do
Template.parse("{{test |a|b|}}")
Template.parse("{{test}}")
Template.parse("{{|test|}}")
end
assert_nothing_raised do
Template.parse("{{test |a|b|}}", :error_mode => :lax)
Template.parse("{{test}}", :error_mode => :lax)
Template.parse("{{|test|}}", :error_mode => :lax)
end
end
+6 -10
View File
@@ -73,11 +73,9 @@ class VariableTest < Test::Unit::TestCase
end
def test_symbol
with_lax_parsing do
var = Variable.new("http://disney.com/logo.gif | image: 'med' ")
assert_equal "http://disney.com/logo.gif", var.name
assert_equal [["image",["'med'"]]], var.filters
end
var = Variable.new("http://disney.com/logo.gif | image: 'med' ", :error_mode => :lax)
assert_equal "http://disney.com/logo.gif", var.name
assert_equal [["image",["'med'"]]], var.filters
end
def test_string_to_filter
@@ -123,11 +121,9 @@ class VariableTest < Test::Unit::TestCase
end
def test_lax_filter_argument_parsing
with_lax_parsing do
var = Variable.new(%! number_of_comments | pluralize: 'comment': 'comments' !)
assert_equal 'number_of_comments', var.name
assert_equal [['pluralize',["'comment'","'comments'"]]], var.filters
end
var = Variable.new(%! number_of_comments | pluralize: 'comment': 'comments' !, :error_mode => :lax)
assert_equal 'number_of_comments', var.name
assert_equal [['pluralize',["'comment'","'comments'"]]], var.filters
end
def test_strict_filter_argument_parsing