Patch 8.2.0203
Problem: :helptags and some other functionality not tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes #5567)
Files: src/testdir/test_compiler.vim, src/testdir/test_ex_mode.vim,
src/testdir/test_excmd.vim, src/testdir/test_filechanged.vim,
src/testdir/test_help.vim, src/testdir/test_help_tagjump.vim,
src/testdir/test_timers.vim, src/testdir/test_window_cmd.vim
*** ../vim-8.2.0202/src/testdir/test_compiler.vim 2019-12-01 14:32:29.000000000 +0100
--- src/testdir/test_compiler.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 60,64 ****
--- 60,68 ----
endfunc
func Test_compiler_error()
+ let g:current_compiler = 'abc'
call assert_fails('compiler doesnotexist', 'E666:')
+ call assert_equal('abc', g:current_compiler)
+ call assert_fails('compiler! doesnotexist', 'E666:')
+ unlet! g:current_compiler
endfunc
*** ../vim-8.2.0202/src/testdir/test_ex_mode.vim 2019-12-18 22:26:15.746294049 +0100
--- src/testdir/test_ex_mode.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 1,5 ****
--- 1,7 ----
" Test editing line in Ex mode (see :help Q and :help gQ).
+ source check.vim
+
" Helper function to test editing line in Q Ex mode
func Ex_Q(cmd)
" Is there a simpler way to test editing Ex line?
***************
*** 52,54 ****
--- 54,87 ----
set sw&
let &encoding = encoding_save
endfunc
+
+ " Test subsittute confirmation prompt :%s/pat/str/c in Ex mode
+ func Test_Ex_substitute()
+ CheckRunVimInTerminal
+ let buf = RunVimInTerminal('', {'rows': 6})
+
+ call term_sendkeys(buf, ":call setline(1, ['foo foo', 'foo foo', 'foo foo'])\<CR>")
+ call term_sendkeys(buf, ":set number\<CR>")
+ call term_sendkeys(buf, "gQ")
+ call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
+
+ call term_sendkeys(buf, "%s/foo/bar/gc\<CR>")
+ call WaitForAssert({-> assert_match(' 1 foo foo', term_getline(buf, 5))},
+ \ 1000)
+ call WaitForAssert({-> assert_match(' ^^^', term_getline(buf, 6))}, 1000)
+ call term_sendkeys(buf, "n\<CR>")
+ call WaitForAssert({-> assert_match(' ^^^', term_getline(buf, 6))},
+ \ 1000)
+ call term_sendkeys(buf, "y\<CR>")
+
+ call term_sendkeys(buf, "q\<CR>")
+ call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
+
+ call term_sendkeys(buf, ":vi\<CR>")
+ call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000)
+
+ call term_sendkeys(buf, ":q!\n")
+ call StopVimInTerminal(buf)
+ endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0202/src/testdir/test_excmd.vim 2020-01-29 21:57:28.741607671 +0100
--- src/testdir/test_excmd.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 1,5 ****
--- 1,7 ----
" Tests for various Ex commands.
+ source check.vim
+
func Test_ex_delete()
new
call setline(1, ['a', 'b', 'c'])
***************
*** 169,172 ****
--- 171,244 ----
close!
endfunc
+ " Test for the :language command
+ func Test_language_cmd()
+ CheckFeature multi_lang
+
+ call assert_fails('language ctype non_existing_lang', 'E197:')
+ call assert_fails('language time non_existing_lang', 'E197:')
+ endfunc
+
+ " Test for the :confirm command dialog
+ func Test_confirm_cmd()
+ CheckNotGui
+ CheckRunVimInTerminal
+
+ call writefile(['foo1'], 'foo')
+ call writefile(['bar1'], 'bar')
+
+ " Test for saving all the modified buffers
+ let buf = RunVimInTerminal('', {'rows': 20})
+ call term_sendkeys(buf, ":set nomore\n")
+ call term_sendkeys(buf, ":new foo\n")
+ call term_sendkeys(buf, ":call setline(1, 'foo2')\n")
+ call term_sendkeys(buf, ":new bar\n")
+ call term_sendkeys(buf, ":call setline(1, 'bar2')\n")
+ call term_sendkeys(buf, ":wincmd b\n")
+ call term_sendkeys(buf, ":confirm qall\n")
+ call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, "A")
+ call StopVimInTerminal(buf)
+
+ call assert_equal(['foo2'], readfile('foo'))
+ call assert_equal(['bar2'], readfile('bar'))
+
+ " Test for discarding all the changes to modified buffers
+ let buf = RunVimInTerminal('', {'rows': 20})
+ call term_sendkeys(buf, ":set nomore\n")
+ call term_sendkeys(buf, ":new foo\n")
+ call term_sendkeys(buf, ":call setline(1, 'foo3')\n")
+ call term_sendkeys(buf, ":new bar\n")
+ call term_sendkeys(buf, ":call setline(1, 'bar3')\n")
+ call term_sendkeys(buf, ":wincmd b\n")
+ call term_sendkeys(buf, ":confirm qall\n")
+ call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, "D")
+ call StopVimInTerminal(buf)
+
+ call assert_equal(['foo2'], readfile('foo'))
+ call assert_equal(['bar2'], readfile('bar'))
+
+ " Test for saving and discarding changes to some buffers
+ let buf = RunVimInTerminal('', {'rows': 20})
+ call term_sendkeys(buf, ":set nomore\n")
+ call term_sendkeys(buf, ":new foo\n")
+ call term_sendkeys(buf, ":call setline(1, 'foo4')\n")
+ call term_sendkeys(buf, ":new bar\n")
+ call term_sendkeys(buf, ":call setline(1, 'bar4')\n")
+ call term_sendkeys(buf, ":wincmd b\n")
+ call term_sendkeys(buf, ":confirm qall\n")
+ call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, "N")
+ call WaitForAssert({-> assert_match('\[Y\]es, (N)o, (C)ancel: ', term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, "Y")
+ call StopVimInTerminal(buf)
+
+ call assert_equal(['foo4'], readfile('foo'))
+ call assert_equal(['bar2'], readfile('bar'))
+
+ call delete('foo')
+ call delete('bar')
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0202/src/testdir/test_filechanged.vim 2019-08-07 22:01:05.000000000 +0200
--- src/testdir/test_filechanged.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 138,144 ****
sleep 2
silent !touch Xchanged_d
let v:warningmsg = ''
! checktime
call assert_equal('', v:warningmsg)
call assert_equal(1, line('$'))
call assert_equal('new line', getline(1))
--- 138,144 ----
sleep 2
silent !touch Xchanged_d
let v:warningmsg = ''
! checktime Xchanged_d
call assert_equal('', v:warningmsg)
call assert_equal(1, line('$'))
call assert_equal('new line', getline(1))
*** ../vim-8.2.0202/src/testdir/test_help.vim 2020-02-02 15:32:09.967762406 +0100
--- src/testdir/test_help.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 72,74 ****
--- 72,112 ----
call feedkeys(":help :undo\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"help :undo :undoj :undol :undojoin :undolist', @:)
endfunc
+
+ " Test for the :helptags command
+ func Test_helptag_cmd()
+ call mkdir('Xdir/a/doc', 'p')
+
+ " No help file to process in the directory
+ call assert_fails('helptags Xdir', 'E151:')
+
+ call writefile([], 'Xdir/a/doc/sample.txt')
+
+ " Test for ++t argument
+ helptags ++t Xdir
+ call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
+ call delete('Xdir/tags')
+
+ " The following tests fail on FreeBSD for some reason
+ if has('unix') && !has('bsd')
+ " Read-only tags file
+ call writefile([''], 'Xdir/tags')
+ call setfperm('Xdir/tags', 'r-xr--r--')
+ call assert_fails('helptags Xdir', 'E152:', getfperm('Xdir/tags'))
+ call delete('Xdir/tags')
+
+ " No permission to read the help file
+ call setfperm('Xdir/a/doc/sample.txt', '-w-------')
+ call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt'))
+ call delete('Xdir/a/doc/sample.txt')
+ call delete('Xdir/tags')
+ endif
+
+ " Duplicate tags in the help file
+ call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
+ call assert_fails('helptags Xdir', 'E154:')
+
+ call delete('Xdir', 'rf')
+ endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0202/src/testdir/test_help_tagjump.vim 2020-02-02 15:32:09.967762406 +0100
--- src/testdir/test_help_tagjump.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 99,104 ****
--- 99,109 ----
call assert_true(getline('.') =~ '\*/\\bar\*')
helpclose
+ help \_$
+ call assert_equal("help", &filetype)
+ call assert_true(getline('.') =~ '\*/\\_$\*')
+ helpclose
+
help CTRL-\_CTRL-N
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*CTRL-\\_CTRL-N\*')
*** ../vim-8.2.0202/src/testdir/test_timers.vim 2020-01-30 18:24:47.001204003 +0100
--- src/testdir/test_timers.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 110,115 ****
--- 110,117 ----
call timer_stop(id)
call assert_equal([], timer_info(id))
+
+ call assert_fails('call timer_info("abc")', 'E39:')
endfunc
func Test_timer_stopall()
***************
*** 152,157 ****
--- 154,161 ----
else
call assert_inrange(0, 10, slept)
endif
+
+ call assert_fails('call timer_pause("abc", 1)', 'E39:')
endfunc
func StopMyself(timer)
***************
*** 246,251 ****
--- 250,259 ----
call WaitForAssert({-> assert_equal(3, g:call_count)})
sleep 50m
call assert_equal(3, g:call_count)
+
+ call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E475:')
+ call assert_fails('call timer_start(100, [])', 'E921:')
+ call assert_fails('call timer_stop("abc")', 'E39:')
endfunc
func FuncWithCaughtError(timer)
***************
*** 405,408 ****
--- 413,425 ----
exe buf .. 'bwipe!'
endfunc
+ " Test for garbage collection when a timer is still running
+ func Test_timer_garbage_collect()
+ let timer = timer_start(1000, function('MyHandler'), {'repeat' : 10})
+ call test_garbagecollect_now()
+ let l = timer_info(timer)
+ call assert_equal(function('MyHandler'), l[0].callback)
+ call timer_stop(timer)
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0202/src/testdir/test_window_cmd.vim 2020-01-06 21:03:20.792592602 +0100
--- src/testdir/test_window_cmd.vim 2020-02-03 21:35:03.994322830 +0100
***************
*** 933,936 ****
--- 933,945 ----
tabclose
endfunc
+ " Test for the :only command
+ func Test_window_only()
+ new
+ set modified
+ new
+ call assert_fails('only', 'E445:')
+ only!
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0202/src/version.c 2020-02-03 21:29:27.631654305 +0100
--- src/version.c 2020-02-03 21:37:34.929726994 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 203,
/**/
--
How To Keep A Healthy Level Of Insanity:
13. Go to a poetry recital and ask why the poems don't rhyme.
/// Bram Moolenaar -- Br...@Moolenaar.net --
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 ///