mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:8.2.0644: insufficient testing for invalid function arguments
Problem: Insufficient testing for invalid function arguments.
Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5988)
99fa721944
Omit test_listener.vim: changed again in patch 8.2.1183.
Omit test_textprop.vim: changed again in patch 8.2.1183.
Cherry-pick quickfix feature checks from patch 8.1.2373.
Omit Test_saveas() change: duplicate and removed in patch 8.2.0866.
This commit is contained in:
@@ -7080,8 +7080,8 @@ setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
|
||||
GetLoclist()->setloclist(winnr)
|
||||
|
||||
setmatches({list} [, {win}]) *setmatches()*
|
||||
Restores a list of matches saved by |getmatches() for the
|
||||
current window|. Returns 0 if successful, otherwise -1. All
|
||||
Restores a list of matches saved by |getmatches()| for the
|
||||
current window. Returns 0 if successful, otherwise -1. All
|
||||
current matches are cleared before the list is restored. See
|
||||
example for |getmatches()|.
|
||||
If {win} is specified, use the window with this number or
|
||||
|
@@ -26,6 +26,7 @@ func Test_setbufline_getbufline()
|
||||
call assert_equal(['d'], getbufline(b, 4))
|
||||
call assert_equal(['e'], getbufline(b, 5))
|
||||
call assert_equal([], getbufline(b, 6))
|
||||
call assert_equal([], getbufline(b, 2, 1))
|
||||
exe "bwipe! " . b
|
||||
endfunc
|
||||
|
||||
|
@@ -182,6 +182,7 @@ func Test_client_server()
|
||||
endif
|
||||
endtry
|
||||
|
||||
call assert_fails('call remote_startserver([])', 'E730:')
|
||||
call assert_fails("let x = remote_peek([])", 'E730:')
|
||||
call assert_fails("let x = remote_read('vim10')", 'E277:')
|
||||
call assert_fails("call server2client('abc', 'xyz')", 'E258:')
|
||||
|
@@ -528,6 +528,7 @@ func Test_setmatches()
|
||||
endif
|
||||
eval set->setmatches()
|
||||
call assert_equal(exp, getmatches())
|
||||
call assert_fails('let m = setmatches([], [])', 'E957:')
|
||||
endfunc
|
||||
|
||||
func Test_empty_concatenate()
|
||||
|
@@ -29,6 +29,8 @@ func Test_has()
|
||||
call assert_equal(0, and(has('ttyout'), 0))
|
||||
call assert_equal(1, has('multi_byte_encoding'))
|
||||
endif
|
||||
call assert_equal(1, has('vcon', 1))
|
||||
call assert_equal(1, has('mouse_gpm_enabled', 1))
|
||||
|
||||
call assert_equal(0, has('nonexistent'))
|
||||
call assert_equal(0, has('nonexistent', 1))
|
||||
@@ -1331,12 +1333,15 @@ endfunc
|
||||
|
||||
" Test for the inputdialog() function
|
||||
func Test_inputdialog()
|
||||
CheckNotGui
|
||||
|
||||
if has('gui_running')
|
||||
call assert_fails('let v=inputdialog([], "xx")', 'E730:')
|
||||
call assert_fails('let v=inputdialog("Q", [])', 'E730:')
|
||||
else
|
||||
call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<CR>", 'xt')
|
||||
call assert_equal('xx', v)
|
||||
call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<Esc>", 'xt')
|
||||
call assert_equal('yy', v)
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Test for inputlist()
|
||||
@@ -1387,6 +1392,7 @@ func Test_balloon_show()
|
||||
call balloon_show('hi!')
|
||||
if !has('gui_running')
|
||||
call balloon_show(range(3))
|
||||
call balloon_show([])
|
||||
endif
|
||||
endfunc
|
||||
|
||||
@@ -2271,6 +2277,9 @@ func Test_range()
|
||||
call assert_fails('let x=range(2, 8, 0)', 'E726:')
|
||||
call assert_fails('let x=range(3, 1)', 'E727:')
|
||||
call assert_fails('let x=range(1, 3, -2)', 'E727:')
|
||||
call assert_fails('let x=range([])', 'E745:')
|
||||
call assert_fails('let x=range(1, [])', 'E745:')
|
||||
call assert_fails('let x=range(1, 4, [])', 'E745:')
|
||||
endfunc
|
||||
|
||||
func Test_garbagecollect_now_fails()
|
||||
|
@@ -160,12 +160,14 @@ endfunc
|
||||
func Test_matchadd_error()
|
||||
call clearmatches()
|
||||
" Nvim: not an error anymore:
|
||||
" call assert_fails("call matchadd('GroupDoesNotExist', 'X')", 'E28:')
|
||||
call matchadd('GroupDoesNotExist', 'X')
|
||||
call assert_equal([{'group': 'GroupDoesNotExist', 'pattern': 'X', 'priority': 10, 'id': 1206}], getmatches())
|
||||
call assert_fails("call matchadd('Search', '\\(')", 'E475:')
|
||||
call assert_fails("call matchadd('Search', 'XXX', 1, 123, 1)", 'E715:')
|
||||
call assert_fails("call matchadd('Error', 'XXX', 1, 3)", 'E798:')
|
||||
call assert_fails("call matchadd('Error', 'XXX', 1, 0)", 'E799:')
|
||||
call assert_fails("call matchadd('Error', 'XXX', [], 0)", 'E745:')
|
||||
endfunc
|
||||
|
||||
func Test_matchaddpos()
|
||||
@@ -305,7 +307,10 @@ func Test_matchaddpos_error()
|
||||
call assert_fails("call matchaddpos('Error', [1], 1, 123, 1)", 'E715:')
|
||||
call assert_fails("call matchaddpos('Error', [1], 1, 5, {'window':12345})", 'E957:')
|
||||
" Why doesn't the following error have an error code E...?
|
||||
" call assert_fails("call matchaddpos('Error', [{}])", 'E290:')
|
||||
call assert_fails("call matchaddpos('Error', [{}])", 'E5031:')
|
||||
call assert_equal(-1, matchaddpos('Error', v:_null_list))
|
||||
call assert_fails("call matchaddpos('Error', [1], [], 1)", 'E745:')
|
||||
endfunc
|
||||
|
||||
func OtherWindowCommon()
|
||||
@@ -362,5 +367,4 @@ func Test_matchadd_other_window()
|
||||
call delete('XscriptMatchCommon')
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -252,6 +252,7 @@ func Test_menu_info()
|
||||
nmenu Test.abc <Nop>
|
||||
call assert_equal('<Nop>', menu_info('Test.abc').rhs)
|
||||
call assert_fails('call menu_info([])', 'E730:')
|
||||
call assert_fails('call menu_info("", [])', 'E730:')
|
||||
nunmenu Test
|
||||
|
||||
" Test for defining menus in different modes
|
||||
|
@@ -285,7 +285,9 @@ func Test_get_register()
|
||||
|
||||
" Test for inserting a multi-line register in the command line
|
||||
call feedkeys(":\<C-R>r\<Esc>", 'xt')
|
||||
call assert_equal("a\rb", histget(':', -1)) " Modified because of #6137
|
||||
" Nvim: no trailing CR because of #6137
|
||||
" call assert_equal("a\rb\r", histget(':', -1))
|
||||
call assert_equal("a\rb", histget(':', -1))
|
||||
|
||||
call assert_fails('let r = getreg("=", [])', 'E745:')
|
||||
call assert_fails('let r = getreg("=", 1, [])', 'E745:')
|
||||
|
@@ -24,4 +24,8 @@ func Test_reltime()
|
||||
call assert_true(reltimefloat(differs) < 0.1)
|
||||
call assert_true(reltimefloat(differs) > 0.0)
|
||||
|
||||
call assert_equal(0, reltime({}))
|
||||
call assert_equal(0, reltime({}, {}))
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -501,10 +501,13 @@ func Test_win_screenpos()
|
||||
call assert_equal([1, 32], win_screenpos(2))
|
||||
call assert_equal([12, 1], win_screenpos(3))
|
||||
call assert_equal([0, 0], win_screenpos(4))
|
||||
call assert_fails('let l = win_screenpos([])', 'E745:')
|
||||
only
|
||||
endfunc
|
||||
|
||||
func Test_window_jump_tag()
|
||||
CheckFeature quickfix
|
||||
|
||||
help
|
||||
/iccf
|
||||
call assert_match('^|iccf|', getline('.'))
|
||||
@@ -734,6 +737,7 @@ func Test_relative_cursor_position_in_one_line_window()
|
||||
|
||||
only!
|
||||
bwipe!
|
||||
call assert_fails('call winrestview(v:_null_dict)', 'E474:')
|
||||
endfunc
|
||||
|
||||
func Test_relative_cursor_position_after_move_and_resize()
|
||||
@@ -910,6 +914,10 @@ func Test_winnr()
|
||||
call assert_fails("echo winnr('ll')", 'E15:')
|
||||
call assert_fails("echo winnr('5')", 'E15:')
|
||||
call assert_equal(4, winnr('0h'))
|
||||
call assert_fails("let w = winnr([])", 'E730:')
|
||||
call assert_equal('unknown', win_gettype(-1))
|
||||
call assert_equal(-1, winheight(-1))
|
||||
call assert_equal(-1, winwidth(-1))
|
||||
|
||||
tabnew
|
||||
call assert_equal(8, tabpagewinnr(1, 'j'))
|
||||
@@ -930,9 +938,12 @@ func Test_winrestview()
|
||||
call assert_equal(view, winsaveview())
|
||||
|
||||
bwipe!
|
||||
call assert_fails('call winrestview(v:_null_dict)', 'E474:')
|
||||
endfunc
|
||||
|
||||
func Test_win_splitmove()
|
||||
CheckFeature quickfix
|
||||
|
||||
edit a
|
||||
leftabove split b
|
||||
leftabove vsplit c
|
||||
@@ -958,6 +969,7 @@ func Test_win_splitmove()
|
||||
call assert_equal(bufname(winbufnr(2)), 'b')
|
||||
call assert_equal(bufname(winbufnr(3)), 'a')
|
||||
call assert_equal(bufname(winbufnr(4)), 'd')
|
||||
call assert_fails('call win_splitmove(winnr(), winnr("k"), v:_null_dict)', 'E474:')
|
||||
only | bd
|
||||
|
||||
call assert_fails('call win_splitmove(winnr(), 123)', 'E957:')
|
||||
|
@@ -1,5 +1,7 @@
|
||||
" Test using the window ID.
|
||||
|
||||
source check.vim
|
||||
|
||||
func Test_win_getid()
|
||||
edit one
|
||||
let id1 = win_getid()
|
||||
@@ -90,10 +92,16 @@ func Test_win_getid()
|
||||
split
|
||||
call assert_equal(sort([id5, win_getid()]), sort(win_findbuf(bufnr5)))
|
||||
|
||||
call assert_fails('let w = win_getid([])', 'E745:')
|
||||
call assert_equal(0, win_getid(-1))
|
||||
call assert_equal(-1, win_getid(1, -1))
|
||||
|
||||
only!
|
||||
endfunc
|
||||
|
||||
func Test_win_getid_curtab()
|
||||
CheckFeature quickfix
|
||||
|
||||
tabedit X
|
||||
tabfirst
|
||||
copen
|
||||
@@ -127,4 +135,8 @@ func Test_winlayout()
|
||||
let w2 = win_getid()
|
||||
call assert_equal(['leaf', w2], 2->winlayout())
|
||||
tabclose
|
||||
|
||||
call assert_equal([], winlayout(-1))
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -260,6 +260,13 @@ func Test_write_errors()
|
||||
close
|
||||
|
||||
call delete('Xfile')
|
||||
|
||||
" Nvim treats NULL list/blob more like empty list/blob
|
||||
" call writefile(v:_null_list, 'Xfile')
|
||||
" call assert_false(filereadable('Xfile'))
|
||||
" call writefile(v:_null_blob, 'Xfile')
|
||||
" call assert_false(filereadable('Xfile'))
|
||||
call assert_fails('call writefile([], "")', 'E482:')
|
||||
endfunc
|
||||
|
||||
" Test for writing a file using invalid file encoding
|
||||
|
Reference in New Issue
Block a user