mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (frame_func_id): __method__ return different name from
methods defined by Module#define_method with a same block. [ruby-core:35386] fixes #4606 * eval (method_entry_of_iseq): new helper function. search control frame stack for a method entry which has given iseq. * test/ruby/test_method.rb: add tests for #4696 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
09c2f41211
commit
5358a5c016
3 changed files with 56 additions and 2 deletions
|
@ -92,6 +92,32 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_nil(eval("class TestCallee; __method__; end"))
|
||||
end
|
||||
|
||||
def test_method_in_define_method_block
|
||||
bug4606 = '[ruby-core:35386]'
|
||||
c = Class.new do
|
||||
[:m1, :m2].each do |m|
|
||||
define_method(m) do
|
||||
__method__
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_equal(:m1, c.new.m1, bug4606)
|
||||
assert_equal(:m2, c.new.m2, bug4606)
|
||||
end
|
||||
|
||||
def test_method_in_block_in_define_method_block
|
||||
bug4606 = '[ruby-core:35386]'
|
||||
c = Class.new do
|
||||
[:m1, :m2].each do |m|
|
||||
define_method(m) do
|
||||
tap { return __method__ }
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_equal(:m1, c.new.m1, bug4606)
|
||||
assert_equal(:m2, c.new.m2, bug4606)
|
||||
end
|
||||
|
||||
def test_body
|
||||
o = Object.new
|
||||
def o.foo; end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue