effil/tests/lua/gc.lua
Ilia 7947d7af17 From luaunit to u-test (#46)
From luaunit to u-test
2017-06-10 14:13:31 +03:00

41 lines
700 B
Lua

require "bootstrap-tests"
local gc = effil.gc
test.gc.tear_down = default_tear_down
test.gc.cleanup = function ()
collectgarbage()
gc.collect()
test.equal(gc.count(), 1)
for i = 0, 10000 do
local tmp = effil.table()
end
collectgarbage()
gc.collect()
test.equal(gc.count(), 1)
end
test.gc.disable = function ()
local nobjects = 10000
collectgarbage()
gc.collect()
test.equal(gc.count(), 1)
gc.pause()
test.is_false(gc.enabled())
for i = 1, nobjects do
local tmp = effil.table()
end
test.equal(gc.count(), nobjects + 1)
collectgarbage()
gc.collect()
test.equal(gc.count(), 1)
gc.resume()
end