Mercurial > vim
comparison src/testdir/test_options.vim @ 19969:b07672d13ff9 v8.2.0540
patch 8.2.0540: regexp and other code not tested
Commit: https://github.com/vim/vim/commit/004a6781b3cf15ca5dd632c38cc09bb3b253d1f8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 11 17:09:31 2020 +0200
patch 8.2.0540: regexp and other code not tested
Problem: Regexp and other code not tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5904)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 11 Apr 2020 17:15:06 +0200 |
parents | 0b42b5e50344 |
children | f27473034f26 |
comparison
equal
deleted
inserted
replaced
19968:1908e92b02fd | 19969:b07672d13ff9 |
---|---|
19 set whichwrap=h,h | 19 set whichwrap=h,h |
20 call assert_equal('h', &whichwrap) | 20 call assert_equal('h', &whichwrap) |
21 | 21 |
22 set whichwrap=h,h,h | 22 set whichwrap=h,h,h |
23 call assert_equal('h', &whichwrap) | 23 call assert_equal('h', &whichwrap) |
24 | |
25 " For compatibility with Vim 3.0 and before, number values are also | |
26 " supported for 'whichwrap' | |
27 set whichwrap=1 | |
28 call assert_equal('b', &whichwrap) | |
29 set whichwrap=2 | |
30 call assert_equal('s', &whichwrap) | |
31 set whichwrap=4 | |
32 call assert_equal('h,l', &whichwrap) | |
33 set whichwrap=8 | |
34 call assert_equal('<,>', &whichwrap) | |
35 set whichwrap=16 | |
36 call assert_equal('[,]', &whichwrap) | |
37 set whichwrap=31 | |
38 call assert_equal('b,s,h,l,<,>,[,]', &whichwrap) | |
24 | 39 |
25 set whichwrap& | 40 set whichwrap& |
26 endfunc | 41 endfunc |
27 | 42 |
28 func Test_isfname() | 43 func Test_isfname() |
80 normal gt | 95 normal gt |
81 call assert_equal('option-window', bufname('')) | 96 call assert_equal('option-window', bufname('')) |
82 | 97 |
83 " close option-window | 98 " close option-window |
84 close | 99 close |
100 | |
101 " Open the options window browse | |
102 if has('browse') | |
103 browse set | |
104 call assert_equal('option-window', bufname('')) | |
105 close | |
106 endif | |
85 endfunc | 107 endfunc |
86 | 108 |
87 func Test_path_keep_commas() | 109 func Test_path_keep_commas() |
88 " Test that changing 'path' keeps two commas. | 110 " Test that changing 'path' keeps two commas. |
89 set path=foo,,bar | 111 set path=foo,,bar |
306 call assert_fails('set backupext=~ patchmode=~', 'E589:') | 328 call assert_fails('set backupext=~ patchmode=~', 'E589:') |
307 call assert_fails('set winminheight=10 winheight=9', 'E591:') | 329 call assert_fails('set winminheight=10 winheight=9', 'E591:') |
308 call assert_fails('set winminwidth=10 winwidth=9', 'E592:') | 330 call assert_fails('set winminwidth=10 winwidth=9', 'E592:') |
309 call assert_fails("set showbreak=\x01", 'E595:') | 331 call assert_fails("set showbreak=\x01", 'E595:') |
310 call assert_fails('set t_foo=', 'E846:') | 332 call assert_fails('set t_foo=', 'E846:') |
333 call assert_fails('set tabstop??', 'E488:') | |
334 call assert_fails('set wrapscan!!', 'E488:') | |
335 call assert_fails('set tabstop&&', 'E488:') | |
336 call assert_fails('set wrapscan<<', 'E488:') | |
337 call assert_fails('set wrapscan=1', 'E474:') | |
338 call assert_fails('set autoindent@', 'E488:') | |
339 call assert_fails('set wildchar=<abc>', 'E474:') | |
340 call assert_fails('set cmdheight=1a', 'E521:') | |
341 if has('python') && has('python3') | |
342 call assert_fails('set pyxversion=6', 'E474:') | |
343 endif | |
311 endfunc | 344 endfunc |
312 | 345 |
313 func CheckWasSet(name) | 346 func CheckWasSet(name) |
314 let verb_cm = execute('verbose set ' .. a:name .. '?') | 347 let verb_cm = execute('verbose set ' .. a:name .. '?') |
315 call assert_match('Last set from.*test_options.vim', verb_cm) | 348 call assert_match('Last set from.*test_options.vim', verb_cm) |
728 exe "normal \<C-c>" | 761 exe "normal \<C-c>" |
729 call assert_equal('Beep!', Screenline(&lines)) | 762 call assert_equal('Beep!', Screenline(&lines)) |
730 set debug& | 763 set debug& |
731 endfunc | 764 endfunc |
732 | 765 |
766 " Test for the default CDPATH option | |
767 func Test_opt_default_cdpath() | |
768 CheckFeature file_in_path | |
769 let after =<< trim [CODE] | |
770 call assert_equal(',/path/to/dir1,/path/to/dir2', &cdpath) | |
771 call writefile(v:errors, 'Xtestout') | |
772 qall | |
773 [CODE] | |
774 if has('unix') | |
775 let $CDPATH='/path/to/dir1:/path/to/dir2' | |
776 else | |
777 let $CDPATH='/path/to/dir1;/path/to/dir2' | |
778 endif | |
779 if RunVim([], after, '') | |
780 call assert_equal([], readfile('Xtestout')) | |
781 call delete('Xtestout') | |
782 endif | |
783 endfunc | |
784 | |
785 " Test for setting keycodes using set | |
786 func Test_opt_set_keycode() | |
787 call assert_fails('set <t_k1=l', 'E474:') | |
788 call assert_fails('set <Home=l', 'E474:') | |
789 set <t_k9>=abcd | |
790 call assert_equal('abcd', &t_k9) | |
791 set <t_k9>& | |
792 set <F9>=xyz | |
793 call assert_equal('xyz', &t_k9) | |
794 set <t_k9>& | |
795 endfunc | |
796 | |
797 " Test for changing options in a sandbox | |
798 func Test_opt_sandbox() | |
799 for opt in ['backupdir', 'cdpath', 'exrc'] | |
800 call assert_fails('sandbox set ' .. opt .. '?', 'E48:') | |
801 endfor | |
802 endfunc | |
803 | |
804 " Test for setting an option with local value to global value | |
805 func Test_opt_local_to_global() | |
806 setglobal equalprg=gprg | |
807 setlocal equalprg=lprg | |
808 call assert_equal('gprg', &g:equalprg) | |
809 call assert_equal('lprg', &l:equalprg) | |
810 call assert_equal('lprg', &equalprg) | |
811 set equalprg< | |
812 call assert_equal('', &l:equalprg) | |
813 call assert_equal('gprg', &equalprg) | |
814 setglobal equalprg=gnewprg | |
815 setlocal equalprg=lnewprg | |
816 setlocal equalprg< | |
817 call assert_equal('gnewprg', &l:equalprg) | |
818 call assert_equal('gnewprg', &equalprg) | |
819 set equalprg& | |
820 endfunc | |
821 | |
822 " Test for incrementing, decrementing and multiplying a number option value | |
823 func Test_opt_num_op() | |
824 set shiftwidth=4 | |
825 set sw+=2 | |
826 call assert_equal(6, &sw) | |
827 set sw-=2 | |
828 call assert_equal(4, &sw) | |
829 set sw^=2 | |
830 call assert_equal(8, &sw) | |
831 set shiftwidth& | |
832 endfunc | |
833 | |
733 " vim: shiftwidth=2 sts=2 expandtab | 834 " vim: shiftwidth=2 sts=2 expandtab |