aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core/path_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-07-08 18:34:38 +0200
committerGitHub <noreply@github.com>2022-07-08 18:34:38 +0200
commit976aa4fbee8a070f362cab6f6ec84e9251a90cf9 (patch)
tree5e8d9c9c59444a25c7801b8f39763c4ba6e1f76d /tests/mason-core/path_spec.lua
parentfeat: add gotests, gomodifytags, impl (#28) (diff)
downloadmason-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/path_spec.lua')
-rw-r--r--tests/mason-core/path_spec.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/mason-core/path_spec.lua b/tests/mason-core/path_spec.lua
new file mode 100644
index 00000000..7c7d417f
--- /dev/null
+++ b/tests/mason-core/path_spec.lua
@@ -0,0 +1,23 @@
+local path = require "mason-core.path"
+
+describe("path", function()
+ it("concatenates paths", function()
+ assert.equal("foo/bar/baz/~", path.concat { "foo", "bar", "baz", "~" })
+ end)
+
+ it("concatenates paths on Windows", function()
+ local old_os = jit.os
+ jit.os = "windows"
+ package.loaded["mason-core.path"] = nil
+ local path = require "mason-core.path"
+ assert.equal([[foo\bar\baz\~]], path.concat { "foo", "bar", "baz", "~" })
+ jit.os = old_os
+ end)
+
+ it("identifies subdirectories", function()
+ assert.is_true(path.is_subdirectory("/foo/bar", "/foo/bar/baz"))
+ assert.is_true(path.is_subdirectory("/foo/bar", "/foo/bar"))
+ assert.is_false(path.is_subdirectory("/foo/bar", "/foo/bas/baz"))
+ assert.is_false(path.is_subdirectory("/foo/bar", "/foo/bars/baz"))
+ end)
+end)