Patch 8.1.2097
Problem:    :mksession is not sufficiently tested.
Solution:   Add more test cases. (Yegappan Lakshmanan, closes #4992)
Files:      src/testdir/test_mksession.vim


*** ../vim-8.1.2096/src/testdir/test_mksession.vim      2019-09-08 
20:55:03.146072987 +0200
--- src/testdir/test_mksession.vim      2019-09-28 19:08:06.831725273 +0200
***************
*** 154,160 ****
  endfunc
  
  func Test_mksession_arglist()
!   argdel *
    next file1 file2 file3 file4
    mksession! Xtest_mks.out
    source Xtest_mks.out
--- 154,160 ----
  endfunc
  
  func Test_mksession_arglist()
!   %argdel
    next file1 file2 file3 file4
    mksession! Xtest_mks.out
    source Xtest_mks.out
***************
*** 536,541 ****
--- 536,658 ----
    call delete('Xtest_mks_quoted.out')
  endfunc
  
+ " Test for storing global variables in a session file
+ func Test_mksession_globals()
+   set sessionoptions+=globals
+ 
+   " create different global variables
+   let g:Global_string = "Sun is shining"
+   let g:Global_count = 100
+   let g:Global_pi = 3.14
+ 
+   mksession! Xtest_mks.out
+ 
+   unlet g:Global_string
+   unlet g:Global_count
+   unlet g:Global_pi
+ 
+   source Xtest_mks.out
+   call assert_equal("Sun is shining", g:Global_string)
+   call assert_equal(100, g:Global_count)
+   call assert_equal(3.14, g:Global_pi)
+ 
+   unlet g:Global_string
+   unlet g:Global_count
+   unlet g:Global_pi
+   call delete('Xtest_mks.out')
+   set sessionoptions&
+ endfunc
+ 
+ " Test for changing backslash to forward slash in filenames
+ func Test_mksession_slash()
+   enew
+   %bwipe!
+   e a\\b\\c
+   mksession! Xtest_mks1.out
+   set sessionoptions+=slash
+   mksession! Xtest_mks2.out
+ 
+   %bwipe!
+   source Xtest_mks1.out
+   call assert_equal('a\b\c', bufname(''))
+   %bwipe!
+   source Xtest_mks2.out
+   call assert_equal('a/b/c', bufname(''))
+ 
+   %bwipe!
+   call delete('Xtest_mks1.out')
+   call delete('Xtest_mks2.out')
+   set sessionoptions&
+ endfunc
+ 
+ " Test for storing global and local argument list in a session file
+ func Test_mkseesion_arglocal()
+   enew | only
+   n a b c
+   new
+   arglocal
+   mksession! Xtest_mks.out
+ 
+   %bwipe!
+   %argdelete
+   argglobal
+   source Xtest_mks.out
+   call assert_equal(2, winnr('$'))
+   call assert_equal(2, arglistid(1))
+   call assert_equal(0, arglistid(2))
+ 
+   %bwipe!
+   %argdelete
+   argglobal
+   call delete('Xtest_mks.out')
+ endfunc
+ 
+ " Test for changing directory to the session file directory
+ func Test_mksession_sesdir()
+   call mkdir('Xproj')
+   mksession! Xproj/Xtest_mks1.out
+   set sessionoptions-=curdir
+   set sessionoptions+=sesdir
+   mksession! Xproj/Xtest_mks2.out
+ 
+   source Xproj/Xtest_mks1.out
+   call assert_equal('testdir', fnamemodify(getcwd(), ':t'))
+   source Xproj/Xtest_mks2.out
+   call assert_equal('Xproj', fnamemodify(getcwd(), ':t'))
+   cd ..
+ 
+   set sessionoptions&
+   call delete('Xproj', 'rf')
+ endfunc
+ 
+ " Test for storing the 'lines' and 'columns' settings
+ func Test_mksession_resize()
+   mksession! Xtest_mks1.out
+   set sessionoptions+=resize
+   mksession! Xtest_mks2.out
+ 
+   let lines = readfile('Xtest_mks1.out')
+   let found_resize = v:false
+   for line in lines
+     if line =~ '^set lines='
+       let found_resize = v:true
+     endif
+   endfor
+   call assert_equal(v:false, found_resize)
+   let lines = readfile('Xtest_mks2.out')
+   let found_resize = v:false
+   for line in lines
+     if line =~ '^set lines='
+       let found_resize = v:true
+     endif
+   endfor
+   call assert_equal(v:true, found_resize)
+ 
+   call delete('Xtest_mks1.out')
+   call delete('Xtest_mks2.out')
+   set sessionoptions&
+ endfunc
+ 
  func s:ClearMappings()
    mapclear
    omapclear
*** ../vim-8.1.2096/src/version.c       2019-09-28 19:04:06.997029566 +0200
--- src/version.c       2019-09-28 19:07:57.963772329 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     2097,
  /**/

-- 
ARTHUR:  Be quiet!
DENNIS:  --but by a two-thirds majority in the case of more--
ARTHUR:  Be quiet!  I order you to be quiet!
WOMAN:   Order, eh -- who does he think he is?
ARTHUR:  I am your king!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201909281709.x8SH9CKu003890%40masaka.moolenaar.net.

Raspunde prin e-mail lui