summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-22 20:15:28 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-22 20:15:28 +0000
commit1d4e7d923266090844ef1bc1afc8704b75b7d057 (patch)
treef52885586dba38fce3933298d629d9d35e62a03a
parentcb61ea5ef3aee59c0c5026c113ef5954992f7ca1 (diff)
* class.c (rb_mod_init_copy): Clear the cached inspect string of a
dup'd anonymous module or class. [ruby-trunk - Bug #6454] * test/ruby/test_module.rb (class TestModule): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--class.c2
-rw-r--r--test/ruby/test_module.rb25
3 files changed, 33 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 79b39570f7..f445502db2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed May 23 05:15:11 2012 Eric Hodel <drbrain@segment7.net>
+
+ * class.c (rb_mod_init_copy): Clear the cached inspect string of a
+ dup'd anonymous module or class. [ruby-trunk - Bug #6454]
+ * test/ruby/test_module.rb (class TestModule): ditto
+
Tue May 22 16:49:15 2012 Koichi Sasada <ko1@atdot.net>
* vm_core.h: add a data type rb_location_t to store iseq location
diff --git a/class.c b/class.c
index 00f508e1b4..8e637c07d0 100644
--- a/class.c
+++ b/class.c
@@ -174,6 +174,8 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
st_free_table(RCLASS_IV_TBL(clone));
}
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
+ CONST_ID(id, "__tmp_classpath__");
+ st_delete(RCLASS_IV_TBL(clone), &id, 0);
CONST_ID(id, "__classpath__");
st_delete(RCLASS_IV_TBL(clone), &id, 0);
CONST_ID(id, "__classid__");
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 88b7dd1572..66cc0073f7 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -259,6 +259,31 @@ class TestModule < Test::Unit::TestCase
assert_equal([:MIXIN, :USER], User.constants.sort)
end
+ def test_dup
+ bug6454 = '[ruby-core:45132]'
+
+ a = Module.new
+ Other.const_set :BUG6454, a
+
+ original = Other::BUG6454.inspect
+
+ b = a.dup
+ Other.const_set :BUG6454_dup, b
+
+ assert_equal "TestModule::Other::BUG6454_dup", b.inspect, bug6454
+ end
+
+ def test_dup_anonymous
+ bug6454 = '[ruby-core:45132]'
+
+ a = Module.new
+ original = a.inspect
+
+ b = a.dup
+
+ refute_equal original, b.inspect, bug6454
+ end
+
def test_included_modules
assert_equal([], Mixin.included_modules)
assert_equal([Mixin], User.included_modules)