summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-07 15:45:10 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-07 15:47:40 +0900
commitd548073f68ae719933c328686df224f74a60d366 (patch)
tree6a831188d76894d6a0efcd90ec0def0235fa1c20 /test
parent789e49dc7e36f2c19a3df6dfa348e95b7105061c (diff)
Enable indentation warning against `if` just after `else`
```ruby if false puts 'false' else if true puts 'true' end # -:5: warning: mismatched indentations at 'end' with 'if' at 3 end ``` [Feature #15990]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_rubyoptions.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 2f78461f2f..d63ca5da4d 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -491,14 +491,17 @@ class TestRubyOptions < Test::Unit::TestCase
["begin", "ensure ; end"],
[" case nil", "when true; end"],
["case nil; when true", "end"],
+ ["if false;", "end", "if true\nelse ", "end"],
].each do
- |b, e = 'end'|
- src = ["#{b}\n", " #{e}\n"]
+ |b, e = 'end', pre = nil, post = nil|
+ src = ["#{pre}#{b}\n", " #{e}\n#{post}"]
k = b[/\A\s*(\S+)/, 1]
e = e[/\A\s*(\S+)/, 1]
+ n = 2
+ n += pre.count("\n") if pre
a.for("no directives with #{b}") do
- err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
+ err = ["#{t.path}:#{n}: warning: mismatched indentations at '#{e}' with '#{k}' at #{n-1}"]
t.rewind
t.truncate(0)
t.puts src
@@ -517,7 +520,7 @@ class TestRubyOptions < Test::Unit::TestCase
end
a.for("false and true directives with #{b}") do
- err = ["#{t.path}:4: warning: mismatched indentations at '#{e}' with '#{k}' at 3"]
+ err = ["#{t.path}:#{n+2}: warning: mismatched indentations at '#{e}' with '#{k}' at #{n+1}"]
t.rewind
t.truncate(0)
t.puts "# -*- warn-indent: false -*-"
@@ -539,7 +542,7 @@ class TestRubyOptions < Test::Unit::TestCase
end
a.for("BOM with #{b}") do
- err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
+ err = ["#{t.path}:#{n}: warning: mismatched indentations at '#{e}' with '#{k}' at #{n-1}"]
t.rewind
t.truncate(0)
t.print "\u{feff}"