diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2023-07-24 15:26:50 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2023-08-25 09:01:21 -0400 |
| commit | f5c8bdaa8ab1e42329c9877794fa5e3e936b2a55 (patch) | |
| tree | 956c345463f96f78a6936f1b1e33ec7e3b3e2066 /test/ruby | |
| parent | ee9cc8e32e04597a4a86b391df2c19aed9fde3e5 (diff) | |
Implement WeakKeyMap using weak references
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8113
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_weakkeymap.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_weakkeymap.rb b/test/ruby/test_weakkeymap.rb index 5df53749ca..be3e80cec4 100644 --- a/test/ruby/test_weakkeymap.rb +++ b/test/ruby/test_weakkeymap.rb @@ -108,6 +108,21 @@ class TestWeakKeyMap < Test::Unit::TestCase RUBY end + def test_compaction + omit "compaction is not supported on this platform" unless GC.respond_to?(:compact) + + assert_separately(%w(-robjspace), <<-'end;') + wm = ObjectSpace::WeakKeyMap.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 + private def assert_weak_include(m, k, n = 100) |
