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

ruby-changes:32028

From: nobu <ko1@a...>
Date: Tue, 10 Dec 2013 14:02:23 +0900 (JST)
Subject: [ruby-changes:32028] nobu:r44107 (trunk): gc.c: fix WeakMap#inspect

nobu	2013-12-10 14:02:17 +0900 (Tue, 10 Dec 2013)

  New Revision: 44107

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

  Log:
    gc.c: fix WeakMap#inspect
    
    * gc.c (wmap_inspect_i): fix key/value order.

  Modified files:
    trunk/gc.c
    trunk/test/ruby/test_weakmap.rb
Index: gc.c
===================================================================
--- gc.c	(revision 44106)
+++ gc.c	(revision 44107)
@@ -6346,8 +6346,8 @@ wmap_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/gc.c#L6346
 
     TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
     str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void *)self);
-    if (w->obj2wmap) {
-	st_foreach(w->obj2wmap, wmap_inspect_i, str);
+    if (w->wmap2obj) {
+	st_foreach(w->wmap2obj, wmap_inspect_i, str);
     }
     RSTRING_PTR(str)[0] = '#';
     rb_str_cat2(str, ">");
Index: test/ruby/test_weakmap.rb
===================================================================
--- test/ruby/test_weakmap.rb	(revision 44106)
+++ test/ruby/test_weakmap.rb	(revision 44107)
@@ -28,6 +28,14 @@ class TestWeakMap < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_weakmap.rb#L28
   alias test_member? test_include?
   alias test_key? test_include?
 
+  def test_inspect
+    x = Object.new
+    k = BasicObject.new
+    @wm[k] = x
+    assert_match(/\A\#<#{@wm.class.name}:[^:]+:\s\#<BasicObject:[^:]*>\s=>\s\#<Object:[^:]*>>\z/,
+                 @wm.inspect)
+  end
+
   def test_each
     m = __callee__[/test_(.*)/, 1]
     x1 = Object.new

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

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