aboutsummaryrefslogtreecommitdiff
path: root/testes/gc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/gc.lua')
-rw-r--r--testes/gc.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 05bf564e..91e78a48 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -18,6 +18,8 @@ assert(collectgarbage("incremental") == "generational")
18assert(collectgarbage("incremental") == "incremental") 18assert(collectgarbage("incremental") == "incremental")
19 19
20 20
21local function nop () end
22
21local function gcinfo () 23local function gcinfo ()
22 return collectgarbage"count" * 1024 24 return collectgarbage"count" * 1024
23end 25end
@@ -388,7 +390,7 @@ if T then
388 collectgarbage() 390 collectgarbage()
389 for i = 1, 10 do assert(s[i]) end 391 for i = 1, 10 do assert(s[i]) end
390 392
391 getmetatable(u).__gc = false 393 getmetatable(u).__gc = nil
392 394
393end 395end
394print '+' 396print '+'
@@ -604,8 +606,8 @@ if T then
604 collectgarbage("stop") 606 collectgarbage("stop")
605 local x = T.newuserdata(0) 607 local x = T.newuserdata(0)
606 local y = T.newuserdata(0) 608 local y = T.newuserdata(0)
607 debug.setmetatable(y, {__gc = true}) -- bless the new udata before... 609 debug.setmetatable(y, {__gc = nop}) -- bless the new udata before...
608 debug.setmetatable(x, {__gc = true}) -- ...the old one 610 debug.setmetatable(x, {__gc = nop}) -- ...the old one
609 assert(T.gccolor(y) == "white") 611 assert(T.gccolor(y) == "white")
610 T.checkmemory() 612 T.checkmemory()
611 collectgarbage("restart") 613 collectgarbage("restart")
@@ -631,6 +633,7 @@ if T then
631 assert(T.totalmem("thread") == t + 1) 633 assert(T.totalmem("thread") == t + 1)
632end 634end
633 635
636
634-- create an object to be collected when state is closed 637-- create an object to be collected when state is closed
635do 638do
636 local setmetatable,assert,type,print,getmetatable = 639 local setmetatable,assert,type,print,getmetatable =
@@ -650,7 +653,7 @@ end
650 653
651-- create several objects to raise errors when collected while closing state 654-- create several objects to raise errors when collected while closing state
652if T then 655if T then
653 local error, assert, warn, find = error, assert, warn, string.find 656 local error, assert, find = error, assert, string.find
654 local n = 0 657 local n = 0
655 local lastmsg 658 local lastmsg
656 local mt = {__gc = function (o) 659 local mt = {__gc = function (o)