Skip to content

Commit c3224bb

Browse files
committed
Exercise TSETR and TSETM slow paths.
1 parent 703e9cf commit c3224bb

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/lang/gc.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ do --- rechain
2828

2929
assert(t[k] == 4)
3030
end
31+
32+
do --- TSETM gc
33+
local function f()
34+
collectgarbage()
35+
return "a", "b"
36+
end
37+
for i = 1, 10 do
38+
local t = {f()}
39+
assert(t[1] == "a")
40+
assert(t[2] == "b")
41+
end
42+
end

test/lib/table/remove.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,22 @@ do --- table.remove(t, 1) removes and returns the first entry
2121
for i=1,100 do assert(tremove(t, 1) == i) end
2222
assert(#t == 100 and t[100] == 200)
2323
end
24+
25+
do --- TSETR hash part +table.new
26+
local tnew = require"table.new"
27+
local t = tnew(0, 16)
28+
for i=10,1,-1 do t[i] = i+3 end
29+
for i=10,1,-1 do assert(tremove(t) == i+3) end
30+
assert(#t == 0)
31+
end
32+
33+
do --- TSETR write barrier +table.new
34+
local tnew = require"table.new"
35+
for _, t in ipairs{{}, tnew(0, 16)} do
36+
for i = 1, 10 do t[i] = {i} end
37+
for i = 1, 10 do
38+
collectgarbage()
39+
assert(tremove(t, 1)[1] == i)
40+
end
41+
end
42+
end

0 commit comments

Comments
 (0)