diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 8effe02310..75ec959ad5 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -265,6 +265,26 @@ class TestObject < Test::Unit::TestCase c.instance_eval { remove_method(:foo) } end + c = Class.new do + def meth1; "meth" end + end + d = Class.new(c) do + alias meth2 meth1 + end + o1 = c.new + assert_respond_to(o1, :meth1) + assert_equal("meth", o1.meth1) + o2 = d.new + assert_respond_to(o2, :meth1) + assert_equal("meth", o2.meth1) + assert_respond_to(o2, :meth2) + assert_equal("meth", o2.meth2) + d.class_eval do + remove_method :meth2 + end + bug2202 = '[ruby-core:26074]' + assert_raise(NoMethodError, bug2202) {o2.meth2} + %w(object_id __send__ initialize).each do |m| assert_in_out_err([], <<-INPUT, %w(:ok), /warning: removing `#{m}' may cause serious problems$/) $VERBOSE = false