mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-23 20:31:17 +08:00
add test to make sure WeakRef objects are autoreleased
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user