diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-29 18:07:16 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-29 18:07:16 +0200 |
| commit | bb11006f635a69dd9244e09e4359ed02eff8fe84 (patch) | |
| tree | 7fda9eda216b1683ff3dd954b6300c13bfaf2b14 /tests | |
| parent | 34b2b5e712ea1cc59004ca48f79f54af162993a5 (diff) | |
| download | lanes-bb11006f635a69dd9244e09e4359ed02eff8fe84.tar.gz lanes-bb11006f635a69dd9244e09e4359ed02eff8fe84.tar.bz2 lanes-bb11006f635a69dd9244e09e4359ed02eff8fe84.zip | |
Internal refactorization to properly handle lua_resume idiosyncrasies
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cancel.lua | 2 | ||||
| -rw-r--r-- | tests/error.lua | 9 | ||||
| -rw-r--r-- | tests/finalizer.lua | 4 | ||||
| -rw-r--r-- | tests/tobeclosed.lua | 2 |
4 files changed, 12 insertions, 5 deletions
diff --git a/tests/cancel.lua b/tests/cancel.lua index 8dfccd2..1984c85 100644 --- a/tests/cancel.lua +++ b/tests/cancel.lua | |||
| @@ -72,7 +72,7 @@ local waitCancellation = function( h, expected_status) | |||
| 72 | until h.status ~= "running" | 72 | until h.status ~= "running" |
| 73 | end | 73 | end |
| 74 | print( "lane status:", h.status) | 74 | print( "lane status:", h.status) |
| 75 | assert( h.status == expected_status, h.status .. " ~= " .. expected_status) | 75 | assert( h.status == expected_status, "lane status " .. h.status .. " (actual) ~= " .. expected_status .. " (expected)") |
| 76 | print "test OK" | 76 | print "test OK" |
| 77 | end | 77 | end |
| 78 | 78 | ||
diff --git a/tests/error.lua b/tests/error.lua index 126161e..a1ba1ce 100644 --- a/tests/error.lua +++ b/tests/error.lua | |||
| @@ -95,12 +95,12 @@ local make_table_error_mt = function() | |||
| 95 | end | 95 | end |
| 96 | 96 | ||
| 97 | local lane_error_as_string = "'lane error as string'" | 97 | local lane_error_as_string = "'lane error as string'" |
| 98 | local lane_error_as_table = setmetatable({}, make_table_error_mt()) | 98 | local lane_error_as_table = setmetatable({"lane error as table"}, make_table_error_mt()) |
| 99 | local lane_error_as_linda = lanes.linda("'lane error'") | 99 | local lane_error_as_linda = lanes.linda("'lane error'") |
| 100 | 100 | ||
| 101 | local finalizer_error_as_string = "'lane error as string'" | 101 | local finalizer_error_as_string = "'finalizer error as string'" |
| 102 | local finalizer_error_as_table = setmetatable({}, make_table_error_mt()) | 102 | local finalizer_error_as_table = setmetatable({"finalizer error as table"}, make_table_error_mt()) |
| 103 | local finalizer_error_as_linda = lanes.linda("'lane error'") | 103 | local finalizer_error_as_linda = lanes.linda("'finalizer error'") |
| 104 | 104 | ||
| 105 | local test_settings = {} | 105 | local test_settings = {} |
| 106 | local configure_tests = function() | 106 | local configure_tests = function() |
| @@ -150,6 +150,7 @@ local configure_tests = function() | |||
| 150 | end | 150 | end |
| 151 | end | 151 | end |
| 152 | end | 152 | end |
| 153 | WR "Tests configured" | ||
| 153 | end | 154 | end |
| 154 | 155 | ||
| 155 | configure_tests() | 156 | configure_tests() |
diff --git a/tests/finalizer.lua b/tests/finalizer.lua index 1412a67..8bf89b4 100644 --- a/tests/finalizer.lua +++ b/tests/finalizer.lua | |||
| @@ -39,6 +39,7 @@ local function lane(error_) | |||
| 39 | error(error_, 0) -- exception here; the value needs NOT be a string | 39 | error(error_, 0) -- exception here; the value needs NOT be a string |
| 40 | end | 40 | end |
| 41 | -- no exception | 41 | -- no exception |
| 42 | io.stderr:write("Lane completed\n") | ||
| 42 | return true | 43 | return true |
| 43 | end | 44 | end |
| 44 | 45 | ||
| @@ -81,10 +82,13 @@ local do_test = function(error_) | |||
| 81 | assert(stack, "no stack trace on error, check 'error_trace_level'") | 82 | assert(stack, "no stack trace on error, check 'error_trace_level'") |
| 82 | io.stderr:write( "Lane error: "..tostring(err).."\n" ) | 83 | io.stderr:write( "Lane error: "..tostring(err).."\n" ) |
| 83 | io.stderr:write( "\t", table.concat(stack,"\t\n"), "\n" ) | 84 | io.stderr:write( "\t", table.concat(stack,"\t\n"), "\n" ) |
| 85 | else | ||
| 86 | io.stderr:write( "Done\n" ) | ||
| 84 | end | 87 | end |
| 85 | end | 88 | end |
| 86 | 89 | ||
| 87 | do_test(nil) | 90 | do_test(nil) |
| 91 | -- do return end | ||
| 88 | do_test("An error") | 92 | do_test("An error") |
| 89 | 93 | ||
| 90 | local on_exit = function() | 94 | local on_exit = function() |
diff --git a/tests/tobeclosed.lua b/tests/tobeclosed.lua index 5ac8ab7..7a5e3ae 100644 --- a/tests/tobeclosed.lua +++ b/tests/tobeclosed.lua | |||
| @@ -83,6 +83,7 @@ do | |||
| 83 | local lane_body = function() | 83 | local lane_body = function() |
| 84 | WR "In lane body" | 84 | WR "In lane body" |
| 85 | lanes.sleep(1) | 85 | lanes.sleep(1) |
| 86 | return "success" | ||
| 86 | end | 87 | end |
| 87 | 88 | ||
| 88 | local h = lanes.gen("*", lane_body)() | 89 | local h = lanes.gen("*", lane_body)() |
| @@ -90,6 +91,7 @@ do | |||
| 90 | local tobeclosed <close> = h | 91 | local tobeclosed <close> = h |
| 91 | end | 92 | end |
| 92 | assert(h.status == "done") | 93 | assert(h.status == "done") |
| 94 | return "success" | ||
| 93 | end | 95 | end |
| 94 | 96 | ||
| 95 | -- ################################################################################################# | 97 | -- ################################################################################################# |
