add test to make sure WeakRef objects are autoreleased

This commit is contained in:
Laurent Sansonetti
2013-05-06 15:32:18 +02:00
parent e0e6712691
commit 517c2a397f

View File

@@ -32,4 +32,14 @@ describe "WeakRef" do
it "cannot be subclassed" do
lambda { class Foo < WeakRef; end }.should.raise(RuntimeError)
end
it "are destroyed like regular objects" do
$weakref_destroyed = false
autorelease_pool do
obj = Object.new
ref = WeakRef.new(obj)
ObjectSpace.define_finalizer(ref, proc { $weakref_destroyed = true })
end
$weakref_destroyed.should == true
end
end