changeset 20990:55b3849ded11 v8.2.1046

patch 8.2.1046: insufficient tests for src/buffer.c Commit: https://github.com/vim/vim/commit/b7e2483655d9b68df0c7349918027d800051a28a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 24 13:37:35 2020 +0200 patch 8.2.1046: insufficient tests for src/buffer.c Problem: Insufficient tests for src/buffer.c. Solution: Add more tests. Move comments related tests to a separate file. (Yegappan Lakshmanan, closes #6325)
author Bram Moolenaar <Bram@vim.org>
date Wed, 24 Jun 2020 13:45:06 +0200
parents c27f8e4ea9d7
children cf7644c0a791
files src/testdir/Make_all.mak src/testdir/test_buffer.vim src/testdir/test_cmdline.vim src/testdir/test_comments.vim src/testdir/test_normal.vim src/testdir/test_textformat.vim src/version.c
diffstat 7 files changed, 487 insertions(+), 272 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -90,6 +90,7 @@ NEW_TESTS = \
 	test_close_count \
 	test_cmdline \
 	test_command_count \
+	test_comments \
 	test_comparators \
 	test_compiler \
 	test_conceal \
@@ -341,6 +342,7 @@ NEW_TESTS_RES = \
 	test_close_count.res \
 	test_cmdline.res \
 	test_command_count.res \
+	test_comments.res \
 	test_comparators.res \
 	test_conceal.res \
 	test_const.res \
--- a/src/testdir/test_buffer.vim
+++ b/src/testdir/test_buffer.vim
@@ -1,5 +1,7 @@
 " Tests for Vim buffer
 
+source check.vim
+
 " Test for the :bunload command with an offset
 func Test_bunload_with_offset()
   %bwipe!
@@ -152,6 +154,24 @@ func Test_bdelete_cmd()
   set nobuflisted
   enew
   call assert_fails('bdelete ' .. bnr, 'E516:')
+
+  " Deleting more than one buffer
+  new Xbuf1
+  new Xbuf2
+  exe 'bdel ' .. bufnr('Xbuf2') .. ' ' .. bufnr('Xbuf1')
+  call assert_equal(1, winnr('$'))
+  call assert_equal(0, getbufinfo('Xbuf1')[0].loaded)
+  call assert_equal(0, getbufinfo('Xbuf2')[0].loaded)
+
+  " Deleting more than one buffer and an invalid buffer
+  new Xbuf1
+  new Xbuf2
+  let cmd = "exe 'bdel ' .. bufnr('Xbuf2') .. ' xxx ' .. bufnr('Xbuf1')"
+  call assert_fails(cmd, 'E94:')
+  call assert_equal(2, winnr('$'))
+  call assert_equal(1, getbufinfo('Xbuf1')[0].loaded)
+  call assert_equal(0, getbufinfo('Xbuf2')[0].loaded)
+
   %bwipe!
 endfunc
 
@@ -166,4 +186,188 @@ func Test_buffer_error()
   %bwipe
 endfunc
 
