summaryrefslogtreecommitdiff
path: root/test/crossfile
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-10-26 14:43:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-10-26 16:20:01 +0800
commit910f81f8e11232da868ccf2822aba5c6b0deadc2 (patch)
treecb5ce73439c61cb5d3cd0299496ff3ed8bdb52c5 /test/crossfile
parent2b2be24989b44d654465cbaef5f77aa93ce62f34 (diff)
downloadlua-language-server-910f81f8e11232da868ccf2822aba5c6b0deadc2.zip
update test
Diffstat (limited to 'test/crossfile')
-rw-r--r--test/crossfile/hover.lua35
1 files changed, 33 insertions, 2 deletions
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index b1c4c804..fee0f068 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -40,7 +40,7 @@ end
function TEST(expect)
files.removeAll()
- local targetScript = expect[1].content
+ local targetScript, targetList = catch(expect[1].content, '?')
local targetUri = furi.encode(expect[1].path)
local sourceScript, sourceList = catch(expect[2].content, '?')
@@ -49,7 +49,9 @@ function TEST(expect)
files.setText(targetUri, targetScript)
files.setText(sourceUri, sourceScript)
- local sourcePos = (sourceList['?'][1][1] + sourceList['?'][1][2]) // 2
+ local cachedList = targetList['?'] + sourceList['?']
+
+ local sourcePos = (cachedList[1][1] + cachedList[1][2]) // 2
local hover = core.byUri(sourceUri, sourcePos)
assert(hover)
hover = tostring(hover):gsub('\r\n', '\n')
@@ -1018,3 +1020,32 @@ function fn()
line1
line2]]}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+
+
+
+for _, x in ipairs({} and {}) do
+ print(<?x?>) -- `x` is infered as `string`
+end
+]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+---@type string[]
+local ss
+
+for _, s in ipairs(ss) do
+ print(s)
+end
+]],
+ },
+ hover = [[
+```lua
+local x: any
+```]]
+}