From 8e77d70e29f936f4e708ee3244046188b8ad0383 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 12 Sep 2020 19:04:22 -0700 Subject: test/vim.validate(): assert normalized stacktrace - The previous commit lost information in the tests. Instead, add some more "normalization" substitutions in pcall_err(), so that the general shape of the stacktrace is included in the asserted text. - Eliminate contains(), it is redundant with matches() --- runtime/lua/vim/shared.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime/lua/vim/shared.lua') diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 750af02f19..995c52e8ed 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -514,20 +514,20 @@ do local optional = (true == spec[3]) if type(t) == 'string' then - local translated_type_name = type_names[t] - if not translated_type_name then + local t_name = type_names[t] + if not t_name then return false, string.format('invalid type name: %s', t) end - if (not optional or val ~= nil) and not _is_type(val, translated_type_name) then - return false, string.format("%s: expected %s, got %s", param_name, translated_type_name, type(val)) + if (not optional or val ~= nil) and not _is_type(val, t_name) then + return false, string.format("%s: expected %s, got %s", param_name, t_name, type(val)) end elseif vim.is_callable(t) then -- Check user-provided validation function. local valid, optional_message = t(val) if not valid then local error_message = string.format("%s: expected %s, got %s", param_name, (spec[3] or '?'), val) - if not (optional_message == nil) then + if optional_message ~= nil then error_message = error_message .. string.format(". Info: %s", optional_message) end -- cgit