ruby-changes:42153
From: nobu <ko1@a...>
Date: Tue, 22 Mar 2016 14:13:59 +0900 (JST)
Subject: [ruby-changes:42153] nobu:r54227 (trunk): test_rubyoptions.rb: other indentation checks
nobu 2016-03-22 14:13:55 +0900 (Tue, 22 Mar 2016) New Revision: 54227 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54227 Log: test_rubyoptions.rb: other indentation checks * test/ruby/test_rubyoptions.rb (test_indentation_check): assert warnings against other keyword mismatches. Modified files: trunk/test/ruby/test_rubyoptions.rb Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 54226) +++ test/ruby/test_rubyoptions.rb (revision 54227) @@ -390,39 +390,60 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L390 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) - - 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]') - - 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]') - - 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]') - } + 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 + + 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 + + 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 + + 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/