aboutsummaryrefslogtreecommitdiff
path: root/unit_tests/scripts/misc/verbose_errors.lua
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-10-30 09:38:43 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2025-10-30 09:38:43 +0100
commit9c768185696879c6642c1f26c86884eaf727fe27 (patch)
tree146b05ec3a24d16239e2bdad32ad65428220b947 /unit_tests/scripts/misc/verbose_errors.lua
parent1ba28e1897acbcba0ab10bd0bfbf9fd13e718bdf (diff)
downloadlanes-9c768185696879c6642c1f26c86884eaf727fe27.tar.gz
lanes-9c768185696879c6642c1f26c86884eaf727fe27.tar.bz2
lanes-9c768185696879c6642c1f26c86884eaf727fe27.zip
Stronger test for verbose_errors
Diffstat (limited to 'unit_tests/scripts/misc/verbose_errors.lua')
-rw-r--r--unit_tests/scripts/misc/verbose_errors.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/unit_tests/scripts/misc/verbose_errors.lua b/unit_tests/scripts/misc/verbose_errors.lua
index 40948ca..b38bf4c 100644
--- a/unit_tests/scripts/misc/verbose_errors.lua
+++ b/unit_tests/scripts/misc/verbose_errors.lua
@@ -4,23 +4,27 @@ local l = lanes.linda{name = "my linda"}
4 4
5 5
6local do_test = function(key_) 6local do_test = function(key_)
7 local t = {[key_] = fixture.newuserdata()} 7 local t = { subtable = { [key_] = { ud = fixture.newuserdata() } } }
8 local b, e = pcall(l.send, l, "k", t) 8 local b, e = pcall(l.send, l, "k", t)
9 assert(b == false and type(e) == "string") 9 assert(b == false and type(e) == "string")
10 local t_key = type(key_) 10 local t_key = type(key_)
11 if t_key == "string" then 11 if t_key == "string" then
12 local x, y = string.find(e, "arg#2." .. key_, 1, true) 12 -- expecting an error about arg#2.subtable.<key_>.ud
13 local x, y = string.find(e, "arg#2.subtable." .. key_ .. ".ud", 1, true)
13 assert(x and y, "got " .. e) 14 assert(x and y, "got " .. e)
14 elseif t_key == "boolean" then 15 elseif t_key == "boolean" then
15 local x, y = string.find(e, "arg#2[" .. tostring(key_) .. "]", 1, true) 16 -- expecting an error about arg#2.subtable[true|false].ud
17 local x, y = string.find(e, "arg#2.subtable[" .. tostring(key_) .. "].ud", 1, true)
16 assert(x and y, "got " .. e) 18 assert(x and y, "got " .. e)
17 elseif t_key == "number" then 19 elseif t_key == "number" then
18 local x, y = string.find(e, "arg#2[" .. key_ .. "]", 1, true) 20 -- expecting an error about arg#2.subtable[<number>].ud
21 local x, y = string.find(e, "arg#2.subtable[" .. key_ .. "].ud", 1, true)
19 assert(x and y, "got " .. e) 22 assert(x and y, "got " .. e)
20 elseif t_key == "userdata" then 23 elseif t_key == "userdata" then
21 local t_name 24 local t_name
22 -- light userdata is formatted by std::format, where the pointer is written as a lowercase hex literal 25 -- light userdata is formatted by std::format, where the pointer is written as a lowercase hex literal
23 local expected = "arg#2[U:0x" .. string.lower(string.match(tostring(key_), "userdata: (%x+)")) .. "]" 26 local expected = "arg#2.subtable[U:0x" .. string.lower(string.match(tostring(key_), "userdata: (%x+)")) .. "].ud"
27 -- expecting an error about arg#2.subtable[U:0x<some hex value>].ud
24 local x, y = string.find(e, expected, 1, true) 28 local x, y = string.find(e, expected, 1, true)
25 assert(x and y, "expecting " .. expected .. " got " .. e) 29 assert(x and y, "expecting " .. expected .. " got " .. e)
26 end 30 end