summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-06 20:03:14 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-06 20:03:14 +0000
commit4b295bb7ca2f4ea4aaee2eaf730fb55aae4f716e (patch)
treea023dd2f7778d1f8da207a3880f071c27e9c0f47 /test/ruby
parent15090079a26e0e432cd3d5df7b2b3d59e4fd3f9a (diff)
merge revision(s) r34399:
* vm_eval.c (vm_call0): should pass block to enumerators. patched by Kazuki Tsujimoto. [ruby-dev:44961][Bug #5731] * vm_eval.c (method_missing), vm_insnhelper.c (vm_call_method): ditto. patched by satoshi shiba. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_object.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 63c1d32bef..db34d14479 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -383,6 +383,57 @@ class TestObject < Test::Unit::TestCase
end
end
+ def test_method_missing_passed_block
+ bug5731 = '[ruby-dev:44961]'
+
+ c = Class.new do
+ def method_missing(meth, *args) yield(meth, *args) end
+ end
+ a = c.new
+ result = nil
+ assert_nothing_raised(LocalJumpError, bug5731) do
+ a.foo {|x| result = x}
+ end
+ assert_equal(:foo, result, bug5731)
+ result = nil
+ e = a.enum_for(:foo)
+ assert_nothing_raised(LocalJumpError, bug5731) do
+ e.each {|x| result = x}
+ end
+ assert_equal(:foo, result, bug5731)
+
+ c = Class.new do
+ def respond_to_missing?(id, priv)
+ true
+ end
+ def method_missing(id, *args, &block)
+ return block.call(:foo, *args)
+ end
+ end
+ foo = c.new
+
+ result = nil
+ assert_nothing_raised(LocalJumpError, bug5731) do
+ foo.foobar {|x| result = x}
+ end
+ assert_equal(:foo, result, bug5731)
+ result = nil
+ assert_nothing_raised(LocalJumpError, bug5731) do
+ foo.enum_for(:foobar).each {|x| result = x}
+ end
+ assert_equal(:foo, result, bug5731)
+
+ result = nil
+ foobar = foo.method(:foobar)
+ foobar.call {|x| result = x}
+ assert_equal(:foo, result, bug5731)
+
+ result = nil
+ foobar = foo.method(:foobar)
+ foobar.enum_for(:call).each {|x| result = x}
+ assert_equal(:foo, result, bug5731)
+ end
+
def test_send_with_no_arguments
assert_raise(ArgumentError) { 1.send }
end