New variable parser!

This commit is contained in:
Tristan Hume
2013-07-25 11:38:57 -04:00
parent f43e973e67
commit 4da7b36139
5 changed files with 76 additions and 15 deletions
+4 -2
View File
@@ -31,9 +31,11 @@ class ParsingQuirksTest < Test::Unit::TestCase
def test_error_on_empty_filter
assert_nothing_raised do
Template.parse("{{test |a|b|}}")
Template.parse("{{test}}")
Template.parse("{{|test|}}")
Template.parse("{{|test}}")
end
assert_raise(SyntaxError) do
Template.parse("{{test |a|b|}}")
end
end
+6 -6
View File
@@ -73,8 +73,8 @@ class VariableTest < Test::Unit::TestCase
end
def test_symbol
var = Variable.new("http://disney.com/logo.gif | image: 'med' ")
assert_equal 'http://disney.com/logo.gif', var.name
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
@@ -114,10 +114,10 @@ class VariableTest < Test::Unit::TestCase
assert_equal [['things',["greeting: \"world\"","farewell: 'goodbye'"]]], var.filters
end
def test_lax_filter_argument_parsing
var = Variable.new(%! number_of_comments | pluralize: 'comment': 'comments' !)
assert_equal 'number_of_comments', var.name
assert_equal [['pluralize',["'comment'","'comments'"]]], var.filters
def test_strict_filter_argument_parsing
assert_raises(SyntaxError) do
Variable.new(%! number_of_comments | pluralize: 'comment': 'comments' !)
end
end
end