neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit eea6a4f2a0ad089e0f92dfbc54c92d88c9fea51e
parent e71cc4a8dc2698038d4a92a8afe216aa891d67bc
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Fri,  8 Jul 2022 10:34:32 +0800

vim-patch:8.2.{0212,0250}

vim-patch:8.2.0212: missing search/substitute pattern hardly tested

Problem:    Missing search/substitute pattern hardly tested.
Solution:   Add test_clear_search_pat() and tests. (Yegappan Lakshmanan,
            closes vim/vim#5579)
https://github.com/vim/vim/commit/07ada5ff2fd8f22ed3233ae5c4ddf87c7b3f56fe

vim-patch:8.2.0250: test_clear_search_pat() is unused

Problem:    test_clear_search_pat() is unused.
Solution:   Remove the function. (Yegappan Lakshmanan, closes vim/vim#5624)
https://github.com/vim/vim/commit/4f5776c17cd86f904a7e2f92db297c73e28939b7

Diffstat:
Msrc/nvim/testdir/test_quickfix.vim | 4++++
Msrc/nvim/testdir/test_search.vim | 39+++++++++++++++++++++++++++++++++++++++
Msrc/nvim/testdir/test_sort.vim | 2++
Msrc/nvim/testdir/test_substitute.vim | 15+++++++++++++++
Msrc/nvim/testdir/test_writefile.vim | 4++++
5 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim @@ -2858,6 +2858,10 @@ func XvimgrepTests(cchar) call assert_equal(0, getbufinfo('Xtestfile1')[0].loaded) call assert_equal([], getbufinfo('Xtestfile2')) + " Test with the last search pattern not set + call test_clear_search_pat() + call assert_fails('Xvimgrep // *', 'E35:') + call delete('Xtestfile1') call delete('Xtestfile2') endfunc diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim @@ -1541,6 +1541,45 @@ func Test_search_special() exe "norm /\x80PS" endfunc +" Test for command failures when the last search pattern is not set. +func Test_search_with_no_last_pat() + call test_clear_search_pat() + call assert_fails("normal i\<C-R>/\e", 'E35:') + call assert_fails("exe '/'", 'E35:') + call assert_fails("exe '?'", 'E35:') + call assert_fails("/", 'E35:') + call assert_fails("?", 'E35:') + call assert_fails("normal n", 'E35:') + call assert_fails("normal N", 'E35:') + call assert_fails("normal gn", 'E35:') + call assert_fails("normal gN", 'E35:') + call assert_fails("normal cgn", 'E35:') + call assert_fails("normal cgN", 'E35:') + let p = [] + let p = @/ + call assert_equal('', p) + call assert_fails("normal :\<C-R>/", 'E35:') + call assert_fails("//p", 'E35:') + call assert_fails(";//p", 'E35:') + call assert_fails("??p", 'E35:') + call assert_fails(";??p", 'E35:') + call assert_fails('g//p', 'E476:') + call assert_fails('v//p', 'E476:') +endfunc + +" Test for using tilde (~) atom in search. This should use the last used +" substitute pattern +func Test_search_tilde_pat() + call test_clear_search_pat() + set regexpengine=1 + call assert_fails('exe "normal /~\<CR>"', 'E33:') + call assert_fails('exe "normal ?~\<CR>"', 'E33:') + set regexpengine=2 + call assert_fails('exe "normal /~\<CR>"', 'E383:') + call assert_fails('exe "normal ?~\<CR>"', 'E383:') + set regexpengine& +endfunc + " Test 'smartcase' with utf-8. func Test_search_smartcase_utf8() new diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim @@ -1486,6 +1486,8 @@ func Test_sort_last_search_pat() call setline(1, ['3b', '1c', '2a']) sort // call assert_equal(['2a', '3b', '1c'], getline(1, '$')) + call test_clear_search_pat() + call assert_fails('sort //', 'E35:') close! endfunc diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim @@ -808,6 +808,21 @@ func Test_sub_expand_text() close! endfunc +" Test for command failures when the last substitute pattern is not set. +func Test_sub_with_no_last_pat() + call test_clear_search_pat() + call assert_fails('~', 'E33:') + call assert_fails('s//abc/g', 'E476:') + call assert_fails('s\/bar', 'E476:') + call assert_fails('s\&bar&', 'E476:') + + call test_clear_search_pat() + let save_cpo = &cpo + set cpo+=/ + call assert_fails('s/abc/%/', 'E33:') + let &cpo = save_cpo +endfunc + func Test_submatch_list_concatenate() let pat = 'A\(.\)' let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])} diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim @@ -206,6 +206,10 @@ func Test_write_errors() call assert_fails('1,2write', 'E140:') close! + call assert_fails('w > Xtest', 'E494:') + + call assert_fails('w > Xtest', 'E494:') + " Try to overwrite a directory if has('unix') call mkdir('Xdir1')