• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision2c4d9ca337693b3bf82249e3f38bebf7213ad637 (tree)
Zeit2020-04-07 04:45:31
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.0522: several errors are not tested for

Commit: https://github.com/vim/vim/commit/ee4e0c1e9a81cb5d96e0060203a9033c2f28588e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 6 21:35:05 2020 +0200

patch 8.2.0522: several errors are not tested for
Problem: Several errors are not tested for.
Solution: Add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5892)

Ändern Zusammenfassung

Diff

diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_autocmd.vim
--- a/src/testdir/test_autocmd.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_autocmd.vim Mon Apr 06 21:45:31 2020 +0200
@@ -2483,4 +2483,28 @@
24832483 delfunc ReadFileCmd
24842484 endfunc
24852485
2486+" Test for passing invalid arguments to autocmd
2487+func Test_autocmd_invalid_args()
2488+ " Additional character after * for event
2489+ call assert_fails('autocmd *a Xfile set ff=unix', 'E215:')
2490+ augroup Test
2491+ augroup END
2492+ " Invalid autocmd event
2493+ call assert_fails('autocmd Bufabc Xfile set ft=vim', 'E216:')
2494+ " Invalid autocmd event in a autocmd group
2495+ call assert_fails('autocmd Test Bufabc Xfile set ft=vim', 'E216:')
2496+ augroup! Test
2497+ " Execute all autocmds
2498+ call assert_fails('doautocmd * BufEnter', 'E217:')
2499+ call assert_fails('augroup! x1a2b3', 'E367:')
2500+ call assert_fails('autocmd BufNew <buffer=999> pwd', 'E680:')
2501+endfunc
2502+
2503+" Test for deep nesting of autocmds
2504+func Test_autocmd_deep_nesting()
2505+ autocmd BufEnter Xfile doautocmd BufEnter Xfile
2506+ call assert_fails('doautocmd BufEnter Xfile', 'E218:')
2507+ autocmd! BufEnter Xfile
2508+endfunc
2509+
24862510 " vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_clientserver.vim
--- a/src/testdir/test_clientserver.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_clientserver.vim Mon Apr 06 21:45:31 2020 +0200
@@ -2,6 +2,11 @@
22
33 source check.vim
44 CheckFeature job
5+
6+if !has('clientserver')
7+ call assert_fails('call remote_startserver("local")', 'E942:')
8+endif
9+
510 CheckFeature clientserver
611
712 source shared.vim
@@ -161,6 +166,7 @@
161166
162167 call assert_fails("let x = remote_peek([])", 'E730:')
163168 call assert_fails("let x = remote_read('vim10')", 'E277:')
169+ call assert_fails("call server2client('abc', 'xyz')", 'E258:')
164170 endfunc
165171
166172 " Uncomment this line to get a debugging log
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_digraph.vim
--- a/src/testdir/test_digraph.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_digraph.vim Mon Apr 06 21:45:31 2020 +0200
@@ -210,6 +210,8 @@
210210 call Put_Dig("00")
211211 call Put_Dig("el")
212212 call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.')))
213+ call assert_fails('exe "digraph a\<Esc> 100"', 'E104:')
214+ call assert_fails('exe "digraph \<Esc>a 100"', 'E104:')
213215 bw!
214216 endfunc
215217
@@ -475,4 +477,15 @@
475477 bwipe!
476478 endfunc
477479
480+" Test for error in a keymap file
481+func Test_loadkeymap_error()
482+ if !has('keymap')
483+ return
484+ endif
485+ call assert_fails('loadkeymap', 'E105:')
486+ call writefile(['loadkeymap', 'a'], 'Xkeymap')
487+ call assert_fails('source Xkeymap', 'E791:')
488+ call delete('Xkeymap')
489+endfunc
490+
478491 " vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_expand.vim
--- a/src/testdir/test_expand.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_expand.vim Mon Apr 06 21:45:31 2020 +0200
@@ -131,6 +131,7 @@
131131 call assert_equal(4, winnr('$'))
132132 call assert_equal('foo!', bufname(winbufnr(1)))
133133 call assert_equal('foo', bufname(winbufnr(2)))
134+ call assert_fails('e %:s/.*//', 'E500:')
134135 %bwipe!
135136 endfunc
136137
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_expr.vim
--- a/src/testdir/test_expr.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_expr.vim Mon Apr 06 21:45:31 2020 +0200
@@ -502,6 +502,7 @@
502502 call assert_fails('echo funcref("{")', 'E475:')
503503 let OneByRef = funcref("One", repeat(["foo"], 20))
504504 call assert_fails('let OneByRef = funcref("One", repeat(["foo"], 21))', 'E118:')
505+ call assert_fails('echo function("min") =~ function("min")', 'E694:')
505506 endfunc
506507
507508 func Test_setmatches()
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_functions.vim
--- a/src/testdir/test_functions.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_functions.vim Mon Apr 06 21:45:31 2020 +0200
@@ -1966,6 +1966,7 @@
19661966 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>"
19671967 " complete_info()
19681968 execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>\<C-r>=[complete_info(range(5)), ''][1]\<CR>"
1969+ call assert_fails('call complete(1, ["a"])', 'E785:')
19691970
19701971 " copy()
19711972 call assert_equal([1, 2, 3], copy(range(1, 3)))
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_gui.vim
--- a/src/testdir/test_gui.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_gui.vim Mon Apr 06 21:45:31 2020 +0200
@@ -388,6 +388,11 @@
388388 call assert_equal('Monospace 10', getfontname())
389389 endif
390390
391+ if has('win32')
392+ " Invalid font names are accepted in GTK GUI
393+ call assert_fails('set guifont=xa1bc23d7f', 'E596:')
394+ endif
395+
391396 if has('xfontset')
392397 let &guifontset = guifontset_saved
393398 endif
@@ -402,6 +407,8 @@
402407 CheckFeature xfontset
403408 let skipped = ''
404409
410+ call assert_fails('set guifontset=*', 'E597:')
411+
405412 let ctype_saved = v:ctype
406413
407414 " First, since XCreateFontSet(3) is very sensitive to locale, fonts must
@@ -468,6 +475,7 @@
468475 endfunc
469476
470477 func Test_set_guifontwide()
478+ call assert_fails('set guifontwide=*', 'E533:')
471479 let skipped = ''
472480
473481 if !g:x11_based_gui
@@ -785,6 +793,7 @@
785793 " It's enough to check the current value since setting 'term' to anything
786794 " other than builtin_gui makes no sense at all.
787795 call assert_equal('builtin_gui', &term)
796+ call assert_fails('set term=xterm', 'E530:')
788797 endfunc
789798
790799 func Test_windowid_variable()
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_highlight.vim
--- a/src/testdir/test_highlight.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_highlight.vim Mon Apr 06 21:45:31 2020 +0200
@@ -689,10 +689,28 @@
689689 endfunc
690690
691691 " Do this test last, sometimes restoring the columns doesn't work
692-function Test_z_no_space_before_xxx()
692+func Test_z_no_space_before_xxx()
693693 let l:org_columns = &columns
694694 set columns=17
695695 let l:hi_StatusLineTermNC = join(split(execute('hi StatusLineTermNC')))
696696 call assert_match('StatusLineTermNC xxx', l:hi_StatusLineTermNC)
697697 let &columns = l:org_columns
698-endfunction
698+endfunc
699+
700+" Test for :highlight command errors
701+func Test_highlight_cmd_errors()
702+ if has('gui_running')
703+ " This test doesn't fail in the MS-Windows console version.
704+ call assert_fails('hi Xcomment ctermfg=fg', 'E419:')
705+ call assert_fails('hi Xcomment ctermfg=bg', 'E420:')
706+ endif
707+
708+ " Try using a very long terminal code. Define a dummy terminal code for this
709+ " test.
710+ let &t_fo = "\<Esc>1;"
711+ let c = repeat("t_fo,", 100) . "t_fo"
712+ call assert_fails('exe "hi Xgroup1 start=" . c', 'E422:')
713+ let &t_fo = ""
714+endfunc
715+
716+" vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_ins_complete.vim
--- a/src/testdir/test_ins_complete.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_ins_complete.vim Mon Apr 06 21:45:31 2020 +0200
@@ -465,3 +465,23 @@
465465 set tags&
466466 %bwipe!
467467 endfunc
468+
469+" Test for 'completefunc' deleting text
470+func Test_completefunc_error()
471+ new
472+ func CompleteFunc(findstart, base)
473+ if a:findstart == 1
474+ normal dd
475+ return col('.') - 1
476+ endif
477+ return ['a', 'b']
478+ endfunc
479+ set completefunc=CompleteFunc
480+ call setline(1, ['', 'abcd', ''])
481+ call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E840:')
482+ set completefunc&
483+ delfunc CompleteFunc
484+ close!
485+endfunc
486+
487+" vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_lambda.vim
--- a/src/testdir/test_lambda.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_lambda.vim Mon Apr 06 21:45:31 2020 +0200
@@ -311,4 +311,20 @@
311311 call assert_fails('ec{@{->{d->()()', 'E15')
312312 endfunc
313313
314+func Test_closure_error()
315+ let l =<< trim END
316+ func F1() closure
317+ return 1
318+ endfunc
319+ END
320+ call writefile(l, 'Xscript')
321+ let caught_932 = 0
322+ try
323+ source Xscript
324+ catch /E932:/
325+ let caught_932 = 1
326+ endtry
327+ call assert_equal(1, caught_932)
328+endfunc
329+
314330 " vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_listdict.vim
--- a/src/testdir/test_listdict.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_listdict.vim Mon Apr 06 21:45:31 2020 +0200
@@ -633,6 +633,7 @@
633633 endif
634634
635635 call assert_fails('call reverse("")', 'E899:')
636+ call assert_fails('call uniq([1, 2], {x, y -> []})', 'E882:')
636637 endfunc
637638
638639 " splitting a string to a List using split()
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_normal.vim
--- a/src/testdir/test_normal.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_normal.vim Mon Apr 06 21:45:31 2020 +0200
@@ -364,6 +364,7 @@
364364 " clean up
365365 unmap <buffer> ,,
366366 set opfunc=
367+ call assert_fails('normal Vg@', 'E774:')
367368 bw!
368369 unlet! g:opt
369370 endfunc
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_options.vim
--- a/src/testdir/test_options.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_options.vim Mon Apr 06 21:45:31 2020 +0200
@@ -195,6 +195,7 @@
195195 new
196196 call feedkeys("i\<C-N>\<Esc>", 'xt')
197197 bwipe!
198+ call assert_fails('set complete=ix', 'E535:')
198199 set complete&
199200 endfun
200201
@@ -381,6 +382,10 @@
381382
382383 set ttytype&
383384 call assert_equal(&ttytype, &term)
385+
386+ if has('gui') && !has('gui_running')
387+ call assert_fails('set term=gui', 'E531:')
388+ endif
384389 endfunc
385390
386391 func Test_set_all()
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_preview.vim
--- a/src/testdir/test_preview.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_preview.vim Mon Apr 06 21:45:31 2020 +0200
@@ -13,3 +13,50 @@
1313 call assert_equal(wincount, winnr('$'))
1414 bwipe
1515 endfunc
16+
17+func Test_window_preview()
18+ CheckFeature quickfix
19+
20+ " Open a preview window
21+ pedit Xa
22+ call assert_equal(2, winnr('$'))
23+ call assert_equal(0, &previewwindow)
24+
25+ " Go to the preview window
26+ wincmd P
27+ call assert_equal(1, &previewwindow)
28+
29+ " Close preview window
30+ wincmd z
31+ call assert_equal(1, winnr('$'))
32+ call assert_equal(0, &previewwindow)
33+
34+ call assert_fails('wincmd P', 'E441:')
35+endfunc
36+
37+func Test_window_preview_from_help()
38+ CheckFeature quickfix
39+
40+ filetype on
41+ call writefile(['/* some C code */'], 'Xpreview.c')
42+ help
43+ pedit Xpreview.c
44+ wincmd P
45+ call assert_equal(1, &previewwindow)
46+ call assert_equal('c', &filetype)
47+ wincmd z
48+
49+ filetype off
50+ close
51+ call delete('Xpreview.c')
52+endfunc
53+
54+func Test_multiple_preview_windows()
55+ new
56+ set previewwindow
57+ new
58+ call assert_fails('set previewwindow', 'E590:')
59+ %bw!
60+endfunc
61+
62+" vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_user_func.vim
--- a/src/testdir/test_user_func.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_user_func.vim Mon Apr 06 21:45:31 2020 +0200
@@ -169,3 +169,10 @@
169169 func Test_failed_call_in_try()
170170 try | call UnknownFunc() | catch | endtry
171171 endfunc
172+
173+" Test for listing user-defined functions
174+func Test_function_list()
175+ call assert_fails("function Xabc", 'E123:')
176+endfunc
177+
178+" vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_vim9_func.vim Mon Apr 06 21:45:31 2020 +0200
@@ -168,10 +168,12 @@
168168
169169 CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:')
170170 CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:')
171+ CheckScriptFailure(['def Func()', 'return 1'], 'E1057:')
171172 enddef
172173
173174 def Test_arg_type_wrong()
174175 CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing <type>')
176+ CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...')
175177 enddef
176178
177179 def Test_vim9script_call()
@@ -436,5 +438,28 @@
436438 CheckDefFailure(['let str: string', 'str = FuncNoArgRetNumber()'], 'E1013: type mismatch, expected string but got number')
437439 enddef
438440
441+" When using CheckScriptFailure() for the below test, E1010 is generated instead
442+" of E1056.
443+func Test_E1056_1059()
444+ let caught_1056 = 0
445+ try
446+ def F():
447+ return 1
448+ enddef
449+ catch /E1056:/
450+ let caught_1056 = 1
451+ endtry
452+ call assert_equal(1, caught_1056)
453+
454+ let caught_1059 = 0
455+ try
456+ def F5(items : list)
457+ echo 'a'
458+ enddef
459+ catch /E1059:/
460+ let caught_1059 = 1
461+ endtry
462+ call assert_equal(1, caught_1059)
463+endfunc
439464
440465 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_vim9_script.vim
--- a/src/testdir/test_vim9_script.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_vim9_script.vim Mon Apr 06 21:45:31 2020 +0200
@@ -259,7 +259,6 @@
259259 call CheckDefFailure(['5tab echo 3'], 'E16:')
260260 enddef
261261
262-
263262 def Test_try_catch()
264263 let l = []
265264 try
@@ -959,7 +958,6 @@
959958 assert_true(caught, 'should have caught an exception')
960959 enddef
961960
962-
963961 " Keep this last, it messes up highlighting.
964962 def Test_substitute_cmd()
965963 new
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_viminfo.vim
--- a/src/testdir/test_viminfo.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_viminfo.vim Mon Apr 06 21:45:31 2020 +0200
@@ -815,3 +815,24 @@
815815 call test_settime(0)
816816 let &viminfo=save_viminfo
817817 endfunc
818+
819+" Test for errors in setting 'viminfo'
820+func Test_viminfo_option_error()
821+ " Missing number
822+ call assert_fails('set viminfo=\"', 'E526:')
823+ for c in split("'/:<@s", '\zs')
824+ call assert_fails('set viminfo=' .. c, 'E526:')
825+ endfor
826+
827+ " Missing comma
828+ call assert_fails('set viminfo=%10!', 'E527:')
829+ call assert_fails('set viminfo=!%10', 'E527:')
830+ call assert_fails('set viminfo=h%10', 'E527:')
831+ call assert_fails('set viminfo=c%10', 'E527:')
832+ call assert_fails('set viminfo=:10%10', 'E527:')
833+
834+ " Missing ' setting
835+ call assert_fails('set viminfo=%10', 'E528:')
836+endfunc
837+
838+" vim: shiftwidth=2 sts=2 expandtab
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_vimscript.vim
--- a/src/testdir/test_vimscript.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_vimscript.vim Mon Apr 06 21:45:31 2020 +0200
@@ -1998,6 +1998,9 @@
19981998 endtry
19991999 call assert_equal(1, caught_e733)
20002000
2001+ " Using endfunc with :if
2002+ call assert_fails('exe "if 1 | endfunc | endif"', 'E193:')
2003+
20012004 " Missing 'in' in a :for statement
20022005 call assert_fails('for i range(1) | endfor', 'E690:')
20032006 endfunc
@@ -2044,6 +2047,15 @@
20442047 @a
20452048 let @a = ''
20462049 endfunc
2050+
2051+ " Deep nesting of function ... endfunction
2052+ func Test5()
2053+ let @a = join(repeat(['function X()'], 51), "\n")
2054+ let @a ..= "\necho v:true\n"
2055+ let @a ..= join(repeat(['endfunction'], 51), "\n")
2056+ @a
2057+ let @a = ''
2058+ endfunc
20472059 [SCRIPT]
20482060 call writefile(lines, 'Xscript')
20492061
@@ -2051,20 +2063,31 @@
20512063
20522064 " Deep nesting of if ... endif
20532065 call term_sendkeys(buf, ":call Test1()\n")
2066+ call term_wait(buf)
20542067 call WaitForAssert({-> assert_match('^E579:', term_getline(buf, 5))})
20552068
20562069 " Deep nesting of for ... endfor
20572070 call term_sendkeys(buf, ":call Test2()\n")
2071+ call term_wait(buf)
20582072 call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
20592073
20602074 " Deep nesting of while ... endwhile
20612075 call term_sendkeys(buf, ":call Test3()\n")
2076+ call term_wait(buf)
20622077 call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
20632078
20642079 " Deep nesting of try ... endtry
20652080 call term_sendkeys(buf, ":call Test4()\n")
2081+ call term_wait(buf)
20662082 call WaitForAssert({-> assert_match('^E601:', term_getline(buf, 5))})
20672083
2084+ " Deep nesting of function ... endfunction
2085+ call term_sendkeys(buf, ":call Test5()\n")
2086+ call term_wait(buf)
2087+ call WaitForAssert({-> assert_match('^E1058:', term_getline(buf, 4))})
2088+ call term_sendkeys(buf, "\<C-C>\n")
2089+ call term_wait(buf)
2090+
20682091 "let l = ''
20692092 "for i in range(1, 6)
20702093 " let l ..= term_getline(buf, i) . "\n"
diff -r db6b095f4073 -r 2c4d9ca33769 src/testdir/test_window_cmd.vim
--- a/src/testdir/test_window_cmd.vim Mon Apr 06 21:15:38 2020 +0200
+++ b/src/testdir/test_window_cmd.vim Mon Apr 06 21:45:31 2020 +0200
@@ -203,43 +203,6 @@
203203 %bw!
204204 endfunc
205205
206-func Test_window_preview()
207- CheckFeature quickfix
208-
209- " Open a preview window
210- pedit Xa
211- call assert_equal(2, winnr('$'))
212- call assert_equal(0, &previewwindow)
213-
214- " Go to the preview window
215- wincmd P
216- call assert_equal(1, &previewwindow)
217-
218- " Close preview window
219- wincmd z
220- call assert_equal(1, winnr('$'))
221- call assert_equal(0, &previewwindow)
222-
223- call assert_fails('wincmd P', 'E441:')
224-endfunc
225-
226-func Test_window_preview_from_help()
227- CheckFeature quickfix
228-
229- filetype on
230- call writefile(['/* some C code */'], 'Xpreview.c')
231- help
232- pedit Xpreview.c
233- wincmd P
234- call assert_equal(1, &previewwindow)
235- call assert_equal('c', &filetype)
236- wincmd z
237-
238- filetype off
239- close
240- call delete('Xpreview.c')
241-endfunc
242-
243206 func Test_window_exchange()
244207 e Xa
245208
diff -r db6b095f4073 -r 2c4d9ca33769 src/version.c
--- a/src/version.c Mon Apr 06 21:15:38 2020 +0200
+++ b/src/version.c Mon Apr 06 21:45:31 2020 +0200
@@ -739,6 +739,8 @@
739739 static int included_patches[] =
740740 { /* Add new patch number below this line */
741741 /**/
742+ 522,
743+/**/
742744 521,
743745 /**/
744746 520,
Show on old repository browser