tests/test.lua

changeset 28
0584f8251f88
parent 11
b2a77ebe7aed
child 29
3f77d77806c1
equal deleted inserted replaced
27:04cfdac393cc 28:0584f8251f88
355 lxp.new({}) 355 lxp.new({})
356 end 356 end
357 collectgarbage(); collectgarbage() 357 collectgarbage(); collectgarbage()
358 assert(math.abs(gcinfo() - x) <= 2) 358 assert(math.abs(gcinfo() - x) <= 2)
359 359
360 -- test for GC (circular references)
361 print("testing garbage collection (circular reference)")
362 collectgarbage(); collectgarbage()
363 local x = gcinfo()
364 for i=1,100000 do
365 -- due to a small bug in Lua...
366 if (math.mod or math.fmod)(i, 100) == 0 then collectgarbage() end
367 local p;
368 p = lxp.new({ StartElement = function () print(p) end });
369 end
370 collectgarbage(); collectgarbage()
371 assert(math.abs(gcinfo() - x) <= 2)
360 372
361 print"OK" 373 print"OK"
362 374

mercurial