Merge pull request #65 from TurtleP/turtlep/one_of_bugfix

Fix assert:one_of for non-string values
This commit is contained in:
Max Cahill 2023-03-29 13:50:51 +11:00 committed by GitHub
commit ea20cbbf21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,9 +90,14 @@ function assert:one_of(a, t, msg, stack_level)
end
end
local values = {}
for index = 1, #t do
values[index] = tostring(t[index])
end
error(("assertion failed: %s not one of %s %s"):format(
tostring(a),
table.concat(t, ", "),
table.concat(values, ", "),
_extra(msg)
), 2 + (stack_level or 0))
end