diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 06:54:56 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 06:54:56 +0000 |
commit | 7a25e90ee5174d975c44ed232258ff5c41a54a18 (patch) | |
tree | 9b95b15923af984a61c93ca05eac6ad1ab4c095d /test | |
parent | 1511ef08ef72e17f648599cf6fddc2ea6d17d27e (diff) |
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_2@55351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_class.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index e17f56f913..e02a3d243d 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -358,6 +358,25 @@ class TestClass < Test::Unit::TestCase end 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 = [] |