diff options
| author | William Boman <william@redwill.se> | 2022-10-30 17:43:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-30 17:43:46 +0100 |
| commit | 37c745fa73b983c86904132efb30ef2a4a76df5e (patch) | |
| tree | c55fe52b7c5c20ed4fdbb3ee073519fd0ccbe6b2 /tests/mason-core/functional | |
| parent | chore: update generated code (#608) (diff) | |
| download | mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.gz mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.bz2 mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.lz mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.xz mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.zst mason-37c745fa73b983c86904132efb30ef2a4a76df5e.zip | |
feat: add provider interface (#601)
Diffstat (limited to 'tests/mason-core/functional')
| -rw-r--r-- | tests/mason-core/functional/function_spec.lua | 7 | ||||
| -rw-r--r-- | tests/mason-core/functional/list_spec.lua | 8 | ||||
| -rw-r--r-- | tests/mason-core/functional/string_spec.lua | 5 |
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/mason-core/functional/function_spec.lua b/tests/mason-core/functional/function_spec.lua index 4da41d40..28abce20 100644 --- a/tests/mason-core/functional/function_spec.lua +++ b/tests/mason-core/functional/function_spec.lua @@ -139,4 +139,11 @@ describe("functional: function", function() assert.is_true(_.T()) assert.is_false(_.F()) end) + + it("should tap values", function() + local fn = spy.new() + assert.equals(42, _.tap(fn, 42)) + assert.spy(fn).was_called() + assert.spy(fn).was_called_with(42) + end) end) diff --git a/tests/mason-core/functional/list_spec.lua b/tests/mason-core/functional/list_spec.lua index add9076e..bbc60763 100644 --- a/tests/mason-core/functional/list_spec.lua +++ b/tests/mason-core/functional/list_spec.lua @@ -203,4 +203,12 @@ describe("functional: list", function() { "person", "camera" }, }, _.partition(_.matches "%u", words)) end) + + it("should return head", function() + assert.equals("Head", _.head { "Head", "Tail", "Tail" }) + end) + + it("should return last", function() + assert.equals("Last", _.last { "Head", "List", "Last" }) + end) end) diff --git a/tests/mason-core/functional/string_spec.lua b/tests/mason-core/functional/string_spec.lua index 25409f64..6fb99c45 100644 --- a/tests/mason-core/functional/string_spec.lua +++ b/tests/mason-core/functional/string_spec.lua @@ -10,6 +10,11 @@ describe("functional: string", function() assert.is_false(_.matches("bar", "foobaz")) end) + it("returns string pattern matches", function() + assert.same({ "foo" }, _.match("foo", "foo")) + assert.same({ "foo", "bar", "baz" }, _.match("(foo) (bar) (baz)", "foo bar baz")) + end) + it("should format strings", function() assert.equals("Hello World!", _.format("%s", "Hello World!")) assert.equals("special manouvers", _.format("%s manouvers", "special")) |
