]> granicus.if.org Git - vim/commitdiff
patch 8.2.1736: failure to compile a pattern not tested much v8.2.1736
authorBram Moolenaar <Bram@vim.org>
Wed, 23 Sep 2020 20:38:05 +0000 (22:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 23 Sep 2020 20:38:05 +0000 (22:38 +0200)
Problem:    Failure to compile a pattern not tested much.
Solution:   Add tests where a pattern fails to compile. (Yegappan Lakshmanan,
            closes #7004)

18 files changed:
src/testdir/gen_opt_test.vim
src/testdir/test_arglist.vim
src/testdir/test_autocmd.vim
src/testdir/test_buffer.vim
src/testdir/test_checkpath.vim
src/testdir/test_cmdline.vim
src/testdir/test_debugger.vim
src/testdir/test_functions.vim
src/testdir/test_history.vim
src/testdir/test_listdict.vim
src/testdir/test_options.vim
src/testdir/test_search_stat.vim
src/testdir/test_sort.vim
src/testdir/test_substitute.vim
src/testdir/test_syntax.vim
src/testdir/test_tagjump.vim
src/testdir/test_user_func.vim
src/version.c

index faff33a863c4fd0adebe47c37e19d555654d6799..271abedce36e7b9831d1e845f50469df5179fc4d 100644 (file)
@@ -73,7 +73,7 @@ let test_values = {
       \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
       \ 'casemap': [['', 'internal'], ['xxx']],
       \ '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']],
       \ 'comments': [['', 'b:#'], ['xxx']],
       \ 'commentstring': [['', '/*%s*/'], ['xxx']],
index 9b23a512e12c5deaaa8d4978f8228d3a1a247ae9..615d8167b31a682062a96749f3747e1108530c03 100644 (file)
@@ -425,6 +425,7 @@ func Test_argdelete()
   call assert_equal(['b'], argv())
   call assert_fails('argdelete', 'E610:')
   call assert_fails('1,100argdelete', 'E16:')
+  call assert_fails('argdel /\)/', 'E55:')
 
   call Reset_arglist()
   args a b c d
index b7067a773ac41a235c0347eaab7d871ff01ce738..b7cc0c0bf2d70826c408ee05703fe8ddb9850d40 100644 (file)
@@ -2520,6 +2520,7 @@ func Test_autocmd_invalid_args()
   call assert_fails('doautocmd * BufEnter', 'E217:')
   call assert_fails('augroup! x1a2b3', 'E367:')
   call assert_fails('autocmd BufNew <buffer=999> pwd', 'E680:')
+  call assert_fails('autocmd BufNew \) set ff=unix', 'E55:')
 endfunc
 
 " Test for deep nesting of autocmds
index e54b6338cb8e9b8a61fb0490c38311534cf10ffd..8ef41e20fb5b0d454e701a31e954ed878b03c87d 100644 (file)
@@ -138,6 +138,7 @@ func Test_bdelete_cmd()
   %bwipe!
   call assert_fails('bdelete 5', 'E516:')
   call assert_fails('1,1bdelete 1 2', 'E488:')
+  call assert_fails('bdelete \)', 'E55:')
 
   " Deleting a unlisted and unloaded buffer
   edit Xfile1
index 28e9105736d58d31914666f1d73b293e9e1ddcf0..f6a3bbce08cc6370717cde9f175fd73e455b10df 100644 (file)
@@ -103,4 +103,19 @@ func Test_checkpath3()
   set includeexpr&
 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
index a547ac4e632cdbd0fefe1c96f5b6ac9d3883f435..026625e0243c8eb109d46b1c58964b0ed870b9c8 100644 (file)
@@ -185,6 +185,8 @@ func Test_map_completion()
   unmap <Left>
   set cpo-=k
 
+  call assert_fails('call feedkeys(":map \\\\%(\<Tab>\<Home>\"\<CR>", "xt")', 'E53:')
+
   unmap <Middle>x
   set cpo&vim
 endfunc
index 8c51675429b6a19494f050f0307502177ed7b789..b6231cf4a8d14cc5d8867d228c1306e2df7b42b2 100644 (file)
@@ -339,6 +339,7 @@ func Test_Debugger()
   call delete('Xtest.vim')
   %bw!
   call assert_fails('breakadd here', 'E32:')
+  call assert_fails('breakadd file Xtest.vim /\)/', 'E55:')
 endfunc
 
 func Test_Backtrace_Through_Source()
index 2492c9379a816f0634283b2977c70d0c7e5f28f7..5e4eacd044ffe63ece84f38ca416695e101eb977 100644 (file)
@@ -973,6 +973,7 @@ func Test_match_func()
   call assert_equal(4,  match('testing', 'ing', -1))
   call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:')
   call assert_equal(-1, match(test_null_list(), 2))
+  call assert_equal(-1, match('abc', '\\%('))
 endfunc
 
 func Test_matchend()
index feb521e232a02a01200b41010a9d7fb39d6ab455..1bea78d5a8e0a4989560982321cd2f2eb6f94acc 100644 (file)
@@ -95,6 +95,7 @@ function Test_History()
   call assert_fails('call histnr([])', 'E730:')
   call assert_fails('history xyz', 'E488:')
   call assert_fails('history ,abc', 'E488:')
+  call assert_fails('call histdel(":", "\\%(")', 'E53:')
 endfunction
 
 function Test_Search_history_window()
index 66b84060a1095317e2c16ff8826d10cec22b5d32..63fa04ef9fb1ddfed4861266f50f3c738411d495 100644 (file)
@@ -753,6 +753,7 @@ func Test_str_split()
   call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1))
   call assert_fails("call split('abc', [])", 'E730:')
   call assert_fails("call split('abc', 'b', [])", 'E745:')
