1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/-ext-/array/test_to_ary_concat.rb
Aaron Patterson 8db269edb3
Guard array when appending
This prevents early collection of the array.  The GC doesn't see the
array on the stack when Ruby is compiled with optimizations enabled

Thanks @jhaberman for the test case

[ruby-core:105099] [Bug #18140]
2021-09-01 10:58:20 -07:00

20 lines
344 B
Ruby

# frozen_string_literal: false
require 'test/unit'
require '-test-/array/to_ary_concat'
class TestConcatStress < Test::Unit::TestCase
def setup
@stress_level = GC.stress
GC.stress = true
end
def teardown
GC.stress = @stress_level
end
def test_concat
arr = [nil]
bar = Bug::Bar.new
arr.concat(bar)
end
end