diff options
| author | William Boman <william@redwill.se> | 2022-05-17 13:49:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-17 13:49:18 +0200 |
| commit | 9fa0bb2822af391db96687ad6ddb66ddb3529c58 (patch) | |
| tree | 82d5838c98e5c0b3f273f23326099383be6b8c0e /tests/core/functional/relation_spec.lua | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.gz mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.bz2 mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.lz mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.xz mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.tar.zst mason-9fa0bb2822af391db96687ad6ddb66ddb3529c58.zip | |
chore(functional): restructure and extend functional modules (#703)
Diffstat (limited to 'tests/core/functional/relation_spec.lua')
| -rw-r--r-- | tests/core/functional/relation_spec.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/core/functional/relation_spec.lua b/tests/core/functional/relation_spec.lua new file mode 100644 index 00000000..41325cf2 --- /dev/null +++ b/tests/core/functional/relation_spec.lua @@ -0,0 +1,36 @@ +local _ = require "nvim-lsp-installer.core.functional" + +describe("functional: relation", function() + it("should check equality", function() + local tbl = {} + local is_tbl = _.equals(tbl) + local is_a = _.equals "a" + local is_42 = _.equals(42) + + assert.is_true(is_tbl(tbl)) + assert.is_true(is_a "a") + assert.is_true(is_42(42)) + assert.is_false(is_a "b") + assert.is_false(is_42(32)) + end) + + it("should check property equality", function() + local fn_key = function() end + local tbl = { a = "a", b = "b", number = 42, [fn_key] = "fun" } + assert.is_true(_.prop_eq("a", "a", tbl)) + assert.is_true(_.prop_eq(fn_key, "fun", tbl)) + assert.is_true(_.prop_eq(fn_key) "fun"(tbl)) + end) + + it("should check whether property satisfies predicate", function() + local obj = { + low = 0, + med = 10, + high = 15, + } + + assert.is_false(_.prop_satisfies(_.gt(10), "low", obj)) + assert.is_false(_.prop_satisfies(_.gt(10), "med")(obj)) + assert.is_true(_.prop_satisfies(_.gt(10)) "high"(obj)) + end) +end) |
