@@ -154,7 +154,7 @@ func Test_mksession_rtp()
154154endfunc
155155
156156func Test_mksession_arglist ()
157- argdel *
157+ % argdel
158158 next file1 file2 file3 file4
159159 mksession ! Xtest_mks.out
160160 source Xtest_mks.out
@@ -536,6 +536,123 @@ func Test_mksession_quote_in_filename()
536536 call delete (' Xtest_mks_quoted.out' )
537537endfunc
538538
539+ " Test for storing global variables in a session file
540+ func Test_mksession_globals ()
541+ set sessionoptions += globals
542+
543+ " create different global variables
544+ let g: Global_string = " Sun is shining"
545+ let g: Global_count = 100
546+ let g: Global_pi = 3.14
547+
548+ mksession ! Xtest_mks.out
549+
550+ unlet g: Global_string
551+ unlet g: Global_count
552+ unlet g: Global_pi
553+
554+ source Xtest_mks.out
555+ call assert_equal (" Sun is shining" , g: Global_string )
556+ call assert_equal (100 , g: Global_count )
557+ call assert_equal (3.14 , g: Global_pi )
558+
559+ unlet g: Global_string
560+ unlet g: Global_count
561+ unlet g: Global_pi
562+ call delete (' Xtest_mks.out' )
563+ set sessionoptions &
564+ endfunc
565+
566+ " Test for changing backslash to forward slash in filenames
567+ func Test_mksession_slash ()
568+ enew
569+ % bwipe!
570+ e a \\ b \\ c
571+ mksession ! Xtest_mks1.out
572+ set sessionoptions += slash
573+ mksession ! Xtest_mks2.out
574+
575+ % bwipe!
576+ source Xtest_mks1.out
577+ call assert_equal (' a\b\c' , bufname (' ' ))
578+ % bwipe!
579+ source Xtest_mks2.out
580+ call assert_equal (' a/b/c' , bufname (' ' ))
581+
582+ % bwipe!
583+ call delete (' Xtest_mks1.out' )
584+ call delete (' Xtest_mks2.out' )
585+ set sessionoptions &
586+ endfunc
587+
588+ " Test for storing global and local argument list in a session file
589+ func Test_mkseesion_arglocal ()
590+ enew | only
591+ n a b c
592+ new
593+ arglocal
594+ mksession ! Xtest_mks.out
595+
596+ % bwipe!
597+ % argdelete
598+ argglobal
599+ source Xtest_mks.out
600+ call assert_equal (2 , winnr (' $' ))
601+ call assert_equal (2 , arglistid (1 ))
602+ call assert_equal (0 , arglistid (2 ))
603+
604+ % bwipe!
605+ % argdelete
606+ argglobal
607+ call delete (' Xtest_mks.out' )
608+ endfunc
609+
610+ " Test for changing directory to the session file directory
611+ func Test_mksession_sesdir ()
612+ call mkdir (' Xproj' )
613+ mksession ! Xproj/Xtest_mks1.out
614+ set sessionoptions -= curdir
615+ set sessionoptions += sesdir
616+ mksession ! Xproj/Xtest_mks2.out
617+
618+ source Xproj/Xtest_mks1.out
619+ call assert_equal (' testdir' , fnamemodify (getcwd (), ' :t' ))
620+ source Xproj/Xtest_mks2.out
621+ call assert_equal (' Xproj' , fnamemodify (getcwd (), ' :t' ))
622+ cd ..
623+
624+ set sessionoptions &
625+ call delete (' Xproj' , ' rf' )
626+ endfunc
627+
628+ " Test for storing the 'lines' and 'columns' settings
629+ func Test_mksession_resize ()
630+ mksession ! Xtest_mks1.out
631+ set sessionoptions += resize
632+ mksession ! Xtest_mks2.out
633+
634+ let lines = readfile (' Xtest_mks1.out' )
635+ let found_resize = v: false
636+ for line in lines
637+ if line = ~ ' ^set lines='
638+ let found_resize = v: true
639+ endif
640+ endfor
641+ call assert_equal (v: false , found_resize)
642+ let lines = readfile (' Xtest_mks2.out' )
643+ let found_resize = v: false
644+ for line in lines
645+ if line = ~ ' ^set lines='
646+ let found_resize = v: true
647+ endif
648+ endfor
649+ call assert_equal (v: true , found_resize)
650+
651+ call delete (' Xtest_mks1.out' )
652+ call delete (' Xtest_mks2.out' )
653+ set sessionoptions &
654+ endfunc
655+
539656func s: ClearMappings ()
540657 mapclear
541658 omapclear
0 commit comments