mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 14:14:36 +00:00
address pr comment
This commit is contained in:
parent
c2316e2ad8
commit
4cbbf6c068
15
assert.lua
15
assert.lua
@ -84,16 +84,17 @@ end
|
||||
|
||||
--assert a value is one of those in a table of options
|
||||
function assert:one_of(a, t, msg, stack_level)
|
||||
local pass = false
|
||||
for index = 1, #t do
|
||||
if t[index] == a then
|
||||
pass = true
|
||||
break
|
||||
for _, value in ipairs(t) do
|
||||
if value == a then
|
||||
return a
|
||||
end
|
||||
end
|
||||
|
||||
assert:equal(pass, true, msg, stack_level)
|
||||
return a
|
||||
error(("assertion failed: %s not one of %s %s"):format(
|
||||
tostring(a),
|
||||
table.concat(t, ", "),
|
||||
_extra(msg)
|
||||
), 2 + (stack_level or 0))
|
||||
end
|
||||
|
||||
--replace everything in assert with nop functions that just return their second argument, for near-zero overhead on release
|
||||
|
Loading…
Reference in New Issue
Block a user