diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-06-24 08:53:36 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-06-24 08:53:36 +0200 |
| commit | 41dcaf101368350a49e756abc41f3e9c3c22ec66 (patch) | |
| tree | ff3e072f027f56feb6e2187c800abfa3386a5431 /unit_tests/scripts | |
| parent | b9f17d8a10c8508a893b0e86000128e0dbf2a146 (diff) | |
| download | lanes-41dcaf101368350a49e756abc41f3e9c3c22ec66.tar.gz lanes-41dcaf101368350a49e756abc41f3e9c3c22ec66.tar.bz2 lanes-41dcaf101368350a49e756abc41f3e9c3c22ec66.zip | |
Move some tests to a separate script
Diffstat (limited to 'unit_tests/scripts')
| -rw-r--r-- | unit_tests/scripts/lane/body_is_a_c_function.lua | 28 | ||||
| -rw-r--r-- | unit_tests/scripts/lane/tasking_basic.lua | 27 |
2 files changed, 28 insertions, 27 deletions
diff --git a/unit_tests/scripts/lane/body_is_a_c_function.lua b/unit_tests/scripts/lane/body_is_a_c_function.lua new file mode 100644 index 0000000..d8d329f --- /dev/null +++ b/unit_tests/scripts/lane/body_is_a_c_function.lua | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | local lanes = require "lanes".configure() | ||
| 2 | |||
| 3 | -- ################################################################################################## | ||
| 4 | -- ################################################################################################## | ||
| 5 | -- ################################################################################################## | ||
| 6 | |||
| 7 | -- we can create a generator where the lane body is a C function | ||
| 8 | do | ||
| 9 | local b, g = pcall(lanes.gen, "*", print) | ||
| 10 | assert(b == true and type(g) == "function") | ||
| 11 | -- we can start the lane | ||
| 12 | local b, h = pcall(g, "hello") | ||
| 13 | -- the lane runs normally | ||
| 14 | h:join() | ||
| 15 | assert(h.status == "done") | ||
| 16 | end | ||
| 17 | |||
| 18 | -- we can create a generator where the lane body is a C function that raises an error | ||
| 19 | do | ||
| 20 | local b, g = pcall(lanes.gen, "*", error) | ||
| 21 | assert(b == true and type(g) == "function") | ||
| 22 | -- we can start the lane | ||
| 23 | local b, h = pcall(g, "this is an error") | ||
| 24 | -- this provides the error that occurred in the lane | ||
| 25 | local s, e, t = h:join() | ||
| 26 | assert(h.status == "error") | ||
| 27 | assert(s == nil and e == "this is an error" and t == nil) | ||
| 28 | end | ||
diff --git a/unit_tests/scripts/lane/tasking_basic.lua b/unit_tests/scripts/lane/tasking_basic.lua index 7a22307..233accf 100644 --- a/unit_tests/scripts/lane/tasking_basic.lua +++ b/unit_tests/scripts/lane/tasking_basic.lua | |||
| @@ -15,33 +15,6 @@ local lanes_linda = assert(lanes.linda) | |||
| 15 | -- ################################################################################################## | 15 | -- ################################################################################################## |
| 16 | -- ################################################################################################## | 16 | -- ################################################################################################## |
| 17 | 17 | ||
| 18 | -- we can create a generator where the lane body is a C function | ||
| 19 | do | ||
| 20 | local b, g = pcall(lanes.gen, "*", print) | ||
| 21 | assert(b == true and type(g) == "function") | ||
| 22 | -- we can start the lane | ||
| 23 | local b, h = pcall(g, "hello") | ||
| 24 | -- the lane runs normally | ||
| 25 | h:join() | ||
| 26 | assert(h.status == "done") | ||
| 27 | end | ||
| 28 | |||
| 29 | -- we can create a generator where the lane body is a C function that raises an error | ||
| 30 | do | ||
| 31 | local b, g = pcall(lanes.gen, "*", error) | ||
| 32 | assert(b == true and type(g) == "function") | ||
| 33 | -- we can start the lane | ||
| 34 | local b, h = pcall(g, "this is an error") | ||
| 35 | -- this provides the error that occurred in the lane | ||
| 36 | local s, e, t = h:join() | ||
| 37 | assert(h.status == "error") | ||
| 38 | assert(s == nil and e == "this is an error" and t == nil) | ||
| 39 | end | ||
| 40 | |||
| 41 | -- ################################################################################################## | ||
| 42 | -- ################################################################################################## | ||
| 43 | -- ################################################################################################## | ||
| 44 | |||
| 45 | local function task(a, b, c) | 18 | local function task(a, b, c) |
| 46 | local new_name = "task("..a..","..b..","..c..")" | 19 | local new_name = "task("..a..","..b..","..c..")" |
| 47 | -- test lane naming change | 20 | -- test lane naming change |
