aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-08 15:29:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-08 15:29:48 +0000
commit6cde2d359a76e0c342f5f3ebe85578556ee74c1f (patch)
treea59408baf2d932d10a78f8da295f83ef40503575 /test
parent3c4ade20195ed345c06852dedb20d106000cbe90 (diff)
downloadruby-6cde2d359a76e0c342f5f3ebe85578556ee74c1f.tar.gz
vm_method.c: fix aliased original name
* vm_method.c (rb_alias): the original name should be properly available method_added method, set the name before calling the hook. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_alias.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb
index d5bbce3dda..3fc1bb4000 100644
--- a/test/ruby/test_alias.rb
+++ b/test/ruby/test_alias.rb
@@ -203,4 +203,32 @@ class TestAlias < Test::Unit::TestCase
assert_equal(obj.method(:bar), obj.method(:foo))
assert_equal(obj.method(:foo), obj.method(:bar))
end
+
+ def test_alias_class_method_added
+ name = nil
+ k = Class.new {
+ def foo;end
+ def self.method_added(mid)
+ @name = instance_method(mid).original_name
+ end
+ alias bar foo
+ name = @name
+ }
+ assert_equal(:foo, k.instance_method(:bar).original_name)
+ assert_equal(:foo, name)
+ end
+
+ def test_alias_module_method_added
+ name = nil
+ k = Module.new {
+ def foo;end
+ def self.method_added(mid)
+ @name = instance_method(mid).original_name
+ end
+ alias bar foo
+ name = @name
+ }
+ assert_equal(:foo, k.instance_method(:bar).original_name)
+ assert_equal(:foo, name)
+ end
end