diff options
| author | Matt Valentine-House <matt@eightbitraptor.com> | 2022-12-21 15:48:00 +0000 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2023-01-03 08:47:48 -0500 |
| commit | 0dc989d031fb8c2b1e0d83e154455b612e3e4b96 (patch) | |
| tree | 55dd9f4501210d1ffd8627ea33f966412fbe9dd8 /test/ruby | |
| parent | fdac148637af2eff49fecbf864f303a16d39bf8c (diff) | |
Fix Error in GC Compaction specs
Previously if any of the tests that move objects between size pools
failed to move anything, then the call to stats.dig would return `nil`
which would then cause assert_operator to error.
This should be a test Failure, rather than an Error so this commit uses
a default value of 0 if stats.dig fails to find a key.
Also refactor object movement tests to use stats.dig, rather than :[]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6978
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_gc_compact.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index d92c979cf0..40a388ca04 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -323,7 +323,7 @@ class TestGCCompact < Test::Unit::TestCase end stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) - assert_operator(stats.dig(:moved_down, :T_ARRAY), :>=, ARY_COUNT) + assert_operator(stats.dig(:moved_down, :T_ARRAY) || 0, :>=, ARY_COUNT) assert(arys) # warning: assigned but unused variable - arys end; end @@ -345,7 +345,7 @@ class TestGCCompact < Test::Unit::TestCase end stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) - assert_operator(stats.dig(:moved_up, :T_ARRAY), :>=, ARY_COUNT) + assert_operator(stats.dig(:moved_up, :T_ARRAY) || 0, :>=, ARY_COUNT) assert(arys) # warning: assigned but unused variable - arys end; end @@ -375,7 +375,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) - assert_operator(stats[:moved_up][:T_OBJECT], :>=, OBJ_COUNT) + assert_operator(stats.dig(:moved_up, :T_OBJECT) || 0, :>=, OBJ_COUNT) end; end |
