diff options
Diffstat (limited to '')
-rw-r--r-- | tests/basic.lua | 23 |
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 | ||
252 | local function PEEK() return linda:get("<-") end | 252 | WR "test linda:get/set..." |
253 | linda:set("<->", "x", "y", "z") | ||
254 | local x,y,z = linda:get("<->", 1) | ||
255 | assert(x == "x" and y == nil and z == nil) | ||
256 | local x,y,z = linda:get("<->", 2) | ||
257 | assert(x == "x" and y == "y" and z == nil) | ||
258 | local x,y,z = linda:get("<->", 3) | ||
259 | assert(x == "x" and y == "y" and z == "z") | ||
260 | local x,y,z,w = linda:get("<->", 4) | ||
261 | assert(x == "x" and y == "y" and z == "z" and w == nil) | ||
262 | local k, x = linda:receive("<->") | ||
263 | assert(k == "<->" and x == "x") | ||
264 | local k,y,z = linda:receive(linda.batched, "<->", 2) | ||
265 | assert(k == "<->" and y == "y" and z == "z") | ||
266 | linda:set("<->") | ||
267 | local x,y,z,w = linda:get("<->", 4) | ||
268 | assert(x == nil and y == nil and z == nil and w == nil) | ||
269 | WR "ok\n" | ||
270 | |||
271 | local function PEEK(...) return linda:get("<-", ...) end | ||
253 | local function SEND(...) linda:send("->", ...) end | 272 | local function SEND(...) linda:send("->", ...) end |
254 | 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 |
255 | 274 | ||
@@ -259,7 +278,7 @@ SEND(1); WR("main ", "1 sent\n") | |||
259 | SEND(2); WR("main ", "2 sent\n") | 278 | SEND(2); WR("main ", "2 sent\n") |
260 | SEND(3); WR("main ", "3 sent\n") | 279 | SEND(3); WR("main ", "3 sent\n") |
261 | SEND(setmetatable({"should be ignored"},{__lanesignore=true})); WR("main ", "__lanesignore table sent\n") | 280 | SEND(setmetatable({"should be ignored"},{__lanesignore=true})); WR("main ", "__lanesignore table sent\n") |
262 | for i=1,100 do | 281 | for 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 |