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