diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-10 12:46:43 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-10 12:46:43 +0000 |
commit | 06dd20f7fe384f69ba4210c929e43a95c215ffa4 (patch) | |
tree | f408cfbb1a38ce6923f83d82261cb88ed5e1926a /test/ruby/test_class.rb | |
parent | 15fbd05e4e53798ee80cc21af22a53edc3c8229b (diff) | |
download | ruby-06dd20f7fe384f69ba4210c929e43a95c215ffa4.tar.gz |
* 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/trunk@54970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_class.rb')
-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 65f854d1ff..66a4059db7 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -378,6 +378,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 = [] |