|
|
|
@ -37,6 +37,33 @@ do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do -- bug in 5.4.0
|
|
|
|
|
-- When an object aged OLD1 is finalized, it is moved from the list
|
|
|
|
|
-- 'finobj' to the *beginning* of the list 'allgc', but that part of the
|
|
|
|
|
-- list was not being visited by 'markold'.
|
|
|
|
|
local A = {}
|
|
|
|
|
A[1] = false -- old anchor for object
|
|
|
|
|
|
|
|
|
|
-- obj finalizer
|
|
|
|
|
local function gcf (obj)
|
|
|
|
|
A[1] = obj -- anchor object
|
|
|
|
|
assert(not T or T.gcage(obj) == "old1")
|
|
|
|
|
obj = nil -- remove it from the stack
|
|
|
|
|
collectgarbage("step", 0) -- do a young collection
|
|
|
|
|
print(getmetatable(A[1]).x) -- metatable was collected
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
collectgarbage() -- make A old
|
|
|
|
|
local obj = {} -- create a new object
|
|
|
|
|
collectgarbage("step", 0) -- make it a survival
|
|
|
|
|
assert(not T or T.gcage(obj) == "survival")
|
|
|
|
|
setmetatable(obj, {__gc = gcf, x = "ok"}) -- create its metatable
|
|
|
|
|
assert(not T or T.gcage(getmetatable(obj)) == "new")
|
|
|
|
|
obj = nil -- clear object
|
|
|
|
|
collectgarbage("step", 0) -- will call obj's finalizer
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if T == nil then
|
|
|
|
|
(Message or print)('\n >>> testC not active: \z
|
|
|
|
|
skipping some generational tests <<<\n')
|
|
|
|
@ -78,6 +105,9 @@ do
|
|
|
|
|
assert(debug.getuservalue(U).x[1] == 234)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- just to make sure
|
|
|
|
|
assert(collectgarbage'isrunning')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- just to make sure
|
|
|
|
|