From dfb4a035c2d80a6be689e14ca495b8ba032f58c4 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 30 Oct 2025 10:02:27 +0100 Subject: Test full userdata keys with verbose_errors --- unit_tests/scripts/misc/verbose_errors.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'unit_tests/scripts') diff --git a/unit_tests/scripts/misc/verbose_errors.lua b/unit_tests/scripts/misc/verbose_errors.lua index b38bf4c..8127980 100644 --- a/unit_tests/scripts/misc/verbose_errors.lua +++ b/unit_tests/scripts/misc/verbose_errors.lua @@ -21,9 +21,13 @@ local do_test = function(key_) local x, y = string.find(e, "arg#2.subtable[" .. key_ .. "].ud", 1, true) assert(x and y, "got " .. e) elseif t_key == "userdata" then - local t_name + -- light userdata results in "userdata: " + local stringified_key = tostring(key_) + local hex = string.match(stringified_key, "userdata: (%x+)") + -- full userdata results in something else + local t_name = hex and ("0x" .. string.lower(hex)) or "" -- light userdata is formatted by std::format, where the pointer is written as a lowercase hex literal - local expected = "arg#2.subtable[U:0x" .. string.lower(string.match(tostring(key_), "userdata: (%x+)")) .. "].ud" + local expected = "arg#2.subtable[U:" .. t_name .. "].ud" -- expecting an error about arg#2.subtable[U:0x].ud local x, y = string.find(e, expected, 1, true) assert(x and y, "expecting " .. expected .. " got " .. e) @@ -36,3 +40,4 @@ do_test(false) do_test(42) do_test(42.44) do_test(lanes.null) +do_test(l) -- cgit v1.2.3-55-g6feb