mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
test(lsp): return tables instead of deserializing strings #34554
This commit is contained in:
@ -24,13 +24,30 @@ int main() {
|
||||
}
|
||||
}]])
|
||||
|
||||
local response = [==[
|
||||
[
|
||||
{"kind":1,"paddingLeft":false,"label":"-> int","position":{"character":22,"line":0},"paddingRight":false},
|
||||
{"kind":2,"paddingLeft":false,"label":"a:","position":{"character":15,"line":5},"paddingRight":true},
|
||||
{"kind":2,"paddingLeft":false,"label":"b:","position":{"character":17,"line":5},"paddingRight":true}
|
||||
]
|
||||
]==]
|
||||
---@type lsp.InlayHint[]
|
||||
local response = {
|
||||
{
|
||||
kind = 1,
|
||||
paddingLeft = false,
|
||||
paddingRight = false,
|
||||
label = '-> int',
|
||||
position = { character = 22, line = 0 },
|
||||
},
|
||||
{
|
||||
kind = 2,
|
||||
paddingLeft = false,
|
||||
paddingRight = true,
|
||||
label = 'a:',
|
||||
position = { character = 15, line = 5 },
|
||||
},
|
||||
{
|
||||
kind = 2,
|
||||
paddingLeft = false,
|
||||
paddingRight = true,
|
||||
label = 'b:',
|
||||
position = { character = 17, line = 5 },
|
||||
},
|
||||
}
|
||||
|
||||
local grid_without_inlay_hints = [[
|
||||
auto add(int a, int b) { return a + b; } |
|
||||
@ -78,7 +95,7 @@ int main() {
|
||||
},
|
||||
handlers = {
|
||||
['textDocument/inlayHint'] = function(_, _, callback)
|
||||
callback(nil, vim.json.decode(response))
|
||||
callback(nil, response)
|
||||
end,
|
||||
},
|
||||
})
|
||||
@ -217,8 +234,6 @@ int main() {
|
||||
|
||||
describe('get()', function()
|
||||
it('returns filtered inlay hints', function()
|
||||
--- @type lsp.InlayHint[]
|
||||
local expected = vim.json.decode(response)
|
||||
local expected2 = {
|
||||
kind = 1,
|
||||
paddingLeft = false,
|
||||
@ -248,9 +263,9 @@ int main() {
|
||||
--- @type vim.lsp.inlay_hint.get.ret
|
||||
eq(
|
||||
{
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = expected[1] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = expected[2] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = expected[3] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = response[1] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = response[2] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = response[3] },
|
||||
{ bufnr = 1, client_id = 2, inlay_hint = expected2 },
|
||||
},
|
||||
exec_lua(function()
|
||||
@ -274,8 +289,8 @@ int main() {
|
||||
|
||||
eq(
|
||||
{
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = expected[2] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = expected[3] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = response[2] },
|
||||
{ bufnr = 1, client_id = 1, inlay_hint = response[3] },
|
||||
},
|
||||
exec_lua(function()
|
||||
return vim.lsp.inlay_hint.get({
|
||||
@ -349,15 +364,13 @@ describe('Inlay hints handler', function()
|
||||
test text
|
||||
]])
|
||||
|
||||
local response = [==[
|
||||
[
|
||||
{ "position": { "line": 0, "character": 0 }, "label": "0" },
|
||||
{ "position": { "line": 0, "character": 0 }, "label": "1" },
|
||||
{ "position": { "line": 0, "character": 0 }, "label": "2" },
|
||||
{ "position": { "line": 0, "character": 0 }, "label": "3" },
|
||||
{ "position": { "line": 0, "character": 0 }, "label": "4" }
|
||||
]
|
||||
]==]
|
||||
local response = {
|
||||
{ position = { line = 0, character = 0 }, label = '0' },
|
||||
{ position = { line = 0, character = 0 }, label = '1' },
|
||||
{ position = { line = 0, character = 0 }, label = '2' },
|
||||
{ position = { line = 0, character = 0 }, label = '3' },
|
||||
{ position = { line = 0, character = 0 }, label = '4' },
|
||||
}
|
||||
|
||||
local grid_without_inlay_hints = [[
|
||||
test text |
|
||||
@ -393,7 +406,7 @@ test text
|
||||
},
|
||||
handlers = {
|
||||
['textDocument/inlayHint'] = function(_, _, callback)
|
||||
callback(nil, vim.json.decode(response))
|
||||
callback(nil, response)
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user