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
This commit is contained in:
nobu 2016-03-22 05:13:55 +00:00
parent 15af93fcc8
commit 8c22a641d9

View File

@ -390,39 +390,60 @@ class TestRubyOptions < Test::Unit::TestCase
end end
def test_indentation_check def test_indentation_check
Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) {|t| all_assertions do |a|
t.puts "begin" Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) do |t|
t.puts " end" [
t.flush "begin", "if false", "for _ in []", "while false",
err = ["#{t.path}:2: warning: mismatched indentations at 'end' with 'begin' at 1"] "def foo", "class X", "module M",
assert_in_out_err(["-w", t.path], "", [], err) ].each do
assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err) |b, e = 'end'|
src = ["#{b}\n", " #{e}\n"]
k = b[/\A\S+/]
t.rewind a.for("no directives with #{b}") do
t.puts "# -*- warn-indent: false -*-" err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
t.puts "begin" t.rewind
t.puts " end" t.truncate(0)
t.flush t.puts src
assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]') t.flush
assert_in_out_err(["-w", t.path], "", [], err)
assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err)
end
err = ["#{t.path}:4: warning: mismatched indentations at 'end' with 'begin' at 3"] a.for("false directive with #{b}") do
t.rewind t.rewind
t.puts "# -*- warn-indent: false -*-" t.truncate(0)
t.puts "# -*- warn-indent: true -*-" t.puts "# -*- warn-indent: false -*-"
t.puts "begin" t.puts src
t.puts " end" t.flush
t.flush assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
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"] a.for("false and true directives with #{b}") do
t.rewind err = ["#{t.path}:4: warning: mismatched indentations at '#{e}' with '#{k}' at 3"]
t.puts "# -*- warn-indent: true -*-" t.rewind
t.puts "begin" t.truncate(0)
t.puts "# -*- warn-indent: false -*-" t.puts "# -*- warn-indent: false -*-"
t.puts " end" t.puts "# -*- warn-indent: true -*-"
t.flush t.puts src
assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]') t.flush
} assert_in_out_err(["-w", t.path], "", [], err, '[ruby-core:25442]')
end
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 end
def test_notfound def test_notfound