summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-18 15:16:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-18 15:16:49 +0800
commit716091ac3646d57af28a106d4a3b15cf3b849544 (patch)
tree36db3a63629e880980cd4b2dff7c2f6a7bc53066 /test
parent2f984c1a2baf162f72240ca7b7f3f530459a71f4 (diff)
downloadlua-language-server-716091ac3646d57af28a106d4a3b15cf3b849544.zip
pass tests
Diffstat (limited to 'test')
-rw-r--r--test/tclient/lclient.lua33
-rw-r--r--test/tclient/tests/single-mode.lua6
2 files changed, 29 insertions, 10 deletions
diff --git a/test/tclient/lclient.lua b/test/tclient/lclient.lua
index 50f13946..4273d88c 100644
--- a/test/tclient/lclient.lua
+++ b/test/tclient/lclient.lua
@@ -49,6 +49,8 @@ function mt:start(callback)
finished = true
end)
+ local jumpedTime = 0
+
while true do
if finished then
break
@@ -64,6 +66,10 @@ function mt:start(callback)
goto CONTINUE
end
timer.timeJump(1.0)
+ jumpedTime = jumpedTime + 1.0
+ if jumpedTime > 2 * 60 * 60 then
+ error('two hours later ...')
+ end
::CONTINUE::
end
@@ -111,10 +117,14 @@ function mt:update()
for _, out in ipairs(outs) do
if out.method then
local callback = self._methods[out.method]
- proto.doResponse {
- id = out.id,
- params = callback(out.params),
- }
+ if callback then
+ proto.doResponse {
+ id = out.id,
+ params = callback(out.params),
+ }
+ elseif out.method:sub(1, 2) ~= '$/' then
+ error('Unknown method: ' .. out.method)
+ end
else
local callback = self._waiting[out.id]
self._waiting[out.id] = nil
@@ -124,8 +134,19 @@ function mt:update()
return true
end
-function mt:register(name, callback)
- self._methods[name] = callback
+function mt:register(method, callback)
+ self._methods[method] = callback
+end
+
+function mt:registerFakers()
+ for _, method in ipairs {
+ 'workspace/configuration',
+ 'textDocument/publishDiagnostics',
+ } do
+ self:register(method, function ()
+ return nil
+ end)
+ end
end
---@return languageClient
diff --git a/test/tclient/tests/single-mode.lua b/test/tclient/tests/single-mode.lua
index e0773a7e..897eee31 100644
--- a/test/tclient/tests/single-mode.lua
+++ b/test/tclient/tests/single-mode.lua
@@ -5,9 +5,7 @@ local util = require 'utility'
---@async
lclient():start(function (client)
- client:register('workspace/configuration', function ()
- return nil
- end)
+ client:registerFakers()
client:awaitRequest('initialize', {
clientInfo = {
@@ -33,7 +31,7 @@ print(x)
ws.awaitReady()
- local locations = client:awaitRequest('textDocument.definition', {
+ local locations = client:awaitRequest('textDocument/definition', {
textDocument = { uri = 'test://single-file.lua' },
position = { line = 1, character = 7 },
})