Skip to content

Commit

Permalink
Exercise TSETR and TSETM slow paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
corsix committed Oct 4, 2016
1 parent 703e9cf commit c3224bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/lang/gc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions test/lib/table/remove.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c3224bb

Please sign in to comment.