Skip to content

Commit

Permalink
Merge pull request #471 from aycabta/stop-dropping-continuing-backslash
Browse files Browse the repository at this point in the history
Stop dropping continuing backslash
  • Loading branch information
hsbt authored Aug 1, 2017
2 parents 69222fd + cb349b1 commit 962e029
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ def identify_string(ltype, quoted = ltype, type = nil)
elsif ch == '\\'
if %w[' /].include? @ltype then
case ch = getc
when "\\", "\n", "'"
when "\n", "'"
when @ltype
str << ch
else
Expand Down
11 changes: 11 additions & 0 deletions test/test_rdoc_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ def test_class_tokenize_regexp_escape
assert_equal expected, tokens
end

def test_class_tokenize_regexp_continuing_backslash
tokens = RDoc::RubyLex.tokenize "/(?<!\\\\)\\n\z/", nil

expected = [
@TK::TkREGEXP.new( 0, 1, 0, "/(?<!\\\\)\\n\z/"),
@TK::TkNL .new(12, 1, 12, "\n"),
]

assert_equal expected, tokens
end

def test_class_tokenize_string
tokens = RDoc::RubyLex.tokenize "'hi'", nil

Expand Down

0 comments on commit 962e029

Please sign in to comment.