Patch 8.2.0698
Problem: Insert mode completion not fully tested.
Solution: Add a few more tests. (Yegappan Lakshmanan, closes #6041)
Files: src/testdir/test_edit.vim, src/testdir/test_ins_complete.vim,
src/testdir/test_textformat.vim
*** ../vim-8.2.0697/src/testdir/test_edit.vim 2020-04-30 22:29:36.626024141
+0200
--- src/testdir/test_edit.vim 2020-05-05 19:55:16.083782457 +0200
***************
*** 328,335 ****
bw!
endfunc
func Test_edit_12()
- " Test changing indent in replace mode
new
call setline(1, ["\tabc", "\tdef"])
call cursor(2, 4)
--- 328,335 ----
bw!
endfunc
+ " Test changing indent in replace mode
func Test_edit_12()
new
call setline(1, ["\tabc", "\tdef"])
call cursor(2, 4)
***************
*** 368,382 ****
call feedkeys("R\<c-t>\<c-t>", 'tnix')
call assert_equal(["\tabc", "\t\t\tdef"], getline(1, '$'))
call assert_equal([0, 2, 2, 0], getpos('.'))
! set et
! set sw& et&
%d
! call setline(1, ["\t/*"])
! set formatoptions=croql
! call cursor(1, 3)
! call feedkeys("A\<cr>\<cr>/", 'tnix')
! call assert_equal(["\t/*", " *", " */"], getline(1, '$'))
! set formatoptions&
bw!
endfunc
--- 368,382 ----
call feedkeys("R\<c-t>\<c-t>", 'tnix')
call assert_equal(["\tabc", "\t\t\tdef"], getline(1, '$'))
call assert_equal([0, 2, 2, 0], getpos('.'))
! set sw&
!
! " In replace mode, after hitting enter in a line with tab characters,
! " pressing backspace should restore the tab characters.
%d
! setlocal autoindent backspace=2
! call setline(1, "\tone\t\ttwo")
! exe "normal ggRred\<CR>six" .. repeat("\<BS>", 8)
! call assert_equal(["\tone\t\ttwo"], getline(1, '$'))
bw!
endfunc
*** ../vim-8.2.0697/src/testdir/test_ins_complete.vim 2020-04-30
22:29:36.626024141 +0200
--- src/testdir/test_ins_complete.vim 2020-05-05 19:55:16.083782457 +0200
***************
*** 493,504 ****
--- 493,535 ----
call setline(1, ['', 'abcd', ''])
call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E578:')
+ " Jump to a different window from the complete function
+ " TODO: The following test causes an ASAN failure. Once this issue is
+ " addressed, enable the following test.
+ "func! CompleteFunc(findstart, base)
+ " if a:findstart == 1
+ " return col('.') - 1
+ " endif
+ " wincmd p
+ " return ['a', 'b']
+ "endfunc
+ "set completefunc=CompleteFunc
+ "new
+ "call assert_fails('exe "normal a\<C-X>\<C-U>"', 'E839:')
+ "close!
+
set completefunc&
delfunc CompleteFunc
delfunc CompleteFunc2
close!
endfunc
+ " Test for returning non-string values from 'completefunc'
+ func Test_completefunc_invalid_data()
+ new
+ func! CompleteFunc(findstart, base)
+ if a:findstart == 1
+ return col('.') - 1
+ endif
+ return [{}, '', 'moon']
+ endfunc
+ set completefunc=CompleteFunc
+ exe "normal i\<C-X>\<C-U>"
+ call assert_equal('moon', getline(1))
+ set completefunc&
+ close!
+ endfunc
+
" Test for errors in using complete() function
func Test_complete_func_error()
call assert_fails('call complete(1, ["a"])', 'E785:')
***************
*** 513,518 ****
--- 544,550 ----
delfunc ListColors
delfunc ListMonths
call assert_fails('call complete_info({})', 'E714:')
+ call assert_equal([], complete_info(['items']).items)
endfunc
" Test for completing words following a completed word in a line
***************
*** 535,538 ****
--- 567,637 ----
close!
endfunc
+ " Test for completing special characters
+ func Test_complete_special_chars()
+ new
+ call setline(1, 'int .*[-\^$ func float')
+ call feedkeys("oin\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>", 'xt')
+ call assert_equal('int .*[-\^$ func float', getline(2))
+ close!
+ endfunc
+
+ " Test for completion when text is wrapped across lines.
+ func Test_complete_across_line()
+ new
+ call setline(1, ['red green blue', 'one two three'])
+ setlocal textwidth=20
+ exe "normal 2G$a re\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>"
+ call assert_equal(['one two three red', 'green blue one'], getline(2, '$'))
+ close!
+ endfunc
+
+ " Test for using CTRL-L to add one character when completing matching
+ func Test_complete_add_onechar()
+ new
+ call setline(1, ['wool', 'woodwork'])
+ call feedkeys("Gowoo\<C-P>\<C-P>\<C-P>\<C-L>f", 'xt')
+ call assert_equal('woof', getline(3))
+
+ " use 'ignorecase' and backspace to erase characters from the prefix string
+ " and then add letters using CTRL-L
+ %d
+ set ignorecase backspace=2
+ setlocal complete=.
+ call setline(1, ['workhorse', 'workload'])
+ normal Go
+ exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>r\<C-L>\<C-L>"
+ call assert_equal('workh', getline(3))
+ set ignorecase& backspace&
+ close!
+ endfunc
+
+ " Test insert completion with 'cindent' (adjust the indent)
+ func Test_complete_with_cindent()
+ new
+ setlocal cindent
+ call setline(1, ['if (i == 1)', " j = 2;"])
+ exe "normal Go{\<CR>i\<C-X>\<C-L>\<C-X>\<C-L>\<CR>}"
+ call assert_equal(['{', "\tif (i == 1)", "\t\tj = 2;", '}'], getline(3,
'$'))
+
+ %d
+ call setline(1, ['when while', '{', ''])
+ setlocal cinkeys+==while
+ exe "normal Giwh\<C-P> "
+ call assert_equal("\twhile ", getline('$'))
+ close!
+ endfunc
+
+ " Test for <CTRL-X> <CTRL-V> completion. Complete commands and functions
+ func Test_complete_cmdline()
+ new
+ exe "normal icaddb\<C-X>\<C-V>"
+ call assert_equal('caddbuffer', getline(1))
+ exe "normal ocall getqf\<C-X>\<C-V>"
+ call assert_equal('call getqflist(', getline(2))
+ exe "normal oabcxyz(\<C-X>\<C-V>"
+ call assert_equal('abcxyz(', getline(3))
+ close!
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0697/src/testdir/test_textformat.vim 2020-05-03
16:04:39.605557874 +0200
--- src/testdir/test_textformat.vim 2020-05-05 19:55:16.083782457 +0200
***************
*** 975,980 ****
--- 975,1004 ----
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()
*** ../vim-8.2.0697/src/version.c 2020-05-05 19:46:16.653307561 +0200
--- src/version.c 2020-05-05 19:56:30.547548451 +0200
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 698,
/**/
--
hundred-and-one symptoms of being an internet addict:
49. You never have to deal with busy signals when calling your ISP...because
you never log off.
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202005051757.045HvsJF011854%40masaka.moolenaar.net.