+" Test for the status messages displayed when unloading, deleting or wiping
+" out buffers
+func Test_buffer_statusmsg()
+  CheckEnglish
+  set report=1
+  new Xbuf1
+  new Xbuf2
+  let bnr = bufnr()
+  exe "normal 2\<C-G>"
+  call assert_match('buf ' .. bnr .. ':', v:statusmsg)
+  bunload Xbuf1 Xbuf2
+  call assert_equal('2 buffers unloaded', v:statusmsg)
+  bdel Xbuf1 Xbuf2
+  call assert_equal('2 buffers deleted', v:statusmsg)
+  bwipe Xbuf1 Xbuf2
+  call assert_equal('2 buffers wiped out', v:statusmsg)
+  set report&
+endfunc
+
+" Test for quitting the 'swapfile exists' dialog with the split buffer
+" command.
+func Test_buffer_sbuf_cleanup()
+  call writefile([], 'Xfile')
+  " first open the file in a buffer
+  new Xfile
+  let bnr = bufnr()
+  close
+  " create the swap file
+  call writefile([], '.Xfile.swp')
+  " Remove the catch-all that runtest.vim adds
+  au! SwapExists
+  augroup BufTest
+    au!
+    autocmd SwapExists Xfile let v:swapchoice='q'
+  augroup END
+  exe 'sbuf ' . bnr
+  call assert_equal(1, winnr('$'))
+  call assert_equal(0, getbufinfo('Xfile')[0].loaded)
+
+  " test for :sball
+  sball
+  call assert_equal(1, winnr('$'))
+  call assert_equal(0, getbufinfo('Xfile')[0].loaded)
+
+  %bw!
+  set shortmess+=F
+  let v:statusmsg = ''
+  edit Xfile
+  call assert_equal('', v:statusmsg)
+  call assert_equal(1, winnr('$'))
+  call assert_equal(0, getbufinfo('Xfile')[0].loaded)
+  set shortmess&
+
+  call delete('Xfile')
+  call delete('.Xfile.swp')
+  augroup BufTest
+    au!
+  augroup END
+  augroup! BufTest
+endfunc
+
+" Test for deleting a modified buffer with :confirm
+func Test_bdel_with_confirm()
+  CheckUnix
+  CheckNotGui
+  CheckFeature dialog_con
+  new
+  call setline(1, 'test')
+  call assert_fails('bdel', 'E89:')
+  call feedkeys('c', 'L')
+  confirm bdel
+  call assert_equal(2, winnr('$'))
+  call assert_equal(1, &modified)
+  call feedkeys('n', 'L')
+  confirm bdel
+  call assert_equal(1, winnr('$'))
+endfunc
+
+" Test for editing another buffer from a modified buffer with :confirm
+func Test_goto_buf_with_confirm()
+  CheckUnix
+  CheckNotGui
+  CheckFeature dialog_con
+  new Xfile
+  enew
+  call setline(1, 'test')
+  call assert_fails('b Xfile', 'E37:')
+  call feedkeys('c', 'L')
+  call assert_fails('confirm b Xfile', 'E37:')
+  call assert_equal(1, &modified)
+  call assert_equal('', @%)
+  call feedkeys('y', 'L')
+  call assert_fails('confirm b Xfile', 'E37:')
+  call assert_equal(1, &modified)
+  call assert_equal('', @%)
+  call feedkeys('n', 'L')
+  confirm b Xfile
+  call assert_equal('Xfile', @%)
+  close!
+endfunc
+
+" Test for splitting buffer with 'switchbuf'
+func Test_buffer_switchbuf()
+  new Xfile
+  wincmd w
+  set switchbuf=useopen
+  sbuf Xfile
+  call assert_equal(1, winnr())
+  call assert_equal(2, winnr('$'))
+  set switchbuf=usetab
+  tabnew
+  sbuf Xfile
+  call assert_equal(1, tabpagenr())
+  call assert_equal(2, tabpagenr('$'))
+  set switchbuf&
+  %bw
+endfunc
+
+" Test for BufAdd autocommand wiping out the buffer
+func Test_bufadd_autocmd_bwipe()
+  %bw!
+  augroup BufAdd_Wipe
+    au!
+    autocmd BufAdd Xfile %bw!
+  augroup END
+  edit Xfile
+  call assert_equal('', @%)
+  call assert_equal(0, bufexists('Xfile'))
+  augroup BufAdd_Wipe
+    au!
+  augroup END
+  augroup! BufAdd_Wipe
+endfunc
+
+" Test for trying to load a buffer with text locked
+" <C-\>e in the command line is used to lock the text
+func Test_load_buf_with_text_locked()
+  new Xfile1
+  edit Xfile2
+  let cmd = ":\<C-\>eexecute(\"normal \<C-O>\")\<CR>\<C-C>"
+  call assert_fails("call feedkeys(cmd, 'xt')", 'E565:')
+  %bw!
+endfunc
+
+" Test for using CTRL-^ to edit the alternative file keeping the cursor
+" position with 'nostartofline'. Also test using the 'buf' command.
+func Test_buffer_edit_altfile()
+  call writefile(repeat(['one two'], 50), 'Xfile1')
+  call writefile(repeat(['five six'], 50), 'Xfile2')
+  set nosol
+  edit Xfile1
+  call cursor(25, 5)
+  edit Xfile2
+  call cursor(30, 4)
+  exe "normal \<C-^>"
+  call assert_equal([0, 25, 5, 0], getpos('.'))
+  exe "normal \<C-^>"
+  call assert_equal([0, 30, 4, 0], getpos('.'))
+  buf Xfile1
+  call assert_equal([0, 25, 5, 0], getpos('.'))
+  buf Xfile2
+  call assert_equal([0, 30, 4, 0], getpos('.'))
+  set sol&
+  call delete('Xfile1')
+  call delete('Xfile2')
+endfunc
+
+" Test for running the :sball command with a maximum window count and a
+" modified buffer
+func Test_sball_with_count()
+  %bw!
+  edit Xfile1
+  call setline(1, ['abc'])
+  new Xfile2
+  new Xfile3
+  new Xfile4
+  2sball
+  call assert_equal(bufnr('Xfile4'), winbufnr(1))
+  call assert_equal(bufnr('Xfile1'), winbufnr(2))
+  call assert_equal(0, getbufinfo('Xfile2')[0].loaded)
+  call assert_equal(0, getbufinfo('Xfile3')[0].loaded)
+  %bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -392,6 +392,7 @@ func Test_getcompletion()
   call delete('Xtags')
   set tags&
 
