From a7e1820a9f9c0b6c84c281c171c105a34aa16738 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 4 Jul 2012 02:11:37 +0000 Subject: __callee__ fix * eval.c (rb_frame_callee, rb_f_callee_name): fix to return the called id. * vm_insnhelper.c (vm_push_frame): set proper method entry. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_method.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index e299b722ee..6a5a75cf20 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -90,6 +90,20 @@ class TestMethod < Test::Unit::TestCase assert_equal(:m, Class.new {define_method(:m) {__method__}}.new.m) assert_equal(:m, Class.new {define_method(:m) {tap{return __method__}}}.new.m) assert_nil(eval("class TestCallee; __method__; end")) + + assert_equal(:test_callee, __callee__) + [ + ["method", Class.new {def m; __callee__; end},], + ["block", Class.new {def m; tap{return __callee__}; end},], + ["define_method", Class.new {define_method(:m) {__callee__}}], + ["define_method block", Class.new {define_method(:m) {tap{return __callee__}}}], + ].each do |mesg, c| + c.class_eval {alias m2 m} + o = c.new + assert_equal(:m, o.m, mesg) + assert_equal(:m2, o.m2, mesg) + end + assert_nil(eval("class TestCallee; __callee__; end")) end def test_method_in_define_method_block -- cgit v1.2.3