diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-31 21:20:50 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-31 21:24:31 -0400 |
commit | 2f79caa02dfa59a97403aaa0b5e343e310c0ba14 (patch) | |
tree | cdfa7d63de4cdc54f6569f8d1c204d4cb9bdd0d1 | |
parent | e39973156173ce8511ff1ae88eec19a3200e08d8 (diff) | |
download | rneovim-2f79caa02dfa59a97403aaa0b5e343e310c0ba14.tar.gz rneovim-2f79caa02dfa59a97403aaa0b5e343e310c0ba14.tar.bz2 rneovim-2f79caa02dfa59a97403aaa0b5e343e310c0ba14.zip |
vim-patch:8.1.2400: test39 is old style
Problem: Test39 is old style.
Solution: Convert the test cases into new style. (Yegappan Lakshmanan,
closes vim/vim#5324)
https://github.com/vim/vim/commit/1f3e7d3bf0aa1e015a591ce8f7ee7ab56589b452
-rw-r--r-- | src/nvim/testdir/test_blockedit.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_visual.vim | 156 |
2 files changed, 155 insertions, 2 deletions
diff --git a/src/nvim/testdir/test_blockedit.vim b/src/nvim/testdir/test_blockedit.vim index 527224ccd2..180524cd73 100644 --- a/src/nvim/testdir/test_blockedit.vim +++ b/src/nvim/testdir/test_blockedit.vim @@ -1,6 +1,5 @@ " Test for block inserting " -" TODO: rewrite test39.in into this new style test func Test_blockinsert_indent() new diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index d9d10b9681..c879db1542 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1,4 +1,4 @@ -" Tests for various Visual mode. +" Tests for various Visual modes. func Test_block_shift_multibyte() " Uses double-wide character. @@ -738,6 +738,160 @@ func Test_select_mode_gv() bwipe! endfunc +" Tests for the visual block mode commands +func Test_visual_block_mode() + new + call append(0, '') + call setline(1, ['abcdefghijklm', 'abcdefghijklm', 'abcdefghijklm', + \ 'abcdefghijklm', 'abcdefghijklm']) + call cursor(1, 1) + + " Test shift-right of a block + exe "normal jllll\<C-V>jj>wll\<C-V>jlll>" + " Test shift-left of a block + exe "normal G$hhhh\<C-V>kk<" + " Test block-insert + exe "normal Gkl\<C-V>kkkIxyz" + " Test block-replace + exe "normal Gllll\<C-V>kkklllrq" + " Test block-change + exe "normal G$khhh\<C-V>hhkkcmno" + call assert_equal(['axyzbcdefghijklm', + \ 'axyzqqqq mno ghijklm', + \ 'axyzqqqqef mno ghijklm', + \ 'axyzqqqqefgmnoklm', + \ 'abcdqqqqijklm'], getline(1, 5)) + + bwipe! +endfunc + +" Test block-insert using cursor keys for movement +func Test_visual_block_insert_cursor_keys() + new + call append(0, ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd']) + call cursor(1, 1) + + exe "norm! l\<C-V>jjjlllI\<Right>\<Right> \<Esc>" + call assert_equal(['aaa aaa', 'bbb bbb', 'ccc ccc', 'ddd ddd'], + \ getline(1, 4)) + + call deletebufline('', 1, '$') + call setline(1, ['xaaa', 'bbbb', 'cccc', 'dddd']) + call cursor(1, 1) + exe "norm! \<C-V>jjjI<>\<Left>p\<Esc>" + call assert_equal(['<p>xaaa', '<p>bbbb', '<p>cccc', '<p>dddd'], + \ getline(1, 4)) + bwipe! +endfunc + +func Test_visual_block_create() + new + call append(0, '') + " Test for Visual block was created with the last <C-v>$ + call setline(1, ['A23', '4567']) + call cursor(1, 1) + exe "norm! l\<C-V>j$Aab\<Esc>" + call assert_equal(['A23ab', '4567ab'], getline(1, 2)) + + " Test for Visual block was created with the middle <C-v>$ (1) + call deletebufline('', 1, '$') + call setline(1, ['B23', '4567']) + call cursor(1, 1) + exe "norm! l\<C-V>j$hAab\<Esc>" + call assert_equal(['B23 ab', '4567ab'], getline(1, 2)) + + " Test for Visual block was created with the middle <C-v>$ (2) + call deletebufline('', 1, '$') + call setline(1, ['C23', '4567']) + call cursor(1, 1) + exe "norm! l\<C-V>j$hhAab\<Esc>" + call assert_equal(['C23ab', '456ab7'], getline(1, 2)) + bwipe! +endfunc + +" Test for Visual block insert when virtualedit=all +func Test_virtualedit_visual_block() + set ve=all + new + call append(0, ["\t\tline1", "\t\tline2", "\t\tline3"]) + call cursor(1, 1) + exe "norm! 07l\<C-V>jjIx\<Esc>" + call assert_equal([" x \tline1", + \ " x \tline2", + \ " x \tline3"], getline(1, 3)) + + " Test for Visual block append when virtualedit=all + exe "norm! 012l\<C-v>jjAx\<Esc>" + call assert_equal([' x x line1', + \ ' x x line2', + \ ' x x line3'], getline(1, 3)) + set ve= + bwipe! +endfunc + +" Test for changing case +func Test_visual_change_case() + new + " gUe must uppercase a whole word, also when ß changes to SS + exe "normal Gothe youtußeuu end\<Esc>Ypk0wgUe\r" + " gUfx must uppercase until x, inclusive. + exe "normal O- youßtußexu -\<Esc>0fogUfx\r" + " VU must uppercase a whole line + exe "normal YpkVU\r" + " same, when it's the last line in the buffer + exe "normal YPGi111\<Esc>VUddP\r" + " Uppercase two lines + exe "normal Oblah di\rdoh dut\<Esc>VkUj\r" + " Uppercase part of two lines + exe "normal ddppi333\<Esc>k0i222\<Esc>fyllvjfuUk" + call assert_equal(['the YOUTUSSEUU end', '- yOUSSTUSSEXu -', + \ 'THE YOUTUSSEUU END', '111THE YOUTUSSEUU END', 'BLAH DI', 'DOH DUT', + \ '222the yoUTUSSEUU END', '333THE YOUTUßeuu end'], getline(2, '$')) + bwipe! +endfunc + +" Test for Visual replace using Enter or NL +func Test_visual_replace_crnl() + new + exe "normal G3o123456789\e2k05l\<C-V>2jr\r" + exe "normal G3o98765\e2k02l\<C-V>2jr\<C-V>\r\n" + exe "normal G3o123456789\e2k05l\<C-V>2jr\n" + exe "normal G3o98765\e2k02l\<C-V>2jr\<C-V>\n" + call assert_equal(['12345', '789', '12345', '789', '12345', '789', "98\r65", + \ "98\r65", "98\r65", '12345', '789', '12345', '789', '12345', '789', + \ "98\n65", "98\n65", "98\n65"], getline(2, '$')) + bwipe! +endfunc + +func Test_ve_block_curpos() + new + " Test cursor position. When ve=block and Visual block mode and $gj + call append(0, ['12345', '789']) + call cursor(1, 3) + set virtualedit=block + exe "norm! \<C-V>$gj\<Esc>" + call assert_equal([0, 2, 4, 0], getpos("'>")) + set virtualedit= + bwipe! +endfunc + +" Test for block_insert when replacing spaces in front of the a with tabs +func Test_block_insert_replace_tabs() + new + set ts=8 sts=4 sw=4 + call append(0, ["#define BO_ALL\t 0x0001", + \ "#define BO_BS\t 0x0002", + \ "#define BO_CRSR\t 0x0004"]) + call cursor(1, 1) + exe "norm! f0\<C-V>2jI\<tab>\<esc>" + call assert_equal([ + \ "#define BO_ALL\t\t0x0001", + \ "#define BO_BS\t \t0x0002", + \ "#define BO_CRSR\t \t0x0004", ''], getline(1, '$')) + set ts& sts& sw& + bwipe! +endfunc + func Test_visual_put_in_block_using_zp() new " paste using zP |