summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-16 21:05:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-16 21:05:55 +0800
commit8d383d5d34ce25faa32f421560632de21239bed5 (patch)
tree2e0ec662a17f13fb08ad45d88260bf6ea88822c6 /test
parente54fb73d81459fcee1e8402da422f56d00684921 (diff)
downloadlua-language-server-8d383d5d34ce25faa32f421560632de21239bed5.zip
add tests for recursive-runner
Diffstat (limited to 'test')
-rw-r--r--test/tclient/init.lua3
-rw-r--r--test/tclient/tests/recursive-runner.lua45
2 files changed, 47 insertions, 1 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua
index eff77d8a..af850869 100644
--- a/test/tclient/init.lua
+++ b/test/tclient/init.lua
@@ -5,12 +5,13 @@ require 'tclient.tests.folders-with-single-file'
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'
require 'tclient.tests.change-workspace-folder'
require 'tclient.tests.jump-source'
require 'tclient.tests.load-relative-library'
require 'tclient.tests.hover-set-local'
require 'tclient.tests.same-prefix'
+require 'tclient.tests.recursive-runner'
+require 'tclient.tests.performance-jass-common'
require 'tclient.tests.build-meta'
diff --git a/test/tclient/tests/recursive-runner.lua b/test/tclient/tests/recursive-runner.lua
new file mode 100644
index 00000000..923314c3
--- /dev/null
+++ b/test/tclient/tests/recursive-runner.lua
@@ -0,0 +1,45 @@
+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 = [[
+---@type number
+local x
+
+---@type number
+local y
+
+x = y
+
+y = x
+]]
+ }
+ })
+
+ ws.awaitReady()
+
+ await.sleep(0.1)
+
+ local hover1 = client:awaitRequest('textDocument/hover', {
+ textDocument = { uri = 'file://test.lua' },
+ position = { line = 1, character = 7 },
+ })
+
+ local hover2 = client:awaitRequest('textDocument/hover', {
+ textDocument = { uri = 'file://test.lua' },
+ position = { line = 8, character = 1 },
+ })
+
+ assert(hover1.contents.value:find 'number')
+ assert(hover2.contents.value:find 'number')
+end)