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:
parent
eb8577a424
commit
970a92bb51
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue