* gc.c (wmap_inspect_i): fix key/value order.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-10 05:02:17 +00:00
Родитель 332decb490
Коммит 9bd802f556
2 изменённых файлов: 10 добавлений и 2 удалений

4
gc.c
Просмотреть файл

@ -6346,8 +6346,8 @@ wmap_inspect(VALUE self)
TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void *)self); str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void *)self);
if (w->obj2wmap) { if (w->wmap2obj) {
st_foreach(w->obj2wmap, wmap_inspect_i, str); st_foreach(w->wmap2obj, wmap_inspect_i, str);
} }
RSTRING_PTR(str)[0] = '#'; RSTRING_PTR(str)[0] = '#';
rb_str_cat2(str, ">"); rb_str_cat2(str, ">");

Просмотреть файл

@ -28,6 +28,14 @@ class TestWeakMap < Test::Unit::TestCase
alias test_member? test_include? alias test_member? test_include?
alias test_key? 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 def test_each
m = __callee__[/test_(.*)/, 1] m = __callee__[/test_(.*)/, 1]
x1 = Object.new x1 = Object.new