Guard against GC.compact when using in tests

This test will error on platforms that don't implement GC.compact

Co-Authored-By: Peter Zhu <peter@peterzhu.ca>
This commit is contained in:
Matt Valentine-House 2024-06-13 20:39:11 +01:00 committed by Alan Wu
parent c093fd86d2
commit 4ab7cc1818

View File

@ -123,6 +123,7 @@ assert_equal '[:ae, :ae]', %q{
# regression test for GC marking stubs in invalidated code
assert_normal_exit %q{
skip true unless defined?(GC.compact)
garbage = Array.new(10_000) { [] } # create garbage to cause iseq movement
eval(<<~RUBY)
def foo(n, garbage)
@ -1229,6 +1230,7 @@ assert_equal 'special', %q{
# Test that object references in generated code get marked and moved
assert_equal "good", %q{
skip :good unless defined?(GC.compact)
def bar
"good"
end
@ -2321,6 +2323,7 @@ assert_equal '123', %q{
# Test EP == BP invalidation with moving ISEQs
assert_equal 'ok', %q{
skip :ok unless defined?(GC.compact)
def entry
ok = proc { :ok } # set #entry as an EP-escaping ISEQ
[nil].reverse_each do # avoid exiting the JIT frame on the constant