aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-22 05:13:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-22 05:13:55 +0000
commit8c22a641d9094add9430e050a405c20d38e1c328 (patch)
tree4a6dfd6f7bb4be25716a88be8c8c9da87f3a6122
parent15af93fcc824cd94222ccb5616a97fd5da08b5f6 (diff)
downloadruby-8c22a641d9094add9430e050a405c20d38e1c328.tar.gz
test_rubyoptions.rb: other indentation checks
* test/ruby/test_rubyoptions.rb (test_indentation_check): assert warnings against other keyword mismatches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_rubyoptions.rb81
1 files changed, 51 insertions, 30 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 1705839bd7..27520b6cb3 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -390,39 +390,60 @@ class TestRubyOptions < Test::Unit::TestCase
end
def test_indentation_check
- Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) {|t|
- t.puts "begin"
- t.puts " end"
- t.flush
- err = ["#{t.path}:2: warning: mismatched indentations at 'end' with 'begin' at 1"]
- assert_in_out_err(["-w", t.path], "", [], err)
- assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err)
+ all_assertions do |a|
+ Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) do |t|
+ [
+ "begin", "if false", "for _ in []", "while false",
+ "def foo", "class X", "module M",
+ ].each do
+ |b, e = 'end'|
+ src = ["#{b}\n", " #{e}\n"]
+ k = b[/\A\S+/]
+
+ a.for("no directives with #{b}") do
+ err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
+ t.rewind
+ t.truncate(0)
+ t.puts src
+ t.flush
+ assert_in_out_err(["-w", t.path], "", [], err)
+ assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err)
+ end
- t.rewind
- t.puts "# -*- warn-indent: false -*-"
- t.puts "begin"
- t.puts " end"
- t.flush
- assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
+ a.for("false directive with #{b}") do
+ t.rewind
+ t.truncate(0)
+ t.puts "# -*- warn-indent: false -*-"
+ t.puts src
+ t.flush
+ assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
+ end
- err = ["#{t.path}:4: warning: mismatched indentations at 'end' with 'begin' at 3"]
- t.rewind
- t.puts "# -*- warn-indent: false -*-"
- t.puts "# -*- warn-indent: true -*-"
- t.puts "begin"
- t.puts " end"
- t.flush
- assert_in_out_err(["-w", t.path], "", [], err, '[ruby-core:25442]')
+ a.for("false and true directives with #{b}") do
+ err = ["#{t.path}:4: warning: mismatched indentations at '#{e}' with '#{k}' at 3"]
+ t.rewind
+ t.truncate(0)
+ t.puts "# -*- warn-indent: false -*-"
+ t.puts "# -*- warn-indent: true -*-"
+ t.puts src
+ t.flush
+ assert_in_out_err(["-w", t.path], "", [], err, '[ruby-core:25442]')
+ end
- err = ["#{t.path}:4: warning: mismatched indentations at 'end' with 'begin' at 2"]
- t.rewind
- t.puts "# -*- warn-indent: true -*-"
- t.puts "begin"
- t.puts "# -*- warn-indent: false -*-"
- t.puts " end"
- t.flush
- assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
- }
+ a.for("false directives after #{b}") do
+ err = ["#{t.path}:4: warning: mismatched indentations at '#{e}' with '#{k}' at 2"]
+ t.rewind
+ t.truncate(0)
+ t.puts "# -*- warn-indent: true -*-"
+ t.puts src[0]
+ t.puts "# -*- warn-indent: false -*-"
+ t.puts src[1]
+ t.flush
+ assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
+ end
+ end
+ end
+ end
end
def test_notfound