diff --git a/test/lang/gc.lua b/test/lang/gc.lua index f820418..35e6a1f 100644 --- a/test/lang/gc.lua +++ b/test/lang/gc.lua @@ -28,3 +28,15 @@ do --- rechain assert(t[k] == 4) end + +do --- TSETM gc + local function f() + collectgarbage() + return "a", "b" + end + for i = 1, 10 do + local t = {f()} + assert(t[1] == "a") + assert(t[2] == "b") + end +end diff --git a/test/lib/table/remove.lua b/test/lib/table/remove.lua index 604f588..1b24a4f 100644 --- a/test/lib/table/remove.lua +++ b/test/lib/table/remove.lua @@ -21,3 +21,22 @@ do --- table.remove(t, 1) removes and returns the first entry for i=1,100 do assert(tremove(t, 1) == i) end assert(#t == 100 and t[100] == 200) end + +do --- TSETR hash part +table.new + local tnew = require"table.new" + local t = tnew(0, 16) + for i=10,1,-1 do t[i] = i+3 end + for i=10,1,-1 do assert(tremove(t) == i+3) end + assert(#t == 0) +end + +do --- TSETR write barrier +table.new + local tnew = require"table.new" + for _, t in ipairs{{}, tnew(0, 16)} do + for i = 1, 10 do t[i] = {i} end + for i = 1, 10 do + collectgarbage() + assert(tremove(t, 1)[1] == i) + end + end +end