aboutsummaryrefslogtreecommitdiffstats
path: root/test/irb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-06-25 23:56:03 +0900
committeraycabta <aycabta@gmail.com>2020-08-18 14:38:01 +0900
commit5474007d6119a5ac021bc9fc1bbf932aab5f0dbb (patch)
tree5dd78aac9cfe002906a7dc427732269e1ac5ecdc /test/irb
parent701217572f865375b137d2830d4da0c3e78de046 (diff)
downloadruby-5474007d6119a5ac021bc9fc1bbf932aab5f0dbb.tar.gz
[ruby/irb] Support oneline method definition
https://github.com/ruby/irb/commit/826ae909c9
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_ruby_lex.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb
index afbad63eed..db15593f37 100644
--- a/test/irb/test_ruby_lex.rb
+++ b/test/irb/test_ruby_lex.rb
@@ -205,5 +205,34 @@ module TestIRB
assert_indenting(lines, row.new_line_spaces, true)
end
end
+
+ def test_oneliner_method_definition
+ input_with_correct_indents = [
+ Row.new(%q(class A), nil, 2),
+ Row.new(%q( def foo0), nil, 4),
+ Row.new(%q( 3), nil, 4),
+ Row.new(%q( end), 2, 2),
+ Row.new(%q( def foo1()), nil, 4),
+ Row.new(%q( 3), nil, 4),
+ Row.new(%q( end), 2, 2),
+ Row.new(%q( def foo2(a, b)), nil, 4),
+ Row.new(%q( a + b), nil, 4),
+ Row.new(%q( end), 2, 2),
+ Row.new(%q( def foo3 a, b), nil, 4),
+ Row.new(%q( a + b), nil, 4),
+ Row.new(%q( end), 2, 2),
+ Row.new(%q( def bar0() = 3), nil, 2),
+ Row.new(%q( def bar1(a) = a), nil, 2),
+ Row.new(%q( def bar2(a, b) = a + b), 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