test/unit_tests.vim | 30 ++++++++++++++++++++++++++++-- diff --git a/test/unit_tests.vim b/test/unit_tests.vim index fceb9c21b57ca085487a0221fc7c77f6eb1c9739..bae85435af864b1877779329ef4f8290d9f4dda8 100644 --- a/test/unit_tests.vim +++ b/test/unit_tests.vim @@ -293,8 +293,8 @@ :%bw! enddef -# Test for LSP code action -def Test_lsp_codeaction() +# Test for :LspCodeAction +def Test_LspCodeAction() silent! edit Xtest.c sleep 500m var lines: list =<< trim END @@ -531,6 +531,32 @@ execute('LspGotoDeclaration')->split("\n")) assert_equal(['Error: LSP server for "a.b" is not found'], execute('LspGotoImpl')->split("\n")) + :%bw! +enddef + +# Test for :LspHighlight +def Test_LspHighlight() + silent! edit Xtest.c + var lines: list =<< trim END + void f1(int arg) + { + int i = arg; + arg = 2; + } + END + setline(1, lines) + :sleep 1 + cursor(1, 13) + :LspHighlight + :sleep 1 + assert_equal([{'id': 0, 'col': 13, 'end': 1, 'type': 'LspTextRef', 'length': 3, 'start': 1}], prop_list(1)) + assert_equal([{'id': 0, 'col': 11, 'end': 1, 'type': 'LspReadRef', 'length': 3, 'start': 1}], prop_list(3)) + assert_equal([{'id': 0, 'col': 3, 'end': 1, 'type': 'LspWriteRef', 'length': 3, 'start': 1}], prop_list(4)) + :LspHighlightClear + :sleep 1 + assert_equal([], prop_list(1)) + assert_equal([], prop_list(3)) + assert_equal([], prop_list(4)) :%bw! enddef