From 8d1a16c36ffd64638e6c3cc8a47b5c56017cdc9f Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 23 Jun 2025 09:08:25 +0200 Subject: Added 2 tests in tasking_basic --- unit_tests/scripts/lane/tasking_basic.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/unit_tests/scripts/lane/tasking_basic.lua b/unit_tests/scripts/lane/tasking_basic.lua index 233accf..7a22307 100644 --- a/unit_tests/scripts/lane/tasking_basic.lua +++ b/unit_tests/scripts/lane/tasking_basic.lua @@ -15,6 +15,33 @@ local lanes_linda = assert(lanes.linda) -- ################################################################################################## -- ################################################################################################## +-- we can create a generator where the lane body is a C function +do + local b, g = pcall(lanes.gen, "*", print) + assert(b == true and type(g) == "function") + -- we can start the lane + local b, h = pcall(g, "hello") + -- the lane runs normally + h:join() + assert(h.status == "done") +end + +-- we can create a generator where the lane body is a C function that raises an error +do + local b, g = pcall(lanes.gen, "*", error) + assert(b == true and type(g) == "function") + -- we can start the lane + local b, h = pcall(g, "this is an error") + -- this provides the error that occurred in the lane + local s, e, t = h:join() + assert(h.status == "error") + assert(s == nil and e == "this is an error" and t == nil) +end + +-- ################################################################################################## +-- ################################################################################################## +-- ################################################################################################## + local function task(a, b, c) local new_name = "task("..a..","..b..","..c..")" -- test lane naming change -- cgit v1.2.3-55-g6feb