diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-core/functional/list_spec.lua | 15 | ||||
| -rw-r--r-- | tests/mason-core/functional/logic_spec.lua | 6 |
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) |
