diff options
Diffstat (limited to 'testes')
-rw-r--r-- | testes/locals.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 28f88e54..8766b3d5 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
@@ -324,6 +324,38 @@ if rawget(_G, "T") then | |||
324 | local _, msg = pcall(test) | 324 | local _, msg = pcall(test) |
325 | assert(msg == 1000) | 325 | assert(msg == 1000) |
326 | 326 | ||
327 | |||
328 | do -- testing 'toclose' in C string buffer | ||
329 | local s = string.rep("a", 10000) | ||
330 | local a = {s, s} | ||
331 | |||
332 | -- ensure proper initialization (stack space, metatable) | ||
333 | table.concat(a) | ||
334 | collectgarbage(); collectgarbage() | ||
335 | |||
336 | local m = T.totalmem() | ||
337 | |||
338 | -- error in the second buffer allocation | ||
339 | T.alloccount(3) | ||
340 | assert(not pcall(table.concat, a)) | ||
341 | T.alloccount() | ||
342 | -- first buffer was released by 'toclose' | ||
343 | assert(T.totalmem() - m <= 5000) | ||
344 | |||
345 | -- error in creation of final string | ||
346 | T.alloccount(4) | ||
347 | assert(not pcall(table.concat, a)) | ||
348 | T.alloccount() | ||
349 | -- second buffer was released by 'toclose' | ||
350 | assert(T.totalmem() - m <= 5000) | ||
351 | |||
352 | -- userdata, upvalue, buffer, buffer, string | ||
353 | T.alloccount(5) | ||
354 | assert(#table.concat(a) == 20000) | ||
355 | T.alloccount() | ||
356 | |||
357 | print'+' | ||
358 | end | ||
327 | end | 359 | end |
328 | 360 | ||
329 | 361 | ||