From 27fd17a79cd2c51e71077bdd896635188ad711b5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 8 Jul 2022 17:43:05 +0800 Subject: vim-patch:8.2.0243: insufficient code coverage for ex_docmd.c functions Problem: Insufficient code coverage for ex_docmd.c functions. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5618) https://github.com/vim/vim/commit/9f6277bdde97b7767ded43a0b5a2023eb601b3b7 Cherry-pick Test_window_only() from patch 8.2.0203. Cherry-pick a memory leak fix from patch 8.2.0399. --- src/nvim/testdir/test_excmd.vim | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/nvim/testdir/test_excmd.vim') diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index df2cf97633..9b59792696 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -22,6 +22,7 @@ func Test_range_error() call assert_fails(':\/echo 1', 'E481:') normal vv call assert_fails(":'<,'>echo 1", 'E481:') + call assert_fails(":\\xcenter", 'E10:') endfunc func Test_buffers_lastused() @@ -391,6 +392,11 @@ func Test_confirm_write_partial_file() call delete('Xscript') endfunc +" Test for the :print command +func Test_print_cmd() + call assert_fails('print', 'E749:') +endfunc + " Test for the :winsize command func Test_winsize_cmd() call assert_fails('winsize 1', 'E465:') @@ -399,6 +405,33 @@ func Test_winsize_cmd() " Actually changing the window size would be flaky. endfunc +" Test for the :redir command +func Test_redir_cmd() + call assert_fails('redir @@', 'E475:') + call assert_fails('redir abc', 'E475:') + if has('unix') + call mkdir('Xdir') + call assert_fails('redir > Xdir', 'E17:') + call delete('Xdir', 'd') + endif + if !has('bsd') + call writefile([], 'Xfile') + call setfperm('Xfile', 'r--r--r--') + call assert_fails('redir! > Xfile', 'E190:') + call delete('Xfile') + endif +endfunc + +" Test for the :filetype command +func Test_filetype_cmd() + call assert_fails('filetype abc', 'E475:') +endfunc + +" Test for the :mode command +func Test_mode_cmd() + call assert_fails('mode abc', 'E359:') +endfunc + " Test for running Ex commands when text is locked. " e in the command line is used to lock the text func Test_run_excmd_with_text_locked() -- cgit