diff options
Diffstat (limited to 'unit_tests/scripts/lane/tasking_send_receive_code.lua')
-rw-r--r-- | unit_tests/scripts/lane/tasking_send_receive_code.lua | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/unit_tests/scripts/lane/tasking_send_receive_code.lua b/unit_tests/scripts/lane/tasking_send_receive_code.lua index cb3663f..fdc2602 100644 --- a/unit_tests/scripts/lane/tasking_send_receive_code.lua +++ b/unit_tests/scripts/lane/tasking_send_receive_code.lua | |||
@@ -53,28 +53,26 @@ local function chunk2(linda) | |||
53 | assert(info.linedefined == 32, "bad linedefined") -- start of 'chunk2' | 53 | assert(info.linedefined == 32, "bad linedefined") -- start of 'chunk2' |
54 | assert(config.strip_functions and info.currentline==-1 or info.currentline > info.linedefined, "bad currentline") -- line of 'debug.getinfo' | 54 | assert(config.strip_functions and info.currentline==-1 or info.currentline > info.linedefined, "bad currentline") -- line of 'debug.getinfo' |
55 | assert(info.lastlinedefined > info.currentline, "bad lastlinedefined") -- end of 'chunk2' | 55 | assert(info.lastlinedefined > info.currentline, "bad lastlinedefined") -- end of 'chunk2' |
56 | local k,func= linda:receive("down") | 56 | assert(linda:count("down") == 2, "bad linda contents") -- function, "ok" |
57 | assert(type(func)=="function", "not a function") | 57 | local k,func,str= linda:receive_batched("down", 2) |
58 | assert(k=="down") | 58 | assert(k=="down") |
59 | assert(type(func)=="function", "not a function") | ||
60 | assert(str=="ok", "bad receive result: " .. tostring(k) .. " -> ".. tostring(str)) | ||
61 | assert(linda:count("down") == 0, "bad linda contents") -- nothing | ||
59 | 62 | ||
60 | func(linda) | 63 | func(linda) |
61 | |||
62 | local k,str= linda:receive("down") | ||
63 | assert(str=="ok", "bad receive result") | ||
64 | |||
65 | linda:send("up", function() return ":)" end, "ok2") | 64 | linda:send("up", function() return ":)" end, "ok2") |
66 | end | 65 | end |
67 | 66 | ||
68 | local linda = lanes_linda{name = "auto"} | 67 | local linda = lanes_linda{name = "auto"} |
69 | local t2= lanes_gen("debug,package,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch | 68 | local t2= lanes_gen("debug,package,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch |
70 | linda:send("down", function(linda) linda:send("up", "ready!") end, | 69 | linda:send("down", function(linda) linda:send("up", "ready!") end, "ok") |
71 | "ok") | ||
72 | -- wait to see if the tiny function gets executed | 70 | -- wait to see if the tiny function gets executed |
73 | -- | 71 | -- |
74 | local k,s= linda:receive(1, "up") | 72 | local k,s= linda:receive(1, "up") |
75 | if t2.status == "error" then | 73 | if t2.status == "error" then |
76 | PRINT("t2 error: " , t2:join()) | 74 | local n,err,s = t2:join() |
77 | assert(false) | 75 | assert(false, "t2 error: " .. err) |
78 | end | 76 | end |
79 | PRINT(s) | 77 | PRINT(s) |
80 | assert(s=="ready!", s .. " is not 'ready!'") | 78 | assert(s=="ready!", s .. " is not 'ready!'") |