Use a single token for identifiers

This commit is contained in:
Justin Li
2014-10-29 11:28:41 -04:00
parent 4dc682313f
commit a07e382617
4 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ class LexerUnitTest < Minitest::Test
def test_fancy_identifiers
tokens = Lexer.new('hi five?').tokenize
assert_equal [[:id,'hi'], [:id, 'five'], [:question, '?'], [:end_of_string]], tokens
assert_equal [[:id,'hi'], [:id, 'five?'], [:end_of_string]], tokens
end
def test_whitespace
+9
View File
@@ -102,6 +102,15 @@ class VariableUnitTest < Minitest::Test
assert_equal 1000.01, var.name
end
def test_dashes
assert_equal VariableLookup.new('foo-bar'), Variable.new('foo-bar').name
assert_equal VariableLookup.new('foo-bar-2'), Variable.new('foo-bar-2').name
with_error_mode :strict do
assert_raises(Liquid::SyntaxError) { Variable.new('foo - bar') }
end
end
def test_string_with_special_chars
var = Variable.new(%| 'hello! $!@.;"ddasd" ' |)
assert_equal 'hello! $!@.;"ddasd" ', var.name