diff options
| author | William Boman <william@redwill.se> | 2022-05-12 18:02:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-12 18:02:47 +0200 |
| commit | f637ef2e6dbfb03cc896143d73749f541ca18e3e (patch) | |
| tree | 2c15a25a2661d5eb424eace9267642977c58d2e9 /tests/core | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.tar mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.tar.gz mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.tar.bz2 mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.tar.lz mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.tar.xz mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.tar.zst mason-f637ef2e6dbfb03cc896143d73749f541ca18e3e.zip | |
feat: patch :LspInfo's "cmd is executable" diagnostic message (#691)
Diffstat (limited to 'tests/core')
| -rw-r--r-- | tests/core/functional_spec.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/core/functional_spec.lua b/tests/core/functional_spec.lua index 8301d47e..734217a2 100644 --- a/tests/core/functional_spec.lua +++ b/tests/core/functional_spec.lua @@ -163,4 +163,43 @@ describe("functional", function() partially_funcy("d", nil, "f") assert.spy(funcy).was_called_with("a", nil, "c", "d", nil, "f") end) + + it("should compose functions", function() + local function add(x) + return function(y) + return y + x + end + end + local function subtract(x) + return function(y) + return y - x + end + end + local function multiply(x) + return function(y) + return y * x + end + end + + local big_maths = functional.compose(add(1), subtract(3), multiply(5)) + + assert.equals(23, big_maths(5)) + end) + + it("should not allow composing no functions", function() + local e = assert.error(function() + functional.compose() + end) + assert.equals("compose requires at least one function", e) + end) + + it("should iterate list in .each", function() + local list = { "BLUE", "YELLOW", "RED" } + local iterate_fn = spy.new() + functional.each(iterate_fn, list) + assert.spy(iterate_fn).was_called(3) + assert.spy(iterate_fn).was_called_with("BLUE", 1) + assert.spy(iterate_fn).was_called_with("YELLOW", 2) + assert.spy(iterate_fn).was_called_with("RED", 3) + end) end) |
