aboutsummaryrefslogtreecommitdiff
path: root/tests/basic.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/basic.lua23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/basic.lua b/tests/basic.lua
index fff19ed..ecd93fc 100644
--- a/tests/basic.lua
+++ b/tests/basic.lua
@@ -249,7 +249,26 @@ assert(type(linda) == "userdata" and tostring(linda) == "Linda: communications")
249 -- ["->"] master -> slave 249 -- ["->"] master -> slave
250 -- ["<-"] slave <- master 250 -- ["<-"] slave <- master
251 251
252local function PEEK() return linda:get("<-") end 252WR "test linda:get/set..."
253linda:set("<->", "x", "y", "z")
254local x,y,z = linda:get("<->", 1)
255assert(x == "x" and y == nil and z == nil)
256local x,y,z = linda:get("<->", 2)
257assert(x == "x" and y == "y" and z == nil)
258local x,y,z = linda:get("<->", 3)
259assert(x == "x" and y == "y" and z == "z")
260local x,y,z,w = linda:get("<->", 4)
261assert(x == "x" and y == "y" and z == "z" and w == nil)
262local k, x = linda:receive("<->")
263assert(k == "<->" and x == "x")
264local k,y,z = linda:receive(linda.batched, "<->", 2)
265assert(k == "<->" and y == "y" and z == "z")
266linda:set("<->")
267local x,y,z,w = linda:get("<->", 4)
268assert(x == nil and y == nil and z == nil and w == nil)
269WR "ok\n"
270
271local function PEEK(...) return linda:get("<-", ...) end
253local function SEND(...) linda:send("->", ...) end 272local function SEND(...) linda:send("->", ...) end
254local function RECEIVE() local k,v = linda:receive(1, "<-") return v end 273local function RECEIVE() local k,v = linda:receive(1, "<-") return v end
255 274
@@ -259,7 +278,7 @@ SEND(1); WR("main ", "1 sent\n")
259SEND(2); WR("main ", "2 sent\n") 278SEND(2); WR("main ", "2 sent\n")
260SEND(3); WR("main ", "3 sent\n") 279SEND(3); WR("main ", "3 sent\n")
261SEND(setmetatable({"should be ignored"},{__lanesignore=true})); WR("main ", "__lanesignore table sent\n") 280SEND(setmetatable({"should be ignored"},{__lanesignore=true})); WR("main ", "__lanesignore table sent\n")
262for i=1,100 do 281for i=1,40 do
263 WR "." 282 WR "."
264 SLEEP(0.0001) 283 SLEEP(0.0001)
265 assert(PEEK() == nil) -- nothing coming in, yet 284 assert(PEEK() == nil) -- nothing coming in, yet