mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Added type check in lume.fn() and additional tests
This commit is contained in:
parent
1a087efe99
commit
3a4ce4fe3b
1
lume.lua
1
lume.lua
@ -235,6 +235,7 @@ end
|
||||
|
||||
|
||||
function lume.fn(fn, ...)
|
||||
assert(isfunction(fn), "expected a function as the first argument")
|
||||
local args = {...}
|
||||
return function(...)
|
||||
local a = lume.merge(lume.clone(args), {...})
|
||||
|
@ -258,6 +258,7 @@ end
|
||||
tests["lume.fn"] = function()
|
||||
local f = lume.fn(function(a, b) return a + b end, 10)
|
||||
testeq( f(5), 15 )
|
||||
tester.test.error( lume.fn, 123 )
|
||||
end
|
||||
|
||||
-- lume.once
|
||||
@ -265,6 +266,7 @@ tests["lume.once"] = function()
|
||||
local f = lume.once(function(a, b) return a + b end, 10)
|
||||
testeq( f(5), 15 )
|
||||
testeq( f(5), nil )
|
||||
tester.test.error( lume.once, 123 )
|
||||
end
|
||||
|
||||
-- lume.time
|
||||
|
Loading…
Reference in New Issue
Block a user