mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 8.1.2100: :mksession is not sufficiently tested
Problem: :mksession is not sufficiently tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes #4993)
This commit is contained in:
@@ -156,11 +156,17 @@ endfunc
|
|||||||
func Test_mksession_arglist()
|
func Test_mksession_arglist()
|
||||||
%argdel
|
%argdel
|
||||||
next file1 file2 file3 file4
|
next file1 file2 file3 file4
|
||||||
|
new
|
||||||
|
next | next
|
||||||
mksession! Xtest_mks.out
|
mksession! Xtest_mks.out
|
||||||
source Xtest_mks.out
|
source Xtest_mks.out
|
||||||
call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
|
call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
|
||||||
|
call assert_equal(2, argidx())
|
||||||
|
wincmd w
|
||||||
|
call assert_equal(0, argidx())
|
||||||
|
|
||||||
call delete('Xtest_mks.out')
|
call delete('Xtest_mks.out')
|
||||||
|
enew | only
|
||||||
argdel *
|
argdel *
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -541,24 +547,28 @@ func Test_mksession_globals()
|
|||||||
set sessionoptions+=globals
|
set sessionoptions+=globals
|
||||||
|
|
||||||
" create different global variables
|
" create different global variables
|
||||||
let g:Global_string = "Sun is shining"
|
let g:Global_string = "Sun is shining\r\n"
|
||||||
let g:Global_count = 100
|
let g:Global_count = 100
|
||||||
let g:Global_pi = 3.14
|
let g:Global_pi = 3.14
|
||||||
|
let g:Global_neg_float = -2.68
|
||||||
|
|
||||||
mksession! Xtest_mks.out
|
mksession! Xtest_mks.out
|
||||||
|
|
||||||
unlet g:Global_string
|
unlet g:Global_string
|
||||||
unlet g:Global_count
|
unlet g:Global_count
|
||||||
unlet g:Global_pi
|
unlet g:Global_pi
|
||||||
|
unlet g:Global_neg_float
|
||||||
|
|
||||||
source Xtest_mks.out
|
source Xtest_mks.out
|
||||||
call assert_equal("Sun is shining", g:Global_string)
|
call assert_equal("Sun is shining\r\n", g:Global_string)
|
||||||
call assert_equal(100, g:Global_count)
|
call assert_equal(100, g:Global_count)
|
||||||
call assert_equal(3.14, g:Global_pi)
|
call assert_equal(3.14, g:Global_pi)
|
||||||
|
call assert_equal(-2.68, g:Global_neg_float)
|
||||||
|
|
||||||
unlet g:Global_string
|
unlet g:Global_string
|
||||||
unlet g:Global_count
|
unlet g:Global_count
|
||||||
unlet g:Global_pi
|
unlet g:Global_pi
|
||||||
|
unlet g:Global_neg_float
|
||||||
call delete('Xtest_mks.out')
|
call delete('Xtest_mks.out')
|
||||||
set sessionoptions&
|
set sessionoptions&
|
||||||
endfunc
|
endfunc
|
||||||
@@ -639,23 +649,123 @@ func Test_mksession_resize()
|
|||||||
for line in lines
|
for line in lines
|
||||||
if line =~ '^set lines='
|
if line =~ '^set lines='
|
||||||
let found_resize = v:true
|
let found_resize = v:true
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call assert_equal(v:false, found_resize)
|
call assert_false(found_resize)
|
||||||
let lines = readfile('Xtest_mks2.out')
|
let lines = readfile('Xtest_mks2.out')
|
||||||
let found_resize = v:false
|
let found_resize = v:false
|
||||||
for line in lines
|
for line in lines
|
||||||
if line =~ '^set lines='
|
if line =~ '^set lines='
|
||||||
let found_resize = v:true
|
let found_resize = v:true
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call assert_equal(v:true, found_resize)
|
call assert_true(found_resize)
|
||||||
|
|
||||||
call delete('Xtest_mks1.out')
|
call delete('Xtest_mks1.out')
|
||||||
call delete('Xtest_mks2.out')
|
call delete('Xtest_mks2.out')
|
||||||
set sessionoptions&
|
set sessionoptions&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for mksession with a named scratch buffer
|
||||||
|
func Test_mksession_scratch()
|
||||||
|
enew | only
|
||||||
|
file Xscratch
|
||||||
|
set buftype=nofile
|
||||||
|
mksession! Xtest_mks.out
|
||||||
|
%bwipe
|
||||||
|
source Xtest_mks.out
|
||||||
|
call assert_equal('Xscratch', bufname(''))
|
||||||
|
call assert_equal('nofile', &buftype)
|
||||||
|
%bwipe
|
||||||
|
call delete('Xtest_mks.out')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for mksession with fold options
|
||||||
|
func Test_mksession_foldopt()
|
||||||
|
set sessionoptions-=options
|
||||||
|
set sessionoptions+=folds
|
||||||
|
new
|
||||||
|
setlocal foldenable
|
||||||
|
setlocal foldmethod=expr
|
||||||
|
setlocal foldmarker=<<<,>>>
|
||||||
|
setlocal foldignore=%
|
||||||
|
setlocal foldlevel=2
|
||||||
|
setlocal foldminlines=10
|
||||||
|
setlocal foldnestmax=15
|
||||||
|
mksession! Xtest_mks.out
|
||||||
|
close
|
||||||
|
%bwipe
|
||||||
|
|
||||||
|
source Xtest_mks.out
|
||||||
|
call assert_true(&foldenable)
|
||||||
|
call assert_equal('expr', &foldmethod)
|
||||||
|
call assert_equal('<<<,>>>', &foldmarker)
|
||||||
|
call assert_equal('%', &foldignore)
|
||||||
|
call assert_equal(2, &foldlevel)
|
||||||
|
call assert_equal(10, &foldminlines)
|
||||||
|
call assert_equal(15, &foldnestmax)
|
||||||
|
|
||||||
|
close
|
||||||
|
%bwipe
|
||||||
|
set sessionoptions&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for mksession with window position
|
||||||
|
func Test_mksession_winpos()
|
||||||
|
if !has('gui_running')
|
||||||
|
" Only applicable in GUI Vim
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
set sessionoptions+=winpos
|
||||||
|
mksession! Xtest_mks.out
|
||||||
|
let found_winpos = v:false
|
||||||
|
let lines = readfile('Xtest_mks.out')
|
||||||
|
for line in lines
|
||||||
|
if line =~ '^winpos '
|
||||||
|
let found_winpos = v:true
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call assert_true(found_winpos)
|
||||||
|
call delete('Xtest_mks.out')
|
||||||
|
set sessionoptions&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for mksession with 'compatible' option
|
||||||
|
func Test_mksession_compatible()
|
||||||
|
mksession! Xtest_mks1.out
|
||||||
|
set compatible
|
||||||
|
mksession! Xtest_mks2.out
|
||||||
|
set nocp
|
||||||
|
|
||||||
|
let test_success = v:false
|
||||||
|
let lines = readfile('Xtest_mks1.out')
|
||||||
|
for line in lines
|
||||||
|
if line =~ '^if &cp | set nocp | endif'
|
||||||
|
let test_success = v:true
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call assert_true(test_success)
|
||||||
|
|
||||||
|
let test_success = v:false
|
||||||
|
let lines = readfile('Xtest_mks2.out')
|
||||||
|
for line in lines
|
||||||
|
if line =~ '^if !&cp | set cp | endif'
|
||||||
|
let test_success = v:true
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call assert_true(test_success)
|
||||||
|
|
||||||
|
call delete('Xtest_mks1.out')
|
||||||
|
call delete('Xtest_mks2.out')
|
||||||
|
set compatible&
|
||||||
|
set sessionoptions&
|
||||||
|
endfunc
|
||||||
|
|
||||||
func s:ClearMappings()
|
func s:ClearMappings()
|
||||||
mapclear
|
mapclear
|
||||||
omapclear
|
omapclear
|
||||||
@@ -698,5 +808,4 @@ func Test_mkvimrc()
|
|||||||
call delete('Xtestvimrc')
|
call delete('Xtestvimrc')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2100,
|
||||||
/**/
|
/**/
|
||||||
2099,
|
2099,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user