Skip to content

Commit 2d6d718

Browse files
yegappanbrammool
authored andcommitted
patch 8.2.2994: various code is not fully tested
Problem: Various code is not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8378)
1 parent 5ffefbb commit 2d6d718

7 files changed

Lines changed: 127 additions & 2 deletions

File tree

src/testdir/test_excmd.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ func Sandbox_tests()
596596
" some options cannot be changed in a sandbox
597597
call assert_fails('set exrc', 'E48:')
598598
call assert_fails('set cdpath', 'E48:')
599-
if has('xim')
599+
if has('xim') && has('gui_gtk')
600600
call assert_fails('set imstyle', 'E48:')
601601
endif
602602
endfunc

src/testdir/test_mapping.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ func Test_list_mappings()
485485
call assert_equal(['n ,k <Nop>'],
486486
\ execute('nmap ,k')->trim()->split("\n"))
487487

488+
" map with space at the beginning
489+
exe "nmap \<C-V> w <Nop>"
490+
call assert_equal(['n <Space>w <Nop>'],
491+
\ execute("nmap \<C-V> w")->trim()->split("\n"))
492+
488493
nmapclear
489494
endfunc
490495

@@ -1411,4 +1416,19 @@ func Test_abbreviate_multi_byte()
14111416
bwipe!
14121417
endfunc
14131418

1419+
" Test for abbreviations with 'latin1' encoding
1420+
func Test_abbreviate_latin1_encoding()
1421+
set encoding=latin1
1422+
call assert_fails('abbr ab#$c ABC', 'E474:')
1423+
new
1424+
iabbr <buffer> #i #include
1425+
iabbr <buffer> ## #enddef
1426+
exe "normal i#i\<C-]>"
1427+
call assert_equal('#include', getline(1))
1428+
exe "normal 0Di##\<C-]>"
1429+
call assert_equal('#enddef', getline(1))
1430+
%bw!
1431+
set encoding=utf-8
1432+
endfunc
1433+
14141434
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_modeline.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,30 @@ func Test_modeline_setoption_verbose()
334334
call delete('Xmodeline')
335335
endfunc
336336

337+
" Test for the 'modeline' default value in compatible and non-compatible modes
338+
" for root and non-root accounts
339+
func Test_modeline_default()
340+
set compatible
341+
call assert_false(&modeline)
342+
set nocompatible
343+
call assert_equal(IsRoot() ? 0 : 1, &modeline)
344+
set compatible&vi
345+
call assert_false(&modeline)
346+
set compatible&vim
347+
call assert_equal(IsRoot() ? 0 : 1, &modeline)
348+
set compatible& modeline&
349+
endfunc
350+
351+
" Some options cannot be set from the modeline when 'diff' option is set
352+
func Test_modeline_diff_buffer()
353+
call writefile(['vim: diff foldmethod=marker wrap'], 'Xfile')
354+
set foldmethod& nowrap
355+
new Xfile
356+
call assert_equal('manual', &foldmethod)
357+
call assert_false(&wrap)
358+
set wrap&
359+
call delete('Xfile')
360+
bw
361+
endfunc
362+
337363
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_options.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,4 +1160,21 @@ func Test_cmdheight()
11601160
set cmdheight&
11611161
endfunc
11621162

1163+
" To specify a control character as a option value, '^' can be used
1164+
func Test_opt_control_char()
1165+
set wildchar=^v
1166+
call assert_equal("\<C-V>", nr2char(&wildchar))
1167+
set wildcharm=^r
1168+
call assert_equal("\<C-R>", nr2char(&wildcharm))
1169+
" Bug: This doesn't work for the 'cedit' and 'termwinkey' options
1170+
set wildchar& wildcharm&
1171+
endfunc
1172+
1173+
" Test for the 'errorbells' option
1174+
func Test_opt_errorbells()
1175+
set errorbells
1176+
call assert_beeps('s/a1b2/x1y2/')
1177+
set noerrorbells
1178+
endfunc
1179+
11631180
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_paste.vim

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,68 @@ func Test_pastetoggle()
159159
call feedkeys("i\<F4>", 'xt')
160160
call assert_false(&paste)
161161
call assert_equal('Hello', getline(1))
162+
" command-line completion for 'pastetoggle' value
163+
call feedkeys(":set pastetoggle=\<Tab>\<C-B>\"\<CR>", 'xt')
164+
call assert_equal('"set pastetoggle=<F4>', @:)
162165
set pastetoggle&
163166
bwipe!
164167
endfunc
165168

169+
" Test for restoring option values when 'paste' is disabled
170+
func Test_paste_opt_restore()
171+
set autoindent expandtab ruler showmatch
172+
if has('rightleft')
173+
set revins hkmap
174+
endif
175+
set smarttab softtabstop=3 textwidth=27 wrapmargin=12
176+
if has('vartabs')
177+
set varsofttabstop=10,20
178+
endif
179+
180+
" enabling 'paste' should reset the above options
181+
set paste
182+
call assert_false(&autoindent)
183+
call assert_false(&expandtab)
184+
if has('rightleft')
185+
call assert_false(&revins)
186+
call assert_false(&hkmap)
187+
endif
188+
call assert_false(&ruler)
189+
call assert_false(&showmatch)
190+
call assert_false(&smarttab)
191+
call assert_equal(0, &softtabstop)
192+
call assert_equal(0, &textwidth)
193+
call assert_equal(0, &wrapmargin)
194+
if has('vartabs')
195+
call assert_equal('', &varsofttabstop)
196+
endif
197+
198+
" disabling 'paste' should restore the option values
199+
set nopaste
200+
call assert_true(&autoindent)
201+
call assert_true(&expandtab)
202+
if has('rightleft')
203+
call assert_true(&revins)
204+
call assert_true(&hkmap)
205+
endif
206+
call assert_true(&ruler)
207+
call assert_true(&showmatch)
208+
call assert_true(&smarttab)
209+
call assert_equal(3, &softtabstop)
210+
call assert_equal(27, &textwidth)
211+
call assert_equal(12, &wrapmargin)
212+
if has('vartabs')
213+
call assert_equal('10,20', &varsofttabstop)
214+
endif
215+
216+
set autoindent& expandtab& ruler& showmatch&
217+
if has('rightleft')
218+
set revins& hkmap&
219+
endif
220+
set smarttab& softtabstop& textwidth& wrapmargin&
221+
if has('vartabs')
222+
set varsofttabstop&
223+
endif
224+
endfunc
225+
166226
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2994,
753755
/**/
754756
2993,
755757
/**/

src/vim9compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ item_exists(char_u *name, size_t len, int cmd UNUSED, cctx_T *cctx)
454454
if (name[len] == '(' || (p[0] == '-' && p[1] == '>'))
455455
{
456456
// Do not check for an internal function, since it might also be a
457-
// valid command, such as ":split" versuse "split()".
457+
// valid command, such as ":split" versus "split()".
458458
// Skip "g:" before a function name.
459459
is_global = (name[0] == 'g' && name[1] == ':');
460460
return find_func(is_global ? name + 2 : name, is_global, cctx) != NULL;

0 commit comments

Comments
 (0)