From f6b072237bbfcf2cb8b797316741671179eb9182 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:12:53 -0700 Subject: [PATCH] tweak to test handling --- .../commands/test/tests/credits.test.lua | 1 + .../commands/test/tests/notify.test.lua | 1 + .../commands/test/tests/notify_bad.test.lua | 1 + .../commands/test/tests/notify_suppress.test.lua | 4 ++-- worldeditadditions_core/utils/format/handle_fn_result.lua | 5 ++++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/worldeditadditions_commands/commands/test/tests/credits.test.lua b/worldeditadditions_commands/commands/test/tests/credits.test.lua index 1b0f79d..ba41f92 100644 --- a/worldeditadditions_commands/commands/test/tests/credits.test.lua +++ b/worldeditadditions_commands/commands/test/tests/credits.test.lua @@ -23,5 +23,6 @@ worldeditadditions.normalize_test("credits", { end end send_credits(1) + return true, "Thank you!" end }) \ No newline at end of file diff --git a/worldeditadditions_commands/commands/test/tests/notify.test.lua b/worldeditadditions_commands/commands/test/tests/notify.test.lua index b0d433d..dfbe1f8 100644 --- a/worldeditadditions_commands/commands/test/tests/notify.test.lua +++ b/worldeditadditions_commands/commands/test/tests/notify.test.lua @@ -9,5 +9,6 @@ worldeditadditions.normalize_test("notify", { Notify.ok(name, message) Notify.info(name, message) Notify.custom(name, "@" .. name, "Good Job", "#FF00D7") + return true end }) \ No newline at end of file diff --git a/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua b/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua index 8e9c374..615783b 100644 --- a/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua +++ b/worldeditadditions_commands/commands/test/tests/notify_bad.test.lua @@ -23,5 +23,6 @@ worldeditadditions.normalize_test("notifybad", { Notify.warn(name, "Invalid color test:") Notify.custom(name, "bad", message, "#FF00") -- Bad colour + return true, "Test complete." end }) \ No newline at end of file diff --git a/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua b/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua index f1da0e3..5d4f40b 100644 --- a/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua +++ b/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua @@ -12,9 +12,9 @@ worldeditadditions.normalize_test("suppress", { return true end) if not result then - Notify.error(name, "Error: suppress_for_function did not call function.") + return false, "Error: suppress_for_function did not call function." else - Notify.ok(name, "suppress_for_function called function.") + return true, "suppress_for_function called function." end end }) \ No newline at end of file diff --git a/worldeditadditions_core/utils/format/handle_fn_result.lua b/worldeditadditions_core/utils/format/handle_fn_result.lua index 0ad81b6..5bc5eb7 100644 --- a/worldeditadditions_core/utils/format/handle_fn_result.lua +++ b/worldeditadditions_core/utils/format/handle_fn_result.lua @@ -11,7 +11,10 @@ local function handle_fn_result(...) if #result > 1 then ret = wea_c.table.tostring(result) elseif #result == 1 then - ret = tostring(result[1]) + if type(result[1]) == "table" then + ret = "Function returned table:\n" .. + wea_c.table.tostring(result[1]) + else ret = tostring(result[1]) end else ret = table.concat({ "Function returned \"",