summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-03 21:40:04 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-03 21:40:04 +0100
commite20b9ececa37a81c0340a78f61e57fa1bf46b06d (patch)
tree52965e69e60cb22155c7895809d5c2eab3505bef
parente7ddf4e3372fad375038ad8771c6d1a7df49c34c (diff)
downloadvim-git-e20b9ececa37a81c0340a78f61e57fa1bf46b06d.tar.gz
patch 8.2.0203: :helptags and some other functionality not testedv8.2.0203
Problem: :helptags and some other functionality not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5567)
-rw-r--r--src/testdir/test_compiler.vim4
-rw-r--r--src/testdir/test_ex_mode.vim33
-rw-r--r--src/testdir/test_excmd.vim72
-rw-r--r--src/testdir/test_filechanged.vim2
-rw-r--r--src/testdir/test_help.vim38
-rw-r--r--src/testdir/test_help_tagjump.vim5
-rw-r--r--src/testdir/test_timers.vim17
-rw-r--r--src/testdir/test_window_cmd.vim9
-rw-r--r--src/version.c2
9 files changed, 181 insertions, 1 deletions
diff --git a/src/testdir/test_compiler.vim b/src/testdir/test_compiler.vim
index 1ce271827..4f02cf1c2 100644
--- 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
index 00a35a306..5899571a9 100644
--- 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'])\<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
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index 37cc24cb4..6174e660b 100644
--- 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
index bfcdb76ab..6d17d9586 100644
--- 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
index ee5ace8f7..3b6ad3923 100644
--- a/src/testdir/test_help.vim
+++ b/src/testdir/test_help.vim
@@ -72,3 +72,41 @@ func Test_help_completion()
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
diff --git a/src/testdir/test_help_tagjump.vim b/src/testdir/test_help_tagjump.vim
index dbe097816..7de2b1551 100644
--- 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
index 383aff54e..37af18c38 100644
--- 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
index 87c1f1f25..cbd08c974 100644
--- 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
index 884e01a5f..43a03fe49 100644
--- 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,