summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_autocmd.vim24
-rw-r--r--src/testdir/test_clientserver.vim6
-rw-r--r--src/testdir/test_digraph.vim13
-rw-r--r--src/testdir/test_expand.vim1
-rw-r--r--src/testdir/test_expr.vim1
-rw-r--r--src/testdir/test_functions.vim1
-rw-r--r--src/testdir/test_gui.vim9
-rw-r--r--src/testdir/test_highlight.vim22
-rw-r--r--src/testdir/test_ins_complete.vim20
-rw-r--r--src/testdir/test_lambda.vim16
-rw-r--r--src/testdir/test_listdict.vim1
-rw-r--r--src/testdir/test_normal.vim1
-rw-r--r--src/testdir/test_options.vim5
-rw-r--r--src/testdir/test_preview.vim47
-rw-r--r--src/testdir/test_user_func.vim7
-rw-r--r--src/testdir/test_vim9_func.vim25
-rw-r--r--src/testdir/test_vim9_script.vim2
-rw-r--r--src/testdir/test_viminfo.vim21
-rw-r--r--src/testdir/test_vimscript.vim23
-rw-r--r--src/testdir/test_window_cmd.vim37
-rw-r--r--src/version.c2
21 files changed, 243 insertions, 41 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index ad2dc2b0e..f79891621 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2483,4 +2483,28 @@ func Test_autocmd_FileReadCmd()
delfunc ReadFileCmd
endfunc
+" Test for passing invalid arguments to autocmd
+func Test_autocmd_invalid_args()
+ " Additional character after * for event
+ call assert_fails('autocmd *a Xfile set ff=unix', 'E215:')
+ augroup Test
+ augroup END
+ " Invalid autocmd event
+ call assert_fails('autocmd Bufabc Xfile set ft=vim', 'E216:')
+ " Invalid autocmd event in a autocmd group
+ call assert_fails('autocmd Test Bufabc Xfile set ft=vim', 'E216:')
+ augroup! Test
+ " Execute all autocmds
+ call assert_fails('doautocmd * BufEnter', 'E217:')
+ call assert_fails('augroup! x1a2b3', 'E367:')
+ call assert_fails('autocmd BufNew <buffer=999> pwd', 'E680:')
+endfunc
+
+" Test for deep nesting of autocmds
+func Test_autocmd_deep_nesting()
+ autocmd BufEnter Xfile doautocmd BufEnter Xfile
+ call assert_fails('doautocmd BufEnter Xfile', 'E218:')
+ autocmd! BufEnter Xfile
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_clientserver.vim b/src/testdir/test_clientserver.vim
index 8a333aa90..7936227eb 100644
--- a/src/testdir/test_clientserver.vim
+++ b/src/testdir/test_clientserver.vim
@@ -2,6 +2,11 @@
source check.vim
CheckFeature job
+
+if !has('clientserver')
+ call assert_fails('call remote_startserver("local")', 'E942:')
+endif
+
CheckFeature clientserver
source shared.vim
@@ -161,6 +166,7 @@ func Test_client_server()
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:')
endfunc
" Uncomment this line to get a debugging log
diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim
index 1feeef20c..3e3dfa89a 100644
--- a/src/testdir/test_digraph.vim
+++ b/src/testdir/test_digraph.vim
@@ -210,6 +210,8 @@ func Test_digraphs()
call Put_Dig("00")
call Put_Dig("el")
call assert_equal(['␀', 'ü', '∞', 'l'], getline(line('.')-3,line('.')))
+ call assert_fails('exe "digraph a\<Esc> 100"', 'E104:')
+ call assert_fails('exe "digraph \<Esc>a 100"', 'E104:')
bw!
endfunc
@@ -475,4 +477,15 @@ func Test_show_digraph_cp1251()
bwipe!
endfunc
+" Test for error in a keymap file
+func Test_loadkeymap_error()
+ if !has('keymap')
+ return
+ endif
+ call assert_fails('loadkeymap', 'E105:')
+ call writefile(['loadkeymap', 'a'], 'Xkeymap')
+ call assert_fails('source Xkeymap', 'E791:')
+ call delete('Xkeymap')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_expand.vim b/src/testdir/test_expand.vim
index 383921bb8..86062234d 100644
--- a/src/testdir/test_expand.vim
+++ b/src/testdir/test_expand.vim
@@ -131,6 +131,7 @@ func Test_expand_filename_multicmd()
call assert_equal(4, winnr('$'))
call assert_equal('foo!', bufname(winbufnr(1)))
call assert_equal('foo', bufname(winbufnr(2)))
+ call assert_fails('e %:s/.*//', 'E500:')
%bwipe!
endfunc
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim
index 13180e692..116f71364 100644
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -502,6 +502,7 @@ func Test_funcref()
call assert_fails('echo funcref("{")', 'E475:')
let OneByRef = funcref("One", repeat(["foo"], 20))
call assert_fails('let OneByRef = funcref("One", repeat(["foo"], 21))', 'E118:')
+ call assert_fails('echo function("min") =~ function("min")', 'E694:')
endfunc
func Test_setmatches()
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 653654f15..427e404c8 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1966,6 +1966,7 @@ func Test_range()
execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>"
" complete_info()
execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>\<C-r>=[complete_info(range(5)), ''][1]\<CR>"
+ call assert_fails('call complete(1, ["a"])', 'E785:')
" copy()
call assert_equal([1, 2, 3], copy(range(1, 3)))
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index 54ba588f7..af4ce246c 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -388,6 +388,11 @@ func Test_set_guifont()
call assert_equal('Monospace 10', getfontname())
endif
+ if has('win32')
+ " Invalid font names are accepted in GTK GUI
+ call assert_fails('set guifont=xa1bc23d7f', 'E596:')
+ endif
+
if has('xfontset')
let &guifontset = guifontset_saved
endif
@@ -402,6 +407,8 @@ func Test_set_guifontset()
CheckFeature xfontset
let skipped = ''
+ call assert_fails('set guifontset=*', 'E597:')
+
let ctype_saved = v:ctype
" First, since XCreateFontSet(3) is very sensitive to locale, fonts must
@@ -468,6 +475,7 @@ func Test_set_guifontset()
endfunc
func Test_set_guifontwide()
+ call assert_fails('set guifontwide=*', 'E533:')
let skipped = ''
if !g:x11_based_gui
@@ -785,6 +793,7 @@ func Test_set_term()
" It's enough to check the current value since setting 'term' to anything
" other than builtin_gui makes no sense at all.
call assert_equal('builtin_gui', &term)
+ call assert_fails('set term=xterm', 'E530:')
endfunc
func Test_windowid_variable()
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
index ac6a10102..dfc9e2421 100644
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -689,10 +689,28 @@ func Test_1_highlight_Normalgroup_exists()
endfunc
" Do this test last, sometimes restoring the columns doesn't work
-function Test_z_no_space_before_xxx()
+func Test_z_no_space_before_xxx()
let l:org_columns = &columns
set columns=17
let l:hi_StatusLineTermNC = join(split(execute('hi StatusLineTermNC')))
call assert_match('StatusLineTermNC xxx', l:hi_StatusLineTermNC)
let &columns = l:org_columns
-endfunction
+endfunc
+
+" Test for :highlight command errors
+func Test_highlight_cmd_errors()
+ if has('gui_running')
+ " This test doesn't fail in the MS-Windows console version.
+ call assert_fails('hi Xcomment ctermfg=fg', 'E419:')
+ call assert_fails('hi Xcomment ctermfg=bg', 'E420:')
+ endif
+
+ " Try using a very long terminal code. Define a dummy terminal code for this
+ " test.
+ let &t_fo = "\<Esc>1;"
+ let c = repeat("t_fo,", 100) . "t_fo"
+ call assert_fails('exe "hi Xgroup1 start=" . c', 'E422:')
+ let &t_fo = ""
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 3a8357739..b7893fffb 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -465,3 +465,23 @@ func Test_ins_compl_tag_sft()
set tags&
%bwipe!
endfunc
+
+" Test for 'completefunc' deleting text
+func Test_completefunc_error()
+ new
+ func CompleteFunc(findstart, base)
+ if a:findstart == 1
+ normal dd
+ return col('.') - 1
+ endif
+ return ['a', 'b']
+ endfunc
+ set completefunc=CompleteFunc
+ call setline(1, ['', 'abcd', ''])
+ call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E840:')
+ set completefunc&
+ delfunc CompleteFunc
+ close!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_lambda.vim b/src/testdir/test_lambda.vim
index bc3d5ace7..44ca911fe 100644
--- a/src/testdir/test_lambda.vim
+++ b/src/testdir/test_lambda.vim
@@ -311,4 +311,20 @@ func Test_lambda_error()
call assert_fails('ec{@{->{d->()()', 'E15')
endfunc
+func Test_closure_error()
+ let l =<< trim END
+ func F1() closure
+ return 1
+ endfunc
+ END
+ call writefile(l, 'Xscript')
+ let caught_932 = 0
+ try
+ source Xscript
+ catch /E932:/
+ let caught_932 = 1
+ endtry
+ call assert_equal(1, caught_932)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 045dbb085..9db103545 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -633,6 +633,7 @@ func Test_reverse_sort_uniq()
endif
call assert_fails('call reverse("")', 'E899:')
+ call assert_fails('call uniq([1, 2], {x, y -> []})', 'E882:')
endfunc
" splitting a string to a List using split()
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index 83a95f9f6..d8afeea3e 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -364,6 +364,7 @@ func Test_normal09a_operatorfunc()
" clean up
unmap <buffer> ,,
set opfunc=
+ call assert_fails('normal Vg@', 'E774:')
bw!
unlet! g:opt
endfunc
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index f1118948d..ef3ae1ad4 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -195,6 +195,7 @@ func Test_complete()
new
call feedkeys("i\<C-N>\<Esc>", 'xt')
bwipe!
+ call assert_fails('set complete=ix', 'E535:')
set complete&
endfun
@@ -381,6 +382,10 @@ func Test_set_ttytype()
set ttytype&
call assert_equal(&ttytype, &term)
+
+ if has('gui') && !has('gui_running')
+ call assert_fails('set term=gui', 'E531:')
+ endif
endfunc
func Test_set_all()
diff --git a/src/testdir/test_preview.vim b/src/testdir/test_preview.vim
index a85798bab..628ad2bfb 100644
--- a/src/testdir/test_preview.vim
+++ b/src/testdir/test_preview.vim
@@ -13,3 +13,50 @@ func Test_Psearch()
call assert_equal(wincount, winnr('$'))
bwipe
endfunc
+
+func Test_window_preview()
+ CheckFeature quickfix
+
+ " Open a preview window
+ pedit Xa
+ call assert_equal(2, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ " Go to the preview window
+ wincmd P
+ call assert_equal(1, &previewwindow)
+
+ " Close preview window
+ wincmd z
+ call assert_equal(1, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ call assert_fails('wincmd P', 'E441:')
+endfunc
+
+func Test_window_preview_from_help()
+ CheckFeature quickfix
+
+ filetype on
+ call writefile(['/* some C code */'], 'Xpreview.c')
+ help
+ pedit Xpreview.c
+ wincmd P
+ call assert_equal(1, &previewwindow)
+ call assert_equal('c', &filetype)
+ wincmd z
+
+ filetype off
+ close
+ call delete('Xpreview.c')
+endfunc
+
+func Test_multiple_preview_windows()
+ new
+ set previewwindow
+ new
+ call assert_fails('set previewwindow', 'E590:')
+ %bw!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim
index 433a65bd3..c8f8d07fd 100644
--- a/src/testdir/test_user_func.vim
+++ b/src/testdir/test_user_func.vim
@@ -169,3 +169,10 @@ endfunc
func Test_failed_call_in_try()
try | call UnknownFunc() | catch | endtry
endfunc
+
+" Test for listing user-defined functions
+func Test_function_list()
+ call assert_fails("function Xabc", 'E123:')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 74653b13e..5554b2d7e 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -168,10 +168,12 @@ def Test_return_type_wrong()
CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:')
CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:')
+ CheckScriptFailure(['def Func()', 'return 1'], 'E1057:')
enddef
def Test_arg_type_wrong()
CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing <type>')
+ CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...')
enddef
def Test_vim9script_call()
@@ -436,5 +438,28 @@ def Test_func_return_type()
CheckDefFailure(['let str: string', 'str = FuncNoArgRetNumber()'], 'E1013: type mismatch, expected string but got number')
enddef
+" When using CheckScriptFailure() for the below test, E1010 is generated instead
+" of E1056.
+func Test_E1056_1059()
+ let caught_1056 = 0
+ try
+ def F():
+ return 1
+ enddef
+ catch /E1056:/
+ let caught_1056 = 1
+ endtry
+ call assert_equal(1, caught_1056)
+
+ let caught_1059 = 0
+ try
+ def F5(items : list)
+ echo 'a'
+ enddef
+ catch /E1059:/
+ let caught_1059 = 1
+ endtry
+ call assert_equal(1, caught_1059)
+endfunc
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 01579a8a3..cab9f8630 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -259,7 +259,6 @@ def Test_cmd_modifier()
call CheckDefFailure(['5tab echo 3'], 'E16:')
enddef
-
def Test_try_catch()
let l = []
try
@@ -959,7 +958,6 @@ def Test_interrupt_loop()
assert_true(caught, 'should have caught an exception')
enddef
-
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
diff --git a/src/testdir/test_viminfo.vim b/src/testdir/test_viminfo.vim
index 044da0a1b..b4708f5f8 100644
--- a/src/testdir/test_viminfo.vim
+++ b/src/testdir/test_viminfo.vim
@@ -815,3 +815,24 @@ func XTest_viminfo_marks_merge()
call test_settime(0)
let &viminfo=save_viminfo
endfunc
+
+" Test for errors in setting 'viminfo'
+func Test_viminfo_option_error()
+ " Missing number
+ call assert_fails('set viminfo=\"', 'E526:')
+ for c in split("'/:<@s", '\zs')
+ call assert_fails('set viminfo=' .. c, 'E526:')
+ endfor
+
+ " Missing comma
+ call assert_fails('set viminfo=%10!', 'E527:')
+ call assert_fails('set viminfo=!%10', 'E527:')
+ call assert_fails('set viminfo=h%10', 'E527:')
+ call assert_fails('set viminfo=c%10', 'E527:')
+ call assert_fails('set viminfo=:10%10', 'E527:')
+
+ " Missing ' setting
+ call assert_fails('set viminfo=%10', 'E528:')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim
index 72eae7c70..9bc670270 100644
--- a/src/testdir/test_vimscript.vim
+++ b/src/testdir/test_vimscript.vim
@@ -1998,6 +1998,9 @@ func Test_missing_end()
endtry
call assert_equal(1, caught_e733)
+ " Using endfunc with :if
+ call assert_fails('exe "if 1 | endfunc | endif"', 'E193:')
+
" Missing 'in' in a :for statement
call assert_fails('for i range(1) | endfor', 'E690:')
endfunc
@@ -2044,6 +2047,15 @@ func Test_deep_nest()
@a
let @a = ''
endfunc
+
+ " Deep nesting of function ... endfunction
+ func Test5()
+ let @a = join(repeat(['function X()'], 51), "\n")
+ let @a ..= "\necho v:true\n"
+ let @a ..= join(repeat(['endfunction'], 51), "\n")
+ @a
+ let @a = ''
+ endfunc
[SCRIPT]
call writefile(lines, 'Xscript')
@@ -2051,20 +2063,31 @@ func Test_deep_nest()
" Deep nesting of if ... endif
call term_sendkeys(buf, ":call Test1()\n")
+ call term_wait(buf)
call WaitForAssert({-> assert_match('^E579:', term_getline(buf, 5))})
" Deep nesting of for ... endfor
call term_sendkeys(buf, ":call Test2()\n")
+ call term_wait(buf)
call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
" Deep nesting of while ... endwhile
call term_sendkeys(buf, ":call Test3()\n")
+ call term_wait(buf)
call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
" Deep nesting of try ... endtry
call term_sendkeys(buf, ":call Test4()\n")
+ call term_wait(buf)
call WaitForAssert({-> assert_match('^E601:', term_getline(buf, 5))})
+ " Deep nesting of function ... endfunction
+ call term_sendkeys(buf, ":call Test5()\n")
+ call term_wait(buf)
+ call WaitForAssert({-> assert_match('^E1058:', term_getline(buf, 4))})
+ call term_sendkeys(buf, "\<C-C>\n")
+ call term_wait(buf)
+
"let l = ''
"for i in range(1, 6)
" let l ..= term_getline(buf, i) . "\n"
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index 001bbaca4..a28c00a4b 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -203,43 +203,6 @@ func Test_window_split_no_room()
%bw!
endfunc
-func Test_window_preview()
- CheckFeature quickfix
-
- " Open a preview window
- pedit Xa
- call assert_equal(2, winnr('$'))
- call assert_equal(0, &previewwindow)
-
- " Go to the preview window
- wincmd P
- call assert_equal(1, &previewwindow)
-
- " Close preview window
- wincmd z
- call assert_equal(1, winnr('$'))
- call assert_equal(0, &previewwindow)
-
- call assert_fails('wincmd P', 'E441:')
-endfunc
-
-func Test_window_preview_from_help()
- CheckFeature quickfix
-
- filetype on
- call writefile(['/* some C code */'], 'Xpreview.c')
- help
- pedit Xpreview.c
- wincmd P
- call assert_equal(1, &previewwindow)
- call assert_equal('c', &filetype)
- wincmd z
-
- filetype off
- close
- call delete('Xpreview.c')
-endfunc
-
func Test_window_exchange()
e Xa
diff --git a/src/version.c b/src/version.c
index 22ac6a831..1b9bc68b6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 522,
+/**/
521,
/**/
520,