mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ripper_state_lex.rb: chomp CR
* lib/rdoc/parser/ripper_state_lex.rb (RDoc::Parser::RipperStateLex): chomp newline, including CR, from here document terminator. Closes: ruby/rdoc#694 Closes: ruby/rdoc#697 Closes: ruby/rdoc#705
This commit is contained in:
parent
a6a26e42b1
commit
6566919176
2 changed files with 17 additions and 1 deletions
|
@ -494,7 +494,8 @@ class RDoc::Parser::RipperStateLex
|
|||
private def heredoc_end?(name, indent, tk)
|
||||
result = false
|
||||
if :on_heredoc_end == tk[:kind] then
|
||||
tk_name = (indent ? tk[:text].gsub(/^ *(.+)\n?$/, '\1') : tk[:text].gsub(/\n\z/, ''))
|
||||
tk_name = tk[:text].chomp
|
||||
tk_name.lstrip! if indent
|
||||
if name == tk_name
|
||||
result = true
|
||||
end
|
||||
|
|
|
@ -2914,6 +2914,21 @@ EXPECTED
|
|||
assert_equal expected, markup_code
|
||||
end
|
||||
|
||||
def test_parse_heredoc_end
|
||||
code = "A = <<eos\n""OK\n""eos\n"
|
||||
util_parser code
|
||||
@parser.parse_statements @top_level
|
||||
@parser.scan
|
||||
c = @top_level.classes.first.constants.first
|
||||
assert_equal("A", c.name)
|
||||
|
||||
util_parser code.gsub(/$/, "\r")
|
||||
@parser.parse_statements @top_level
|
||||
@parser.scan
|
||||
c = @top_level.classes.first.constants.first
|
||||
assert_equal("A", c.name)
|
||||
end
|
||||
|
||||
def test_parse_statements_method_oneliner_with_regexp
|
||||
util_parser <<RUBY
|
||||
class Foo
|
||||
|
|
Loading…
Reference in a new issue