Skip to content

Commit

Permalink
Merge pull request #478 from aycabta/fix-percent-string-literal-with-…
Browse files Browse the repository at this point in the history
…operator

Fix percent string literal with operator
  • Loading branch information
hsbt authored Aug 8, 2017
2 parents 4acef28 + 4f707ae commit d3f8522
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ def identify_string(ltype, quoted = ltype, type = nil)
str = if ltype == quoted and %w[" ' /].include? ltype then
ltype.dup
else
"%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]||quoted}"
"%#{type}#{PERCENT_PAREN_REV[quoted]||quoted}"
end

subtype = nil
Expand Down
2 changes: 1 addition & 1 deletion test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,7 @@ def test_sanity_interpolation_crazy
def test_sanity_interpolation_curly
util_parser '%{ #{} }'

assert_equal '%Q{ #{} }', @parser.get_tk.text
assert_equal '%{ #{} }', @parser.get_tk.text
assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
end

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 @@ -331,6 +331,17 @@ def test_class_tokenize_percent_w_quote
assert_equal expected, tokens
end

def test_class_tokenize_percent_sign_quote
tokens = RDoc::RubyLex.tokenize '%%hi%', nil

expected = [
@TK::TkSTRING.new( 0, 1, 0, '%%hi%'),
@TK::TkNL .new( 5, 1, 5, "\n"),
]

assert_equal expected, tokens
end

def test_class_tokenize_regexp
tokens = RDoc::RubyLex.tokenize "/hay/", nil

Expand Down

0 comments on commit d3f8522

Please sign in to comment.