mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-25 23:24:35 +00:00
[added] assert:some for nil checks
This commit is contained in:
parent
284856d2c3
commit
a367d18b51
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user