Better support in 'ltests' for tracing the GC

This commit is contained in:
Roberto Ierusalimschy
2024-10-21 15:18:20 -03:00
parent d0815046d0
commit 258355734d
5 changed files with 67 additions and 30 deletions

View File

@@ -560,8 +560,8 @@ if T then -- tests for weird cases collecting upvalues
-- create coroutine in a weak table, so it will never be marked
t.co = coroutine.wrap(foo)
local f = t.co() -- create function to access local 'a'
T.gcstate("atomic") -- ensure all objects are traversed
assert(T.gcstate() == "atomic")
T.gcstate("enteratomic") -- ensure all objects are traversed
assert(T.gcstate() == "enteratomic")
assert(t.co() == 100) -- resume coroutine, creating new table for 'a'
assert(T.gccolor(t.co) == "white") -- thread was not traversed
T.gcstate("pause") -- collect thread, but should mark 'a' before that
@@ -574,7 +574,7 @@ if T then -- tests for weird cases collecting upvalues
collectgarbage()
collectgarbage"stop"
local a = {} -- avoid 'u' as first element in 'allgc'
T.gcstate"atomic"
T.gcstate"enteratomic"
T.gcstate"sweepallgc"
local x = {}
assert(T.gccolor(u) == "black") -- userdata is "old" (black)