diff options
| author | William Boman <william@redwill.se> | 2022-07-08 18:34:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-08 18:34:38 +0200 |
| commit | 976aa4fbee8a070f362cab6f6ec84e9251a90cf9 (patch) | |
| tree | 5e8d9c9c59444a25c7801b8f39763c4ba6e1f76d /tests/mason-core/functional/table_spec.lua | |
| parent | feat: add gotests, gomodifytags, impl (#28) (diff) | |
| download | mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.gz mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.bz2 mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.lz mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.xz mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.zst mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.zip | |
refactor: add mason-schemas and mason-core modules (#29)
* refactor: add mason-schemas and move generated filetype map to mason-lspconfig
* refactor: add mason-core module
Diffstat (limited to 'tests/mason-core/functional/table_spec.lua')
| -rw-r--r-- | tests/mason-core/functional/table_spec.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/mason-core/functional/table_spec.lua b/tests/mason-core/functional/table_spec.lua new file mode 100644 index 00000000..012c981c --- /dev/null +++ b/tests/mason-core/functional/table_spec.lua @@ -0,0 +1,51 @@ +local _ = require "mason-core.functional" + +describe("functional: table", function() + it("retrieves property of table", function() + assert.equals("hello", _.prop("a", { a = "hello" })) + end) + + it("picks properties of table", function() + local function fn() end + assert.same( + { + ["key1"] = 1, + [fn] = 2, + }, + _.pick({ "key1", fn }, { + ["key1"] = 1, + [fn] = 2, + [3] = 3, + }) + ) + end) + + it("converts table to pairs", function() + assert.same( + _.sort_by(_.nth(1), { + { + "skies", + "cloudy", + }, + { + "temperature", + "20°", + }, + }), + _.sort_by(_.nth(1), _.to_pairs { skies = "cloudy", temperature = "20°" }) + ) + end) + + it("should invert tables", function() + assert.same( + { + val1 = "key1", + val2 = "key2", + }, + _.invert { + key1 = "val1", + key2 = "val2", + } + ) + end) +end) |
