diff options
| author | William Boman <william@redwill.se> | 2022-12-19 11:41:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-19 10:41:58 +0000 |
| commit | 582fe9e53f192f7062c5811153916189e2301f23 (patch) | |
| tree | d87d134bc9db2df9937901fb948f42b23c8270ae /tests | |
| parent | fix(functional): spread function args in _.apply (#770) (diff) | |
| download | mason-582fe9e53f192f7062c5811153916189e2301f23.tar mason-582fe9e53f192f7062c5811153916189e2301f23.tar.gz mason-582fe9e53f192f7062c5811153916189e2301f23.tar.bz2 mason-582fe9e53f192f7062c5811153916189e2301f23.tar.lz mason-582fe9e53f192f7062c5811153916189e2301f23.tar.xz mason-582fe9e53f192f7062c5811153916189e2301f23.tar.zst mason-582fe9e53f192f7062c5811153916189e2301f23.zip | |
feat(functional): add list.reduce (#772)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-core/functional/list_spec.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/mason-core/functional/list_spec.lua b/tests/mason-core/functional/list_spec.lua index a53da4ac..7c3d8cfb 100644 --- a/tests/mason-core/functional/list_spec.lua +++ b/tests/mason-core/functional/list_spec.lua @@ -253,4 +253,15 @@ describe("functional: list", function() assert.same({ "First", "Second", "Third", "I", "Have", "Poor", "Imagination" }, _.drop_last(0, list)) assert.same({}, _.drop_last(10000, list)) end) + + it("should reduce lists", function() + local add = spy.new(_.add) + assert.equals(15, _.reduce(add, 0, { 1, 2, 3, 4, 5 })) + assert.spy(add).was_called(5) + assert.spy(add).was_called_with(0, 1) + assert.spy(add).was_called_with(1, 2) + assert.spy(add).was_called_with(3, 3) + assert.spy(add).was_called_with(6, 4) + assert.spy(add).was_called_with(10, 5) + end) end) |
