summaryrefslogtreecommitdiff
path: root/test/ruby/test_weakmap.rb
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-07-24 15:26:10 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-08-25 09:01:21 -0400
commitee9cc8e32e04597a4a86b391df2c19aed9fde3e5 (patch)
tree6775a480714642571c8e30336fc2a1abab44815a /test/ruby/test_weakmap.rb
parent2091bf94931bddcf23b196fc8fe108ebd7ec1648 (diff)
Implement WeakMap using weak references
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8113
Diffstat (limited to 'test/ruby/test_weakmap.rb')
-rw-r--r--test/ruby/test_weakmap.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb
index 6b3dc678ad..b42787ad5e 100644
--- a/test/ruby/test_weakmap.rb
+++ b/test/ruby/test_weakmap.rb
@@ -193,9 +193,10 @@ class TestWeakMap < Test::Unit::TestCase
end;
end
- def test_compaction_bug_19529
+ def test_compaction
omit "compaction is not supported on this platform" unless GC.respond_to?(:compact)
+ # [Bug #19529]
obj = Object.new
100.times do |i|
GC.compact
@@ -211,6 +212,17 @@ class TestWeakMap < Test::Unit::TestCase
end
GC.compact
end;
+
+ assert_separately(%w(-robjspace), <<-'end;')
+ wm = ObjectSpace::WeakMap.new
+ key = Object.new
+ val = Object.new
+ wm[key] = val
+
+ GC.verify_compaction_references(expand_heap: true, toward: :empty)
+
+ assert_equal(val, wm[key])
+ end;
end
def test_replaced_values_bug_19531