diff options
author | aycabta <aycabta@gmail.com> | 2021-01-03 03:25:47 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-01-05 18:06:34 +0900 |
commit | 5a1866caff1ec7d924c4101ea05e9d460b6ef3ae (patch) | |
tree | 6289a03b84007f4f7e5088e70bc83add918d2ecf /test/irb/test_ruby_lex.rb | |
parent | 505e01fe12007382aa2cd4b7231698597f563b42 (diff) |
[ruby/irb] Use Ripper::Lexer#scan to take broken tokens
ref. https://github.com/ruby/reline/pull/242
https://github.com/ruby/irb/commit/54f90cb6c9
Diffstat (limited to 'test/irb/test_ruby_lex.rb')
-rw-r--r-- | test/irb/test_ruby_lex.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 69fa1f3f33..0c7c9f2704 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -367,6 +367,25 @@ module TestIRB end end + def test_broken_heredoc + if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') + skip 'This test needs Ripper::Lexer#scan to take broken tokens' + end + input_with_correct_indents = [ + Row.new(%q(def foo), nil, 2, 1), + Row.new(%q( <<~Q), nil, 2, 1), + Row.new(%q( Qend), nil, 2, 1), + ] + + lines = [] + input_with_correct_indents.each do |row| + lines << row.content + assert_indenting(lines, row.current_line_spaces, false) + assert_indenting(lines, row.new_line_spaces, true) + assert_nesting_level(lines, row.nesting_level) + end + end + PromptRow = Struct.new(:prompt, :content) class MockIO_DynamicPrompt |