summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-06-18 10:07:27 -0400
committerPeter Zhu <peter@peterzhu.ca>2024-06-18 14:21:37 -0400
commiteb215c8dc659f810abc4d112c000a5778fbbe423 (patch)
tree79d2c2f5d9664d179988fc1d10b8b57699ca0548
parentb8a592fe6e2d1b537b229625cd3d439a7d5a6eb5 (diff)
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.
-rw-r--r--test/ruby/test_weakmap.rb2
1 files changed, 1 insertions, 1 deletions
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