Project

General

Profile

Actions

Bug #1442

closed

indentation check and coverage for toplevel do not work

Added by mame (Yusuke Endoh) over 16 years ago. Updated over 14 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-05-07 trunk 23361) [i686-linux]
Backport:
[ruby-dev:38382]

Description

=begin
遠藤です。

[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
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0