diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-20 10:03:54 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-20 10:03:54 +0000 |
commit | 272dd5c6b7c5cfe05a8b360b9e9d76a90f9e647f (patch) | |
tree | 87b5bfcc92f5317d3393a694082de70ea188dbef /test | |
parent | 74bca55da9e509592bd04bc785b6eb86082f8cfe (diff) |
merge revision(s) 38364,38366: [Backport #7557]
* object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copy
* class.c (rb_class_init_copy): rename to class_init_copy_check, performs type
checks on arguments to prevent reinitialization of initialized class
[ruby-core:50869] [Bug #7557]
* class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS
* test/ruby/test_class.rb (class TestClass): related test
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@38507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_class.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 55940a8891..3d894da03c 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -258,4 +258,19 @@ class TestClass < Test::Unit::TestCase END assert_equal(42, PrivateClass.new.foo) end + + def test_cannot_reinitialize_class_with_initialize_copy # [ruby-core:50869] + assert_in_out_err([], <<-RUBY, ["Object"], []) + class Class + def initialize_copy(*); super; end + end + + class A; end + class B; end + + A.send(:initialize_copy, Class.new(B)) rescue nil + + p A.superclass + RUBY + end end |