From fc54af8aa136888d8c5a8bf7d68594f979a43946 Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 22 Jan 2021 11:51:54 +0900 Subject: [ruby/irb] Indent correctly with keyword "for" and "in" https://github.com/ruby/irb/commit/47c83ea724 --- test/irb/test_ruby_lex.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/irb') diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index ed4944afc6..7a001116ba 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -333,6 +333,38 @@ module TestIRB end end + def test_corresponding_syntax_to_keyword_for + input_with_correct_indents = [ + Row.new(%q(for i in [1]), nil, 2, 1), + Row.new(%q( puts i), nil, 2, 1), + Row.new(%q(end), 0, 0, 0), + ] + + 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 + + def test_corresponding_syntax_to_keyword_for_with_do + input_with_correct_indents = [ + Row.new(%q(for i in [1] do), nil, 2, 1), + Row.new(%q( puts i), nil, 2, 1), + Row.new(%q(end), 0, 0, 0), + ] + + 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 + def test_heredoc_with_indent input_with_correct_indents = [ Row.new(%q(<<~Q), nil, 0, 0), -- cgit v1.2.3