File: pause.lua

package info (click to toggle)
lua-copas 4.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: makefile: 62; sh: 43
file content (30 lines) | stat: -rw-r--r-- 603 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- check no memory leaks when sleeping

-- make sure we are pointing to the local copas first
package.path = string.format("../src/?.lua;%s", package.path)

local copas = require("copas")

local t1 = copas.addthread(
    function()
        copas.pauseforever()  -- sleep until woken up
    end
)


-- prepare GC test
local validate_gc = setmetatable({
    [t1] = true,
  },{ __mode = "k" })

-- start test
copas.loop()

t1 = nil  -- luacheck: ignore
collectgarbage()
collectgarbage()

--check GC
assert(next(validate_gc) == nil, "the 'validate_gc' table should have been empty!")

print "test success!"