Skip to content

Commit bfb2bb1

Browse files
dpellebrammool
authored andcommitted
patch 8.2.3345: some code not covered by tests
Problem: Some code not covered by tests. Solution: Add a few more tests. (Dominique Pellé, closes #8757)
1 parent d2e9cce commit bfb2bb1

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

src/testdir/test_arglist.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ func Test_argadd()
8282
new
8383
arga
8484
call assert_equal(0, len(argv()))
85+
86+
if has('unix')
87+
call assert_fails('argadd `Xdoes_not_exist`', 'E479:')
88+
endif
8589
endfunc
8690

8791
func Test_argadd_empty_curbuf()
@@ -434,6 +438,8 @@ func Test_argdelete()
434438
argdel
435439
call Assert_argc(['a', 'c', 'd'])
436440
%argdel
441+
442+
call assert_fails('argdel does_not_exist', 'E480:')
437443
endfunc
438444

439445
func Test_argdelete_completion()

src/testdir/test_cmdline.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,14 @@ func Test_cmdline_complete_various()
845845
call feedkeys(":doautocmd BufNew,BufEn\<C-A>\<C-B>\"\<CR>", 'xt')
846846
call assert_equal("\"doautocmd BufNew,BufEnter", @:)
847847

848+
" completion of file name in :doautocmd
849+
call writefile([], 'Xfile1')
850+
call writefile([], 'Xfile2')
851+
call feedkeys(":doautocmd BufEnter Xfi\<C-A>\<C-B>\"\<CR>", 'xt')
852+
call assert_equal("\"doautocmd BufEnter Xfile1 Xfile2", @:)
853+
call delete('Xfile1')
854+
call delete('Xfile2')
855+
848856
" completion for the :augroup command
849857
augroup XTest
850858
augroup END
@@ -1415,6 +1423,10 @@ func Test_cmd_backtick()
14151423
argadd `=['a', 'b', 'c']`
14161424
call assert_equal(['a', 'b', 'c'], argv())
14171425
%argd
1426+
1427+
argadd `echo abc def`
1428+
call assert_equal(['abc def'], argv())
1429+
%argd
14181430
endfunc
14191431

14201432
" Test for the :! command

src/testdir/test_spellfile.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,33 @@ func Test_spellfile_COMMON()
10161016
call delete('XtestCOMMON-utf8.spl')
10171017
endfunc
10181018

1019+
" Test NOSUGGEST (see :help spell-COMMON)
1020+
func Test_spellfile_NOSUGGEST()
1021+
call writefile(['2', 'foo/X', 'fog'], 'XtestNOSUGGEST.dic')
1022+
call writefile(['NOSUGGEST X'], 'XtestNOSUGGEST.aff')
1023+
1024+
mkspell! XtestNOSUGGEST-utf8.spl XtestNOSUGGEST
1025+
set spell spelllang=XtestNOSUGGEST-utf8.spl
1026+
1027+
for goodword in ['foo', 'Foo', 'FOO', 'fog', 'Fog', 'FOG']
1028+
call assert_equal(['', ''], spellbadword(goodword), goodword)
1029+
endfor
1030+
for badword in ['foO', 'fOO', 'fooo', 'foog', 'foofog', 'fogfoo']
1031+
call assert_equal([badword, 'bad'], spellbadword(badword))
1032+
endfor
1033+
1034+
call assert_equal(['fog'], spellsuggest('fooo', 1))
1035+
call assert_equal(['fog'], spellsuggest('fOo', 1))
1036+
call assert_equal(['fog'], spellsuggest('foG', 1))
1037+
call assert_equal(['fog'], spellsuggest('fogg', 1))
1038+
1039+
set spell& spelllang&
1040+
call delete('XtestNOSUGGEST.dic')
1041+
call delete('XtestNOSUGGEST.aff')
1042+
call delete('XtestNOSUGGEST-utf8.spl')
1043+
endfunc
1044+
1045+
10191046
" Test CIRCUMFIX (see: :help spell-CIRCUMFIX)
10201047
func Test_spellfile_CIRCUMFIX()
10211048
" Example taken verbatim from https://github.com/hunspell/hunspell/tree/master/tests

src/testdir/test_substitute.vim

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,4 +943,41 @@ func Test_substitute_skipped_range()
943943
bwipe!
944944
endfunc
945945

946+
" Test using the 'gdefault' option (when on, flag 'g' is default on).
947+
func Test_substitute_gdefault()
948+
new
949+
950+
" First check without 'gdefault'
951+
call setline(1, 'foo bar foo')
952+
s/foo/FOO/
953+
call assert_equal('FOO bar foo', getline(1))
954+
call setline(1, 'foo bar foo')
955+
s/foo/FOO/g
956+
call assert_equal('FOO bar FOO', getline(1))
957+
call setline(1, 'foo bar foo')
958+
s/foo/FOO/gg
959+
call assert_equal('FOO bar foo', getline(1))
960+
961+
" Then check with 'gdefault'
962+
set gdefault
963+
call setline(1, 'foo bar foo')
964+
s/foo/FOO/
965+
call assert_equal('FOO bar FOO', getline(1))
966+
call setline(1, 'foo bar foo')
967+
s/foo/FOO/g
968+
call assert_equal('FOO bar foo', getline(1))
969+
call setline(1, 'foo bar foo')
970+
s/foo/FOO/gg
971+
call assert_equal('FOO bar FOO', getline(1))
972+
973+
" Setting 'compatible' should reset 'gdefault'
974+
call assert_equal(1, &gdefault)
975+
set compatible
976+
call assert_equal(0, &gdefault)
977+
set nocompatible
978+
call assert_equal(0, &gdefault)
979+
980+
bw!
981+
endfunc
982+
946983
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3345,
758760
/**/
759761
3344,
760762
/**/

0 commit comments

Comments
 (0)