vim-patch:8.2.2837: various code lines not covered by tests

Problem:    Various code lines not covered by tests.
Solution:   Add test cases. (Dominique Pellé, closes vim/vim#8178)

6d37e8e3ba

Co-authored-by: Dominique Pelle <dominique.pelle@gmail.com>
This commit is contained in:
zeertzjq
2022-10-27 07:53:54 +08:00
parent c86371258c
commit 624f6a8ca0
5 changed files with 47 additions and 0 deletions

View File

@@ -683,6 +683,12 @@ func Test_sandbox()
sandbox call Sandbox_tests() sandbox call Sandbox_tests()
endfunc endfunc
func Test_command_not_implemented_E319()
if !has('mzscheme')
call assert_fails('mzscheme', 'E319:')
endif
endfunc
func Test_not_break_expression_register() func Test_not_break_expression_register()
call setreg('=', '1+1') call setreg('=', '1+1')
if 0 if 0

View File

@@ -1018,7 +1018,9 @@ func Test_charidx()
call assert_equal(2, charidx(a, 4)) call assert_equal(2, charidx(a, 4))
call assert_equal(3, charidx(a, 7)) call assert_equal(3, charidx(a, 7))
call assert_equal(-1, charidx(a, 8)) call assert_equal(-1, charidx(a, 8))
call assert_equal(-1, charidx(a, -1))
call assert_equal(-1, charidx('', 0)) call assert_equal(-1, charidx('', 0))
call assert_equal(-1, charidx(v:_null_string, 0))
" count composing characters " count composing characters
call assert_equal(0, charidx(a, 0, 1)) call assert_equal(0, charidx(a, 0, 1))

View File

@@ -1116,6 +1116,35 @@ func Test_opt_reset_scroll()
call delete('Xscroll') call delete('Xscroll')
endfunc endfunc
" Check that VIM_POSIX env variable influences default value of 'cpo' and 'shm'
func Test_VIM_POSIX()
throw 'Skipped: Nvim does not support $VIM_POSIX'
let saved_VIM_POSIX = getenv("VIM_POSIX")
call setenv('VIM_POSIX', "1")
let after =<< trim [CODE]
call writefile([&cpo, &shm], 'X_VIM_POSIX')
qall
[CODE]
if RunVim([], after, '')
call assert_equal(['aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>#{|&/\.;',
\ 'AS'], readfile('X_VIM_POSIX'))
endif
call setenv('VIM_POSIX', v:null)
let after =<< trim [CODE]
call writefile([&cpo, &shm], 'X_VIM_POSIX')
qall
[CODE]
if RunVim([], after, '')
call assert_equal(['aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>;',
\ 'S'], readfile('X_VIM_POSIX'))
endif
call delete('X_VIM_POSIX')
call setenv('VIM_POSIX', saved_VIM_POSIX)
endfunc
" Test for setting an option to a Vi or Vim default " Test for setting an option to a Vi or Vim default
func Test_opt_default() func Test_opt_default()
throw 'Skipped: Nvim has different defaults' throw 'Skipped: Nvim has different defaults'

View File

@@ -620,6 +620,12 @@ func Test_invalid_args()
endfor endfor
if has('gui_gtk') if has('gui_gtk')
let out = split(system(GetVimCommand() .. ' --socketid'), "\n")
call assert_equal(1, v:shell_error)
call assert_match('^VIM - Vi IMproved .* (.*)$', out[0])
call assert_equal('Argument missing after: "--socketid"', out[1])
call assert_equal('More info with: "vim -h"', out[2])
for opt in ['--socketid x', '--socketid 0xg'] for opt in ['--socketid x', '--socketid 0xg']
let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") let out = split(system(GetVimCommand() .. ' ' .. opt), "\n")
call assert_equal(1, v:shell_error) call assert_equal(1, v:shell_error)
@@ -627,6 +633,7 @@ func Test_invalid_args()
call assert_equal('Invalid argument for: "--socketid"', out[1]) call assert_equal('Invalid argument for: "--socketid"', out[1])
call assert_equal('More info with: "vim -h"', out[2]) call assert_equal('More info with: "vim -h"', out[2])
endfor endfor
endif endif
endfunc endfunc

View File

@@ -113,6 +113,9 @@ func Test_syntime()
let a = execute('syntime report') let a = execute('syntime report')
call assert_equal("\nNo Syntax items defined for this buffer", a) call assert_equal("\nNo Syntax items defined for this buffer", a)
let a = execute('syntime clear')
call assert_equal("\nNo Syntax items defined for this buffer", a)
view samples/memfile_test.c view samples/memfile_test.c
setfiletype cpp setfiletype cpp
redraw redraw