diff options
| author | William Boman <william@redwill.se> | 2024-05-11 21:22:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-11 21:22:49 +0200 |
| commit | 0f1cb65f436b769733d18b41572f617a1fb41f62 (patch) | |
| tree | 05da82b94b6abd153c300418e019d4a3401ab5ef /tests | |
| parent | perf(registry): significantly improve the "file:" protocol performance (#1702) (diff) | |
| download | mason-0f1cb65f436b769733d18b41572f617a1fb41f62.tar mason-0f1cb65f436b769733d18b41572f617a1fb41f62.tar.gz mason-0f1cb65f436b769733d18b41572f617a1fb41f62.tar.bz2 mason-0f1cb65f436b769733d18b41572f617a1fb41f62.tar.lz mason-0f1cb65f436b769733d18b41572f617a1fb41f62.tar.xz mason-0f1cb65f436b769733d18b41572f617a1fb41f62.tar.zst mason-0f1cb65f436b769733d18b41572f617a1fb41f62.zip | |
fix: fix usage of deprecated Neovim APIs (#1703)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-core/functional/list_spec.lua | 23 | ||||
| -rw-r--r-- | tests/mason-core/functional/type_spec.lua | 12 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/mason-core/functional/list_spec.lua b/tests/mason-core/functional/list_spec.lua index 396d3b60..3dba6295 100644 --- a/tests/mason-core/functional/list_spec.lua +++ b/tests/mason-core/functional/list_spec.lua @@ -292,6 +292,29 @@ describe("functional: list", function() }) ) end) + + it("should flatten tables", function() + assert.same({ 1, 2, 3 }, _.flatten { 1, 2, 3 }) + assert.same({ 1, 2, 3, "a" }, _.flatten { 1, { 2 }, { 3 }, "a" }) + assert.same({ 1, 2, 3, 4, 5 }, _.flatten { 1, { { 2, 3 }, { 4 } }, { 5 } }) + end) + + -- Note: this is not necessarily a requirement, but it is expected to behave this way as of writing. + it("should flatten keyed tables", function() + assert.same( + { + "-xvf", + "file", + }, + _.flatten { + { "-xvf", { "file" } }, + cmd = "tar", + env = { + LC_ALL = "latin", + }, + } + ) + end) end) describe("list immutability", function() diff --git a/tests/mason-core/functional/type_spec.lua b/tests/mason-core/functional/type_spec.lua index e75a5647..e9e0abec 100644 --- a/tests/mason-core/functional/type_spec.lua +++ b/tests/mason-core/functional/type_spec.lua @@ -23,4 +23,16 @@ describe("functional: type", function() assert.is_true(is_boolean(true)) assert.is_false(is_boolean(1)) end) + + it("should check is_list", function() + assert.is_true(_.is_list {}) + assert.is_true(_.is_list { 1, 2, 3 }) + assert.is_true(_.is_list { 1, "a" }) + assert.is_false(_.is_list(vim.empty_dict())) + assert.is_false(_.is_list { 1, 2, keyed = "value" }) + if vim.fn.has "nvim-0.10.0" == 1 then + -- meh + assert.is_false(_.is_list { 1, 2, nil, 3 }) + end + end) end) |
