mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Fix tokenzing empty strings
This commit is contained in:
@@ -64,9 +64,17 @@ module Linguist
|
||||
|
||||
# Skip single or double quoted strings
|
||||
elsif s.scan(/"/)
|
||||
s.skip_until(/[^\\]"/)
|
||||
if s.peek(1) == "\""
|
||||
s.getch
|
||||
else
|
||||
s.skip_until(/[^\\]"/)
|
||||
end
|
||||
elsif s.scan(/'/)
|
||||
s.skip_until(/[^\\]'/)
|
||||
if s.peek(1) == "'"
|
||||
s.getch
|
||||
else
|
||||
s.skip_until(/[^\\]'/)
|
||||
end
|
||||
|
||||
# Skip number literals
|
||||
elsif s.scan(/(0x)?\d(\d|\.)*/)
|
||||
|
||||
@@ -20,6 +20,10 @@ class TestTokenizer < Test::Unit::TestCase
|
||||
assert_equal %w(print), tokenize("print 'Josh'")
|
||||
assert_equal %w(print), tokenize('print "Hello \"Josh\""')
|
||||
assert_equal %w(print), tokenize("print 'Hello \\'Josh\\''")
|
||||
assert_equal %w(print), tokenize("print \"Hello\", \"Josh\"")
|
||||
assert_equal %w(print), tokenize("print 'Hello', 'Josh'")
|
||||
assert_equal %w(print), tokenize("print \"Hello\", \"\", \"Josh\"")
|
||||
assert_equal %w(print), tokenize("print 'Hello', '', 'Josh'")
|
||||
end
|
||||
|
||||
def test_skip_number_literals
|
||||
|
||||
Reference in New Issue
Block a user