Verified Commit 5e7ee8bc authored by Karel Koci's avatar Karel Koci 🤘

err report: add test for multiple errors

Check if error output contains both error messages when multiple errors
happens.
parent 7c690f90
......@@ -19,14 +19,24 @@ along with Updater. If not, see <http://www.gnu.org/licenses/>.
-- Just for testing purposes
local testing = {}
function testing.values()
return 42, "hello"
end
function testing:method()
return type(self)
end
testing.subtable = {}
function testing.subtable.echo(...)
return ...
end
function testing.twoerrs()
local multi = utils.exception('multiple', "Multiple exceptions (2)")
multi.errors = { "error1", utils.exception('simulation', "error2") }
error(multi)
end
return testing
......@@ -127,6 +127,17 @@ START_INTERPRETER_TEST(call_error)
ck_assert_msg(strstr(error, "Test error"), "Error %s doesn't contain Test error", error);
END_INTERPRETER_TEST
START_INTERPRETER_TEST(call_error_multi)
/*
* Check we can call a function that produces two errors and both errors
* would be propagated.
*/
const char *error = interpreter_call(interpreter, "testing.twoerrs", NULL, "");
ck_assert_msg(error, "Didn't get an error");
ck_assert_msg(strstr(error, "error1"), "Error %s doesn't contain Test error1", error);
ck_assert_msg(strstr(error, "error2"), "Error %s doesn't contain Test error2", error);
END_INTERPRETER_TEST
START_INTERPRETER_TEST(call_noparams)
/*
* Test we may call a function and extract its results.
......@@ -250,6 +261,7 @@ Suite *gen_test_suite(void) {
// Run the tests ‒ each test case takes 2*i and 2*i + 1 indices
tcase_add_loop_test(interpreter, loading, 0, 2 * sizeof loading_cases / sizeof *loading_cases);
tcase_add_test(interpreter, call_error);
tcase_add_test(interpreter, call_error_multi);
tcase_add_test(interpreter, call_noparams);
tcase_add_test(interpreter, call_method);
tcase_add_test(interpreter, call_echo);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment