address pr comment

This commit is contained in:
TurtleP 2023-03-20 09:48:56 -04:00
parent c2316e2ad8
commit 4cbbf6c068

View File

@ -84,16 +84,17 @@ end
--assert a value is one of those in a table of options --assert a value is one of those in a table of options
function assert:one_of(a, t, msg, stack_level) function assert:one_of(a, t, msg, stack_level)
local pass = false for _, value in ipairs(t) do
for index = 1, #t do if value == a then
if t[index] == a then return a
pass = true
break
end end
end end
assert:equal(pass, true, msg, stack_level) error(("assertion failed: %s not one of %s %s"):format(
return a tostring(a),
table.concat(t, ", "),
_extra(msg)
), 2 + (stack_level or 0))
end end
--replace everything in assert with nop functions that just return their second argument, for near-zero overhead on release --replace everything in assert with nop functions that just return their second argument, for near-zero overhead on release