diff options
author | Jean Boussier <[email protected]> | 2024-07-03 16:17:34 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2024-07-03 17:16:17 +0200 |
commit | 786cf9db488dd83a8c13c88485602c778e5d9564 (patch) | |
tree | 4938e53e0bbcf53cd940613409581e66a232471f /test | |
parent | 5f20957b85cad4c4bb5bd46559d5ee13b019a970 (diff) |
array.c: Remove outdated assertions
Following [Feature #20589] it can happen that we change the
capacity of a frozen array, so these assertions no longer make
sense.
Normally we don't hit them because `Array#freeze` shrinks the
array, but if somehow the Array was frozen using `Object#freeze`
then we may shrink it after it was frozen.
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_array.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index a8e039e82b..66251b9fb0 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -3493,6 +3493,17 @@ class TestArray < Test::Unit::TestCase assert_typed_equal(e, v, Complex, msg) end + def test_shrink_shared_array + assert_normal_exit(<<~'RUBY', '[Feature #20589]') + array = [] + # Make sure the array is allocated + 10.times { |i| array << i } + # Simulate a C extension using OBJ_FREEZE + Object.instance_method(:freeze).bind_call(array) + array.dup + RUBY + end + def test_sum assert_int_equal(0, [].sum) assert_int_equal(3, [3].sum) |