0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.1736: failure to compile a pattern not tested much

Problem:    Failure to compile a pattern not tested much.
Solution:   Add tests where a pattern fails to compile. (Yegappan Lakshmanan,
            closes #7004)
This commit is contained in:
Bram Moolenaar
2020-09-23 22:38:05 +02:00
parent 851d108313
commit 531be47ac5
18 changed files with 47 additions and 1 deletions

View File

@@ -73,7 +73,7 @@ let test_values = {
\ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']], \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
\ 'casemap': [['', 'internal'], ['xxx']], \ 'casemap': [['', 'internal'], ['xxx']],
\ 'cedit': [['', '\<Esc>'], ['xxx', 'f']], \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
\ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*']], \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
\ 'colorcolumn': [['', '8', '+2'], ['xxx']], \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
\ 'comments': [['', 'b:#'], ['xxx']], \ 'comments': [['', 'b:#'], ['xxx']],
\ 'commentstring': [['', '/*%s*/'], ['xxx']], \ 'commentstring': [['', '/*%s*/'], ['xxx']],

View File

@@ -425,6 +425,7 @@ func Test_argdelete()
call assert_equal(['b'], argv()) call assert_equal(['b'], argv())
call assert_fails('argdelete', 'E610:') call assert_fails('argdelete', 'E610:')
call assert_fails('1,100argdelete', 'E16:') call assert_fails('1,100argdelete', 'E16:')
call assert_fails('argdel /\)/', 'E55:')
call Reset_arglist() call Reset_arglist()
args a b c d args a b c d

View File

@@ -2520,6 +2520,7 @@ func Test_autocmd_invalid_args()
call assert_fails('doautocmd * BufEnter', 'E217:') call assert_fails('doautocmd * BufEnter', 'E217:')
call assert_fails('augroup! x1a2b3', 'E367:') call assert_fails('augroup! x1a2b3', 'E367:')
call assert_fails('autocmd BufNew <buffer=999> pwd', 'E680:') call assert_fails('autocmd BufNew <buffer=999> pwd', 'E680:')
call assert_fails('autocmd BufNew \) set ff=unix', 'E55:')
endfunc endfunc
" Test for deep nesting of autocmds " Test for deep nesting of autocmds

View File

@@ -138,6 +138,7 @@ func Test_bdelete_cmd()
%bwipe! %bwipe!
call assert_fails('bdelete 5', 'E516:') call assert_fails('bdelete 5', 'E516:')
call assert_fails('1,1bdelete 1 2', 'E488:') call assert_fails('1,1bdelete 1 2', 'E488:')
call assert_fails('bdelete \)', 'E55:')
" Deleting a unlisted and unloaded buffer " Deleting a unlisted and unloaded buffer
edit Xfile1 edit Xfile1

View File

@@ -103,4 +103,19 @@ func Test_checkpath3()
set includeexpr& set includeexpr&
endfunc endfunc
" Test for invalid regex in 'include' and 'define' options
func Test_checkpath_errors()
let save_include = &include
set include=\\%(
call assert_fails('checkpath', 'E53:')
let &include = save_include
let save_define = &define
set define=\\%(
call assert_fails('dsearch abc', 'E53:')
let &define = save_define
call assert_fails('psearch \%(', 'E53:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -185,6 +185,8 @@ func Test_map_completion()
unmap <Left> unmap <Left>
set cpo-=k set cpo-=k
call assert_fails('call feedkeys(":map \\\\%(\<Tab>\<Home>\"\<CR>", "xt")', 'E53:')
unmap <Middle>x unmap <Middle>x
set cpo&vim set cpo&vim
endfunc endfunc

View File

@@ -339,6 +339,7 @@ func Test_Debugger()
call delete('Xtest.vim') call delete('Xtest.vim')
%bw! %bw!
call assert_fails('breakadd here', 'E32:') call assert_fails('breakadd here', 'E32:')
call assert_fails('breakadd file Xtest.vim /\)/', 'E55:')
endfunc endfunc
func Test_Backtrace_Through_Source() func Test_Backtrace_Through_Source()

View File

@@ -973,6 +973,7 @@ func Test_match_func()
call assert_equal(4, match('testing', 'ing', -1)) call assert_equal(4, match('testing', 'ing', -1))
call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:') call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:')
call assert_equal(-1, match(test_null_list(), 2)) call assert_equal(-1, match(test_null_list(), 2))
call assert_equal(-1, match('abc', '\\%('))
endfunc endfunc
func Test_matchend() func Test_matchend()

View File

@@ -95,6 +95,7 @@ function Test_History()
call assert_fails('call histnr([])', 'E730:') call assert_fails('call histnr([])', 'E730:')
call assert_fails('history xyz', 'E488:') call assert_fails('history xyz', 'E488:')
call assert_fails('history ,abc', 'E488:') call assert_fails('history ,abc', 'E488:')
call assert_fails('call histdel(":", "\\%(")', 'E53:')
endfunction endfunction
function Test_Search_history_window() function Test_Search_history_window()

View File

@@ -753,6 +753,7 @@ func Test_str_split()
call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1)) call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1))
call assert_fails("call split('abc', [])", 'E730:') call assert_fails("call split('abc', [])", 'E730:')
call assert_fails("call split('abc', 'b', [])", 'E745:') call assert_fails("call split('abc', 'b', [])", 'E745:')
call assert_equal(['abc'], split('abc', '\\%('))
endfunc endfunc
" compare recursively linked list and dict " compare recursively linked list and dict

