mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
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
This commit is contained in:
parent
97cd982a3e
commit
7c072b35d1
3 changed files with 38 additions and 9 deletions
|
@ -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]'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue