mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 13:59:03 -06:00
18 lines
320 B
Lua
18 lines
320 B
Lua
|
-- Preconditions for cpml functions.
|
||
|
local precond = {}
|
||
|
|
||
|
|
||
|
function precond.typeof(t, expected, msg)
|
||
|
if type(t) ~= expected then
|
||
|
error(("%s: %s (<%s> expected)"):format(msg, type(t), expected), 3)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function precond.assert(cond, msg, ...)
|
||
|
if not cond then
|
||
|
error(msg:format(...), 3)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return precond
|