]> granicus.if.org Git - vim/commitdiff
patch 8.2.0203: :helptags and some other functionality not tested v8.2.0203
authorBram Moolenaar <Bram@vim.org>
Mon, 3 Feb 2020 20:40:04 +0000 (21:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 3 Feb 2020 20:40:04 +0000 (21:40 +0100)
Problem:    :helptags and some other functionality not tested.
Solution:   Add more tests. (Yegappan Lakshmanan, closes #5567)

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
src/version.c

index 1ce2718278dddded760e8f5b0fa553e4846e1f69..4f02cf1c2f9642afc81b986b1c462788dbe3735a 100644 (file)
@@ -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
index 00a35a3061697727a4136475c9c97ac728628bc7..5899571a972a11359eee4e791b4a5bef5e13c88c 100644 (file)
@@ -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
index 37cc24cb4cfebefe7b4c7a3543a52930f78f06bb..6174e660bec80089d157525cfd70202e7e46d01a 100644 (file)
@@ -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
index bfcdb76abb5793a3b2982545c3293438b7cf0399..6d17d9586d6e5cf2cf659392036e99479dd0f52d 100644 (file)
@@ -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))
index ee5ace8f74d287413975fa42a42aa4995b3c43a6..3b6ad3923bb6f3a3d13aaac44943d656b89733c6 100644 (file)
@@ -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
index dbe0978169a5b936958b129f943c3cf9e6b238f6..7de2b1551c77446df5631ec2e40a5c30c99814a4 100644 (file)
@@ -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\*')
index 383aff54e518697c35900816b49ff644de4ce2e0..37af18c3822872559b62509777632c7e6d6e860f 100644 (file)
@@ -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
index 87c1f1f25a3fe728262fe313d64991f07d7dbc36..cbd08c974156bb173c58270d5838ec158b3c117a 100644 (file)
@@ -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
index 884e01a5f4cd1a56f25d51198cee01301ad77681..43a03fe497d794a5f65cb554a8d5622de0e510a3 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    203,
 /**/
     202,
 /**/