aboutsummaryrefslogtreecommitdiff
path: root/testes/api.lua
diff options
context:
space:
mode:
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