aboutsummaryrefslogtreecommitdiff
path: root/testes/api.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-01-01 12:14:56 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-01-01 12:14:56 -0200
commitc6f7181e910b6b2ff1346b5486a31be87b1da5af (patch)
tree92cc716487c83ecd9860444f23fd55ef65358cbb /testes/api.lua
parent437a5b07d415e1a74160ddfd804017171d6cc5cb (diff)
downloadlua-c6f7181e910b6b2ff1346b5486a31be87b1da5af.tar.gz
lua-c6f7181e910b6b2ff1346b5486a31be87b1da5af.tar.bz2
lua-c6f7181e910b6b2ff1346b5486a31be87b1da5af.zip
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.lua28
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
114 114
115-- testing warnings 115-- testing warnings
116T.testC([[ 116T.testC([[
117 warning "*This " 117 warning "#This shold be a"
118 warning "warning " 118 warning " single "
119 warning "should be in a" 119 warning "warning
120 warning " single line
121" 120"
122 warning "*This should be " 121 warning "#This should be "
123 warning "another warning 122 warning "another one
124" 123"
125]]) 124]])
126 125
@@ -896,24 +895,15 @@ do -- testing errors during GC
896 a[i] = T.newuserdata(i) -- creates several udata 895 a[i] = T.newuserdata(i) -- creates several udata
897 end 896 end
898 for i=1,20,2 do -- mark half of them to raise errors during GC 897 for i=1,20,2 do -- mark half of them to raise errors during GC
899 debug.setmetatable(a[i], {__gc = function (x) error("error inside gc") end}) 898 debug.setmetatable(a[i],
899 {__gc = function (x) error("@expected error in gc") end})
900 end 900 end
901 for i=2,20,2 do -- mark the other half to count and to create more garbage 901 for i=2,20,2 do -- mark the other half to count and to create more garbage
902 debug.setmetatable(a[i], {__gc = function (x) load("A=A+1")() end}) 902 debug.setmetatable(a[i], {__gc = function (x) load("A=A+1")() end})
903 end 903 end
904 a = nil
904 _G.A = 0 905 _G.A = 0
905 a = 0 906 collectgarbage()
906 while 1 do
907 local stat, msg = pcall(collectgarbage)
908 if stat then
909 break -- stop when no more errors
910 else
911 a = a + 1
912 assert(string.find(msg, "__gc"))
913 end
914 end
915 assert(a == 10) -- number of errors
916
917 assert(A == 10) -- number of normal collections 907 assert(A == 10) -- number of normal collections
918 collectgarbage("restart") 908 collectgarbage("restart")
919end 909end