+  call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:')
   call assert_fails('call getcompletion("", "burp")', 'E475:')
   call assert_fails('call getcompletion("abc", [])', 'E475:')
 endfunc
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_comments.vim
@@ -0,0 +1,277 @@
+" Tests for the various flags in the 'comments' option
+
+" Test for the 'n' flag in 'comments'
+func Test_comment_nested()
+  new
+  setlocal comments=n:> fo+=ro
+  exe "normal i> B\nD\<C-C>ggOA\<C-C>joC\<C-C>Go\<BS>>>> F\nH"
+  exe "normal 5GOE\<C-C>6GoG"
+  let expected =<< trim END
+    > A
+    > B
+    > C
+    > D
+    >>>> E
+    >>>> F
+    >>>> G
+    >>>> H
+  END
+  call assert_equal(expected, getline(1, '$'))
+  close!
+endfunc
+
+" Test for the 'b' flag in 'comments'
+func Test_comment_blank()
+  new
+  setlocal comments=b:* fo+=ro
+  exe "normal i* E\nF\n\<BS>G\nH\<C-C>ggOC\<C-C>O\<BS>B\<C-C>OA\<C-C>2joD"
+  let expected =<< trim END
+    A
+    *B
+    * C
+    * D
+    * E
+    * F
+    *G
+    H
+  END
+  call assert_equal(expected, getline(1, '$'))
+  close!
+endfunc
+
+" Test for the 'f' flag in 'comments' (only the first line has a comment
+" string)
+func Test_comment_firstline()
+  new
+  setlocal comments=f:- fo+=ro
+  exe "normal i- B\nD\<C-C>ggoC\<C-C>ggOA\<C-C>"
+  call assert_equal(['A', '- B', '  C', '  D'], getline(1, '$'))
+  %d
+  setlocal comments=:-
+  exe "normal i- B\nD\<C-C>ggoC\<C-C>ggOA\<C-C>"
+  call assert_equal(['- A', '- B', '- C', '- D'], getline(1, '$'))
+  close!
+endfunc
+
+" Test for the 's', 'm' and 'e' flags in 'comments'
+" Test for automatically adding comment leaders in insert mode
+func Test_comment_threepiece()
+  new
+  setlocal expandtab
+  call setline(1, ["\t/*"])
+  setlocal formatoptions=croql
+  call cursor(1, 3)
+  call feedkeys("A\<cr>\<cr>/", 'tnix')
+  call assert_equal(["\t/*", " *", " */"], getline(1, '$'))
+
+  " If a comment ends in a single line, then don't add it in the next line
+  %d
+  call setline(1, '/* line1 */')
+  call feedkeys("A\<CR>next line", 'xt')
+  call assert_equal(['/* line1 */', 'next line'], getline(1, '$'))
+
+  %d
+  " Copy the trailing indentation from the leader comment to a new line
+  setlocal autoindent noexpandtab
+  call feedkeys("a\t/*\tone\ntwo\n/", 'xt')
+  call assert_equal(["\t/*\tone", "\t *\ttwo", "\t */"], getline(1, '$'))
+  close!
+endfunc
+
+" Test for the 'r' flag in 'comments' (right align comment)
+func Test_comment_rightalign()
+  new
+  setlocal comments=sr:/***,m:**,ex-2:******/ fo+=ro
+  exe "normal i=\<C-C>o\t  /***\nD\n/"
+  exe "normal 2GOA\<C-C>joB\<C-C>jOC\<C-C>joE\<C-C>GOF\<C-C>joG"
+  let expected =<< trim END
+    =
+    A
+    	  /***
+    	    ** B
+    	    ** C
+    	    ** D
+    	    ** E
+    	    **     F
+    	    ******/
+    G
+  END
+  call assert_equal(expected, getline(1, '$'))
+  close!
+endfunc
+
+" Test for the 'O' flag in 'comments'
+func Test_comment_O()
+  new
+  setlocal comments=Ob:* fo+=ro
+  exe "normal i* B\nD\<C-C>kOA\<C-C>joC"
+  let expected =<< trim END
+    A
+    * B
+    * C
+    * D
+  END
+  call assert_equal(expected, getline(1, '$'))
+  close!
+endfunc
+
+" Test for using a multibyte character as a comment leader
+func Test_comment_multibyte_leader()
+  new
+  let t =<< trim END
+    {
+    X
+    Xa
+    XaY
+    XY
+    XYZ
+    X Y
+    X YZ
+    XX
+    XXa
+    XXY
+    }
+  END
+  call setline(1, t)
+  call cursor(2, 1)
+
+  set tw=2 fo=cqm comments=n:X
+  exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
+  let t =<< trim END
+    X
+    Xa
+    XaY
+    XY
+    XYZ
+    X Y
+    X YZ
+    XX
+    XXa
+    XXY
+  END
+  exe "normal o\n" . join(t, "\n")
+
+  let expected =<< trim END
+    {
+    X
+    Xa
+    Xa
+    XY
+    XY
+    XY
+    XZ
+    X Y
+    X Y
+    X Z
+    XX
+    XXa
+    XXY
+
+    X
+    Xa
+    Xa
+    XY
+    XY
+    XY
+    XZ
+    X Y
+    X Y
+    X Z
+    XX
+    XXa
+    XXY
+    }
+  END
+  call assert_equal(expected, getline(1, '$'))
+
+  set tw& fo& comments&
+  close!
+endfunc
+
+" Test for a space character in 'comments' setting
+func Test_comment_space()
+  new
+  setlocal comments=b:\ > fo+=ro
+  exe "normal i> B\nD\<C-C>ggOA\<C-C>joC"
+  exe "normal Go > F\nH\<C-C>kOE\<C-C>joG"
+  let expected =<< trim END
+    A
+    > B
+    C
+    D
+     > E
+     > F
+     > G
+     > H
+  END
+  call assert_equal(expected, getline(1, '$'))
+  close!
+endfunc
+
+" Test for formatting lines with and without comments
+func Test_comment_format_lines()
+  new
+  call setline(1, ['one', '/* two */', 'three'])
+  normal gggqG
+  call assert_equal(['one', '/* two */', 'three'], getline(1, '$'))
+  close!
+endfunc
+
+" Test for using 'a' in 'formatoptions' with comments
+func Test_comment_autoformat()
+  new
+  setlocal formatoptions+=a
+  call feedkeys("a- one\n- two\n", 'xt')
+  call assert_equal(['- one', '- two', ''], getline(1, '$'))
+
+  %d
+  call feedkeys("a\none\n", 'xt')
+  call assert_equal(['', 'one', ''], getline(1, '$'))
+
+  setlocal formatoptions+=aw
+  %d
+  call feedkeys("aone \ntwo\n", 'xt')
+  call assert_equal(['one two', ''], getline(1, '$'))
+
+  %d
+  call feedkeys("aone\ntwo\n", 'xt')
+  call assert_equal(['one', 'two', ''], getline(1, '$'))
+
+  close!
+endfunc
+
+" Test for joining lines with comments ('j' flag in 'formatoptions')
+func Test_comment_join_lines_fo_j()
+  new
+  setlocal fo+=j comments=://
+  call setline(1, ['i++; // comment1', '           // comment2'])
+  normal J
+  call assert_equal('i++; // comment1 comment2', getline(1))
+  setlocal fo-=j
+  call setline(1, ['i++; // comment1', '           // comment2'])
+  normal J
+  call assert_equal('i++; // comment1 // comment2', getline(1))
+  " Test with nested comments
+  setlocal fo+=j comments=n:>,n:)
+  call setline(1, ['i++; > ) > ) comment1', '           > ) comment2'])
+  normal J
+  call assert_equal('i++; > ) > ) comment1 comment2', getline(1))
+  close!
+endfunc
+
+" Test for formatting lines where only the first line has a comment.
+func Test_comment_format_firstline_comment()
+  new
+  setlocal formatoptions=tcq
+  call setline(1, ['- one two', 'three'])
+  normal gggqG
+  call assert_equal(['- one two three'], getline(1, '$'))
+
+  %d
+  call setline(1, ['- one', '- two'])
+  normal gggqG
+  call assert_equal(['- one', '- two'], getline(1, '$'))
+  close!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -1267,6 +1267,7 @@ func Test_normal21_nv_hat()
   edit Xfoo | %bw
   call assert_fails(':buffer #', 'E86')
   call assert_fails(':execute "normal! \<C-^>"', 'E23')
