From d2cc188ad5aecce659127a9c98713e9acd1a97ce Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 9 Dec 2013 07:13:40 +0000 Subject: 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 --- test/ruby/test_weakmap.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby/test_weakmap.rb') diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb index 383b5e1f31..c0d1747d2a 100644 --- a/test/ruby/test_weakmap.rb +++ b/test/ruby/test_weakmap.rb @@ -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 -- cgit v1.2.3