ruby/test/ripper/test_lexer.rb
usa 5024abe0cf merge revision(s) 58545,58584: [Backport #13536]
ripper/lexer.rb: nested indented heredoc

	* ext/ripper/lib/ripper/lexer.rb (on_heredoc_dedent): fix for
	  nested indedented here documents, where `Elem`s are nested too.
	  [ruby-core:80977] [Bug #13536]
	ripper/lexer.rb: nested indented heredoc

	* ext/ripper/lib/ripper/lexer.rb (on_heredoc_dedent): insert
	  stripped leading spaces as `on_ignored_sp` elements, so that the
	  original source can be reconsructed.
	  [ruby-core:80977] [Bug #13536]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-30 10:30:56 +00:00

35 lines
611 B
Ruby

# frozen_string_literal: true
begin
require_relative 'dummyparser'
require 'test/unit'
ripper_test = true
module TestRipper; end
rescue LoadError
end
class TestRipper::Lexer < Test::Unit::TestCase
def test_nested_dedent_heredoc
bug = '[ruby-core:80977] [Bug #13536]'
str = <<~'E'
<<~"D"
#{
<<~"B"
this must be a valid ruby
B
}
D
E
assert_equal(str, Ripper.tokenize(str).join(""), bug)
str = <<~'E'
<<~"D"
#{
<<~"B"
this must be a valid ruby
B
}
D
E
assert_equal(str, Ripper.tokenize(str).join(""), bug)
end
end