+  call assert_fails("normal i\<C-R>#", 'E23:')
 
   " Test for the expected behavior when switching between two named buffers.
   edit Xfoo | edit Xbar
--- a/src/testdir/test_textformat.vim
+++ b/src/testdir/test_textformat.vim
@@ -784,78 +784,6 @@ func Test_tw_2_fo_tm_noai()
   bwipe!
 endfunc
 
-func Test_tw_2_fo_cqm_com()
-  new
-  let t =<< trim END
-    {
-    X
-    Xa
-    XaY
-    XY
-    XYZ
-    X Y
-    X YZ
-    XX
-    XXa
-    XXY
-    }
-  END
-  call setline(1, t)
-  call cursor(2, 1)
-
-  set tw=2 fo=cqm comments=n:X
-  exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
-  let t =<< trim END
-    X
-    Xa
-    XaY
-    XY
-    XYZ
-    X Y
-    X YZ
-    XX
-    XXa
-    XXY
-  END
-  exe "normal o\n" . join(t, "\n")
-
-  let expected =<< trim END
-    {
-    X
-    Xa
-    Xa
-    XY
-    XY
-    XY
-    XZ
-    X Y
-    X Y
-    X Z
-    XX
-    XXa
-    XXY
-
-    X
-    Xa
-    Xa
-    XY
-    XY
-    XY
-    XZ
-    X Y
-    X Y
-    X Z
-    XX
-    XXa
-    XXY
-    }
-  END
-  call assert_equal(expected, getline(1, '$'))
-
-  set tw& fo& comments&
-  bwipe!
-endfunc
-
 func Test_tw_2_fo_tm_replace()
   new
   let t =<< trim END
