Patch 8.2.2901
Problem: Some operators not fully tested.
Solution: Add a few test cases. (Yegappan Lakshmanan, closes #8282)
Files: src/testdir/test_cpoptions.vim, src/testdir/test_increment.vim,
src/testdir/test_normal.vim, src/testdir/test_virtualedit.vim,
src/testdir/test_visual.vim
*** ../vim-8.2.2900/src/testdir/test_cpoptions.vim 2020-07-11
22:14:54.310422225 +0200
--- src/testdir/test_cpoptions.vim 2021-05-29 16:26:26.779241528 +0200
***************
*** 167,172 ****
--- 167,173 ----
call assert_beeps('normal "ayl')
" change an empty line
call assert_beeps('normal lcTa')
+ call assert_beeps('normal 0c0')
" delete an empty line
call assert_beeps('normal D')
call assert_beeps('normal dl')
*** ../vim-8.2.2900/src/testdir/test_increment.vim 2020-12-18
19:49:52.345571854 +0100
--- src/testdir/test_increment.vim 2021-05-29 16:26:26.779241528 +0200
***************
*** 876,879 ****
--- 876,896 ----
set virtualedit&
endfunc
+ " Test for incrementing a signed hexadecimal and octal number
+ func Test_normal_increment_signed_hexoct_nr()
+ new
+ " negative sign before a hex number should be ignored
+ call setline(1, ["-0x9"])
+ exe "norm \<C-A>"
+ call assert_equal(["-0xa"], getline(1, '$'))
+ exe "norm \<C-X>"
+ call assert_equal(["-0x9"], getline(1, '$'))
+ call setline(1, ["-007"])
+ exe "norm \<C-A>"
+ call assert_equal(["-010"], getline(1, '$'))
+ exe "norm \<C-X>"
+ call assert_equal(["-007"], getline(1, '$'))
+ bw!
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2900/src/testdir/test_normal.vim 2021-03-13 13:14:00.810145346
+0100
--- src/testdir/test_normal.vim 2021-05-29 16:26:26.779241528 +0200
***************
*** 1986,1991 ****
--- 1986,2001 ----
call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2))
set whichwrap&
+ " try changing the case with a double byte encoding (DBCS)
+ %bw!
+ let enc = &enc
+ set encoding=cp932
+ call setline(1, "\u8470")
+ normal ~
+ normal gU$gu$gUgUg~g~gugu
+ call assert_equal("\u8470", getline(1))
+ let &encoding = enc
+
" clean up
bw!
endfunc
***************
*** 3324,3327 ****
--- 3334,3358 ----
close!
endfunc
+ " Test for << and >> commands to shift text by 'shiftwidth'
+ func Test_normal_shift_rightleft()
+ new
+ call setline(1, ['one', '', "\t", ' two', "\tthree", ' four'])
+ set shiftwidth=2 tabstop=8
+ normal gg6>>
+ call assert_equal([' one', '', "\t ", ' two', "\t three", "\tfour"],
+ \ getline(1, '$'))
+ normal ggVG2>>
+ call assert_equal([' one', '', "\t ", "\ttwo",
+ \ "\t three", "\t four"], getline(1, '$'))
+ normal gg6<<
+ call assert_equal([' one', '', "\t ", ' two', "\t three",
+ \ "\t four"], getline(1, '$'))
+ normal ggVG2<<
+ call assert_equal(['one', '', "\t", ' two', "\tthree", ' four'],
+ \ getline(1, '$'))
+ set shiftwidth& tabstop&
+ bw!
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2900/src/testdir/test_virtualedit.vim 2020-06-20
16:05:29.016185239 +0200
--- src/testdir/test_virtualedit.vim 2021-05-29 16:26:26.779241528 +0200
***************
*** 80,85 ****
--- 80,89 ----
call setline(1, "\t⒌")
normal Cx
call assert_equal('x', getline(1))
+ " Do a visual block change
+ call setline(1, ['a', 'b', 'c'])
+ exe "normal gg3l\<C-V>2jcx"
+ call assert_equal(['a x', 'b x', 'c x'], getline(1, '$'))
bwipe!
set virtualedit=
endfunc
***************
*** 289,294 ****
--- 293,308 ----
call append(0, '"r"')
normal gg$5lrxa
call assert_equal('"r" x', getline(1))
+ " visual block replace
+ %d _
+ call setline(1, ['a', '', 'b'])
+ exe "normal 2l\<C-V>2jrx"
+ call assert_equal(['a x', ' x', 'b x'], getline(1, '$'))
+ " visual characterwise selection replace after eol
+ %d _
+ call setline(1, 'a')
+ normal 4lv2lrx
+ call assert_equal('a xxx', getline(1))
bwipe!
set virtualedit=
endfunc
***************
*** 375,378 ****
--- 389,405 ----
close!
endfunc
+ " Test for delete (x) on EOL character and after EOL
+ func Test_delete_past_eol()
+ new
+ call setline(1, "ab")
+ set virtualedit=all
+ exe "normal 2lx"
+ call assert_equal('ab', getline(1))
+ exe "normal 10lx"
+ call assert_equal('ab', getline(1))
+ set virtualedit&
+ bw!
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2900/src/testdir/test_visual.vim 2020-10-04 16:16:50.919838655
+0200
--- src/testdir/test_visual.vim 2021-05-29 16:26:26.779241528 +0200
***************
*** 81,92 ****
" thus preventing the problem:
exe "normal! GV:call TriggerTheProblem()\<CR>"
call assert_equal("Everything's fine.", g:msg)
-
endfunc
" Test for visual block shift and tab characters.
func Test_block_shift_tab()
! enew!
call append(0, repeat(['one two three'], 5))
call cursor(1,1)
exe "normal i\<C-G>u"
--- 81,91 ----
" thus preventing the problem:
exe "normal! GV:call TriggerTheProblem()\<CR>"
call assert_equal("Everything's fine.", g:msg)
endfunc
" Test for visual block shift and tab characters.
func Test_block_shift_tab()
! new
call append(0, repeat(['one two three'], 5))
call cursor(1,1)
exe "normal i\<C-G>u"
***************
*** 95,101 ****
call assert_equal('on1 two three', getline(2))
call assert_equal('on1 two three', getline(5))
! enew!
call append(0, repeat(['abcdefghijklmnopqrstuvwxyz'], 5))
call cursor(1,1)
exe "normal \<C-V>4jI \<Esc>j<<11|D"
--- 94,100 ----
call assert_equal('on1 two three', getline(2))
call assert_equal('on1 two three', getline(5))
! %d _
call append(0, repeat(['abcdefghijklmnopqrstuvwxyz'], 5))
call cursor(1,1)
exe "normal \<C-V>4jI \<Esc>j<<11|D"
***************
*** 120,131 ****
call assert_equal(" abc\<Tab>\<Tab>defghijklmnopqrstuvwxyz", getline(4))
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(5))
! enew!
endfunc
" Tests Blockwise Visual when there are TABs before the text.
func Test_blockwise_visual()
! enew!
call append(0, ['123456',
\ '234567',
\ '345678',
--- 119,144 ----
call assert_equal(" abc\<Tab>\<Tab>defghijklmnopqrstuvwxyz", getline(4))
call assert_equal(" abc\<Tab> defghijklmnopqrstuvwxyz", getline(5))
! " Test for block shift with space characters at the beginning and with
! " 'noexpandtab' and 'expandtab'
! %d _
! call setline(1, [" 1", " 2", " 3"])
! setlocal shiftwidth=2 noexpandtab
! exe "normal gg\<C-V>3j>"
! call assert_equal(["\t1", "\t2", "\t3"], getline(1, '$'))
! %d _
! call setline(1, [" 1", " 2", " 3"])
! setlocal shiftwidth=2 expandtab
! exe "normal gg\<C-V>3j>"
! call assert_equal([" 1", " 2", " 3"], getline(1, '$'))
! setlocal shiftwidth&
!
! bw!
endfunc
" Tests Blockwise Visual when there are TABs before the text.
func Test_blockwise_visual()
! new
call append(0, ['123456',
\ '234567',
\ '345678',
***************
*** 147,158 ****
\ "\t\tsomext",
\ "\t\ttesext"], getline(1, 7))
! enew!
endfunc
" Test swapping corners in blockwise visual mode with o and O
func Test_blockwise_visual_o_O()
! enew!
exe "norm! 10i.\<Esc>Y4P3lj\<C-V>4l2jr "
exe "norm! gvO\<Esc>ra"
--- 160,171 ----
\ "\t\tsomext",
\ "\t\ttesext"], getline(1, 7))
! bw!
endfunc
" Test swapping corners in blockwise visual mode with o and O
func Test_blockwise_visual_o_O()
! new
exe "norm! 10i.\<Esc>Y4P3lj\<C-V>4l2jr "
exe "norm! gvO\<Esc>ra"
***************
*** 171,177 ****
\ '...a bf.',
\ '..........'], getline(1, '$'))
! enew!
endfun
" Test Virtual replace mode.
--- 184,190 ----
\ '...a bf.',
\ '..........'], getline(1, '$'))
! bw!
endfun
" Test Virtual replace mode.
***************
*** 459,473 ****
" Test for 'p'ut in visual block mode
func Test_visual_block_put()
! enew
!
call append(0, ['One', 'Two', 'Three'])
normal gg
yank
call feedkeys("jl\<C-V>ljp", 'xt')
call assert_equal(['One', 'T', 'Tee', 'One', ''], getline(1, '$'))
!
! enew!
endfunc
" Visual modes (v V CTRL-V) followed by an operator; count; repeating
--- 472,484 ----
" Test for 'p'ut in visual block mode
func Test_visual_block_put()
! new
call append(0, ['One', 'Two', 'Three'])
normal gg
yank
call feedkeys("jl\<C-V>ljp", 'xt')
call assert_equal(['One', 'T', 'Tee', 'One', ''], getline(1, '$'))
! bw!
endfunc
" Visual modes (v V CTRL-V) followed by an operator; count; repeating
***************
*** 646,651 ****
--- 657,668 ----
norm! G1vy
call assert_equal('four', @")
+ " characterwise visual mode: replace a single character line and the eol
+ %d _
+ call setline(1, "a")
+ normal v$rx
+ call assert_equal(['x'], getline(1, '$'))
+
bwipe!
endfunc
***************
*** 741,746 ****
--- 758,823 ----
exe "normal! \<C-V>j2lD"
call assert_equal(['ax', 'ax'], getline(3, 4))
+ " Test block insert with a short line that ends before the block
+ %d _
+ call setline(1, [" one", "a", " two"])
+ exe "normal gg\<C-V>2jIx"
+ call assert_equal([" xone", "a", " xtwo"], getline(1, '$'))
+
+ " Test block append at EOL with '$' and without '$'
+ %d _
+ call setline(1, ["one", "a", "two"])
+ exe "normal gg$\<C-V>2jAx"
+ call assert_equal(["onex", "ax", "twox"], getline(1, '$'))
+ %d _
+ call setline(1, ["one", "a", "two"])
+ exe "normal gg3l\<C-V>2jAx"
+ call assert_equal(["onex", "a x", "twox"], getline(1, '$'))
+
+ " Test block replace with an empty line in the middle and use $ to jump to
+ " the end of the line.
+ %d _
+ call setline(1, ['one', '', 'two'])
+ exe "normal gg$\<C-V>2jrx"
+ call assert_equal(["onx", "", "twx"], getline(1, '$'))
+
+ " Test block replace with an empty line in the middle and move cursor to the
+ " end of the line
+ %d _
+ call setline(1, ['one', '', 'two'])
+ exe "normal gg2l\<C-V>2jrx"
+ call assert_equal(["onx", "", "twx"], getline(1, '$'))
+
+ " Replace odd number of characters with a multibyte character
+ %d _
+ call setline(1, ['abcd', 'efgh'])
+ exe "normal ggl\<C-V>2ljr\u1100"
+ call assert_equal(["a\u1100 ", "e\u1100 "], getline(1, '$'))
+
+ " During visual block append, if the cursor moved outside of the selected
+ " range, then the edit should not be applied to the block.
+ %d _
+ call setline(1, ['aaa', 'bbb', 'ccc'])
+ exe "normal 2G\<C-V>jAx\<Up>"
+ call assert_equal(['aaa', 'bxbb', 'ccc'], getline(1, '$'))
+
+ " During visual block append, if the cursor is moved before the start of the
+ " block, then the new text should be appended there.
+ %d _
+ call setline(1, ['aaa', 'bbb', 'ccc'])
+ exe "normal $\<C-V>2jA\<Left>x"
+ " BUG: Instead of adding x as the third character in all the three lines,
+ " 'a' is added in the second and third lines at the end. This bug is not
+ " reproducible if this operation is performed manually.
+ "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$'))
+ call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$'))
+
+ " Change a characterwise motion to a blockwise motion using CTRL-V
+ %d _
+ call setline(1, ['123', '456', '789'])
+ exe "normal ld\<C-V>j"
+ call assert_equal(['13', '46', '789'], getline(1, '$'))
+
bwipe!
endfunc
*** ../vim-8.2.2900/src/version.c 2021-05-29 14:30:40.192274126 +0200
--- src/version.c 2021-05-29 16:26:57.647151941 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2901,
/**/
--
Q: What's orange and sounds like a parrot?
A: A carrot
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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/202105291430.14TEUu1e1530264%40masaka.moolenaar.net.