diff options
| -rw-r--r-- | lua/mason-core/functional/function.lua | 2 | ||||
| -rw-r--r-- | tests/mason-core/functional/function_spec.lua | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lua/mason-core/functional/function.lua b/lua/mason-core/functional/function.lua index 863df28e..59d3af26 100644 --- a/lua/mason-core/functional/function.lua +++ b/lua/mason-core/functional/function.lua @@ -107,7 +107,7 @@ end, 2) ---@param args V[] ---@return R _.apply = _.curryN(function(fn, args) - return fn(args) + return fn(unpack(args)) end, 2) ---@generic T, V diff --git a/tests/mason-core/functional/function_spec.lua b/tests/mason-core/functional/function_spec.lua index 6b36b53b..9f5189fd 100644 --- a/tests/mason-core/functional/function_spec.lua +++ b/tests/mason-core/functional/function_spec.lua @@ -147,6 +147,14 @@ describe("functional: function", function() assert.spy(fn).was_called_with(42) end) + it("should apply function", function() + local max = spy.new(math.max) + local max_fn = _.apply(max) + assert.equals(42, max_fn { 1, 2, 3, 4, 5, 6, 7, 8, 9, 42, 10, 8, 4 }) + assert.spy(max).was_called(1) + assert.spy(max).was_called_with(1, 2, 3, 4, 5, 6, 7, 8, 9, 42, 10, 8, 4) + end) + it("should apply value to function", function() local agent = spy.new() _.apply_to("007", agent) |
