summaryrefslogtreecommitdiff
path: root/test/ruby/test_weakmap.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-09 07:13:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-09 07:13:40 +0000
commitd2cc188ad5aecce659127a9c98713e9acd1a97ce (patch)
treeef82797dee49e60b0383b108b96ee1be62e4e5a1 /test/ruby/test_weakmap.rb
parentb73a30644187018b099ef148778b914a670d94f6 (diff)
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
Diffstat (limited to 'test/ruby/test_weakmap.rb')
-rw-r--r--test/ruby/test_weakmap.rb14
1 files changed, 14 insertions, 0 deletions
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