comparison src/testdir/test_mksession.vim @ 18205:e2feda1547bd v8.1.2097

patch 8.1.2097: :mksession is not sufficiently tested Commit: https://github.com/vim/vim/commit/66f0e6c6e201c75c24d4aa8fac46e926f7ac9054 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 28 19:08:45 2019 +0200 patch 8.1.2097: :mksession is not sufficiently tested Problem: :mksession is not sufficiently tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4992)
author Bram Moolenaar <Bram@vim.org>
date Sat, 28 Sep 2019 19:15:04 +0200
parents 049a7481d737
children f93c2b6f7167
comparison
equal deleted inserted replaced
18204:a33f6f825b46 18205:e2feda1547bd
152 152
153 call delete('Xtest_mks.out') 153 call delete('Xtest_mks.out')
154 endfunc 154 endfunc
155 155
156 func Test_mksession_arglist() 156 func Test_mksession_arglist()
157 argdel * 157 %argdel
158 next file1 file2 file3 file4 158 next file1 file2 file3 file4
159 mksession! Xtest_mks.out 159 mksession! Xtest_mks.out
160 source Xtest_mks.out 160 source Xtest_mks.out
161 call assert_equal(['file1', 'file2', 'file3', 'file4'], argv()) 161 call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
162 162
534 534
535 %bwipe! 535 %bwipe!
536 call delete('Xtest_mks_quoted.out') 536 call delete('Xtest_mks_quoted.out')
537 endfunc 537 endfunc
538 538
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
539 func s:ClearMappings() 656 func s:ClearMappings()
540 mapclear 657 mapclear
541 omapclear 658 omapclear
542 mapclear! 659 mapclear!
543 lmapclear 660 lmapclear