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)
07ada5ff2f

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)
4f5776c17c
This commit is contained in:
zeertzjq 2022-07-08 10:34:32 +08:00
parent e71cc4a8dc
commit eea6a4f2a0
5 changed files with 64 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)]])}

View File

@ -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')