aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core/functional/table_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-12-10 19:55:41 +0100
committerGitHub <noreply@github.com>2022-12-10 18:55:41 +0000
commitfbc72a0c2fe16a93b18ce8facdc9b66e7183f75d (patch)
treebe37b4bd7b0320dbfa3e08dae8c90540c0eaa335 /tests/mason-core/functional/table_spec.lua
parentchore: update generated code (#754) (diff)
downloadmason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.tar
mason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.tar.gz
mason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.tar.bz2
mason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.tar.lz
mason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.tar.xz
mason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.tar.zst
mason-fbc72a0c2fe16a93b18ce8facdc9b66e7183f75d.zip
feat(functional): add some more functions (#755)
Diffstat (limited to 'tests/mason-core/functional/table_spec.lua')
-rw-r--r--tests/mason-core/functional/table_spec.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/mason-core/functional/table_spec.lua b/tests/mason-core/functional/table_spec.lua
index c897b5ca..357f7120 100644
--- a/tests/mason-core/functional/table_spec.lua
+++ b/tests/mason-core/functional/table_spec.lua
@@ -68,4 +68,47 @@ describe("functional: table", function()
}
)
end)
+
+ it("should evolve table", function()
+ assert.same(
+ {
+ non_existent = nil,
+ firstname = "JOHN",
+ lastname = "DOE",
+ age = 42,
+ },
+ _.evolve({
+ non_existent = _.always "hello",
+ firstname = _.to_upper,
+ lastname = _.to_upper,
+ age = _.add(2),
+ }, {
+ firstname = "John",
+ lastname = "Doe",
+ age = 40,
+ })
+ )
+ end)
+
+ it("should merge left", function()
+ assert.same(
+ {
+ firstname = "John",
+ lastname = "Doe",
+ },
+ _.merge_left({
+ firstname = "John",
+ }, {
+ firstname = "Jane",
+ lastname = "Doe",
+ })
+ )
+ end)
+
+ it("should dissoc keys", function()
+ assert.same({
+ a = "a",
+ c = "c",
+ }, _.dissoc("b", { a = "a", b = "b", c = "c" }))
+ end)
end)