diff --git a/lume.lua b/lume.lua index a0b75fc..73c2b33 100644 --- a/lume.lua +++ b/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), {...}) diff --git a/test/test_lume.lua b/test/test_lume.lua index ee1e191..57ac598 100644 --- a/test/test_lume.lua +++ b/test/test_lume.lua @@ -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