diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-10-28 16:47:37 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-10-28 16:47:37 +0800 |
commit | f859ed45793a7a6be015de45c1e17cdaab27a1af (patch) | |
tree | e9ce65f5270d9df735eb6f3174d1807058d1ce6e /test/crossfile | |
parent | e6a689c92e455db4a7fe70affbe7bf9213aa6301 (diff) | |
download | lua-language-server-f859ed45793a7a6be015de45c1e17cdaab27a1af.zip |
resolve #691
Diffstat (limited to 'test/crossfile')
-rw-r--r-- | test/crossfile/completion.lua | 108 | ||||
-rw-r--r-- | test/crossfile/definition.lua | 25 |
2 files changed, 132 insertions, 1 deletions
diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua index 172f9d6f..27acb15d 100644 --- a/test/crossfile/completion.lua +++ b/test/crossfile/completion.lua @@ -87,7 +87,7 @@ function TEST(data) local pos for _, info in ipairs(data) do local uri = furi.encode(info.path) - local script = info.content + local script = info.content or '' if info.main then local newScript, catched = catch(script, '?') pos = catched['?'][1][1] @@ -565,9 +565,115 @@ TEST { ]], main = true, }, + completion = nil, } TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require '<??>' + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require 'a<??>' + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +config.set('Lua.runtime.pathStrict', true) + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require '<??>' + ]], + main = true, + }, + completion = { + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require 'a<??>' + ]], + main = true, + }, + completion = { + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +config.set('Lua.runtime.pathStrict', false) + +TEST { { path = 'xxx.lua', content = '' diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index 37c10db6..862d95e8 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -117,6 +117,31 @@ TEST { }, } +config.set('Lua.runtime.pathStrict', true) +TEST { + { + path = 'aaa/bbb.lua', + content = '', + }, + { + path = 'b.lua', + content = 'require "<?bbb?>"', + }, +} + +TEST { + { + path = 'aaa/bbb.lua', + content = '<!!>', + }, + { + path = 'b.lua', + content = 'require "<?aaa.bbb?>"', + }, +} + +config.set('Lua.runtime.pathStrict', false) + TEST { { path = 'a.lua', |