aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-01-02 06:47:41 +0100
committerGitHub <noreply@github.com>2023-01-02 06:47:41 +0100
commit2953751d1beda5eeec54fd7bb743614c56febc18 (patch)
treea98799e3d0cd836f5317ed33e14bc8f47123f716 /tests
parentfix(ui): do not override existing MasonNormal hl group (#833) (diff)
downloadmason-2953751d1beda5eeec54fd7bb743614c56febc18.tar
mason-2953751d1beda5eeec54fd7bb743614c56febc18.tar.gz
mason-2953751d1beda5eeec54fd7bb743614c56febc18.tar.bz2
mason-2953751d1beda5eeec54fd7bb743614c56febc18.tar.lz
mason-2953751d1beda5eeec54fd7bb743614c56febc18.tar.xz
mason-2953751d1beda5eeec54fd7bb743614c56febc18.tar.zst
mason-2953751d1beda5eeec54fd7bb743614c56febc18.zip
feat(functional): add split_every and default_to (#835)
Diffstat (limited to 'tests')
-rw-r--r--tests/mason-core/functional/list_spec.lua15
-rw-r--r--tests/mason-core/functional/logic_spec.lua6
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/mason-core/functional/list_spec.lua b/tests/mason-core/functional/list_spec.lua
index 6c14e5a9..043f058b 100644
--- a/tests/mason-core/functional/list_spec.lua
+++ b/tests/mason-core/functional/list_spec.lua
@@ -264,6 +264,21 @@ describe("functional: list", function()
assert.spy(add).was_called_with(6, 4)
assert.spy(add).was_called_with(10, 5)
end)
+
+ it("should split lists", function()
+ assert.same({
+ { 1, 2, 3 },
+ { 4, 5, 6 },
+ { 7 },
+ }, _.split_every(3, { 1, 2, 3, 4, 5, 6, 7 }))
+
+ assert.same({ { 1, 2, 3 } }, _.split_every(5, { 1, 2, 3 }))
+ assert.same({ { 1 }, { 2 }, { 3 } }, _.split_every(1, { 1, 2, 3 }))
+
+ assert.has_error(function()
+ _.split_every(0, {})
+ end)
+ end)
end)
describe("list immutability", function()
diff --git a/tests/mason-core/functional/logic_spec.lua b/tests/mason-core/functional/logic_spec.lua
index 7c795443..b15fd6ae 100644
--- a/tests/mason-core/functional/logic_spec.lua
+++ b/tests/mason-core/functional/logic_spec.lua
@@ -54,4 +54,10 @@ describe("functional: logic", function()
assert.is_true(_.complement(_.is_nil, "not nil"))
assert.is_false(_.complement(_.is_nil, nil))
end)
+
+ it("should default to provided value", function()
+ local fortytwo = _.default_to(42)
+ assert.equals(42, fortytwo(nil))
+ assert.equals(1337, fortytwo(1337))
+ end)
end)