ruby-changes:27170
From: nobu <ko1@a...>
Date: Wed, 13 Feb 2013 18:10:24 +0900 (JST)
Subject: [ruby-changes:27170] nobu:r39222 (trunk): proc.c: show the given name
nobu 2013-02-13 18:10:12 +0900 (Wed, 13 Feb 2013) New Revision: 39222 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39222 Log: proc.c: show the given name * proc.c (method_inspect): show the given name primarily, and original_id if aliased. [ruby-core:52048] [Bug #7806] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_method.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39221) +++ ChangeLog (revision 39222) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Feb 13 18:10:09 2013 Nobuyoshi Nakada <nobu@r...> + + * proc.c (method_inspect): show the given name primarily, and + original_id if aliased. [ruby-core:52048] [Bug #7806] + Wed Feb 13 17:56:39 2013 Nobuyoshi Nakada <nobu@r...> * configure.in (warnflags): disable -Werror by default unless Index: proc.c =================================================================== --- proc.c (revision 39221) +++ proc.c (revision 39222) @@ -1958,7 +1958,11 @@ method_inspect(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L1958 } } rb_str_buf_cat2(str, sharp); - rb_str_append(str, rb_id2str(data->me->def->original_id)); + rb_str_append(str, rb_id2str(data->id)); + if (data->id != data->me->def->original_id) { + rb_str_catf(str, "(%"PRIsVALUE")", + rb_id2str(data->me->def->original_id)); + } if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { rb_str_buf_cat2(str, " (not-implemented)"); } Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 39221) +++ test/ruby/test_method.rb (revision 39222) @@ -189,6 +189,11 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L189 assert_equal(class << o; self; end, m.owner) assert_equal(:foo, m.unbind.name) assert_equal(class << o; self; end, m.unbind.owner) + class << o + alias bar foo + end + m = o.method(:bar) + assert_equal(:bar, m.name) end def test_instance_method @@ -311,6 +316,12 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L316 c2.class_eval { private :foo } m2 = c2.new.method(:foo) assert_equal("#<Method: #{ c2.inspect }(#{ c.inspect })#foo>", m2.inspect) + + bug7806 = '[ruby-core:52048] [Bug #7806]' + c3 = Class.new(c) + c3.class_eval { alias bar foo } + m3 = c3.new.method(:bar) + assert_equal("#<Method: #{ c3.inspect }#bar(foo)>", m3.inspect, bug7806) end def test_callee_top_level -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/