diff options
Diffstat (limited to 'unit_tests/scripts/misc/verbose_errors.lua')
| -rw-r--r-- | unit_tests/scripts/misc/verbose_errors.lua | 14 |
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 | ||
| 6 | local do_test = function(key_) | 6 | local 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 |
