summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-11-27 11:30:47 -0500
committerPeter Zhu <[email protected]>2023-11-27 12:40:26 -0500
commit150ed44d87e2d5b00f38019a487e05a67a303482 (patch)
tree4529f79d8f9de20071717bc9c189b43e557ee346 /test/ruby/test_array.rb
parent3af56e87ca79740521c81e1336cfb5523f55ee29 (diff)
Fix compaction during ary_make_partial
The ary_make_shared call may allocate, which can trigger a GC compaction. This can cause the array to be embedded because it has a length of 0.
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 6c0db0832b..838ef15b91 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1693,6 +1693,10 @@ class TestArray < Test::Unit::TestCase
assert_equal([100], a.slice(-1, 1_000_000_000))
end
+ def test_slice_gc_compact_stress
+ EnvUtil.under_gc_compact_stress { assert_equal([1, 2, 3, 4, 5], (0..10).to_a[1, 5]) }
+ end
+
def test_slice!
a = @cls[1, 2, 3, 4, 5]
assert_equal(3, a.slice!(2))