Fix. Test for Lua > 5.1

This commit is contained in:
Alexey Melnichuk 2016-09-27 18:20:34 +03:00
parent e7f83e7aa6
commit a836734bfc

View File

@ -2,10 +2,17 @@ local curl = require "lcurl"
local called, active_coroutine = 0 local called, active_coroutine = 0
-- for Lua 5.1 compat
local function co_running()
local co, main = coroutine.running()
if main == true then return nil end
return co
end
function on_timer() function on_timer()
called = called + 1 called = called + 1
-- use `os.exit` because now Lua-cURL did not propogate error from callback -- use `os.exit` because now Lua-cURL did not propogate error from callback
if coroutine.running() ~= active_coroutine then os.exit(-1) end if co_running() ~= active_coroutine then os.exit(-1) end
end end
local function test_1() local function test_1()