diff options
Diffstat (limited to 'tests/basic.lua')
-rw-r--r-- | tests/basic.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/basic.lua b/tests/basic.lua index ab8a080..da7d756 100644 --- a/tests/basic.lua +++ b/tests/basic.lua | |||
@@ -29,6 +29,11 @@ local function PRINT(...) | |||
29 | end | 29 | end |
30 | end | 30 | end |
31 | 31 | ||
32 | local SLEEP = function(...) | ||
33 | local k, v = lanes.sleep(...) | ||
34 | assert(k == nil and v == "timeout") | ||
35 | end | ||
36 | |||
32 | local gc_cb = function(name_, status_) | 37 | local gc_cb = function(name_, status_) |
33 | PRINT(" ---> lane '" .. name_ .. "' collected with status '" .. status_ .. "'") | 38 | PRINT(" ---> lane '" .. name_ .. "' collected with status '" .. status_ .. "'") |
34 | end | 39 | end |
@@ -256,7 +261,7 @@ SEND(3); WR("main ", "3 sent\n") | |||
256 | SEND(setmetatable({"should be ignored"},{__lanesignore=true})); WR("main ", "__lanesignore table sent\n") | 261 | SEND(setmetatable({"should be ignored"},{__lanesignore=true})); WR("main ", "__lanesignore table sent\n") |
257 | for i=1,100 do | 262 | for i=1,100 do |
258 | WR "." | 263 | WR "." |
259 | lanes.sleep(0.0001) | 264 | SLEEP(0.0001) |
260 | assert(PEEK() == nil) -- nothing coming in, yet | 265 | assert(PEEK() == nil) -- nothing coming in, yet |
261 | end | 266 | end |
262 | SEND(nil); WR("\nmain ", "nil sent\n") | 267 | SEND(nil); WR("\nmain ", "nil sent\n") |
@@ -293,7 +298,7 @@ comms_lane = nil | |||
293 | collectgarbage() | 298 | collectgarbage() |
294 | -- wait | 299 | -- wait |
295 | WR("waiting 1s") | 300 | WR("waiting 1s") |
296 | lanes.sleep(1) | 301 | SLEEP(1) |
297 | 302 | ||
298 | -- ################################################################################################## | 303 | -- ################################################################################################## |
299 | -- ################################################################################################## | 304 | -- ################################################################################################## |
@@ -470,7 +475,7 @@ end) | |||
470 | 475 | ||
471 | h= S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values | 476 | h= S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values |
472 | -- wait a bit so that the lane has a chance to set its debug name | 477 | -- wait a bit so that the lane has a chance to set its debug name |
473 | lanes.sleep(0.5) | 478 | SLEEP(0.5) |
474 | print("joining with '" .. h:get_debug_threadname() .. "'") | 479 | print("joining with '" .. h:get_debug_threadname() .. "'") |
475 | local a,b,c,d= h:join() | 480 | local a,b,c,d= h:join() |
476 | if h.status == "error" then | 481 | if h.status == "error" then |