+  call assert_equal(['abc'], split('abc', '\\%('))
 endfunc
 
 " compare recursively linked list and dict
index ec40ccc5fbb2546260cf8c338cd02b027cd8ca24..22e0809ad016f70c273c4cac05ee072bb2820a07 100644 (file)
@@ -411,6 +411,7 @@ func Test_set_errors()
     call assert_fails('set pyxversion=6', 'E474:')
   endif
   call assert_fails("let &tabstop='ab'", 'E521:')
+  call assert_fails('set spellcapcheck=%\\(', 'E54:')
 endfunc
 
 func CheckWasSet(name)
index 73cea033ea7e48228b2a43c90f59c40323f96973..2afccef5d16005011b9585e9f8fb033ebf8c130b 100644 (file)
@@ -260,6 +260,14 @@ endfunc
 
 func Test_searchcount_fails()
   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
 
 func Test_searchcount_in_statusline()
index c7504b7a74ca6b4b1a4756c3dc032a98a147a068..d76132ee57a694ea14341dceb85b0c604e08304e 100644 (file)
@@ -1256,6 +1256,7 @@ func Test_sort_cmd()
   call assert_fails('sort no', 'E474:')
   call assert_fails('sort c', 'E475:')
   call assert_fails('sort #pat%', 'E654:')
+  call assert_fails('sort /\%(/', 'E53:')
 
   enew!
 endfunc
index a137aa5272ddd34907ba8508586b152b6c2674f9..f38eb55b81fc0240d05d0405ece76262facd4c76 100644 (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', 'A', [])", 'E730:')
+  call assert_fails("let s=substitute('abc', '\\%(', 'A', 'g')", 'E53:')
 
   bwipe!
 endfunc
index 8a021851f36675b10d1caa809db660f34232dd22..dc05355865481318617ed846c8d5d9ce1ff5c9e4 100644 (file)
@@ -373,6 +373,7 @@ func Test_syntax_invalid_arg()
   call AssertFails('syntax cluster contains=Abc', 'E400:')
   call AssertFails("syntax match Character /'.'", 'E401:')
   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', 'E404:')
   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 region Block start="{" contains=F,ALLBUT', 'E408:')
   call AssertFails("syntax match Characters contains=a.*x /'.'/", 'E409:')
+  call assert_fails('syntax match Search /abc/ contains=ALLBUT,/\%(/', 'E53:')
 endfunc
 
 func Test_syn_sync()
index ab4841f89182a4a129270dccc2bf738fdd3fd50f..a872b1ce9771b7340acfc1f806187d853f190a43 100644 (file)
@@ -184,6 +184,10 @@ function Test_keyword_jump()
   call search("start")
   exe "normal! 5\<C-W>\<C-I>"
   call assert_equal("          start OK if found this line", getline('.'))
+
+  " invalid tag search pattern
+  call assert_fails('tag /\%(/', 'E426:')
+
   enew! | only
   call delete('Xtestfile')
   call delete('Xinclude')
index ed07d99b7de0a2ccbc95be4d83af432c314e8e19..2edaec87ece02b00f64f5572873669f27be82591 100644 (file)
@@ -410,6 +410,9 @@ func Test_func_def_error()
   call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript')
   call assert_fails('source Xscript', 'E746:')
   call delete('Xscript')
+
+  " Try to list functions using an invalid search pattern
+  call assert_fails('function /\%(/', 'E53:')
 endfunc
 
 " Test for deleting a function
index d85ac1b2dd630a75d1bd81e398ba90f7e72986d0..a2383c9e79d6b94405b32677dc6ded33a6b55956 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1736,
 /**/
     1735,
 /**/