diff options
author | NAKAMURA Usaku <usa@ruby-lang.org> | 2021-12-31 19:48:17 +0900 |
---|---|---|
committer | NAKAMURA Usaku <usa@ruby-lang.org> | 2021-12-31 19:48:17 +0900 |
commit | 7d3cff6e41d73a00f3d0fdb337743f654e42f1a8 (patch) | |
tree | dd8221f8ee5c007cab207fe2385cb5c80ee4bb18 /test | |
parent | b829811131ec7741ce701ff8a8b101604fb0d595 (diff) |
merge revision(s) a2d4e1cda68a49980a4f9f353f400efbde7e7884,d6c5a30cfdf658280338dbb8c8b17fab3190b928: [Backport #18392]
Fixed the check order in wmap_live_p [Bug #18392]
Check if the object is a pointer to heap before check the flag in
that object.
---
gc.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
ObjectSpace::WeakMap#inspect: check if living object [Bug #18392]
---
gc.c | 29 +++++++++++++++++++++++------
test/ruby/test_weakmap.rb | 9 +++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_weakmap.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb index 3b9eef770a..46d8b50c03 100644 --- a/test/ruby/test_weakmap.rb +++ b/test/ruby/test_weakmap.rb @@ -73,6 +73,15 @@ class TestWeakMap < Test::Unit::TestCase @wm.inspect) end + def test_inspect_garbage + 1000.times do |i| + @wm[i] = Object.new + @wm.inspect + end + assert_match(/\A\#<#{@wm.class.name}:[^:]++:(?:\s\d+\s=>\s\#<(?:Object|collected):[^:<>]*+>(?:,|>\z))+/, + @wm.inspect) + end + def test_each m = __callee__[/test_(.*)/, 1] x1 = Object.new |