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:
parent
0a5b32c45a
commit
d6f5e30df8
1 changed files with 12 additions and 19 deletions
|
@ -64,27 +64,20 @@ End
|
|||
!b
|
||||
END
|
||||
assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
|
||||
fin = Struct.new(:garbage).new
|
||||
class << fin
|
||||
alias call garbage=
|
||||
end
|
||||
assertion = proc do
|
||||
fin.garbage = nil
|
||||
assert_nothing_raised(ArgumentError) {
|
||||
EnvUtil.under_gc_stress do
|
||||
3.times do
|
||||
ObjectSpace.define_finalizer([], fin)
|
||||
end
|
||||
GC.start
|
||||
|
||||
code = proc do |priv|
|
||||
<<-"CODE"
|
||||
fin = Object.new
|
||||
class << fin
|
||||
#{priv}def call(id)
|
||||
puts "finalized"
|
||||
end
|
||||
}
|
||||
assert_not_nil(fin.garbage)
|
||||
end
|
||||
ObjectSpace.define_finalizer([], fin)
|
||||
CODE
|
||||
end
|
||||
assertion.call
|
||||
class << fin
|
||||
private :call
|
||||
end
|
||||
assertion.call
|
||||
assert_in_out_err([], code[""], ["finalized"])
|
||||
assert_in_out_err([], code["private "], ["finalized"])
|
||||
end
|
||||
|
||||
def test_each_object
|
||||
|
|
Loading…
Reference in a new issue