summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-17 17:34:22 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-17 17:34:22 +0000
commit57b26f83051d13442ffa6269230ea9d5803b6d1b (patch)
tree0180d96b1f83f420f5155275ecce133dcd606752 /test
parent4c9a4c333102faf6b905e26300151c81780411a2 (diff)
merge revision(s) 43334: [Backport #9030]
* vm_insnhelper.c (vm_call_method): set ci->me to 0 when the original method of a refined method is undef to avoid SEGV. * vm_method.c (rb_method_entry_without_refinements): return 0 when the original method of a refined method is undef to avoid SEGV. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index b9d9c3e30d..2110221fc1 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -905,6 +905,56 @@ class TestRefinement < Test::Unit::TestCase
INPUT
end
+ def test_refine_undefed_method_and_call
+ assert_in_out_err([], <<-INPUT, ["NoMethodError"], [])
+ $VERBOSE = nil #to suppress warning "Refinements are experimental, ..."
+ class Foo
+ def foo
+ end
+
+ undef foo
+ end
+
+ module FooExt
+ refine Foo do
+ def foo
+ end
+ end
+ end
+
+ begin
+ Foo.new.foo
+ rescue => e
+ p e.class
+ end
+ INPUT
+ end
+
+ def test_refine_undefed_method_and_send
+ assert_in_out_err([], <<-INPUT, ["NoMethodError"], [])
+ $VERBOSE = nil #to suppress warning "Refinements are experimental, ..."
+ class Foo
+ def foo
+ end
+
+ undef foo
+ end
+
+ module FooExt
+ refine Foo do
+ def foo
+ end
+ end
+ end
+
+ begin
+ Foo.new.send(:foo)
+ rescue => e
+ p e.class
+ end
+ INPUT
+ end
+
private
def eval_using(mod, s)