Skip to content

Commit 7237cab

Browse files
yegappanbrammool
authored andcommitted
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)
1 parent 831bdf8 commit 7237cab

7 files changed

Lines changed: 400 additions & 72 deletions

File tree

src/evalfunc.c

Lines changed: 68 additions & 64 deletions
Large diffs are not rendered by default.

src/testdir/test_assert.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ func Test_mouse_position()
374374
call test_setmouse(5, 1)
375375
call feedkeys("\<LeftMouse>", "xt")
376376
call assert_equal([0, 2, 1, 0], getpos('.'))
377+
call assert_fails('call test_setmouse("", 2)', 'E474:')
378+
call assert_fails('call test_setmouse(1, "")', 'E474:')
377379
bwipe!
378380
let &mouse = save_mouse
379381
endfunc

src/testdir/test_gui.vim

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ func Test_gui_mouse_event()
882882
new
883883
call setline(1, ['one two three', 'four five six'])
884884

885-
" place the cursor using left click
885+
" place the cursor using left click in normal mode
886886
call cursor(1, 1)
887887
call test_gui_mouse_event(0, 2, 4, 0, 0)
888888
call test_gui_mouse_event(3, 2, 4, 0, 0)
@@ -1092,9 +1092,70 @@ func Test_gui_mouse_event()
10921092
set mouse&
10931093
let &guioptions = save_guioptions
10941094

1095+
" Test invalid parameters for test_gui_mouse_event()
1096+
call assert_fails('call test_gui_mouse_event("", 1, 2, 3, 4)', 'E474:')
1097+
call assert_fails('call test_gui_mouse_event(0, "", 2, 3, 4)', 'E474:')
1098+
call assert_fails('call test_gui_mouse_event(0, 1, "", 3, 4)', 'E474:')
1099+
call assert_fails('call test_gui_mouse_event(0, 1, 2, "", 4)', 'E474:')
1100+
call assert_fails('call test_gui_mouse_event(0, 1, 2, 3, "")', 'E474:')
1101+
10951102
bw!
10961103
call test_override('no_query_mouse', 0)
10971104
set mousemodel&
10981105
endfunc
10991106

1107+
" Test for 'guitablabel' and 'guitabtooltip' options
1108+
func TestGuiTabLabel()
1109+
call add(g:TabLabels, v:lnum + 100)
1110+
let bufnrlist = tabpagebuflist(v:lnum)
1111+
return bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
1112+
endfunc
1113+
1114+
func TestGuiTabToolTip()
1115+
call add(g:TabToolTips, v:lnum + 200)
1116+
let bufnrlist = tabpagebuflist(v:lnum)
1117+
return bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
1118+
endfunc
1119+
1120+
func Test_gui_tablabel_tooltip()
1121+
%bw!
1122+
" Removing the tabline at the end of this test, reduces the window height by
1123+
" one. Save and restore it after the test.
1124+
let save_lines = &lines
1125+
edit one
1126+
set modified
1127+
tabnew two
1128+
set modified
1129+
tabnew three
1130+
set modified
1131+
let g:TabLabels = []
1132+
set guitablabel=%{TestGuiTabLabel()}
1133+
call test_override('starting', 1)
1134+
redrawtabline
1135+
call test_override('starting', 0)
1136+
call assert_true(index(g:TabLabels, 101) != -1)
1137+
call assert_true(index(g:TabLabels, 102) != -1)
1138+
call assert_true(index(g:TabLabels, 103) != -1)
1139+
set guitablabel&
1140+
unlet g:TabLabels
1141+
1142+
if has('gui_gtk')
1143+
" Only on GTK+, the tooltip function is called even if the mouse is not
1144+
" on the tabline. on Win32 and Motif, the tooltip function is called only
1145+
" when the mouse pointer is over the tabline.
1146+
let g:TabToolTips = []
1147+
set guitabtooltip=%{TestGuiTabToolTip()}
1148+
call test_override('starting', 1)
1149+
redrawtabline
1150+
call test_override('starting', 0)
1151+
call assert_true(index(g:TabToolTips, 201) != -1)
1152+
call assert_true(index(g:TabToolTips, 202) != -1)
1153+
call assert_true(index(g:TabToolTips, 203) != -1)
1154+
set guitabtooltip&
1155+
unlet g:TabToolTips
1156+
endif
1157+
%bw!
1158+
let &lines = save_lines
1159+
endfunc
1160+
11001161
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_popupwin.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,8 +1552,8 @@ func Test_popup_filter()
15521552
call assert_equal(9, getcurpos()[2])
15531553
call feedkeys('0', 'xt')
15541554
call assert_equal('0', g:ignored)
1555-
redraw
1556-
call assert_equal(1, getcurpos()[2])
1555+
normal! l
1556+
call assert_equal(2, getcurpos()[2])
15571557

15581558
" x closes the popup
15591559
call feedkeys('x', 'xt')

0 commit comments

Comments
 (0)