test: drop assert.is_true() and friends

This commit is contained in:
Justin M. Keyes
2026-07-20 18:11:52 +02:00
parent 6d8c8b18d5
commit 1250821ba8
11 changed files with 131 additions and 156 deletions

View File

@@ -5,7 +5,7 @@ local FORMAT_DEPTH = 100
--- @param value any
--- @return string
local function format_value(value)
local function fmt(value)
if type(value) == 'string' then
return string.format('%q', value)
end
@@ -36,8 +36,8 @@ end
local function comparison_message(expected, actual, comparator)
return ('Expected values to be %s.\nExpected:\n%s\nActual:\n%s'):format(
comparator,
format_value(expected),
format_value(actual)
fmt(expected),
fmt(actual)
)
end
@@ -63,30 +63,10 @@ function M.neq(expected, actual, context)
not vim.deep_equal(expected, actual),
actual,
context,
('Expected values to differ.\nValue:\n%s'):format(format_value(actual))
('Expected values to differ.\nValue:\n%s'):format(fmt(actual))
)
end
--- @param value any
--- @param context? any
--- @return any
function M.is_true(value, context)
return M.eq(true, value, context)
end
--- @param value any
--- @param context? any
--- @return any
function M.is_false(value, context)
return M.eq(false, value, context)
end
-- TODO(lewis6991): remove these aliases
M.True = M.is_true
M.False = M.is_false
M.equals = M.eq
M.Equal = M.eq
return setmetatable(M, {
--- @param condition any
--- @param message? string