test/hexapdf/test_importer.rb in hexapdf-0.8.0 vs test/hexapdf/test_importer.rb in hexapdf-0.9.0

- old
+ new

@@ -4,11 +4,17 @@ require 'hexapdf/importer' require 'hexapdf/document' describe HexaPDF::Importer::NullableWeakRef do it "returns nil instead of an error when the referred-to object is GCed" do - obj = HexaPDF::Importer::NullableWeakRef.new(Object.new) - GC.start + refs = [] + obj = nil + 100.times do + refs << HexaPDF::Importer::NullableWeakRef.new(Object.new) + ObjectSpace.garbage_collect + ObjectSpace.garbage_collect + break if (obj = refs.find {|ref| !ref.weakref_alive? }) + end assert_equal("", obj.to_s) end end describe HexaPDF::Importer do