File size: 727 Bytes
d7c5875 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | local mod = {}
function mod.checkType(...)
local dinfo = debug.getinfo(2, "n")
local len = select('#', ...)
for i = 1, len, 2 do
local validType = select(i, ...)
local curentType = type(select(i + 1, ...))
assert(curentType == validType, ("bad argument #%d to '%s' (%s expected, got %s)"):format(math.floor((i + 1) / 2), dinfo.name, validType, curentType))
end
end
function mod.checkGenType(gtype, ...)
local dinfo = debug.getinfo(2, "n")
local len = select('#', ...)
for i = 1, len do
local curentType = type(select(i, ...))
assert(curentType == gtype, ("bad argument #%d to '%s' (%s expected, got %s)"):format(i, dinfo.name, validType, curentType))
end
end
return mod
|