Open devurandom opened 5 years ago
this should be easy to add, see http://stevedonovan.github.io/Penlight/api/libraries/pl.types.html#is_callable
care to create a PR @devurandom ?
You mean to copy the code from Penlight?
--- is the object either a function or a callable object?.
-- @param obj Object to check.
function types.is_callable (obj)
return type(obj) == 'function' or getmetatable(obj) and getmetatable(obj).__call and true
end
Sure, I can do that.
No, busted already relies on Penlight, so all you have to do is add an assertion that uses that function.
But the assertions reside in luassert/src/assertions.lua, i.e. in luassert, which currently does not depend on Penlight.
@devurandom you are totally right, sorry for the noise.
Feel free to make a PR and reference this issue
luassert has its own implementation btw; in luassert.util
, see https://github.com/Olivine-Labs/luassert/blob/master/src/util.lua#L274
It would be useful to have an
is_calleable
assertion that tests whetheris_function(argument)
oris_function(debug.getmetatable(argument)._call)
.