diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-21 11:42:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-21 11:42:03 +0000 |
commit | 1f29e8e2baa548bba9e385ebbade2198b4cc3859 (patch) | |
tree | f2a3cd8fc4533cf4ca850c37f317357bcb09553d /test | |
parent | 5258f67d179757c9d0e4db115691e6a02d07da48 (diff) | |
download | ruby-1f29e8e2baa548bba9e385ebbade2198b4cc3859.tar.gz |
class.c: do nothing if copying self
* class.c (rb_mod_init_copy): do nothing if copying self.
[ruby-dev:47989] [Bug #9535]
* hash.c (rb_hash_initialize_copy): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_hash.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c0745dd166..6ef817d0c2 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -108,6 +108,12 @@ class TestHash < Test::Unit::TestCase assert_empty(h) end + def test_self_initialize_copy + h = @cls[1=>2] + h.instance_eval {initialize_copy(h)} + assert_equal(2, h[1]) + end + def test_dup_will_rehash set1 = @cls[] set2 = @cls[set1 => true] diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 57a01db28e..5eb0457496 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -364,6 +364,17 @@ class TestModule < Test::Unit::TestCase assert_equal([:MIXIN, :USER], User.constants.sort) end + def test_self_initialize_copy + bug9535 = '[ruby-dev:47989] [Bug #9535]' + m = Module.new do + def foo + :ok + end + initialize_copy(self) + end + assert_equal(:ok, Object.new.extend(m).foo, bug9535) + end + def test_dup bug6454 = '[ruby-core:45132]' |