]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add a test for LspHighlight
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 22 Jan 2022 17:07:12 +0000 (09:07 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 22 Jan 2022 17:07:12 +0000 (09:07 -0800)
test/unit_tests.vim

index fceb9c21b57ca085487a0221fc7c77f6eb1c9739..bae85435af864b1877779329ef4f8290d9f4dda8 100644 (file)
@@ -293,8 +293,8 @@ def Test_lsp_diags()
   :%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<string> =<< trim END
@@ -534,6 +534,32 @@ def Test_lsp_goto_definition()
   :%bw!
 enddef
 
+# Test for :LspHighlight
+def Test_LspHighlight()
+  silent! edit Xtest.c
+  var lines: list<string> =<< 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
+
 def LspRunTests()
   :set nomore
   :set debug=beep