@@ -975,140 +903,6 @@ func Test_whichwrap_multi_byte()
   bwipe!
 endfunc
 
-" Test for automatically adding comment leaders in insert mode
-func Test_threepiece_comment()
-  new
-  setlocal expandtab
-  call setline(1, ["\t/*"])
-  setlocal formatoptions=croql
-  call cursor(1, 3)
-  call feedkeys("A\<cr>\<cr>/", 'tnix')
-  call assert_equal(["\t/*", " *", " */"], getline(1, '$'))
-
-  " If a comment ends in a single line, then don't add it in the next line
-  %d
-  call setline(1, '/* line1 */')
-  call feedkeys("A\<CR>next line", 'xt')
-  call assert_equal(['/* line1 */', 'next line'], getline(1, '$'))
-
-  %d
-  " Copy the trailing indentation from the leader comment to a new line
-  setlocal autoindent noexpandtab
-  call feedkeys("a\t/*\tone\ntwo\n/", 'xt')
-  call assert_equal(["\t/*\tone", "\t *\ttwo", "\t */"], getline(1, '$'))
-  close!
-endfunc
-
-" Test for the 'f' flag in 'comments' (only the first line has the comment
-" string)
-func Test_firstline_comment()
-  new
-  setlocal comments=f:- fo+=ro
-  exe "normal i- B\nD\<C-C>ggoC\<C-C>ggOA\<C-C>"
-  call assert_equal(['A', '- B', '  C', '  D'], getline(1, '$'))
-  %d
-  setlocal comments=:-
-  exe "normal i- B\nD\<C-C>ggoC\<C-C>ggOA\<C-C>"
-  call assert_equal(['- A', '- B', '- C', '- D'], getline(1, '$'))
-  %bw!
-endfunc
-
-" Test for the 'r' flag in 'comments' (right align comment)
-func Test_comment_rightalign()
-  new
-  setlocal comments=sr:/***,m:**,ex-2:******/ fo+=ro
-  exe "normal i=\<C-C>o\t  /***\nD\n/"
-  exe "normal 2GOA\<C-C>joB\<C-C>jOC\<C-C>joE\<C-C>GOF\<C-C>joG"
-  let expected =<< trim END
-    =
-    A
-    	  /***
-    	    ** B
-    	    ** C
-    	    ** D
-    	    ** E
-    	    **     F
-    	    ******/
-    G
-  END
-  call assert_equal(expected, getline(1, '$'))
-  %bw!
-endfunc
-
-" Test for the 'b' flag in 'comments'
-func Test_comment_blank()
-  new
-  setlocal comments=b:* fo+=ro
-  exe "normal i* E\nF\n\<BS>G\nH\<C-C>ggOC\<C-C>O\<BS>B\<C-C>OA\<C-C>2joD"
-  let expected =<< trim END
-    A
-    *B
-    * C
-    * D
-    * E
-    * F
-    *G
-    H
-  END
-  call assert_equal(expected, getline(1, '$'))
-  %bw!
-endfunc
-
-" Test for the 'n' flag in comments
-func Test_comment_nested()
-  new
-  setlocal comments=n:> fo+=ro
-  exe "normal i> B\nD\<C-C>ggOA\<C-C>joC\<C-C>Go\<BS>>>> F\nH"
-  exe "normal 5GOE\<C-C>6GoG"
-  let expected =<< trim END
-    > A
-    > B
-    > C
-    > D
-    >>>> E
-    >>>> F
-    >>>> G
-    >>>> H
-  END
-  call assert_equal(expected, getline(1, '$'))
-  %bw!
-endfunc
-
-" Test for a space character in 'comments' setting
-func Test_comment_space()
-  new
-  setlocal comments=b:\ > fo+=ro
-  exe "normal i> B\nD\<C-C>ggOA\<C-C>joC"
-  exe "normal Go > F\nH\<C-C>kOE\<C-C>joG"
-  let expected =<< trim END
-    A
-    > B
-    C
-    D
-     > E
-     > F
-     > G
-     > H
-  END
-  call assert_equal(expected, getline(1, '$'))
-  %bw!
-endfunc
-
-" Test for the 'O' flag in 'comments'
-func Test_comment_O()
-  new
-  setlocal comments=Ob:* fo+=ro
-  exe "normal i* B\nD\<C-C>kOA\<C-C>joC"
-  let expected =<< trim END
-    A
-    * B
-    * C
-    * D
-  END
-  call assert_equal(expected, getline(1, '$'))
-  %bw!
-endfunc
-
 " Test for 'a' and 'w' flags in 'formatoptions'
 func Test_fo_a_w()
   new
