[added] assert:some for nil checks

This commit is contained in:
Max Cahill 2020-05-19 13:00:23 +10:00
parent 284856d2c3
commit a367d18b51

View File

@ -26,6 +26,15 @@ local function _extra(msg)
return "(note: " .. msg .. ")"
end
--assert a value is not nil
function assert:some(v, msg, stack_level)
if v == nil then
error(("assertion failed: value is nil %s"):format(
_extra(msg)
), 2 + (stack_level or 0))
end
end
--assert two values are equal
function assert:equals(a, b, msg, stack_level)
if a ~= b then