Skip to content

Commit 1f448d9

Browse files
committed
patch 8.2.2643: various code not covered by tests
Problem: Various code not covered by tests. Solution: Add a few more test. (Yegappan Lakshmanan, closes #7995)
1 parent e98f60a commit 1f448d9

File tree

6 files changed

+83
-1
lines changed

6 files changed

+83
-1
lines changed

src/testdir/test_edit.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,33 @@ func Test_edit_13()
411411
bwipe!
412412
endfunc
413413

414+
" Test for autoindent removing indent when insert mode is stopped. Some parts
415+
" of the code is exercised only when interactive mode is used. So use Vim in a
416+
" terminal.
417+
func Test_autoindent_remove_indent()
418+
CheckRunVimInTerminal
419+
let buf = RunVimInTerminal('-N Xfile', {'rows': 6, 'cols' : 20})
420+
call TermWait(buf)
421+
call term_sendkeys(buf, ":set autoindent\n")
422+
" leaving insert mode in a new line with indent added by autoindent, should
423+
" remove the indent.
424+
call term_sendkeys(buf, "i\<Tab>foo\<CR>\<Esc>")
425+
" Need to delay for sometime, otherwise the code in getchar.c will not be
426+
" exercised.
427+
call TermWait(buf, 50)
428+
" when a line is wrapped and the cursor is at the start of the second line,
429+
" leaving insert mode, should move the cursor back to the first line.
430+
call term_sendkeys(buf, "o" .. repeat('x', 20) .. "\<Esc>")
431+
" Need to delay for sometime, otherwise the code in getchar.c will not be
432+
" exercised.
433+
call TermWait(buf, 50)
434+
call term_sendkeys(buf, ":w\n")
435+
call TermWait(buf)
436+
call StopVimInTerminal(buf)
437+
call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xfile'))
438+
call delete('Xfile')
439+
endfunc
440+
414441
func Test_edit_CR()
415442
" Test for <CR> in insert mode
416443
" basically only in quickfix mode ist tested, the rest

src/testdir/test_functions.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ func Test_input_func()
14311431
call assert_equal('item1 item2 item3', c)
14321432

14331433
" Test for using special characters as default input
1434-
call feedkeys(":let c = input('name? ', \"x\<BS>y\")\<CR>\<CR>", 'xt')
1434+
call feedkeys(":let c = input('name? ', \"x\\<BS>y\")\<CR>\<CR>", 'xt')
14351435
call assert_equal('y', c)
14361436

14371437
" Test for using <CR> as default input

src/testdir/test_mapping.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,4 +1389,14 @@ func Test_map_cmdkey_redo()
13891389
ounmap i-
13901390
endfunc
13911391

1392+
" Test for using <script> with a map to remap characters in rhs
1393+
func Test_script_local_remap()
1394+
new
1395+
inoremap <buffer> <SID>xyz mno
1396+
inoremap <buffer> <script> abc st<SID>xyzre
1397+
normal iabc
1398+
call assert_equal('stmnore', getline(1))
1399+
bwipe!
1400+
endfunc
1401+
13921402
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_termcodes.vim

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,4 +2314,38 @@ func Test_Keycode_Translation()
23142314
endfor
23152315
endfunc
23162316

2317+
" Test for terminal keycodes that doesn't have termcap entries
2318+
func Test_special_term_keycodes()
2319+
new
2320+
" Test for <xHome>, <S-xHome> and <C-xHome>
2321+
" send <K_SPECIAL> <KS_EXTRA> keycode
2322+
call feedkeys("i\<C-K>\x80\xfd\x3f\n", 'xt')
2323+
" send <K_SPECIAL> <KS_MODIFIER> bitmap <K_SPECIAL> <KS_EXTRA> keycode
2324+
call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3f\n", 'xt')
2325+
call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3f\n", 'xt')
2326+
" Test for <xEnd>, <S-xEnd> and <C-xEnd>
2327+
call feedkeys("i\<C-K>\x80\xfd\x3d\n", 'xt')
2328+
call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3d\n", 'xt')
2329+
call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3d\n", 'xt')
2330+
" Test for <zHome>, <S-zHome> and <C-zHome>
2331+
call feedkeys("i\<C-K>\x80\xfd\x40\n", 'xt')
2332+
call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x40\n", 'xt')
2333+
call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x40\n", 'xt')
2334+
" Test for <zEnd>, <S-zEnd> and <C-zEnd>
2335+
call feedkeys("i\<C-K>\x80\xfd\x3e\n", 'xt')
2336+
call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3e\n", 'xt')
2337+
call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3e\n", 'xt')
2338+
" Test for <xUp>, <xDown>, <xLeft> and <xRight>
2339+
call feedkeys("i\<C-K>\x80\xfd\x41\n", 'xt')
2340+
call feedkeys("i\<C-K>\x80\xfd\x42\n", 'xt')
2341+
call feedkeys("i\<C-K>\x80\xfd\x43\n", 'xt')
2342+
call feedkeys("i\<C-K>\x80\xfd\x44\n", 'xt')
2343+
call assert_equal(['<Home>', '<S-Home>', '<C-Home>',
2344+
\ '<End>', '<S-End>', '<C-End>',
2345+
\ '<Home>', '<S-Home>', '<C-Home>',
2346+
\ '<End>', '<S-End>', '<C-End>',
2347+
\ '<Up>', '<Down>', '<Left>', '<Right>', ''], getline(1, '$'))
2348+
bw!
2349+
endfunc
2350+
23172351
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_undo.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,4 +747,13 @@ func Test_redo_repeat_numbered_register()
747747
bwipe!
748748
endfunc
749749

750+
" Test for redo in insert mode using CTRL-O with multibyte characters
751+
func Test_redo_multibyte_in_insert_mode()
752+
new
753+
call feedkeys("a\<C-K>ft", 'xt')
754+
call feedkeys("uiHe\<C-O>.llo", 'xt')
755+
call assert_equal("He\ufb05llo", getline(1))
756+
bwipe!
757+
endfunc
758+
750759
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2643,
753755
/**/
754756
2642,
755757
/**/

0 commit comments

Comments
 (0)