add test case for garbage collect

This commit is contained in:
Anod Chow 2018-09-10 12:35:31 +08:00
parent ecb457dcb1
commit e816e80493

View File

@ -312,6 +312,20 @@ local function test_slice()
assert( #j == 0 )
end
local function test_gc()
local buf = ByteArray.create()
local mt = getmetatable(buf)
local f = mt.__gc
local is_collect = false
mt.__gc = function( ... )
is_collect = true
f(...)
end
buf = nil
collectgarbage("collect")
assert( is_collect==false )
end
test_readonly()
test_index()
test_tostring()
@ -327,3 +341,4 @@ test_write_integer()
test_write_float()
test_write_cstr()
test_write_bytes()
test_gc()