@@ -1143,25 +937,6 @@ func Test_fo_a_w()
   %bw!
 endfunc
 
-" Test for 'j' flag in 'formatoptions'
-func Test_fo_j()
-  new
-  setlocal fo+=j comments=://
-  call setline(1, ['i++; // comment1', '           // comment2'])
-  normal J
-  call assert_equal('i++; // comment1 comment2', getline(1))
-  setlocal fo-=j
-  call setline(1, ['i++; // comment1', '           // comment2'])
-  normal J
-  call assert_equal('i++; // comment1 // comment2', getline(1))
-  " Test with nested comments
-  setlocal fo+=j comments=n:>,n:)
-  call setline(1, ['i++; > ) > ) comment1', '           > ) comment2'])
-  normal J
-  call assert_equal('i++; > ) > ) comment1 comment2', getline(1))
-  %bw!
-endfunc
-
 " Test for formatting lines using gq in visual mode
 func Test_visual_gq_format()
   new
@@ -1296,51 +1071,4 @@ func Test_fo_2()
   close!
 endfunc
 
-" Test for formatting lines where only the first line has a comment.
-func Test_fo_gq_with_firstline_comment()
-  new
-  setlocal formatoptions=tcq
-  call setline(1, ['- one two', 'three'])
-  normal gggqG
-  call assert_equal(['- one two three'], getline(1, '$'))
-
-  %d
-  call setline(1, ['- one', '- two'])
-  normal gggqG
-  call assert_equal(['- one', '- two'], getline(1, '$'))
-  close!
-endfunc
-
-" Test for trying to join a comment line with a non-comment line
-func Test_join_comments()
-  new
-  call setline(1, ['one', '/* two */', 'three'])
-  normal gggqG
-  call assert_equal(['one', '/* two */', 'three'], getline(1, '$'))
-  close!
-endfunc
-
-" Test for using 'a' in 'formatoptions' with comments
-func Test_autoformat_comments()
-  new
-  setlocal formatoptions+=a
-  call feedkeys("a- one\n- two\n", 'xt')
-  call assert_equal(['- one', '- two', ''], getline(1, '$'))
-
-  %d
-  call feedkeys("a\none\n", 'xt')
-  call assert_equal(['', 'one', ''], getline(1, '$'))
-
-  setlocal formatoptions+=aw
-  %d
-  call feedkeys("aone \ntwo\n", 'xt')
-  call assert_equal(['one two', ''], getline(1, '$'))
-
-  %d
-  call feedkeys("aone\ntwo\n", 'xt')
-  call assert_equal(['one', 'two', ''], getline(1, '$'))
-
-  close!
-endfunc
-
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1046,
+/**/
     1045,
 /**/
     1044,