From 3e11fad84b58eadf44a749bae494182ced816f07 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 9 Oct 2024 01:06:57 +0200 Subject: [PATCH] Fix return in ensure hiding test errors --- test/fiddle/test_func.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/fiddle/test_func.rb b/test/fiddle/test_func.rb index 4e76523d..ca503f92 100644 --- a/test/fiddle/test_func.rb +++ b/test/fiddle/test_func.rb @@ -64,6 +64,10 @@ def test_strtod end def test_qsort1 + if RUBY_ENGINE == "jruby" + omit("The untouched sanity check is broken on JRuby: https://github.com/jruby/jruby/issues/8365") + end + closure_class = Class.new(Closure) do def call(x, y) Pointer.new(x)[0] <=> Pointer.new(y)[0] @@ -91,14 +95,15 @@ def call(x, y) end ensure # We can't use ObjectSpace with JRuby. - return if RUBY_ENGINE == "jruby" - # Ensure freeing all closures. - # See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091 . - not_freed_closures = [] - ObjectSpace.each_object(Fiddle::Closure) do |closure| - not_freed_closures << closure unless closure.freed? + unless RUBY_ENGINE == "jruby" + # Ensure freeing all closures. + # See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091 . + not_freed_closures = [] + ObjectSpace.each_object(Fiddle::Closure) do |closure| + not_freed_closures << closure unless closure.freed? + end + assert_equal([], not_freed_closures) end - assert_equal([], not_freed_closures) end def test_snprintf