diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-03-10 07:48:13 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-03-10 07:48:13 +0100 |
commit | 1671f4488105ee12a6a8558ae351436c26ab55fc (patch) | |
tree | 2e6bd3ba9c7cb5a443d97c03bc82046ff3ce087c /src/testdir | |
parent | 5269bd2a724fdb8c16c9635ef744a670f1bc8bd5 (diff) |
patch 8.2.0369: various Normal mode commands not fully testedv8.2.0369
Problem: Various Normal mode commands not fully tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes #5751)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_arglist.vim | 5 | ||||
-rw-r--r-- | src/testdir/test_changelist.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_charsearch.vim | 14 | ||||
-rw-r--r-- | src/testdir/test_cmdline.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_edit.vim | 44 | ||||
-rw-r--r-- | src/testdir/test_ex_mode.vim | 13 | ||||
-rw-r--r-- | src/testdir/test_excmd.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_gf.vim | 15 | ||||
-rw-r--r-- | src/testdir/test_iminsert.vim | 20 | ||||
-rw-r--r-- | src/testdir/test_increment.vim | 8 | ||||
-rw-r--r-- | src/testdir/test_marks.vim | 24 | ||||
-rw-r--r-- | src/testdir/test_normal.vim | 245 | ||||
-rw-r--r-- | src/testdir/test_prompt_buffer.vim | 10 | ||||
-rw-r--r-- | src/testdir/test_put.vim | 12 | ||||
-rw-r--r-- | src/testdir/test_registers.vim | 3 | ||||
-rw-r--r-- | src/testdir/test_tagjump.vim | 33 | ||||
-rw-r--r-- | src/testdir/test_visual.vim | 34 |
17 files changed, 440 insertions, 50 deletions
diff --git a/src/testdir/test_arglist.vim b/src/testdir/test_arglist.vim index a3921c1808..d73a3ccc27 100644 --- a/src/testdir/test_arglist.vim +++ b/src/testdir/test_arglist.vim @@ -539,6 +539,11 @@ func Test_quit_with_arglist() call term_wait(buf) call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))}) only! + " When this test fails, swap files are left behind which breaks subsequent + " tests + call delete('.a.swp') + call delete('.b.swp') + call delete('.c.swp') endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_changelist.vim b/src/testdir/test_changelist.vim index ce77c1f3c7..3741f32e69 100644 --- a/src/testdir/test_changelist.vim +++ b/src/testdir/test_changelist.vim @@ -46,3 +46,5 @@ func Test_getchangelist() call delete('Xfile1.txt') call delete('Xfile2.txt') endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_charsearch.vim b/src/testdir/test_charsearch.vim index 6f09e85a42..683bcabe34 100644 --- a/src/testdir/test_charsearch.vim +++ b/src/testdir/test_charsearch.vim @@ -1,3 +1,4 @@ +" Test for character search commands - t, T, f, F, ; and , func Test_charsearch() enew! @@ -60,3 +61,16 @@ func Test_search_cmds() call assert_equal('ddd yee y', getline(6)) enew! endfunc + +" Test for character search in virtual edit mode with <Tab> +func Test_csearch_virtualedit() + new + set virtualedit=all + call setline(1, "a\tb") + normal! tb + call assert_equal([0, 1, 2, 6], getpos('.')) + set virtualedit& + close! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 610f91e8b3..28bab7b70b 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -957,6 +957,10 @@ endfunc func Test_cmdwin_feedkeys() " This should not generate E488 call feedkeys("q:\<CR>", 'x') + " Using feedkeys with q: only should automatically close the cmd window + call feedkeys('q:', 'xt') + call assert_equal(1, winnr('$')) + call assert_equal('', getcmdwintype()) endfunc " Tests for the issues fixed in 7.4.441. diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index 9d2d0f34ac..b2d41990fc 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -281,7 +281,7 @@ func Test_edit_11() call cursor(2, 1) call feedkeys("i\<c-f>int c;\<esc>", 'tnix') call cursor(3, 1) - call feedkeys("i/* comment */", 'tnix') + call feedkeys("\<Insert>/* comment */", 'tnix') call assert_equal(['{', "\<tab>int c;", "/* comment */"], getline(1, '$')) " added changed cindentkeys slightly set cindent cinkeys+=*/ @@ -1267,16 +1267,6 @@ func Test_edit_forbidden() catch /^Vim\%((\a\+)\)\=:E117/ " catch E117: unknown function endtry au! InsertCharPre - " Not allowed to enter ex mode when text is locked - au InsertCharPre <buffer> :normal! gQ<CR> - let caught_e523 = 0 - try - call feedkeys("ix\<esc>", 'xt') - catch /^Vim\%((\a\+)\)\=:E523/ " catch E523 - let caught_e523 = 1 - endtry - call assert_equal(1, caught_e523) - au! InsertCharPre " 3) edit when completion is shown fun! Complete(findstart, base) if a:findstart @@ -1550,4 +1540,36 @@ func Test_edit_noesckeys() set esckeys endfunc +" Test for running an invalid ex command in insert mode using CTRL-O +" Note that vim has a hard-coded sleep of 3 seconds. So this test will take +" more than 3 seconds to complete. +func Test_edit_ctrl_o_invalid_cmd() + new + set showmode showcmd + let caught_e492 = 0 + try + call feedkeys("i\<C-O>:invalid\<CR>abc\<Esc>", "xt") + catch /E492:/ + let caught_e492 = 1 + endtry + call assert_equal(1, caught_e492) + call assert_equal('abc', getline(1)) + set showmode& showcmd& + close! +endfunc + +" Test for inserting text at the beginning of a line +func Test_insert_before_first_nonblank() + new + call setline(1, ' ') + normal! Ia + call assert_equal(' a', getline(1)) + set cpo+=H + call setline(1, ' ') + normal! Ia + call assert_equal(' a ', getline(1)) + set cpo-=H + close! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim index 95144dde39..e50e6a57ff 100644 --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -158,4 +158,17 @@ func Test_Ex_echo_backslash() \ "E15: Invalid expression: \\\nm") endfunc +func Test_ex_mode_errors() + " Not allowed to enter ex mode when text is locked + au InsertCharPre <buffer> normal! gQ<CR> + let caught_e523 = 0 + try + call feedkeys("ix\<esc>", 'xt') + catch /^Vim\%((\a\+)\)\=:E523/ " catch E523 + let caught_e523 = 1 + endtry + call assert_equal(1, caught_e523) + au! InsertCharPre +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim index c594548647..a0645e8957 100644 --- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -57,6 +57,10 @@ func Test_copy() 1,3copy 2 call assert_equal(['L1', 'L2', 'L1', 'L2', 'L3', 'L3', 'L4'], getline(1, 7)) + " Specifying a count before using : to run an ex-command + exe "normal! gg4:yank\<CR>" + call assert_equal("L1\nL2\nL1\nL2\n", @") + close! endfunc diff --git a/src/testdir/test_gf.vim b/src/testdir/test_gf.vim index 4a4ffcefa1..829b7c2992 100644 --- a/src/testdir/test_gf.vim +++ b/src/testdir/test_gf.vim @@ -130,5 +130,20 @@ func Test_gf_error() call setline(1, '/doesnotexist') call assert_fails('normal gf', 'E447:') call assert_fails('normal gF', 'E447:') + call assert_fails('normal [f', 'E447:') + + " gf is not allowed when text is locked + au InsertCharPre <buffer> normal! gF<CR> + let caught_e523 = 0 + try + call feedkeys("ix\<esc>", 'xt') + catch /^Vim\%((\a\+)\)\=:E523/ " catch E523 + let caught_e523 = 1 + endtry + call assert_equal(1, caught_e523) + au! InsertCharPre + bwipe! endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_iminsert.vim b/src/testdir/test_iminsert.vim index 1880662af2..d49cd07cca 100644 --- a/src/testdir/test_iminsert.vim +++ b/src/testdir/test_iminsert.vim @@ -63,4 +63,24 @@ func Test_getimstatus() set imstatusfunc= endfunc +" Test for using an lmap in insert mode +func Test_lmap_in_insert_mode() + new + call setline(1, 'abc') + lmap { w + set iminsert=1 + call feedkeys('r{', 'xt') + call assert_equal('wbc', getline(1)) + set iminsert=2 + call feedkeys('$r{', 'xt') + call assert_equal('wb{', getline(1)) + call setline(1, 'vim web') + set iminsert=1 + call feedkeys('0f{', 'xt') + call assert_equal(5, col('.')) + set iminsert& + lunmap { + close! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_increment.vim b/src/testdir/test_increment.vim index ad355dce9b..4aa7adf200 100644 --- a/src/testdir/test_increment.vim +++ b/src/testdir/test_increment.vim @@ -775,6 +775,14 @@ func Test_increment_empty_line() call setline(1, ['0', '0', '0', '0', '0', '0', '']) exe "normal Gvgg\<C-A>" call assert_equal(['1', '1', '1', '1', '1', '1', ''], getline(1, 7)) + + " Ctrl-A/Ctrl-X should do nothing in operator pending mode + %d + call setline(1, 'one two') + exe "normal! c\<C-A>l" + exe "normal! c\<C-X>l" + call assert_equal('one two', getline(1)) + bwipe! endfunc diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim index 24c8a41711..360d1f31e2 100644 --- a/src/testdir/test_marks.vim +++ b/src/testdir/test_marks.vim @@ -195,6 +195,7 @@ func Test_mark_error() call assert_fails('mark', 'E471:') call assert_fails('mark xx', 'E488:') call assert_fails('mark _', 'E191:') + call assert_beeps('normal! m~') endfunc " Test for :lockmarks when pasting content @@ -221,4 +222,27 @@ func Test_marks_k_cmd() close! endfunc +" Test for file marks (A-Z) +func Test_file_mark() + new Xone + call setline(1, ['aaa', 'bbb']) + norm! G$mB + w! + new Xtwo + call setline(1, ['ccc', 'ddd']) + norm! GmD + w! + + enew + normal! `B + call assert_equal('Xone', bufname()) + call assert_equal([2, 3], [line('.'), col('.')]) + normal! 'D + call assert_equal('Xtwo', bufname()) + call assert_equal([2, 1], [line('.'), col('.')]) + + call delete('Xone') + call delete('Xtwo') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 6c2c6296c6..85edddf2cb 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -54,7 +54,7 @@ func OpfuncDummy(type, ...) let g:bufnr=bufnr('%') endfunc -fun! Test_normal00_optrans() +func Test_normal00_optrans() new call append(0, ['1 This is a simple test: abcd', '2 This is the second line', '3 this is the third line']) 1 @@ -95,6 +95,12 @@ func Test_normal01_keymodel() 50 call feedkeys("\<S-Up>y", 'tx') call assert_equal(['49', '5'], getreg(0, 0, 1)) + " Use the different Shift special keys + 50 + call feedkeys("\<S-Right>\<S-Left>\<S-Up>\<S-Down>\<S-Home>\<S-End>y", 'tx') + call assert_equal(['50'], getline("'<", "'>")) + call assert_equal(['50', ''], getreg(0, 0, 1)) + " Do not start visual mode when keymodel= set keymodel= 50 @@ -434,8 +440,8 @@ func Test_normal11_showcmd() bw! endfunc +" Test for nv_error and normal command errors func Test_normal12_nv_error() - " Test for nv_error 10new call setline(1, range(1,5)) " should not do anything, just beep @@ -445,6 +451,22 @@ func Test_normal12_nv_error() call assert_beeps("normal! g\<C-A>") call assert_beeps("normal! g\<C-X>") call assert_beeps("normal! g\<C-B>") + call assert_beeps("normal! vQ\<Esc>") + call assert_beeps("normal! 2[[") + call assert_beeps("normal! 2]]") + call assert_beeps("normal! 2[]") + call assert_beeps("normal! 2][") + call assert_beeps("normal! 4[z") + call assert_beeps("normal! 4]z") + call assert_beeps("normal! 4[c") + call assert_beeps("normal! 4]c") + call assert_beeps("normal! 200%") + call assert_beeps("normal! %") + call assert_beeps("normal! 2{") + call assert_beeps("normal! 2}") + call assert_beeps("normal! r\<Right>") + call assert_beeps("normal! 8ry") + call assert_beeps('normal! "@') bw! endfunc @@ -500,6 +522,12 @@ func Test_normal14_page_eol() bw! endfunc +" Test for errors with z command +func Test_normal_z_error() + call assert_beeps('normal! z2p') + call assert_beeps('normal! zp') +endfunc + func Test_normal15_z_scroll_vert() " basic test for z commands that scroll the window call Setup_NewWindow() @@ -600,6 +628,13 @@ func Test_normal16_z_scroll_hor() $put =lineB 1d + " Test for zl and zh with a count + norm! 0z10l + call assert_equal([11, 1], [col('.'), wincol()]) + norm! z4h + call assert_equal([11, 5], [col('.'), wincol()]) + normal! 2gg + " Test for zl 1 norm! 5zl @@ -722,6 +757,27 @@ func Test_normal17_z_scroll_hor2() bw! endfunc +" Test for H, M and L commands with folds +func Test_scroll_cmds() + 15new + call setline(1, range(1, 100)) + exe "normal! 30ggz\<CR>" + set foldenable + 33,36fold + 40,43fold + 46,49fold + let h = winheight(0) + " Top of the screen = 30 + " Folded lines = 9 + " Bottom of the screen = 30 + h + 9 - 1 + normal! 4L + call assert_equal(35 + h, line('.')) + normal! 4H + call assert_equal(33, line('.')) + set foldenable& + close! +endfunc + func Test_normal18_z_fold() " basic tests for foldopen/folddelete if !has("folding") @@ -731,6 +787,9 @@ func Test_normal18_z_fold() 50 setl foldenable fdm=marker foldlevel=5 + call assert_beeps('normal! zj') + call assert_beeps('normal! zk') + " Test for zF " First fold norm! 4zF @@ -1157,6 +1216,9 @@ func Test_normal22_zet() let a = readfile('Xfile') call assert_equal(['1', '2'], a) + " Unsupported Z command + call assert_beeps('normal! ZW') + " clean up for file in ['Xfile'] call delete(file) @@ -1225,6 +1287,15 @@ func Test_normal23_K() call assert_match("man --pager=cat 'man'", a) endif + " Error cases + call setline(1, '#$#') + call assert_fails('normal! ggK', 'E349:') + call setline(1, '---') + call assert_fails('normal! ggv2lK', 'E349:') + call setline(1, ['abc', 'xyz']) + call assert_fails("normal! gg2lv2h\<C-]>", 'E426:') + call assert_beeps("normal! ggVjK") + " clean up let &keywordprg = k bw! @@ -1383,8 +1454,8 @@ func Test_normal27_bracket() bw! endfunc +" Test for ( and ) sentence movements func Test_normal28_parenthesis() - " basic testing for ( and ) new call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) @@ -1402,12 +1473,27 @@ func Test_normal28_parenthesis() norm! $d( call assert_equal(['With some sentences!', '', ' ', '', 'This is a long sentence', ''], getline(1, '$')) + " It is an error if a next sentence is not found + %d + call setline(1, '.SH') + call assert_beeps('normal )') + + " Jumping to a fold should open the fold + call setline(1, ['', '', 'one', 'two', 'three']) + set foldenable + 2,$fold + call feedkeys(')', 'xt') + call assert_equal(3, line('.')) + call assert_equal(1, foldlevel('.')) + call assert_equal(-1, foldclosed('.')) + set foldenable& + " clean up bw! endfunc -fun! Test_normal29_brace() - " basic test for { and } movements +" Test for { and } paragraph movements +func Test_normal29_brace() let text =<< trim [DATA] A paragraph begins after each empty line, and also at each of a set of paragraph macros, specified by the pairs of characters in the 'paragraphs' @@ -1561,12 +1647,24 @@ fun! Test_normal29_brace() [DATA] call assert_equal(expected, getline(1, '$')) + " Jumping to a fold should open the fold + %d + call setline(1, ['', 'one', 'two', '']) + set foldenable + 2,$fold + call feedkeys('}', 'xt') + call assert_equal(4, line('.')) + call assert_equal(1, foldlevel('.')) + call assert_equal(-1, foldclosed('.')) + set foldenable& + " clean up set cpo-={ bw! endfunc -fun! Test_normal30_changecase() +" Test for ~ command +func Test_normal30_changecase() new call append(0, 'This is a simple test: äüöß') norm! 1ggVu @@ -1586,8 +1684,23 @@ fun! Test_normal30_changecase() norm! V~ call assert_equal('THIS IS A simple test: äüöss', getline('.')) - " Turkish ASCII turns to multi-byte. On some systems Turkish locale - " is available but toupper()/tolower() don't do the right thing. + " Test for changing case across lines using 'whichwrap' + call setline(1, ['aaaaaa', 'aaaaaa']) + normal! gg10~ + call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2)) + set whichwrap+=~ + normal! gg10~ + call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2)) + set whichwrap& + + " clean up + bw! +endfunc + +" Turkish ASCII turns to multi-byte. On some systems Turkish locale +" is available but toupper()/tolower() don't do the right thing. +func Test_normal_changecase_turkish() + new try lang tr_TR.UTF-8 set casemap= @@ -1631,21 +1744,11 @@ fun! Test_normal30_changecase() " can't use Turkish locale throw 'Skipped: Turkish locale not available' endtry - - call setline(1, ['aaaaaa', 'aaaaaa']) - normal! gg10~ - call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2)) - set whichwrap+=~ - normal! gg10~ - call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2)) - set whichwrap& - - " clean up - bw! + close! endfunc -fun! Test_normal31_r_cmd() - " Test for r command +" Test for r (replace) command +func Test_normal31_r_cmd() new call append(0, 'This is a simple test: abcd') exe "norm! 1gg$r\<cr>" @@ -1664,6 +1767,22 @@ fun! Test_normal31_r_cmd() exe "norm! 1gg05rf" call assert_equal('fffffis a', getline(1)) + " When replacing characters, copy characters from above and below lines + " using CTRL-Y and CTRL-E. + " Different code paths are used for utf-8 and latin1 encodings + set showmatch + for enc in ['latin1', 'utf-8'] + enew! + let &encoding = enc + call setline(1, [' {a}', 'xxxxxxxxxx', ' [b]']) + exe "norm! 2gg5r\<C-Y>l5r\<C-E>" + call assert_equal(' {a}x [b]x', getline(2)) + endfor + set showmatch& + + " r command should fail in operator pending mode + call assert_beeps('normal! cr') + " clean up set noautoindent bw! @@ -1687,7 +1806,7 @@ endfunc " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G, " gi and gI commands -fun! Test_normal33_g_cmd2() +func Test_normal33_g_cmd2() if !has("jumplist") return endif @@ -1736,6 +1855,16 @@ fun! Test_normal33_g_cmd2() norm! g& call assert_equal(['11', '22', '33', '44', '55', '66', '77', '88', '9', '110', 'a', 'b', 'c', 'dd'], getline(1, '$')) + " Jumping to a fold using gg should open the fold + set foldenable + set foldopen+=jump + 5,8fold + call feedkeys('6gg', 'xt') + call assert_equal(1, foldlevel('.')) + call assert_equal(-1, foldclosed('.')) + set foldopen-=jump + set foldenable& + " Test for gv %d call append('$', repeat(['abcdefgh'], 8)) @@ -1849,6 +1978,10 @@ fun! Test_normal33_g_cmd2() call assert_equal('foo first line', getline(1)) set virtualedit& + " Test for aboring a g command using CTRL-\ CTRL-G + exe "normal! g\<C-\>\<C-G>" + call assert_equal('foo first line', getline('.')) + " clean up bw! endfunc @@ -1860,6 +1993,10 @@ func Test_g_ctrl_g() let a = execute(":norm! g\<c-g>") call assert_equal("\n--No lines in buffer--", a) + " Test for CTRL-G (same as :file) + let a = execute(":norm! \<c-g>") + call assert_equal("\n\n\"[No Name]\" --No lines in buffer--", a) + call setline(1, ['first line', 'second line']) " Test g CTRL-g with dos, mac and unix file type. @@ -1928,7 +2065,7 @@ func Test_g_ctrl_g() endfunc " Test for g8 -fun! Test_normal34_g_cmd3() +func Test_normal34_g_cmd3() new let a=execute(':norm! 1G0g8') call assert_equal("\nNUL", a) @@ -1978,7 +2115,7 @@ func Test_normal_8g8() endfunc " Test for g< -fun! Test_normal35_g_cmd4() +func Test_normal35_g_cmd4() " Cannot capture its output, " probably a bug, therefore, test disabled: throw "Skipped: output of g< can't be tested currently" @@ -1988,7 +2125,7 @@ fun! Test_normal35_g_cmd4() endfunc " Test for gp gP go -fun! Test_normal36_g_cmd5() +func Test_normal36_g_cmd5() new call append(0, 'abcdefghijklmnopqrstuvwxyz') set ff=unix @@ -2027,7 +2164,7 @@ fun! Test_normal36_g_cmd5() endfunc " Test for gt and gT -fun! Test_normal37_g_cmd6() +func Test_normal37_g_cmd6() tabnew 1.txt tabnew 2.txt tabnew 3.txt @@ -2054,7 +2191,7 @@ fun! Test_normal37_g_cmd6() endfunc " Test for <Home> and <C-Home> key -fun! Test_normal38_nvhome() +func Test_normal38_nvhome() new call setline(1, range(10)) $ @@ -2076,8 +2213,21 @@ fun! Test_normal38_nvhome() bw! endfunc +" Test for <End> and <C-End> keys +func Test_normal_nvend() + new + call setline(1, map(range(1, 10), '"line" .. v:val')) + exe "normal! \<End>" + call assert_equal(5, col('.')) + exe "normal! 4\<End>" + call assert_equal([4, 5], [line('.'), col('.')]) + exe "normal! \<C-End>" + call assert_equal([10, 6], [line('.'), col('.')]) + close! +endfunc + " Test for cw cW ce -fun! Test_normal39_cw() +func Test_normal39_cw() " Test for cw and cW on whitespace " and cpo+=w setting new @@ -2117,7 +2267,7 @@ fun! Test_normal39_cw() endfunc " Test for CTRL-\ commands -fun! Test_normal40_ctrl_bsl() +func Test_normal40_ctrl_bsl() new call append(0, 'here are some words') exe "norm! 1gg0a\<C-\>\<C-N>" @@ -2136,13 +2286,18 @@ fun! Test_normal40_ctrl_bsl() set noim call assert_equal('are some words', getline(1)) call assert_false(&insertmode) + call assert_beeps("normal! \<C-\>\<C-A>", 'xt') + + " Using CTRL-\ CTRL-N in cmd window should close the window + call feedkeys("q:\<C-\>\<C-N>", 'xt') + call assert_equal('', getcmdwintype()) " clean up bw! endfunc " Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>= in insert mode -fun! Test_normal41_insert_reg() +func Test_normal41_insert_reg() new set sts=2 sw=2 ts=8 tw=0 call append(0, ["aaa\tbbb\tccc", '', '', '']) @@ -2198,7 +2353,7 @@ func Test_normal42_halfpage() endfunc " Tests for text object aw -fun! Test_normal43_textobject1() +func Test_normal43_textobject1() new call append(0, ['foobar,eins,foobar', 'foo,zwei,foo ']) " diw @@ -2434,6 +2589,8 @@ func Test_normal52_rl() call assert_equal(19, col('.')) call feedkeys("\<right>", 'tx') call assert_equal(18, col('.')) + call feedkeys("\<left>", 'tx') + call assert_equal(19, col('.')) call feedkeys("\<s-right>", 'tx') call assert_equal(13, col('.')) call feedkeys("\<c-right>", 'tx') @@ -2557,6 +2714,8 @@ func Test_changelist() normal g; call assert_equal([2, 2], [line('.'), col('.')]) call assert_fails('normal g;', 'E662:') + new + call assert_fails('normal g;', 'E664:') %bwipe! let &ul = save_ul endfunc @@ -2603,6 +2762,10 @@ endfunc " Jumping to beginning and end of methods in Java-like languages func Test_java_motion() new + call assert_beeps('normal! [m') + call assert_beeps('normal! ]m') + call assert_beeps('normal! [M') + call assert_beeps('normal! ]M') a Piece of Java { @@ -2677,7 +2840,7 @@ Piece of Java close! endfunc -fun! Test_normal_gdollar_cmd() +func Test_normal_gdollar_cmd() if !has("jumplist") return endif @@ -2840,12 +3003,28 @@ func Test_wincmd_with_count() endfunc " Test for 'b', 'B' 'ge' and 'gE' commands -func Test_backward_motion() +func Test_horiz_motion() + new normal! gg call assert_beeps('normal! b') call assert_beeps('normal! B') call assert_beeps('normal! gE') call assert_beeps('normal! ge') + " <S-Backspace> moves one word left and <C-Backspace> moves one WORD left + call setline(1, 'one ,two ,three') + exe "normal! $\<S-BS>" + call assert_equal(11, col('.')) + exe "normal! $\<C-BS>" + call assert_equal(10, col('.')) + close! +endfunc + +" Test for using a : command in operator pending mode +func Test_normal_colon_op() + new + call setline(1, ['one', 'two']) + call assert_beeps("normal! Gc:d\<CR>") + close! endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim index e13f9a6b2d..fb5d1343a8 100644 --- a/src/testdir/test_prompt_buffer.vim +++ b/src/testdir/test_prompt_buffer.vim @@ -132,6 +132,16 @@ func Test_prompt_buffer_edit() normal! i call assert_beeps('normal! dd') call assert_beeps('normal! ~') + call assert_beeps('normal! o') + call assert_beeps('normal! O') + call assert_beeps('normal! p') + call assert_beeps('normal! P') + call assert_beeps('normal! u') + call assert_beeps('normal! ra') + call assert_beeps('normal! s') + call assert_beeps('normal! S') + call assert_beeps("normal! \<C-A>") + call assert_beeps("normal! \<C-X>") close! endfunc diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim index 225ebd1f3d..e9d3fc5966 100644 --- a/src/testdir/test_put.vim +++ b/src/testdir/test_put.vim @@ -113,3 +113,15 @@ func Test_put_p_indent_visual() call assert_equal('select that text', getline(2)) bwipe! endfunc + +" Test for deleting all the contents of a buffer with a put +func Test_put_visual_delete_all_lines() + new + call setline(1, ['one', 'two', 'three']) + let @r = '' + normal! VG"rgp + call assert_equal(1, line('$')) + close! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim index b8f0a1012f..0f86987136 100644 --- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -395,6 +395,9 @@ func Test_execute_register() @q @ call assert_equal(3, i) + + " cannot execute a register in operator pending mode + call assert_beeps('normal! c@r') endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim index 29c3840597..6b73239ed5 100644 --- a/src/testdir/test_tagjump.vim +++ b/src/testdir/test_tagjump.vim @@ -1140,7 +1140,7 @@ endfunc " Test for :dsearch, :dlist, :djump and :dsplit commands " Test for [d, ]d, [D, ]D, [ CTRL-D, ] CTRL-D and CTRL-W d commands -func Test_def_search() +func Test_macro_search() new call setline(1, ['#define FOO 1', '#define FOO 2', '#define FOO 3', \ '#define FOO 4', '#define FOO 5']) @@ -1236,4 +1236,35 @@ func Test_def_search() close! endfunc +" Test for [*, [/, ]* and ]/ +func Test_comment_search() + new + call setline(1, ['', '/*', ' *', ' *', ' */']) + normal! 4gg[/ + call assert_equal([2, 1], [line('.'), col('.')]) + normal! 3gg[* + call assert_equal([2, 1], [line('.'), col('.')]) + normal! 3gg]/ + call assert_equal([5, 3], [line('.'), col('.')]) + normal! 3gg]* + call assert_equal([5, 3], [line('.'), col('.')]) + %d + call setline(1, ['', '/*', ' *', ' *']) + call assert_beeps('normal! 3gg]/') + %d + call setline(1, ['', ' *', ' *', ' */']) + call assert_beeps('normal! 4gg[/') + %d + call setline(1, ' /* comment */') + normal! 15|[/ + call assert_equal(9, col('.')) + normal! 15|]/ + call assert_equal(21, col('.')) + call setline(1, ' comment */') + call assert_beeps('normal! 15|[/') + call setline(1, ' /* comment') + call assert_beeps('normal! 15|]/') + close! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim index c15c6144dd..c1a3a00a57 100644 --- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -157,11 +157,16 @@ func Test_blockwise_visual_o_O() exe "norm! gvO\<Esc>rb" exe "norm! gvo\<C-c>rc" exe "norm! gvO\<C-c>rd" + set selection=exclusive + exe "norm! gvOo\<C-c>re" + call assert_equal('...a be.', getline(4)) + exe "norm! gvOO\<C-c>rf" + set selection& call assert_equal(['..........', \ '...c d..', \ '... ..', - \ '...a b..', + \ '...a bf.', \ '..........'], getline(1, '$')) enew! @@ -645,6 +650,16 @@ func Test_characterwise_select_mode() exe "normal Gkgh\<Down>\<End>\<Del>" call assert_equal(['', 'a', ''], getline(1, '$')) + " CTRL-H in select mode behaves like 'x' + call setline(1, 'abcdef') + exe "normal! gggh\<Right>\<Right>\<Right>\<C-H>" + call assert_equal('ef', getline(1)) + + " CTRL-O in select mode switches to visual mode for one command + call setline(1, 'abcdef') + exe "normal! gggh\<C-O>3lm" + call assert_equal('mef', getline(1)) + sunmap <lt>End> sunmap <lt>Down> sunmap <lt>Del> @@ -752,8 +767,7 @@ endfunc func Test_visual_block_mode() new call append(0, '') - call setline(1, ['abcdefghijklm', 'abcdefghijklm', 'abcdefghijklm', - \ 'abcdefghijklm', 'abcdefghijklm']) + call setline(1, repeat(['abcdefghijklm'], 5)) call cursor(1, 1) " Test shift-right of a block @@ -772,6 +786,16 @@ func Test_visual_block_mode() \ 'axyzqqqqefgmnoklm', \ 'abcdqqqqijklm'], getline(1, 5)) + " Test 'C' to change t |