aboutsummaryrefslogtreecommitdiff
path: root/testes/gc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/gc.lua')
-rw-r--r--testes/gc.lua42
1 files changed, 23 insertions, 19 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 381c5548..03093e34 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -125,7 +125,7 @@ do
125 end 125 end
126 126
127 a:test() 127 a:test()
128 128 _G.temp = nil
129end 129end
130 130
131 131
@@ -134,7 +134,7 @@ do local f = function () end end
134 134
135 135
136print("functions with errors") 136print("functions with errors")
137prog = [[ 137local prog = [[
138do 138do
139 a = 10; 139 a = 10;
140 function foo(x,y) 140 function foo(x,y)
@@ -153,22 +153,25 @@ do
153 end 153 end
154 end 154 end
155end 155end
156rawset(_G, "a", nil)
157_G.x = nil
156 158
157foo = nil 159do
158print('long strings') 160 foo = nil
159x = "01234567890123456789012345678901234567890123456789012345678901234567890123456789" 161 print('long strings')
160assert(string.len(x)==80) 162 local x = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"
161s = '' 163 assert(string.len(x)==80)
162k = math.min(300, (math.maxinteger // 80) // 2) 164 local s = ''
163for n = 1, k do s = s..x; j=tostring(n) end 165 local k = math.min(300, (math.maxinteger // 80) // 2)
164assert(string.len(s) == k*80) 166 for n = 1, k do s = s..x; local j=tostring(n) end
165s = string.sub(s, 1, 10000) 167 assert(string.len(s) == k*80)
166s, i = string.gsub(s, '(%d%d%d%d)', '') 168 s = string.sub(s, 1, 10000)
167assert(i==10000 // 4) 169 local s, i = string.gsub(s, '(%d%d%d%d)', '')
168s = nil 170 assert(i==10000 // 4)
169x = nil 171
170 172 assert(_G["while"] == 234)
171assert(_G["while"] == 234) 173 _G["while"] = nil
174end
172 175
173 176
174-- 177--
@@ -227,8 +230,8 @@ end
227 230
228 231
229print("clearing tables") 232print("clearing tables")
230lim = 15 233local lim = 15
231a = {} 234local a = {}
232-- fill a with `collectable' indices 235-- fill a with `collectable' indices
233for i=1,lim do a[{}] = i end 236for i=1,lim do a[{}] = i end
234b = {} 237b = {}
@@ -552,6 +555,7 @@ do
552 for i=1,1000 do _ENV.a = {} end -- no collection during the loop 555 for i=1,1000 do _ENV.a = {} end -- no collection during the loop
553 until gcinfo() > 2 * x 556 until gcinfo() > 2 * x
554 collectgarbage"restart" 557 collectgarbage"restart"
558 _ENV.a = nil
555end 559end
556 560
557 561