diff options
| author | Andrii Furmanets <furmanets.andriy@gmail.com> | 2026-03-04 16:41:27 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-03-05 10:04:44 +0100 |
| commit | 6531343242e28b179e6d3d25af3b7fb65c90b66b (patch) | |
| tree | e6b2abb512b94eb921277f2f3b1cade05e6fadee | |
| parent | 858c96c568b64a5fcb7f93b567643e7b2b565307 (diff) | |
weakmap: return assigned value from #[]= and add regression test
| -rw-r--r-- | test/ruby/test_weakmap.rb | 7 | ||||
| -rw-r--r-- | weakmap.c | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb index 4f5823ecf4..2f5c747339 100644 --- a/test/ruby/test_weakmap.rb +++ b/test/ruby/test_weakmap.rb @@ -39,6 +39,13 @@ class TestWeakMap < Test::Unit::TestCase assert_same(:foo, @wm[x]) end + def test_aset_returns_value + key = Object.new + value = Object.new + + assert_same(value, @wm.send(:[]=, key, value)) + end + def assert_weak_include(m, k, n = 100) if n > 0 return assert_weak_include(m, k, n-1) @@ -394,7 +394,7 @@ wmap_aset(VALUE self, VALUE key, VALUE val) RB_OBJ_WRITTEN(self, Qundef, key); RB_OBJ_WRITTEN(self, Qundef, val); - return Qnil; + return val; } /* Retrieves a weakly referenced object with the given key */ |
