1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

gc.c: ObjectSpace::WeakMap#size

* gc.c (wmap_size): add ObjectSpace::WeakMap#size and #length.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-09 07:13:40 +00:00
parent b73a306441
commit d2cc188ad5
3 changed files with 34 additions and 0 deletions

View file

@ -93,4 +93,18 @@ class TestWeakMap < Test::Unit::TestCase
end
assert_equal(2, n)
end
def test_size
m = __callee__[/test_(.*)/, 1]
assert_equal(0, @wm.__send__(m))
x1 = "foo"
k1 = Object.new
@wm[k1] = x1
assert_equal(1, @wm.__send__(m))
x2 = "bar"
k2 = Object.new
@wm[k2] = x2
assert_equal(2, @wm.__send__(m))
end
alias test_length test_size
end