From 8c6dd375a7fc4da62b49475bce5ea5a64105e5cd Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 22 Feb 2014 02:49:01 +0000 Subject: merge revision(s) r45076: [Backport #9535] * 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/branches/ruby_2_0_0@45096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_hash.rb | 6 ++++++ test/ruby/test_module.rb | 11 +++++++++++ 2 files changed, 17 insertions(+) (limited to 'test') diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index a77c5cf43f..b545395780 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 4bc725d2b5..047f7c99d3 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -309,6 +309,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]' -- cgit v1.2.3