patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Problem: Vim9: builtin function arguments not checked at compile time.
Solution: Add more argument type specs. Check arguments to test_setmouse()
and test_gui_mouse_event(). (Yegappan Lakshmanan, closes #8425)
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index 3472012..e935e5f 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -882,7 +882,7 @@
new
call setline(1, ['one two three', 'four five six'])
- " place the cursor using left click
+ " place the cursor using left click in normal mode
call cursor(1, 1)
call test_gui_mouse_event(0, 2, 4, 0, 0)
call test_gui_mouse_event(3, 2, 4, 0, 0)
@@ -1092,9 +1092,70 @@
set mouse&
let &guioptions = save_guioptions
+ " Test invalid parameters for test_gui_mouse_event()
+ call assert_fails('call test_gui_mouse_event("", 1, 2, 3, 4)', 'E474:')
+ call assert_fails('call test_gui_mouse_event(0, "", 2, 3, 4)', 'E474:')
+ call assert_fails('call test_gui_mouse_event(0, 1, "", 3, 4)', 'E474:')
+ call assert_fails('call test_gui_mouse_event(0, 1, 2, "", 4)', 'E474:')
+ call assert_fails('call test_gui_mouse_event(0, 1, 2, 3, "")', 'E474:')
+
bw!
call test_override('no_query_mouse', 0)
set mousemodel&
endfunc
+" Test for 'guitablabel' and 'guitabtooltip' options
+func TestGuiTabLabel()
+ call add(g:TabLabels, v:lnum + 100)
+ let bufnrlist = tabpagebuflist(v:lnum)
+ return bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
+endfunc
+
+func TestGuiTabToolTip()
+ call add(g:TabToolTips, v:lnum + 200)
+ let bufnrlist = tabpagebuflist(v:lnum)
+ return bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
+endfunc
+
+func Test_gui_tablabel_tooltip()
+ %bw!
+ " Removing the tabline at the end of this test, reduces the window height by
+ " one. Save and restore it after the test.
+ let save_lines = &lines
+ edit one
+ set modified
+ tabnew two
+ set modified
+ tabnew three
+ set modified
+ let g:TabLabels = []
+ set guitablabel=%{TestGuiTabLabel()}
+ call test_override('starting', 1)
+ redrawtabline
+ call test_override('starting', 0)
+ call assert_true(index(g:TabLabels, 101) != -1)
+ call assert_true(index(g:TabLabels, 102) != -1)
+ call assert_true(index(g:TabLabels, 103) != -1)
+ set guitablabel&
+ unlet g:TabLabels
+
+ if has('gui_gtk')
+ " Only on GTK+, the tooltip function is called even if the mouse is not
+ " on the tabline. on Win32 and Motif, the tooltip function is called only
+ " when the mouse pointer is over the tabline.
+ let g:TabToolTips = []
+ set guitabtooltip=%{TestGuiTabToolTip()}
+ call test_override('starting', 1)
+ redrawtabline
+ call test_override('starting', 0)
+ call assert_true(index(g:TabToolTips, 201) != -1)
+ call assert_true(index(g:TabToolTips, 202) != -1)
+ call assert_true(index(g:TabToolTips, 203) != -1)
+ set guitabtooltip&
+ unlet g:TabToolTips
+ endif
+ %bw!
+ let &lines = save_lines
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab