diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/basic.lua b/tests/basic.lua index 28f0334..cad3764 100644 --- a/tests/basic.lua +++ b/tests/basic.lua | |||
@@ -218,16 +218,16 @@ local function WR(...) io.stderr:write(...) end | |||
218 | 218 | ||
219 | local chunk= function(linda) | 219 | local chunk= function(linda) |
220 | local function receive() return linda:receive("->") end | 220 | local function receive() return linda:receive("->") end |
221 | local function send(...) linda:send("<-", ...) end | 221 | local function send(...) local _res, _err = linda:send("<-", ...) assert(_res == true and _err == nil) end |
222 | 222 | ||
223 | WR("chunk ", "Lane starts!\n") | 223 | WR("chunk ", "Lane starts!\n") |
224 | 224 | ||
225 | local k,v | 225 | local k,v |
226 | k,v=receive(); WR("chunk ", v.." received (expecting 1)\n"); assert(v==1) | 226 | k,v=receive(); WR("chunk ", v.." received (expecting 1)\n"); assert(k and v==1) |
227 | k,v=receive(); WR("chunk ", v.." received (expecting 2)\n"); assert(v==2) | 227 | k,v=receive(); WR("chunk ", v.." received (expecting 2)\n"); assert(k and v==2) |
228 | k,v=receive(); WR("chunk ", v.." received (expecting 3)\n"); assert(v==3) | 228 | k,v=receive(); WR("chunk ", v.." received (expecting 3)\n"); assert(k and v==3) |
229 | k,v=receive(); WR("chunk ", tostring(v).." received (expecting nil from __lanesconvert)\n"); assert(v==nil, "table with __lanesconvert==lanes.null should be received as nil, got " .. tostring(v)) -- a table with __lanesconvert was sent | 229 | k,v=receive(); WR("chunk ", tostring(v).." received (expecting nil from __lanesconvert)\n"); assert(k and v==nil, "table with __lanesconvert==lanes.null should be received as nil, got " .. tostring(v)) -- a table with __lanesconvert was sent |
230 | k,v=receive(); WR("chunk ", tostring(v).." received (expecting nil)\n"); assert(v==nil) | 230 | k,v=receive(); WR("chunk ", tostring(v).." received (expecting nil)\n"); assert(k and v==nil) |
231 | 231 | ||
232 | send(4,5,6); WR("chunk ", "4,5,6 sent\n") | 232 | send(4,5,6); WR("chunk ", "4,5,6 sent\n") |
233 | send 'aaa'; WR("chunk ", "'aaa' sent\n") | 233 | send 'aaa'; WR("chunk ", "'aaa' sent\n") |
@@ -269,7 +269,7 @@ assert(x == nil and y == nil and z == nil and w == nil) | |||
269 | WR "ok\n" | 269 | WR "ok\n" |
270 | 270 | ||
271 | local function PEEK(...) return linda:get("<-", ...) end | 271 | local function PEEK(...) return linda:get("<-", ...) end |
272 | local function SEND(...) linda:send("->", ...) end | 272 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end |
273 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end | 273 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end |
274 | 274 | ||
275 | local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch | 275 | local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch |