From 547d2378acca6ee376a9f1b0a619c919e834b3cb Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 31 Jul 2023 10:26:43 -0400 Subject: [PATCH] Assert that at least one element has been embedded It's not guaranteed that the first element will always be embedded. --- test/ruby/test_gc_compact.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index 44da6aabee..5cdd06ffcf 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -324,7 +324,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats.dig(:moved_down, :T_ARRAY) || 0, :>=, ARY_COUNT) - assert_include(ObjectSpace.dump(arys[0]), '"embedded":true') + refute_empty(arys.keep_if { |o| ObjectSpace.dump(o).include?('"embedded":true') }) end; end @@ -346,7 +346,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats.dig(:moved_up, :T_ARRAY) || 0, :>=, ARY_COUNT) - assert_include(ObjectSpace.dump(arys[0]), '"embedded":true') + refute_empty(arys.keep_if { |o| ObjectSpace.dump(o).include?('"embedded":true') }) end; end @@ -376,7 +376,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats.dig(:moved_up, :T_OBJECT) || 0, :>=, OBJ_COUNT) - assert_include(ObjectSpace.dump(ary[0]), '"embedded":true') + refute_empty(ary.keep_if { |o| ObjectSpace.dump(o).include?('"embedded":true') }) end; end @@ -395,7 +395,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats[:moved_up][:T_STRING], :>=, STR_COUNT) - assert_include(ObjectSpace.dump(ary[0]), '"embedded":true') + refute_empty(ary.keep_if { |o| ObjectSpace.dump(o).include?('"embedded":true') }) end; end @@ -413,7 +413,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats[:moved_down][:T_STRING], :>=, STR_COUNT) - assert_include(ObjectSpace.dump(ary[0]), '"embedded":true') + refute_empty(ary.keep_if { |o| ObjectSpace.dump(o).include?('"embedded":true') }) end; end