diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-01-01 12:14:56 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-01-01 12:14:56 -0200 |
| commit | c6f7181e910b6b2ff1346b5486a31be87b1da5af (patch) | |
| tree | 92cc716487c83ecd9860444f23fd55ef65358cbb /testes/api.lua | |
| parent | 437a5b07d415e1a74160ddfd804017171d6cc5cb (diff) | |
| download | lua-github-c6f7181e910b6b2ff1346b5486a31be87b1da5af.tar.gz | |
No more LUA_ERRGCMM errors
Errors in finalizers (__gc metamethods) are never propagated.
Instead, they generate a warning.
Diffstat (limited to 'testes/api.lua')
| -rw-r--r-- | testes/api.lua | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/testes/api.lua b/testes/api.lua index b4d63866..893a36cb 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -114,13 +114,12 @@ end -- testing warnings T.testC([[ - warning "*This " - warning "warning " - warning "should be in a" - warning " single line + warning "#This shold be a" + warning " single " + warning "warning " - warning "*This should be " - warning "another warning + warning "#This should be " + warning "another one " ]]) @@ -896,24 +895,15 @@ do -- testing errors during GC a[i] = T.newuserdata(i) -- creates several udata end for i=1,20,2 do -- mark half of them to raise errors during GC - debug.setmetatable(a[i], {__gc = function (x) error("error inside gc") end}) + debug.setmetatable(a[i], + {__gc = function (x) error("@expected error in gc") end}) end for i=2,20,2 do -- mark the other half to count and to create more garbage debug.setmetatable(a[i], {__gc = function (x) load("A=A+1")() end}) end + a = nil _G.A = 0 - a = 0 - while 1 do - local stat, msg = pcall(collectgarbage) - if stat then - break -- stop when no more errors - else - a = a + 1 - assert(string.find(msg, "__gc")) - end - end - assert(a == 10) -- number of errors - + collectgarbage() assert(A == 10) -- number of normal collections collectgarbage("restart") end |
