From 7c072b35d18391b9a1f848c6adc707c3ebbb1791 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 8 May 2014 05:34:31 +0000 Subject: class.c: always clear tables first * class.c (rb_mod_init_copy): always clear instance variable, constant and method tables first, regardless the source tables. [ruby-dev:48182] [Bug #9813] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_module.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index b5e128ba3c..af626e5f47 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -375,6 +375,25 @@ class TestModule < Test::Unit::TestCase assert_equal(:ok, Object.new.extend(m).foo, bug9535) end + def test_initialize_copy_empty + bug9813 = '[ruby-dev:48182] [Bug #9813]' + m = Module.new do + def x + end + const_set(:X, 1) + @x = 2 + end + assert_equal([:x], m.instance_methods) + assert_equal([:@x], m.instance_variables) + assert_equal([:X], m.constants) + m.module_eval do + initialize_copy(Module.new) + end + assert_empty(m.instance_methods, bug9813) + assert_empty(m.instance_variables, bug9813) + assert_empty(m.constants, bug9813) + end + def test_dup bug6454 = '[ruby-core:45132]' -- cgit v1.2.3