aboutsummaryrefslogtreecommitdiff
path: root/testes/gc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/gc.lua')
-rw-r--r--testes/gc.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 9ea054c1..6bdc98ca 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -369,6 +369,7 @@ if T then
369 s[n] = i 369 s[n] = i
370 end 370 end
371 371
372 warn("@store")
372 collectgarbage() 373 collectgarbage()
373 assert(string.find(_WARN, "error in __gc metamethod")) 374 assert(string.find(_WARN, "error in __gc metamethod"))
374 assert(string.match(_WARN, "@(.-)@") == "expected") 375 assert(string.match(_WARN, "@(.-)@") == "expected")
@@ -383,6 +384,7 @@ if T then
383 for i = 1, 10 do assert(s[i]) end 384 for i = 1, 10 do assert(s[i]) end
384 385
385 getmetatable(u).__gc = nil 386 getmetatable(u).__gc = nil
387 warn("@normal")
386 388
387end 389end
388print '+' 390print '+'
@@ -475,9 +477,11 @@ end
475 477
476-- errors during collection 478-- errors during collection
477if T then 479if T then
480 warn("@store")
478 u = setmetatable({}, {__gc = function () error "@expected error" end}) 481 u = setmetatable({}, {__gc = function () error "@expected error" end})
479 u = nil 482 u = nil
480 collectgarbage() 483 collectgarbage()
484 warn("@normal")
481end 485end
482 486
483 487
@@ -645,7 +649,7 @@ end
645 649
646-- create several objects to raise errors when collected while closing state 650-- create several objects to raise errors when collected while closing state
647if T then 651if T then
648 local error, assert, find = error, assert, string.find 652 local error, assert, find, warn = error, assert, string.find, warn
649 local n = 0 653 local n = 0
650 local lastmsg 654 local lastmsg
651 local mt = {__gc = function (o) 655 local mt = {__gc = function (o)
@@ -659,7 +663,9 @@ if T then
659 else 663 else
660 assert(lastmsg == _WARN) -- subsequent error messages are equal 664 assert(lastmsg == _WARN) -- subsequent error messages are equal
661 end 665 end
666 warn("@store")
662 error"@expected warning" 667 error"@expected warning"
668 warn("@normal")
663 end} 669 end}
664 for i = 10, 1, -1 do 670 for i = 10, 1, -1 do
665 -- create object and preserve it until the end 671 -- create object and preserve it until the end