From bd823c3c1d573735629f6ba218dbc0208ead7908 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sat, 22 Jan 2022 11:20:41 -0800 Subject: [PATCH] Add test for LspShowSignature --- test/unit_tests.vim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/unit_tests.vim b/test/unit_tests.vim index 297ec1d..0b3057d 100644 --- a/test/unit_tests.vim +++ b/test/unit_tests.vim @@ -591,6 +591,45 @@ def Test_LspHover() :%bw! enddef +# Test for :LspShowSignature +def Test_LspShowSignature() + silent! edit Xtest.c + var lines: list =<< trim END + int MyFunc(int a, int b) + { + return 0; + } + + void f2(void) + { + MyFunc( + } + END + setline(1, lines) + :sleep 1 + cursor(8, 10) + :LspShowSignature + :sleep 1 + var p: list = popup_list() + var bnr: number = winbufnr(p[0]) + assert_equal(1, p->len()) + assert_equal(['MyFunc(int a, int b) -> int'], getbufline(bnr, 1, '$')) + assert_equal([{'id': 0, 'col': 8, 'type_bufnr': 11, 'end': 1, 'type': 'signature', 'length': 5, 'start': 1}], prop_list(1, {bufnr: bnr})) + popup_close(p[0]) + + setline(line('.'), ' MyFunc(10, ') + cursor(8, 13) + :LspShowSignature + :sleep 1 + p = popup_list() + bnr = winbufnr(p[0]) + assert_equal(1, p->len()) + assert_equal(['MyFunc(int a, int b) -> int'], getbufline(bnr, 1, '$')) + assert_equal([{'id': 0, 'col': 15, 'type_bufnr': 11, 'end': 1, 'type': 'signature', 'length': 5, 'start': 1}], prop_list(1, {bufnr: bnr})) + popup_close(p[0]) + :%bw! +enddef + def LspRunTests() :set nomore :set debug=beep -- 2.48.1