aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 16:49:58 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 16:49:58 +0200
commitae582acdb1bfb3fb4171682b884545d174e95aa9 (patch)
treeb0c9c0b14f6d57cd8ce1c14d4d23df1adb0bc539 /tests
parent3f5c16116a3a7740ac4ac62b663661d772543c2e (diff)
downloadlanes-ae582acdb1bfb3fb4171682b884545d174e95aa9.tar.gz
lanes-ae582acdb1bfb3fb4171682b884545d174e95aa9.tar.bz2
lanes-ae582acdb1bfb3fb4171682b884545d174e95aa9.zip
linda:send() returns nil,<something> in case of error
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.lua14
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
219local chunk= function(linda) 219local 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)
269WR "ok\n" 269WR "ok\n"
270 270
271local function PEEK(...) return linda:get("<-", ...) end 271local function PEEK(...) return linda:get("<-", ...) end
272local function SEND(...) linda:send("->", ...) end 272local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end
273local function RECEIVE() local k,v = linda:receive(1, "<-") return v end 273local function RECEIVE() local k,v = linda:receive(1, "<-") return v end
274 274
275local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch 275local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch