From eb215c8dc659f810abc4d112c000a5778fbbe423 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 18 Jun 2024 10:07:27 -0400 Subject: Fix flaky TestWeakMap#test_inspect_garbage If a GC is ran before the assert_match, then the WeakMap would be empty and would not have any objects, so the regular expression match would fail. This changes the regular expression to work even if the WeakMap is empty. --- test/ruby/test_weakmap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb index 97d7197dbb..9f8528050e 100644 --- a/test/ruby/test_weakmap.rb +++ b/test/ruby/test_weakmap.rb @@ -78,7 +78,7 @@ class TestWeakMap < Test::Unit::TestCase @wm[i] = Object.new @wm.inspect end - assert_match(/\A\#<#{@wm.class.name}:[^:]++:(?:\s\d+\s=>\s\#<(?:Object|collected):[^:<>]*+>(?:,|>\z))+/, + assert_match(/\A\#<#{@wm.class.name}:0x[\da-f]+(?::(?: \d+ => \#<(?:Object|collected):0x[\da-f]+>,?)+)?>\z/, @wm.inspect) end -- cgit v1.2.3