From: Yusuke Endoh Date: 2009-05-07T21:26:43+09:00 Subject: [ruby-dev:38382] [Bug #1442] indentation check and coverage for toplevel do not work Bug #1442: indentation check and coverage for toplevel do not work http://redmine.ruby-lang.org/issues/show/1442 起票者: Yusuke Endoh ステータス: Open, 優先度: Normal カテゴリ: core ruby -v: ruby 1.9.2dev (2009-05-07 trunk 23361) [i686-linux] 遠藤です。 [ruby-dev:38050] を redmine に登録します。 ----- トップレベルのファイルに対してインデント対応チェックと coverage が 動きません。 $ cat test.rb begin end $ ./ruby -vw test.rb ruby 1.9.2dev (2009-02-19 trunk 22427) [i686-linux] $ require したファイルであれば動きます。 $ ./ruby -wr test.rb -e '' /home/mame/work/ruby19/ruby/test.rb:2: warning: mismatched indentations at 'end' with 'begin' at 1 r21079 から r21571 あたりの ruby.c への変更で、トップレベルが eval 相当で評価されるようになったことが原因のようです。 ----- これにあわせて、以下のテストを追加しようと思います。 Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 23361) +++ test/ruby/test_rubyoptions.rb (working copy) @@ -284,4 +284,15 @@ assert_in_out_err(%w(- -#=foo), "#!ruby -s\n", [], /invalid name for global variable - -# \(NameError\)/) end + + def test_indentation_check + t = Tempfile.new(["test_ruby_test_rubyoption", ".rb"]) + t.puts "begin" + t.puts " end" + t.close + assert_in_out_err(["-w", t.path], "", [], /:2: warning: mismatched indentations at 'end' with 'begin' at 1/) + assert_in_out_err(["-wr", t.path, "-e", ""], "", [], /:2: warning: mismatched indentations at 'end' with 'begin' at 1/) + ensure + t.close(true) if t + end end -- Yusuke ENDOH ---------------------------------------- http://redmine.ruby-lang.org