summaryrefslogtreecommitdiff
path: root/test/irb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-12-26 23:34:27 +0900
committeraycabta <aycabta@gmail.com>2021-01-05 18:04:45 +0900
commitcce72a24119b5c2177100865f52376ca4b32bd9d (patch)
treeea1540b10612ce97737f7aab869255dc3e1bc01c /test/irb
parente91160f7579a572e198067b9c0697c91be1876e7 (diff)
[ruby/irb] Newline in oneliner def doesn't reset indent
This closes ruby/irb#132. https://github.com/ruby/irb/commit/43456dcf5e
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_ruby_lex.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb
index 41b5d49..30bae1e 100644
--- a/test/irb/test_ruby_lex.rb
+++ b/test/irb/test_ruby_lex.rb
@@ -263,6 +263,23 @@ module TestIRB
end
end
+ def test_oneliner_def_in_multiple_lines
+ input_with_correct_indents = [
+ Row.new(%q(def a()=[), nil, 4, 2),
+ Row.new(%q( 1,), nil, 4, 1),
+ Row.new(%q(].), 0, 0, 0),
+ Row.new(%q(to_s), nil, 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
+
PromptRow = Struct.new(:prompt, :content)
class MockIO_DynamicPrompt