summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-08-16 16:02:16 -0400
committerPeter Zhu <[email protected]>2024-08-19 10:58:36 -0400
commitcb2848772210f8e00956a24db650f8b06786fd3c (patch)
tree0335728d1ac426aecdd046ac038d2b6fb9934cee /test
parent786d0006524b0ca282a05593ca3dff3633890af7 (diff)
Make assertions allow incremental GC when disabled
When assertions are enabled, the following code triggers an assertion error: GC.disable GC.start(immediate_mark: false, immediate_sweep: false) 10_000_000.times { Object.new } This is because the GC.start ignores that the GC is disabled and will start incremental marking and lazy sweeping. But the assertions in gc_marks_continue and gc_sweep_continue assert that GC is not disabled. This commit changes it for the assertion to pass if the GC was triggered from a method.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11391
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_gc.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index a05da28f7e..9029f2bda8 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -856,6 +856,16 @@ class TestGc < Test::Unit::TestCase
ensure
GC.enable unless disabled
end
+
+ begin
+ disabled = GC.disable
+ c = GC.count
+ GC.start(immediate_mark: false, immediate_sweep: false)
+ 10_000.times { Object.new }
+ assert_equal 1, GC.count - c
+ ensure
+ GC.enable unless disabled
+ end
end
def test_vm_object