[前][次][番号順一覧][スレッド一覧]

ruby-changes:23708

From: drbrain <ko1@a...>
Date: Wed, 23 May 2012 05:15:40 +0900 (JST)
Subject: [ruby-changes:23708] drbrain:r35759 (trunk): * class.c (rb_mod_init_copy): Clear the cached inspect string of a

drbrain	2012-05-23 05:15:28 +0900 (Wed, 23 May 2012)

  New Revision: 35759

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35759

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/test/ruby/test_module.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35758)
+++ ChangeLog	(revision 35759)
@@ -1,3 +1,9 @@
+Wed May 23 05:15:11 2012  Eric Hodel  <drbrain@s...>
+
+	* 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@a...>
 
 	* vm_core.h: add a data type rb_location_t to store iseq location
Index: class.c
===================================================================
--- class.c	(revision 35758)
+++ class.c	(revision 35759)
@@ -174,6 +174,8 @@
 	    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__");
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 35758)
+++ test/ruby/test_module.rb	(revision 35759)
@@ -259,6 +259,31 @@
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]