Skip to content

Commit d3f8522

Browse files
authored
Merge pull request #478 from aycabta/fix-percent-string-literal-with-operator
Fix percent string literal with operator
2 parents 4acef28 + 4f707ae commit d3f8522

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ def identify_string(ltype, quoted = ltype, type = nil)
12991299
str = if ltype == quoted and %w[" ' /].include? ltype then
13001300
ltype.dup
13011301
else
1302-
"%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]||quoted}"
1302+
"%#{type}#{PERCENT_PAREN_REV[quoted]||quoted}"
13031303
end
13041304

13051305
subtype = nil

test/test_rdoc_parser_ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,7 @@ def test_sanity_interpolation_crazy
28592859
def test_sanity_interpolation_curly
28602860
util_parser '%{ #{} }'
28612861

2862-
assert_equal '%Q{ #{} }', @parser.get_tk.text
2862+
assert_equal '%{ #{} }', @parser.get_tk.text
28632863
assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
28642864
end
28652865

test/test_rdoc_ruby_lex.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ def test_class_tokenize_percent_w_quote
331331
assert_equal expected, tokens
332332
end
333333

334+
def test_class_tokenize_percent_sign_quote
335+
tokens = RDoc::RubyLex.tokenize '%%hi%', nil
336+
337+
expected = [
338+
@TK::TkSTRING.new( 0, 1, 0, '%%hi%'),
339+
@TK::TkNL .new( 5, 1, 5, "\n"),
340+
]
341+
342+
assert_equal expected, tokens
343+
end
344+
334345
def test_class_tokenize_regexp
335346
tokens = RDoc::RubyLex.tokenize "/hay/", nil
336347

0 commit comments

Comments
 (0)