summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-16 17:24:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-16 17:24:27 +0800
commitea1c5197c469779ba7cd18f1a8da5da9908f2149 (patch)
tree24e8332c50f247c7d66e4d4cdfe847e2e6b1d9c6 /test
parent2dd1bdb05cb317613cd634208953d8450acf4d52 (diff)
downloadlua-language-server-ea1c5197c469779ba7cd18f1a8da5da9908f2149.zip
fix #1218 don't compile `for` in `local`
would prevent compiling for other keys
Diffstat (limited to 'test')
-rw-r--r--test/tclient/init.lua1
-rw-r--r--test/tclient/tests/hover-pairs.lua40
2 files changed, 41 insertions, 0 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua
index e8d3963e..04640b79 100644
--- a/test/tclient/init.lua
+++ b/test/tclient/init.lua
@@ -6,3 +6,4 @@ require 'tclient.tests.load-library'
require 'tclient.tests.files-associations'
require 'tclient.tests.resolve-completion'
require 'tclient.tests.performance-jass-common'
+require 'tclient.tests.hover-pairs'
diff --git a/test/tclient/tests/hover-pairs.lua b/test/tclient/tests/hover-pairs.lua
new file mode 100644
index 00000000..d7f6f103
--- /dev/null
+++ b/test/tclient/tests/hover-pairs.lua
@@ -0,0 +1,40 @@
+local lclient = require 'lclient'
+local ws = require 'workspace'
+local await = require 'await'
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+ client:initialize()
+
+ client:notify('textDocument/didOpen', {
+ textDocument = {
+ uri = 'file://test.lua',
+ languageId = 'lua',
+ version = 0,
+ text = [[
+local t ---@type table<string, number>
+for key, value in pairs(t) do
+ print(key, value) --key or value is unknown
+end
+]]
+ }
+ })
+
+ ws.awaitReady()
+
+ await.sleep(0.1)
+
+ local hover1 = client:awaitRequest('textDocument/hover', {
+ textDocument = { uri = 'file://test.lua' },
+ position = { line = 2, character = 11 },
+ })
+
+ local hover2 = client:awaitRequest('textDocument/hover', {
+ textDocument = { uri = 'file://test.lua' },
+ position = { line = 2, character = 17 },
+ })
+
+ assert(hover1.contents.value:find 'string')
+ assert(hover2.contents.value:find 'number')
+end)