summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-30 01:49:21 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-30 01:49:21 +0000
commit59f5fa102af7777ba1c620b764fa05f62dad9b54 (patch)
tree705fcdae3058eec37e84035030f7deadf0c34136 /test
parent7eca2a43b98d7a752a9dc1c19a0955f343b3383d (diff)
* vm_method.c (rb_undef): raise a NameError if the original method
of a refined method is not defined. * vm_insnhelper.c (rb_method_entry_eq): added NULL check to avoid SEGV. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_refinement.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 60681b2f1a..92f293cad5 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1016,6 +1016,50 @@ class TestRefinement < Test::Unit::TestCase
assert_not_send([FooSub, :method_defined?, :z])
end
+ def test_undef_refined_method
+ bug8966 = '[ruby-core:57466] [Bug #8966]'
+
+ assert_in_out_err([], <<-INPUT, ["NameError"], [], bug8966)
+ module Foo
+ refine Object do
+ def foo
+ puts "foo"
+ end
+ end
+ end
+
+ using Foo
+
+ class Object
+ begin
+ undef foo
+ rescue Exception => e
+ p e.class
+ end
+ end
+ INPUT
+
+ assert_in_out_err([], <<-INPUT, ["NameError"], [], bug8966)
+ module Foo
+ refine Object do
+ def foo
+ puts "foo"
+ end
+ end
+ end
+
+ # without `using Foo'
+
+ class Object
+ begin
+ undef foo
+ rescue Exception => e
+ p e.class
+ end
+ end
+ INPUT
+ end
+
private
def eval_using(mod, s)