From 64a4223203928443ee5a49dbb7579e1db53a4056 Mon Sep 17 00:00:00 2001 From: Thomas Harning Jr Date: Thu, 6 Sep 2007 00:05:55 -0400 Subject: Added timertest. Prevented GC-ed events from causing an abort. --- test/timertest.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/timertest.lua (limited to 'test') diff --git a/test/timertest.lua b/test/timertest.lua new file mode 100644 index 0000000..ec1257c --- /dev/null +++ b/test/timertest.lua @@ -0,0 +1,19 @@ +require("luaevent.core") + +c = luaevent.core.new() +local f = 100 +local function createEvent() + return c:addevent(nil, luaevent.core.EV_TIMEOUT, function(ev) io.write(".." .. f) f = f - 1 if f < 0 then return -1 end collectgarbage() end, 0.01) +end +ev = createEvent() +print("TESTING Garbage-collect-safe version") +c:loop() +assert(f < 0, "DID NOT FINISH LOOPING") +io.write("\n") +print("TESTING Garbage-collect unsafe version") +f = 100 +createEvent() +c:loop() +assert(f >= 0, "Did not perform expected collection") +io.write("\n") +print("Completed both tests") -- cgit v1.2.3