aboutsummaryrefslogtreecommitdiffstats
path: root/test/irb
diff options
context:
space:
mode:
authorNobuhiro IMAI <nov@yo.rim.or.jp>2020-03-02 22:16:11 +0900
committeraycabta <aycabta@gmail.com>2020-07-22 02:31:47 +0900
commitf6e789e3b07ede0b5842c7f64940e4cd9ed876fd (patch)
treeac0dbfbd17e187fa7515ea28fd732c44b79ab094 /test/irb
parent22d38d54751e3e23144d4b4e1fb8ed67626c89c8 (diff)
downloadruby-f6e789e3b07ede0b5842c7f64940e4cd9ed876fd.tar.gz
[ruby/irb] handle rescue modifier properly
https://github.com/ruby/irb/commit/6de1341f5e
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_ruby_lex.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb
index 7768a6a5dd..afbad63eed 100644
--- a/test/irb/test_ruby_lex.rb
+++ b/test/irb/test_ruby_lex.rb
@@ -178,5 +178,32 @@ module TestIRB
assert_indenting(lines, row.new_line_spaces, true)
end
end
+
+ def test_mixed_rescue
+ input_with_correct_indents = [
+ Row.new(%q(def m), nil, 2),
+ Row.new(%q( begin), nil, 4),
+ Row.new(%q( begin), nil, 6),
+ Row.new(%q( x = a rescue 4), nil, 6),
+ Row.new(%q( y = [(a rescue 5)]), nil, 6),
+ Row.new(%q( [x, y]), nil, 6),
+ Row.new(%q( rescue => e), 4, 6),
+ Row.new(%q( raise e rescue 8), nil, 6),
+ Row.new(%q( end), 4, 4),
+ Row.new(%q( rescue), 2, 4),
+ Row.new(%q( raise rescue 11), nil, 4),
+ Row.new(%q( end), 2, 2),
+ Row.new(%q(rescue => e), 0, 2),
+ Row.new(%q( raise e rescue 14), nil, 2),
+ Row.new(%q(end), 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)
+ end
+ end
end
end