Skip to content

Commit

Permalink
Fix async test
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Oct 1, 2014
1 parent 660740f commit 607a3ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/tap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ local uv = require('luv')
local dump = require('lib/utils').dump

local function protect(...)
local text = table.concat({...}, "\t")
local n = select('#', ...)
local arguments = {...}
for i = 1, n do
arguments[i] = tostring(arguments[i])
end

local text = table.concat(arguments, "\t")
text = " " .. string.gsub(text, "\n", "\n ")
print(text)
end
Expand Down
2 changes: 1 addition & 1 deletion src/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static int luv_new_async(lua_State* L) {
lua_pop(L, 1);
return luv_error(L, ret);
}
luv_check_callback(L, handle->data, LUV_ASYNC, 1);
handle->data = luv_setup_handle(L);
luv_check_callback(L, handle->data, LUV_ASYNC, 1);
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ require('lib/tap')(function (test)
end))
end)

test("simple async", function (print, p, expect, uv)
local async
async = uv.new_async(expect(function (self)
assert(self == async)
uv.close(async)
end))
uv.async_send(async)
end)

end)
4 changes: 2 additions & 2 deletions tests/test-timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ require('lib/tap')(function (test)
if r == 0 then
uv.timer_set_repeat(timer, 8)
uv.timer_again(timer)
elseif r == 1 then
elseif r == 2 then
uv.timer_stop(timer)
uv.close(timer)
else
uv.timer_set_repeat(timer, r / 2)
end
end, 5), 10, 0)
end, 4), 10, 0)
end)

end)

0 comments on commit 607a3ec

Please sign in to comment.