comparison src/testdir/test_edit.vim @ 20941:505d97ea54da v8.2.1022

patch 8.2.1022: various parts of code not covered by tests Commit: https://github.com/vim/vim/commit/845e0ee59430eac07e74b6cb92020e420d17953d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 20 16:05:32 2020 +0200 patch 8.2.1022: various parts of code not covered by tests Problem: Various parts of code not covered by tests. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6300)
author Bram Moolenaar <Bram@vim.org>
date Sat, 20 Jun 2020 16:15:04 +0200
parents 1725bb56178a
children 93dae47699fb
comparison
equal deleted inserted replaced
20940:88ce5327f213 20941:505d97ea54da
399 exe "normal 0eea\<CR>\<CR>\<Esc>" 399 exe "normal 0eea\<CR>\<CR>\<Esc>"
400 call assert_equal(" foo bar", getline(1)) 400 call assert_equal(" foo bar", getline(1))
401 call assert_equal("", getline(2)) 401 call assert_equal("", getline(2))
402 call assert_equal(" baz", getline(3)) 402 call assert_equal(" baz", getline(3))
403 set autoindent& 403 set autoindent&
404
405 " pressing <C-U> to erase line should keep the indent with 'autoindent'
406 set backspace=2 autoindent
407 %d
408 exe "normal i\tone\<CR>three\<C-U>two"
409 call assert_equal(["\tone", "\ttwo"], getline(1, '$'))
410 set backspace& autoindent&
411
404 bwipe! 412 bwipe!
405 endfunc 413 endfunc
406 414
407 func Test_edit_CR() 415 func Test_edit_CR()
408 " Test for <CR> in insert mode 416 " Test for <CR> in insert mode
1299 bw! 1307 bw!
1300 endfunc 1308 endfunc
1301 1309
1302 func Test_edit_rightleft() 1310 func Test_edit_rightleft()
1303 " Cursor in rightleft mode moves differently 1311 " Cursor in rightleft mode moves differently
1304 if !exists("+rightleft") 1312 CheckFeature rightleft
1305 return
1306 endif
1307 call NewWindow(10, 20) 1313 call NewWindow(10, 20)
1308 call setline(1, ['abc', 'def', 'ghi']) 1314 call setline(1, ['abc', 'def', 'ghi'])
1309 call cursor(1, 2) 1315 call cursor(1, 2)
1310 set rightleft 1316 set rightleft
1311 " Screen looks as expected 1317 " Screen looks as expected
1346 \" ca", 1352 \" ca",
1347 \" fed", 1353 \" fed",
1348 \" ihg", 1354 \" ihg",
1349 \" ~"] 1355 \" ~"]
1350 call assert_equal(join(expect, "\n"), join(lines, "\n")) 1356 call assert_equal(join(expect, "\n"), join(lines, "\n"))
1357 %d _
1358 call test_override('redraw_flag', 1)
1359 call test_override('char_avail', 1)
1360 call feedkeys("a\<C-V>x41", "xt")
1361 redraw!
1362 call assert_equal(repeat(' ', 19) .. 'A', Screenline(1))
1363 call test_override('ALL', 0)
1351 set norightleft 1364 set norightleft
1352 bw! 1365 bw!
1353 endfunc 1366 endfunc
1354 1367
1355 func Test_edit_complete_very_long_name() 1368 func Test_edit_complete_very_long_name()
1681 call assert_match('\[Permission Denied\]', msg) 1694 call assert_match('\[Permission Denied\]', msg)
1682 close! 1695 close!
1683 call delete('Xfile') 1696 call delete('Xfile')
1684 endfunc 1697 endfunc
1685 1698
1699 " Pressing escape in 'insertmode' should beep
1700 func Test_edit_insertmode_esc_beeps()
1701 new
1702 set insertmode
1703 call assert_beeps("call feedkeys(\"one\<Esc>\", 'xt')")
1704 set insertmode&
1705 " unsupported CTRL-G command should beep in insert mode.
1706 call assert_beeps("normal i\<C-G>l")
1707 close!
1708 endfunc
1709
1710 " Test for 'hkmap' and 'hkmapp'
1711 func Test_edit_hkmap()
1712 CheckFeature rightleft
1713 if has('win32') && !has('gui')
1714 " Test fails on the MS-Windows terminal version
1715 return
1716 endif
1717 new
1718
1719 set revins hkmap
1720 let str = 'abcdefghijklmnopqrstuvwxyz'
1721 let str ..= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1722 let str ..= '`/'',.;'
1723 call feedkeys('i' .. str, 'xt')
1724 let expected = "óõú,.;"
1725 let expected ..= "ZYXWVUTSRQPONMLKJIHGFEDCBA"
1726 let expected ..= "æèñ'äåàãø/ôíîöêìçïéòë÷âáðù"
1727 call assert_equal(expected, getline(1))
1728
1729 %d
1730 set revins hkmap hkmapp
1731 let str = 'abcdefghijklmnopqrstuvwxyz'
1732 let str ..= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1733 call feedkeys('i' .. str, 'xt')
1734 let expected = "õYXWVUTSRQóOïíLKJIHGFEDêBA"
1735 let expected ..= "öòXùåèúæø'ôñðîì÷çéäâóǟãëáà"
1736 call assert_equal(expected, getline(1))
1737
1738 set revins& hkmap& hkmapp&
1739 close!
1740 endfunc
1741
1742 " Test for 'allowrevins' and using CTRL-_ in insert mode
1743 func Test_edit_allowrevins()
1744 CheckFeature rightleft
1745 new
1746 set allowrevins
1747 call feedkeys("iABC\<C-_>DEF\<C-_>GHI", 'xt')
1748 call assert_equal('ABCFEDGHI', getline(1))
1749 set allowrevins&
1750 close!
1751 endfunc
1752
1753 " Test for inserting a register in insert mode using CTRL-R
1754 func Test_edit_insert_reg()
1755 new
1756 let g:Line = ''
1757 func SaveFirstLine()
1758 let g:Line = Screenline(1)
1759 return 'r'
1760 endfunc
1761 inoremap <expr> <buffer> <F2> SaveFirstLine()
1762 call test_override('redraw_flag', 1)
1763 call test_override('char_avail', 1)
1764 let @r = 'sample'
1765 call feedkeys("a\<C-R>=SaveFirstLine()\<CR>", "xt")
1766 call assert_equal('"', g:Line)
1767 call test_override('ALL', 0)
1768 close!
1769 endfunc
1770
1771 " When a character is inserted at the last position of the last line in a
1772 " window, the window contents should be scrolled one line up. If the top line
1773 " is part of a fold, then the entire fold should be scrolled up.
1774 func Test_edit_lastline_scroll()
1775 new
1776 let h = winheight(0)
1777 let lines = ['one', 'two', 'three']
1778 let lines += repeat(['vim'], h - 4)
1779 call setline(1, lines)
1780 call setline(h, repeat('x', winwidth(0) - 1))
1781 call feedkeys("GAx", 'xt')
1782 redraw!
1783 call assert_equal(h - 1, winline())
1784 call assert_equal(2, line('w0'))
1785
1786 " scroll with a fold
1787 1,2fold
1788 normal gg
1789 call setline(h + 1, repeat('x', winwidth(0) - 1))
1790 call feedkeys("GAx", 'xt')
1791 redraw!
1792 call assert_equal(h - 1, winline())
1793 call assert_equal(3, line('w0'))
1794
1795 close!
1796 endfunc
1797
1686 " vim: shiftwidth=2 sts=2 expandtab 1798 " vim: shiftwidth=2 sts=2 expandtab