diff options
author | Sewbacca <sebastian.kalus@kolabnow.com> | 2022-11-23 22:59:49 +0100 |
---|---|---|
committer | Sewbacca <sebastian.kalus@kolabnow.com> | 2022-11-23 22:59:49 +0100 |
commit | d848fdaf49fa8be5c12aed73cea3cac34ca8836d (patch) | |
tree | 754123577f80f978826d82a68bdb72ca7281d8fe /test/crossfile | |
parent | 832784a3f5f9c48921ce9c9f9d6fc4e3f4376d04 (diff) | |
download | lua-language-server-d848fdaf49fa8be5c12aed73cea3cac34ca8836d.zip |
Added few tests
Diffstat (limited to 'test/crossfile')
-rw-r--r-- | test/crossfile/completion.lua | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua index 79762646..12b33323 100644 --- a/test/crossfile/completion.lua +++ b/test/crossfile/completion.lua @@ -133,6 +133,18 @@ function TEST(data) assert(eq(expect, result)) end +local function WITH_CONFIG(cfg, f) + local prev = { } + for k, v in pairs(cfg) do + prev[k] = config.get(nil, k) + config.set(nil, k, v) + end + f() + for k, v in pairs(prev) do + config.set(nil, k, v) + end +end + TEST { { path = 'abc.lua', @@ -976,3 +988,74 @@ TEST { }, completion = EXISTS } + +-- Find obscured modules + +WITH_CONFIG({ + ["Lua.runtime.pathStrict"] = true, + ["Lua.runtime.path"] = { + "?/init.lua", + "sub/?/init.lua", + "obscure_path/?/?/init.lua" + }, +}, function() + TEST { + { path = 'myLib/init.lua', content = 'return {}' }, + { + path = 'main.lua', + main = true, + content = [[ + myLib<??> + ]], + }, + completion = EXISTS + } + + TEST { + { path = 'sub/myLib/init.lua', content = 'return {}' }, + { + path = 'main.lua', + main = true, + content = [[ + myLib<??> + ]], + }, + completion = EXISTS + } + + TEST { + { path = 'sub/myLib/sublib/init.lua', content = 'return {}' }, + { + path = 'main.lua', + main = true, + content = [[ + sublib<??> + ]], + }, + completion = EXISTS + } + + TEST { + { path = 'sublib/init.lua', content = 'return {}' }, + { + path = 'main.lua', + main = true, + content = [[ + sublib<??> + ]], + }, + completion = EXISTS + } + + TEST { + { path = 'obscure_path/myLib/obscure/myLib/obscure/init.lua', content = 'return {}' }, + { + path = 'main.lua', + main = true, + content = [[ + obscure<??> + ]], + }, + completion = EXISTS + } +end) |