1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_objectspace.rb: run in separate process

* test/ruby/test_objectspace.rb (TestObjectSpace#test_finalizer): run
  in separate process so that finalizers run at termination certainly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-11-09 18:12:39 +00:00
parent 0a5b32c45a
commit d6f5e30df8

View file

@ -64,27 +64,20 @@ End
!b !b
END END
assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) } assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
fin = Struct.new(:garbage).new
class << fin code = proc do |priv|
alias call garbage= <<-"CODE"
end fin = Object.new
assertion = proc do class << fin
fin.garbage = nil #{priv}def call(id)
assert_nothing_raised(ArgumentError) { puts "finalized"
EnvUtil.under_gc_stress do
3.times do
ObjectSpace.define_finalizer([], fin)
end
GC.start
end end
} end
assert_not_nil(fin.garbage) ObjectSpace.define_finalizer([], fin)
CODE
end end
assertion.call assert_in_out_err([], code[""], ["finalized"])
class << fin assert_in_out_err([], code["private "], ["finalized"])
private :call
end
assertion.call
end end
def test_each_object def test_each_object