Sha256: e67f31b8f4badccfa0f88dd5da8d1ce7f050b8efc60f619a75424007e215f714
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require "weakref" RSpec.describe "Leaks", actor_system: :global, leaktest: true, skip: !ENV["CELLULOID_LEAKTEST"] && "leak test disabled" do class LeakActor include Celluloid def initialize(arg) @arg = arg end def call(_arg) [] end def terminate; end end def wait_for_release(weak, _what, count = 1000) trash = [] count.times do |step| GC.start return true unless weak.weakref_alive? trash << "*" * step end false end def do_actor(what) actor = LeakActor.new what weak = yield actor actor.terminate actor = nil weak end def actor_life(what, &block) GC.start weak = do_actor what, &block expect(wait_for_release(weak, what)).to be_truthy end context "celluloid actor" do xit "is properly destroyed upon termination" do actor_life("actor") do |actor| WeakRef.new actor end end end context "celluloid actor call" do it "does not hold a reference its arguments on completion" do actor_life("call-arg") do |actor| arg = [] actor.call arg weak = WeakRef.new arg arg = nil weak end end it "does not hold a reference to the return value" do actor_life("call-result") do |actor| result = actor.call nil weak = WeakRef.new result result = nil weak end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
celluloid-0.18.0 | spec/celluloid/misc/leak_spec.rb |
celluloid-0.18.0.pre2 | spec/celluloid/misc/leak_spec.rb |