# HG changeset patch # User Bram Moolenaar # Date 1580762703 -3600 # Node ID 2f0f308c069c03a8ac1a2a430b76439e62887101 # Parent f061872089a9f7f06699800e74367380f9948e9e patch 8.2.0203: :helptags and some other functionality not tested Commit: https://github.com/vim/vim/commit/e20b9ececa37a81c0340a78f61e57fa1bf46b06d Author: Bram Moolenaar Date: Mon Feb 3 21:40:04 2020 +0100 patch 8.2.0203: :helptags and some other functionality not tested Problem: :helptags and some other functionality not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5567) diff --git a/src/testdir/test_compiler.vim b/src/testdir/test_compiler.vim --- a/src/testdir/test_compiler.vim +++ b/src/testdir/test_compiler.vim @@ -60,5 +60,9 @@ func Test_compiler_completion() 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 diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -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,3 +54,34 @@ func Test_ex_mode() 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'])\") + call term_sendkeys(buf, ":set number\") + call term_sendkeys(buf, "gQ") + call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000) + + call term_sendkeys(buf, "%s/foo/bar/gc\") + 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\") + call WaitForAssert({-> assert_match(' ^^^', term_getline(buf, 6))}, + \ 1000) + call term_sendkeys(buf, "y\") + + call term_sendkeys(buf, "q\") + call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000) + + call term_sendkeys(buf, ":vi\") + 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 diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim --- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -1,5 +1,7 @@ " Tests for various Ex commands. +source check.vim + func Test_ex_delete() new call setline(1, ['a', 'b', 'c']) @@ -169,4 +171,74 @@ func Test_change_cmd() 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 diff --git a/src/testdir/test_filechanged.vim b/src/testdir/test_filechanged.vim --- a/src/testdir/test_filechanged.vim +++ b/src/testdir/test_filechanged.vim @@ -138,7 +138,7 @@ func Test_file_changed_dialog() sleep 2 silent !touch Xchanged_d let v:warningmsg = '' - checktime + checktime Xchanged_d call assert_equal('', v:warningmsg) call assert_equal(1, line('$')) call assert_equal('new line', getline(1)) diff --git a/src/testdir/test_help.vim b/src/testdir/test_help.vim --- a/src/testdir/test_help.vim +++ b/src/testdir/test_help.vim @@ -72,3 +72,41 @@ func Test_help_completion() call feedkeys(":help :undo\\\"\", '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 diff --git a/src/testdir/test_help_tagjump.vim b/src/testdir/test_help_tagjump.vim --- a/src/testdir/test_help_tagjump.vim +++ b/src/testdir/test_help_tagjump.vim @@ -99,6 +99,11 @@ func Test_help_tagjump() 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\*') diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim --- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -110,6 +110,8 @@ func Test_timer_info() call timer_stop(id) call assert_equal([], timer_info(id)) + + call assert_fails('call timer_info("abc")', 'E39:') endfunc func Test_timer_stopall() @@ -152,6 +154,8 @@ func Test_timer_paused() else call assert_inrange(0, 10, slept) endif + + call assert_fails('call timer_pause("abc", 1)', 'E39:') endfunc func StopMyself(timer) @@ -246,6 +250,10 @@ func Test_timer_errors() 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,4 +413,13 @@ func Test_timer_error_in_timer_callback( 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 diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -933,4 +933,13 @@ func Test_win_splitmove() 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 203, +/**/ 202, /**/ 201,