summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-12-23 16:22:14 -0500
committerPeter Zhu <[email protected]>2023-12-23 18:00:27 -0500
commit50bf4373411a8780270c7ba1cc983d5756a4fde1 (patch)
tree214b4635bd0d4eaa0c6cb8ff4be675c3ad2e9e2d /test
parenta2ebf9cc63f0805bc7dd9a92e66bf589a869447e (diff)
Fix String#sub for GC compaction
The test fails when RGENGC_CHECK_MODE is turned on: TestString#test_sub_gc_compact_stress = 9.42 s 1) Failure: TestString#test_sub_gc_compact_stress [test/ruby/test_string.rb:2089]: <"aaa [amp] yyy"> expected but was <"aaa [] yyy">.
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index ae392b2da6..333b610bc5 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2081,6 +2081,15 @@ CODE
}
end
+ def test_sub_gc_compact_stress
+ EnvUtil.under_gc_compact_stress do
+ m = /&(?<foo>.*?);/.match(S("aaa &amp; yyy"))
+ assert_equal("amp", m["foo"])
+
+ assert_equal("aaa [amp] yyy", S("aaa &amp; yyy").sub(/&(?<foo>.*?);/, S('[\k<foo>]')))
+ end
+ end
+
def test_sub!
a = S("hello")
b = a.dup