spec for gears.object: Test weak signals better

Since weak signals specifically exist to do magic with the garbage collector, do
a couple of garbage collection cycles and verify that this does not disconnect
the callback function prematurely (the function is kept alive since it is a
local variable).

(I actually did a mistake that makes this enhanced test fail and fixed it before
committing)

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2015-11-19 17:58:49 +01:00 committed by Daniel Hahler
parent eb8577a424
commit 970a92bb51
1 changed files with 6 additions and 0 deletions

View File

@ -52,6 +52,12 @@ describe("gears.object", function()
called = true
end
obj:weak_connect_signal("signal", cb)
-- Check that the GC doesn't disconnect the signal
for i = 1, 10 do
collectgarbage("collect")
end
obj:emit_signal("signal")
assert.is_true(called)
end)