diff options
Diffstat (limited to 'testes/gc.lua')
-rw-r--r-- | testes/gc.lua | 11 |
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") | |||
18 | assert(collectgarbage("incremental") == "incremental") | 18 | assert(collectgarbage("incremental") == "incremental") |
19 | 19 | ||
20 | 20 | ||
21 | local function nop () end | ||
22 | |||
21 | local function gcinfo () | 23 | local function gcinfo () |
22 | return collectgarbage"count" * 1024 | 24 | return collectgarbage"count" * 1024 |
23 | end | 25 | end |
@@ -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 | ||
393 | end | 395 | end |
394 | print '+' | 396 | print '+' |
@@ -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) |
632 | end | 634 | end |
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 |
635 | do | 638 | do |
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 |
652 | if T then | 655 | if 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) |