summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-31 00:11:26 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-31 00:11:26 +0000
commitffafcd96e66ec6a4b7150616b00bd0bab145671d (patch)
tree00bee4fe35ee0079960fc187fb95802ce3cb9cd8 /test
parentd3818d6b55af209f9e75a3dda098510a525fcd71 (diff)
merges r31436 and r31437 from trunk into ruby_1_9_2.
-- * 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 -- * eval.c (frame_func_id): store result of method_entry_of_iseq() to cfp->me because method_entry_of_iseq() might become expensive. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_method.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 7be70b00a6..3a728e1599 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -78,6 +78,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