View File

@@ -411,6 +411,7 @@ func Test_set_errors()
call assert_fails('set pyxversion=6', 'E474:') call assert_fails('set pyxversion=6', 'E474:')
endif endif
call assert_fails("let &tabstop='ab'", 'E521:') call assert_fails("let &tabstop='ab'", 'E521:')
call assert_fails('set spellcapcheck=%\\(', 'E54:')
endfunc endfunc
func CheckWasSet(name) func CheckWasSet(name)

View File

@@ -260,6 +260,14 @@ endfunc
func Test_searchcount_fails() func Test_searchcount_fails()
call assert_fails('echo searchcount("boo!")', 'E715:') call assert_fails('echo searchcount("boo!")', 'E715:')
call assert_fails('echo searchcount({"timeout" : []})', 'E745:')
call assert_fails('echo searchcount({"maxcount" : []})', 'E745:')
call assert_fails('echo searchcount({"pattern" : []})', 'E730:')
call assert_fails('echo searchcount({"pos" : 1})', 'E475:')
call assert_fails('echo searchcount({"pos" : [1]})', 'E475:')
call assert_fails('echo searchcount({"pos" : [[], 2, 3]})', 'E745:')
call assert_fails('echo searchcount({"pos" : [1, [], 3]})', 'E745:')
call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
endfunc endfunc
func Test_searchcount_in_statusline() func Test_searchcount_in_statusline()

View File

@@ -1256,6 +1256,7 @@ func Test_sort_cmd()
call assert_fails('sort no', 'E474:') call assert_fails('sort no', 'E474:')
call assert_fails('sort c', 'E475:') call assert_fails('sort c', 'E475:')
call assert_fails('sort #pat%', 'E654:') call assert_fails('sort #pat%', 'E654:')
call assert_fails('sort /\%(/', 'E53:')
enew! enew!
endfunc endfunc

View File

@@ -246,6 +246,7 @@ func Test_substitute_errors()
call assert_fails("let s=substitute('abcda', [], 'A', 'g')", 'E730:') call assert_fails("let s=substitute('abcda', [], 'A', 'g')", 'E730:')
call assert_fails("let s=substitute('abcda', 'a', [], 'g')", 'E730:') call assert_fails("let s=substitute('abcda', 'a', [], 'g')", 'E730:')
call assert_fails("let s=substitute('abcda', 'a', 'A', [])", 'E730:') call assert_fails("let s=substitute('abcda', 'a', 'A', [])", 'E730:')
call assert_fails("let s=substitute('abc', '\\%(', 'A', 'g')", 'E53:')
bwipe! bwipe!
endfunc endfunc

View File

@@ -373,6 +373,7 @@ func Test_syntax_invalid_arg()
call AssertFails('syntax cluster contains=Abc', 'E400:') call AssertFails('syntax cluster contains=Abc', 'E400:')
call AssertFails("syntax match Character /'.'", 'E401:') call AssertFails("syntax match Character /'.'", 'E401:')
call AssertFails("syntax match Character /'.'/a", 'E402:') call AssertFails("syntax match Character /'.'/a", 'E402:')
call assert_fails('syntax sync linecont /\%(/', 'E53:')
call assert_fails('syntax sync linecont /pat', 'E404:') call assert_fails('syntax sync linecont /pat', 'E404:')
call assert_fails('syntax sync linecont', 'E404:') call assert_fails('syntax sync linecont', 'E404:')
call assert_fails('syntax sync linecont /pat1/ linecont /pat2/', 'E403:') call assert_fails('syntax sync linecont /pat1/ linecont /pat2/', 'E403:')
@@ -382,6 +383,7 @@ func Test_syntax_invalid_arg()
call AssertFails('syntax match ccFoo "Foo" nextgroup=ALLBUT,F', 'E407:') call AssertFails('syntax match ccFoo "Foo" nextgroup=ALLBUT,F', 'E407:')
call AssertFails('syntax region Block start="{" contains=F,ALLBUT', 'E408:') call AssertFails('syntax region Block start="{" contains=F,ALLBUT', 'E408:')
call AssertFails("syntax match Characters contains=a.*x /'.'/", 'E409:') call AssertFails("syntax match Characters contains=a.*x /'.'/", 'E409:')
call assert_fails('syntax match Search /abc/ contains=ALLBUT,/\%(/', 'E53:')
endfunc endfunc
func Test_syn_sync() func Test_syn_sync()

View File

@@ -184,6 +184,10 @@ function Test_keyword_jump()
call search("start") call search("start")
exe "normal! 5\<C-W>\<C-I>" exe "normal! 5\<C-W>\<C-I>"
call assert_equal(" start OK if found this line", getline('.')) call assert_equal(" start OK if found this line", getline('.'))
" invalid tag search pattern
call assert_fails('tag /\%(/', 'E426:')
enew! | only enew! | only
call delete('Xtestfile') call delete('Xtestfile')
call delete('Xinclude') call delete('Xinclude')

View File

@@ -410,6 +410,9 @@ func Test_func_def_error()
call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript') call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript')
call assert_fails('source Xscript', 'E746:') call assert_fails('source Xscript', 'E746:')
call delete('Xscript') call delete('Xscript')
" Try to list functions using an invalid search pattern
call assert_fails('function /\%(/', 'E53:')
endfunc endfunc
" Test for deleting a function " Test for deleting a function

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1736,
/**/ /**/
1735, 1735,
/**/ /**/