From cd1e32f7ff27f86927acad462ac94ef92216acd9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 13 Jun 2016 18:33:28 +0000 Subject: merge revision(s) 54970: [Backport #12367] * insns.def (defineclass): Also raise an error when redeclaring the superclass of a class as Object and it has another superclass. [Bug #12367] [ruby-core:75446] * test/ruby/test_class.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_class.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 81c11e6f88..59b720813c 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -375,6 +375,25 @@ class TestClass < Test::Unit::TestCase } end + define_method :test_invalid_reset_superclass do + class A; end + class SuperclassCannotBeReset < A + end + assert_equal A, SuperclassCannotBeReset.superclass + + assert_raise_with_message(TypeError, /superclass mismatch/) { + class SuperclassCannotBeReset < String + end + } + + assert_raise_with_message(TypeError, /superclass mismatch/, "[ruby-core:75446]") { + class SuperclassCannotBeReset < Object + end + } + + assert_equal A, SuperclassCannotBeReset.superclass + end + def test_cloned_singleton_method_added bug5283 = '[ruby-dev:44477]' added = [] -- cgit v1.2.3