comparison src/testdir/test_normal.vim @ 19625:f70a3c1000bb v8.2.0369

patch 8.2.0369: various Normal mode commands not fully tested Commit: https://github.com/vim/vim/commit/1671f4488105ee12a6a8558ae351436c26ab55fc Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 10 07:48:13 2020 +0100 patch 8.2.0369: various Normal mode commands not fully tested Problem: Various Normal mode commands not fully tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5751)
author Bram Moolenaar <Bram@vim.org>
date Tue, 10 Mar 2020 08:00:06 +0100
parents 9c15be376631
children b3e93a05c3ca
comparison
equal deleted inserted replaced
19624:ce4838c19ca1 19625:f70a3c1000bb
52 " Create a new dummy window 52 " Create a new dummy window
53 new 53 new
54 let g:bufnr=bufnr('%') 54 let g:bufnr=bufnr('%')
55 endfunc 55 endfunc
56 56
57 fun! Test_normal00_optrans() 57 func Test_normal00_optrans()
58 new 58 new
59 call append(0, ['1 This is a simple test: abcd', '2 This is the second line', '3 this is the third line']) 59 call append(0, ['1 This is a simple test: abcd', '2 This is the second line', '3 this is the third line'])
60 1 60 1
61 exe "norm! Sfoobar\<esc>" 61 exe "norm! Sfoobar\<esc>"
62 call assert_equal(['foobar', '2 This is the second line', '3 this is the third line', ''], getline(1,'$')) 62 call assert_equal(['foobar', '2 This is the second line', '3 this is the third line', ''], getline(1,'$'))
93 call assert_equal(['49', '50'], getline("'<", "'>")) 93 call assert_equal(['49', '50'], getline("'<", "'>"))
94 " Start visual mode when keymodel = startsel 94 " Start visual mode when keymodel = startsel
95 50 95 50
96 call feedkeys("\<S-Up>y", 'tx') 96 call feedkeys("\<S-Up>y", 'tx')
97 call assert_equal(['49', '5'], getreg(0, 0, 1)) 97 call assert_equal(['49', '5'], getreg(0, 0, 1))
98 " Use the different Shift special keys
99 50
100 call feedkeys("\<S-Right>\<S-Left>\<S-Up>\<S-Down>\<S-Home>\<S-End>y", 'tx')
101 call assert_equal(['50'], getline("'<", "'>"))
102 call assert_equal(['50', ''], getreg(0, 0, 1))
103
98 " Do not start visual mode when keymodel= 104 " Do not start visual mode when keymodel=
99 set keymodel= 105 set keymodel=
100 50 106 50
101 call feedkeys("\<S-Up>y$", 'tx') 107 call feedkeys("\<S-Up>y$", 'tx')
102 call assert_equal(['42'], getreg(0, 0, 1)) 108 call assert_equal(['42'], getreg(0, 0, 1))
432 exe "norm! 0d3\<del>2l" 438 exe "norm! 0d3\<del>2l"
433 call assert_equal('obar2foobar3', getline('.')) 439 call assert_equal('obar2foobar3', getline('.'))
434 bw! 440 bw!
435 endfunc 441 endfunc
436 442
443 " Test for nv_error and normal command errors
437 func Test_normal12_nv_error() 444 func Test_normal12_nv_error()
438 " Test for nv_error
439 10new 445 10new
440 call setline(1, range(1,5)) 446 call setline(1, range(1,5))
441 " should not do anything, just beep 447 " should not do anything, just beep
442 call assert_beeps('exe "norm! <c-k>"') 448 call assert_beeps('exe "norm! <c-k>"')
443 call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) 449 call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$'))
444 call assert_beeps('normal! G2dd') 450 call assert_beeps('normal! G2dd')
445 call assert_beeps("normal! g\<C-A>") 451 call assert_beeps("normal! g\<C-A>")
446 call assert_beeps("normal! g\<C-X>") 452 call assert_beeps("normal! g\<C-X>")
447 call assert_beeps("normal! g\<C-B>") 453 call assert_beeps("normal! g\<C-B>")
454 call assert_beeps("normal! vQ\<Esc>")
455 call assert_beeps("normal! 2[[")
456 call assert_beeps("normal! 2]]")
457 call assert_beeps("normal! 2[]")
458 call assert_beeps("normal! 2][")
459 call assert_beeps("normal! 4[z")
460 call assert_beeps("normal! 4]z")
461 call assert_beeps("normal! 4[c")
462 call assert_beeps("normal! 4]c")
463 call assert_beeps("normal! 200%")
464 call assert_beeps("normal! %")
465 call assert_beeps("normal! 2{")
466 call assert_beeps("normal! 2}")
467 call assert_beeps("normal! r\<Right>")
468 call assert_beeps("normal! 8ry")
469 call assert_beeps('normal! "@')
448 bw! 470 bw!
449 endfunc 471 endfunc
450 472
451 func Test_normal13_help() 473 func Test_normal13_help()
452 " Test for F1 474 " Test for F1
498 " check with valgrind that cursor is put back in column 1 520 " check with valgrind that cursor is put back in column 1
499 exe "norm 2\<c-b>" 521 exe "norm 2\<c-b>"
500 bw! 522 bw!
501 endfunc 523 endfunc
502 524
525 " Test for errors with z command
526 func Test_normal_z_error()
527 call assert_beeps('normal! z2p')
528 call assert_beeps('normal! zp')
529 endfunc
530
503 func Test_normal15_z_scroll_vert() 531 func Test_normal15_z_scroll_vert()
504 " basic test for z commands that scroll the window 532 " basic test for z commands that scroll the window
505 call Setup_NewWindow() 533 call Setup_NewWindow()
506 100 534 100
507 norm! >> 535 norm! >>
597 let lineA='abcdefghijklmnopqrstuvwxyz' 625 let lineA='abcdefghijklmnopqrstuvwxyz'
598 let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' 626 let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
599 $put =lineA 627 $put =lineA
600 $put =lineB 628 $put =lineB
601 1d 629 1d
630
631 " Test for zl and zh with a count
632 norm! 0z10l
633 call assert_equal([11, 1], [col('.'), wincol()])
634 norm! z4h
635 call assert_equal([11, 5], [col('.'), wincol()])
636 normal! 2gg
602 637
603 " Test for zl 638 " Test for zl
604 1 639 1
605 norm! 5zl 640 norm! 5zl
606 call assert_equal(lineA, getline('.')) 641 call assert_equal(lineA, getline('.'))
720 " cleanup 755 " cleanup
721 set wrap listchars=eol:$ sidescrolloff=0 756 set wrap listchars=eol:$ sidescrolloff=0
722 bw! 757 bw!
723 endfunc 758 endfunc
724 759
760 " Test for H, M and L commands with folds
761 func Test_scroll_cmds()
762 15new
763 call setline(1, range(1, 100))
764 exe "normal! 30ggz\<CR>"
765 set foldenable
766 33,36fold
767 40,43fold
768 46,49fold
769 let h = winheight(0)
770 " Top of the screen = 30
771 " Folded lines = 9
772 " Bottom of the screen = 30 + h + 9 - 1
773 normal! 4L
774 call assert_equal(35 + h, line('.'))
775 normal! 4H
776 call assert_equal(33, line('.'))
777 set foldenable&
778 close!
779 endfunc
780
725 func Test_normal18_z_fold() 781 func Test_normal18_z_fold()
726 " basic tests for foldopen/folddelete 782 " basic tests for foldopen/folddelete
727 if !has("folding") 783 if !has("folding")
728 return 784 return
729 endif 785 endif
730 call Setup_NewWindow() 786 call Setup_NewWindow()
731 50 787 50
732 setl foldenable fdm=marker foldlevel=5 788 setl foldenable fdm=marker foldlevel=5
789
790 call assert_beeps('normal! zj')
791 call assert_beeps('normal! zk')
733 792
734 " Test for zF 793 " Test for zF
735 " First fold 794 " First fold
736 norm! 4zF 795 norm! 4zF
737 " check that folds have been created 796 " check that folds have been created
1154 " Test for ZQ 1213 " Test for ZQ
1155 call writefile(['1', '2'], 'Xfile') 1214 call writefile(['1', '2'], 'Xfile')
1156 call system(GetVimCommand() . args . ' -c "%d" -c ":norm! ZQ" Xfile') 1215 call system(GetVimCommand() . args . ' -c "%d" -c ":norm! ZQ" Xfile')
1157 let a = readfile('Xfile') 1216 let a = readfile('Xfile')
1158 call assert_equal(['1', '2'], a) 1217 call assert_equal(['1', '2'], a)
1218
1219 " Unsupported Z command
1220 call assert_beeps('normal! ZW')
1159 1221
1160 " clean up 1222 " clean up
1161 for file in ['Xfile'] 1223 for file in ['Xfile']
1162 call delete(file) 1224 call delete(file)
1163 endfor 1225 endfor
1223 call assert_match("man -P cat 'man'", a) 1285 call assert_match("man -P cat 'man'", a)
1224 else 1286 else
1225 call assert_match("man --pager=cat 'man'", a) 1287 call assert_match("man --pager=cat 'man'", a)
1226 endif 1288 endif
1227 1289
1290 " Error cases
1291 call setline(1, '#$#')
1292 call assert_fails('normal! ggK', 'E349:')
1293 call setline(1, '---')
1294 call assert_fails('normal! ggv2lK', 'E349:')
1295 call setline(1, ['abc', 'xyz'])
1296 call assert_fails("normal! gg2lv2h\<C-]>", 'E426:')
1297 call assert_beeps("normal! ggVjK")
1298
1228 " clean up 1299 " clean up
1229 let &keywordprg = k 1300 let &keywordprg = k
1230 bw! 1301 bw!
1231 endfunc 1302 endfunc
1232 1303
1381 1452
1382 " clean up 1453 " clean up
1383 bw! 1454 bw!
1384 endfunc 1455 endfunc
1385 1456
1457 " Test for ( and ) sentence movements
1386 func Test_normal28_parenthesis() 1458 func Test_normal28_parenthesis()
1387 " basic testing for ( and )
1388 new 1459 new
1389 call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) 1460 call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
1390 1461
1391 $ 1462 $
1392 norm! d( 1463 norm! d(
1400 call append('$', ['This is a long sentence', '', 'spanning', 'over several lines. ']) 1471 call append('$', ['This is a long sentence', '', 'spanning', 'over several lines. '])
1401 $ 1472 $
1402 norm! $d( 1473 norm! $d(
1403 call assert_equal(['With some sentences!', '', ' ', '', 'This is a long sentence', ''], getline(1, '$')) 1474 call assert_equal(['With some sentences!', '', ' ', '', 'This is a long sentence', ''], getline(1, '$'))
1404 1475
1405 " clean up 1476 " It is an error if a next sentence is not found
1406 bw! 1477 %d
1407 endfunc 1478 call setline(1, '.SH')
1408 1479 call assert_beeps('normal )')
1409 fun! Test_normal29_brace() 1480
1410 " basic test for { and } movements 1481 " Jumping to a fold should open the fold
1482 call setline(1, ['', '', 'one', 'two', 'three'])
1483 set foldenable
1484 2,$fold
1485 call feedkeys(')', 'xt')
1486 call assert_equal(3, line('.'))
1487 call assert_equal(1, foldlevel('.'))
1488 call assert_equal(-1, foldclosed('.'))
1489 set foldenable&
1490
1491 " clean up
1492 bw!
1493 endfunc
1494
1495 " Test for { and } paragraph movements
1496 func Test_normal29_brace()
1411 let text =<< trim [DATA] 1497 let text =<< trim [DATA]
1412 A paragraph begins after each empty line, and also at each of a set of 1498 A paragraph begins after each empty line, and also at each of a set of
1413 paragraph macros, specified by the pairs of characters in the 'paragraphs' 1499 paragraph macros, specified by the pairs of characters in the 'paragraphs'
1414 option. The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to 1500 option. The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to
1415 the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in 1501 the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in
1559 } 1645 }
1560 1646
1561 [DATA] 1647 [DATA]
1562 call assert_equal(expected, getline(1, '$')) 1648 call assert_equal(expected, getline(1, '$'))
1563 1649
1650 " Jumping to a fold should open the fold
1651 %d
1652 call setline(1, ['', 'one', 'two', ''])
1653 set foldenable
1654 2,$fold
1655 call feedkeys('}', 'xt')
1656 call assert_equal(4, line('.'))
1657 call assert_equal(1, foldlevel('.'))
1658 call assert_equal(-1, foldclosed('.'))
1659 set foldenable&
1660
1564 " clean up 1661 " clean up
1565 set cpo-={ 1662 set cpo-={
1566 bw! 1663 bw!
1567 endfunc 1664 endfunc
1568 1665
1569 fun! Test_normal30_changecase() 1666 " Test for ~ command
1667 func Test_normal30_changecase()
1570 new 1668 new
1571 call append(0, 'This is a simple test: äüöß') 1669 call append(0, 'This is a simple test: äüöß')
1572 norm! 1ggVu 1670 norm! 1ggVu
1573 call assert_equal('this is a simple test: äüöß', getline('.')) 1671 call assert_equal('this is a simple test: äüöß', getline('.'))
1574 norm! VU 1672 norm! VU
1584 norm! 010~ 1682 norm! 010~
1585 call assert_equal('this is a SIMPLE TEST: ÄÜÖSS', getline('.')) 1683 call assert_equal('this is a SIMPLE TEST: ÄÜÖSS', getline('.'))
1586 norm! V~ 1684 norm! V~
1587 call assert_equal('THIS IS A simple test: äüöss', getline('.')) 1685 call assert_equal('THIS IS A simple test: äüöss', getline('.'))
1588 1686
1589 " Turkish ASCII turns to multi-byte. On some systems Turkish locale 1687 " Test for changing case across lines using 'whichwrap'
1590 " is available but toupper()/tolower() don't do the right thing. 1688 call setline(1, ['aaaaaa', 'aaaaaa'])
1689 normal! gg10~
1690 call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2))
1691 set whichwrap+=~
1692 normal! gg10~
1693 call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2))
1694 set whichwrap&
1695
1696 " clean up
1697 bw!
1698 endfunc
1699
1700 " Turkish ASCII turns to multi-byte. On some systems Turkish locale
1701 " is available but toupper()/tolower() don't do the right thing.
1702 func Test_normal_changecase_turkish()
1703 new
1591 try 1704 try
1592 lang tr_TR.UTF-8 1705 lang tr_TR.UTF-8
1593 set casemap= 1706 set casemap=
1594 let iupper = toupper('i') 1707 let iupper = toupper('i')
1595 if iupper == "\u0130" 1708 if iupper == "\u0130"
1629 lang en_US.UTF-8 1742 lang en_US.UTF-8
1630 catch /E197:/ 1743 catch /E197:/
1631 " can't use Turkish locale 1744 " can't use Turkish locale
1632 throw 'Skipped: Turkish locale not available' 1745 throw 'Skipped: Turkish locale not available'
1633 endtry 1746 endtry
1634 1747 close!
1635 call setline(1, ['aaaaaa', 'aaaaaa']) 1748 endfunc
1636 normal! gg10~ 1749
1637 call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2)) 1750 " Test for r (replace) command
1638 set whichwrap+=~ 1751 func Test_normal31_r_cmd()
1639 normal! gg10~
1640 call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2))
1641 set whichwrap&
1642
1643 " clean up
1644 bw!
1645 endfunc
1646
1647 fun! Test_normal31_r_cmd()
1648 " Test for r command
1649 new 1752 new
1650 call append(0, 'This is a simple test: abcd') 1753 call append(0, 'This is a simple test: abcd')
1651 exe "norm! 1gg$r\<cr>" 1754 exe "norm! 1gg$r\<cr>"
1652 call assert_equal(['This is a simple test: abc', '', ''], getline(1,'$')) 1755 call assert_equal(['This is a simple test: abc', '', ''], getline(1,'$'))
1653 exe "norm! 1gg2wlr\<cr>" 1756 exe "norm! 1gg2wlr\<cr>"
1662 call assert_equal('^M^M^M^M^M^M^M^M^M', strtrans(getline(1))) 1765 call assert_equal('^M^M^M^M^M^M^M^M^M', strtrans(getline(1)))
1663 call setline(1, 'This is a') 1766 call setline(1, 'This is a')
1664 exe "norm! 1gg05rf" 1767 exe "norm! 1gg05rf"
1665 call assert_equal('fffffis a', getline(1)) 1768 call assert_equal('fffffis a', getline(1))
1666 1769
1770 " When replacing characters, copy characters from above and below lines
1771 " using CTRL-Y and CTRL-E.
1772 " Different code paths are used for utf-8 and latin1 encodings
1773 set showmatch
1774 for enc in ['latin1', 'utf-8']
1775 enew!
1776 let &encoding = enc
1777 call setline(1, [' {a}', 'xxxxxxxxxx', ' [b]'])
1778 exe "norm! 2gg5r\<C-Y>l5r\<C-E>"
1779 call assert_equal(' {a}x [b]x', getline(2))
1780 endfor
1781 set showmatch&
1782
1783 " r command should fail in operator pending mode
1784 call assert_beeps('normal! cr')
1785
1667 " clean up 1786 " clean up
1668 set noautoindent 1787 set noautoindent
1669 bw! 1788 bw!
1670 endfunc 1789 endfunc
1671 1790
1685 bw! 1804 bw!
1686 endfunc 1805 endfunc
1687 1806
1688 " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G, 1807 " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G,
1689 " gi and gI commands 1808 " gi and gI commands
1690 fun! Test_normal33_g_cmd2() 1809 func Test_normal33_g_cmd2()
1691 if !has("jumplist") 1810 if !has("jumplist")
1692 return 1811 return
1693 endif 1812 endif
1694 call Setup_NewWindow() 1813 call Setup_NewWindow()
1695 " Test for g` 1814 " Test for g`
1733 call append('$', ['a', 'b', 'c', 'd']) 1852 call append('$', ['a', 'b', 'c', 'd'])
1734 $s/\w/&&/g 1853 $s/\w/&&/g
1735 exe "norm! /[1-8]\<cr>" 1854 exe "norm! /[1-8]\<cr>"
1736 norm! g& 1855 norm! g&
1737 call assert_equal(['11', '22', '33', '44', '55', '66', '77', '88', '9', '110', 'a', 'b', 'c', 'dd'], getline(1, '$')) 1856 call assert_equal(['11', '22', '33', '44', '55', '66', '77', '88', '9', '110', 'a', 'b', 'c', 'dd'], getline(1, '$'))
1857
1858 " Jumping to a fold using gg should open the fold
1859 set foldenable
1860 set foldopen+=jump
1861 5,8fold
1862 call feedkeys('6gg', 'xt')
1863 call assert_equal(1, foldlevel('.'))
1864 call assert_equal(-1, foldclosed('.'))
1865 set foldopen-=jump
1866 set foldenable&
1738 1867
1739 " Test for gv 1868 " Test for gv
1740 %d 1869 %d
1741 call append('$', repeat(['abcdefgh'], 8)) 1870 call append('$', repeat(['abcdefgh'], 8))
1742 exe "norm! 2gg02l\<c-v>2j2ly" 1871 exe "norm! 2gg02l\<c-v>2j2ly"
1847 call setline(1, 'foo') 1976 call setline(1, 'foo')
1848 normal! Ggifirst line 1977 normal! Ggifirst line
1849 call assert_equal('foo first line', getline(1)) 1978 call assert_equal('foo first line', getline(1))
1850 set virtualedit& 1979 set virtualedit&
1851 1980
1981 " Test for aboring a g command using CTRL-\ CTRL-G
1982 exe "normal! g\<C-\>\<C-G>"
1983 call assert_equal('foo first line', getline('.'))
1984
1852 " clean up 1985 " clean up
1853 bw! 1986 bw!
1854 endfunc 1987 endfunc
1855 1988
1856 " Test for g CTRL-G 1989 " Test for g CTRL-G
1857 func Test_g_ctrl_g() 1990 func Test_g_ctrl_g()
1858 new 1991 new
1859 1992
1860 let a = execute(":norm! g\<c-g>") 1993 let a = execute(":norm! g\<c-g>")
1861 call assert_equal("\n--No lines in buffer--", a) 1994 call assert_equal("\n--No lines in buffer--", a)
1995
1996 " Test for CTRL-G (same as :file)
1997 let a = execute(":norm! \<c-g>")
1998 call assert_equal("\n\n\"[No Name]\" --No lines in buffer--", a)
1862 1999
1863 call setline(1, ['first line', 'second line']) 2000 call setline(1, ['first line', 'second line'])
1864 2001
1865 " Test g CTRL-g with dos, mac and unix file type. 2002 " Test g CTRL-g with dos, mac and unix file type.
1866 norm! gojll 2003 norm! gojll
1926 set ff& 2063 set ff&
1927 bwipe! 2064 bwipe!
1928 endfunc 2065 endfunc
1929 2066
1930 " Test for g8 2067 " Test for g8
1931 fun! Test_normal34_g_cmd3() 2068 func Test_normal34_g_cmd3()
1932 new 2069 new
1933 let a=execute(':norm! 1G0g8') 2070 let a=execute(':norm! 1G0g8')
1934 call assert_equal("\nNUL", a) 2071 call assert_equal("\nNUL", a)
1935 2072
1936 call setline(1, 'abcdefghijklmnopqrstuvwxyzäüö') 2073 call setline(1, 'abcdefghijklmnopqrstuvwxyzäüö')
1976 2113
1977 bw! 2114 bw!
1978 endfunc 2115 endfunc
1979 2116
1980 " Test for g< 2117 " Test for g<
1981 fun! Test_normal35_g_cmd4() 2118 func Test_normal35_g_cmd4()
1982 " Cannot capture its output, 2119 " Cannot capture its output,
1983 " probably a bug, therefore, test disabled: 2120 " probably a bug, therefore, test disabled:
1984 throw "Skipped: output of g< can't be tested currently" 2121 throw "Skipped: output of g< can't be tested currently"
1985 echo "a\nb\nc\nd" 2122 echo "a\nb\nc\nd"
1986 let b=execute(':norm! g<') 2123 let b=execute(':norm! g<')
1987 call assert_true(!empty(b), 'failed `execute(g<)`') 2124 call assert_true(!empty(b), 'failed `execute(g<)`')
1988 endfunc 2125 endfunc
1989 2126
1990 " Test for gp gP go 2127 " Test for gp gP go
1991 fun! Test_normal36_g_cmd5() 2128 func Test_normal36_g_cmd5()
1992 new 2129 new
1993 call append(0, 'abcdefghijklmnopqrstuvwxyz') 2130 call append(0, 'abcdefghijklmnopqrstuvwxyz')
1994 set ff=unix 2131 set ff=unix
1995 " Test for gp gP 2132 " Test for gp gP
1996 call append(1, range(1,10)) 2133 call append(1, range(1,10))
2025 " clean up 2162 " clean up
2026 bw! 2163 bw!
2027 endfunc 2164 endfunc
2028 2165
2029 " Test for gt and gT 2166 " Test for gt and gT
2030 fun! Test_normal37_g_cmd6() 2167 func Test_normal37_g_cmd6()
2031 tabnew 1.txt 2168 tabnew 1.txt
2032 tabnew 2.txt 2169 tabnew 2.txt
2033 tabnew 3.txt 2170 tabnew 3.txt
2034 norm! 1gt 2171 norm! 1gt
2035 call assert_equal(1, tabpagenr()) 2172 call assert_equal(1, tabpagenr())
2052 " clean up 2189 " clean up
2053 call assert_fails(':tabclose', 'E784:') 2190 call assert_fails(':tabclose', 'E784:')
2054 endfunc 2191 endfunc
2055 2192
2056 " Test for <Home> and <C-Home> key 2193 " Test for <Home> and <C-Home> key
2057 fun! Test_normal38_nvhome() 2194 func Test_normal38_nvhome()
2058 new 2195 new
2059 call setline(1, range(10)) 2196 call setline(1, range(10))
2060 $ 2197 $
2061 setl et sw=2 2198 setl et sw=2
2062 norm! V10>$ 2199 norm! V10>$
2074 2211
2075 " clean up 2212 " clean up
2076 bw! 2213 bw!
2077 endfunc 2214 endfunc
2078 2215
2216 " Test for <End> and <C-End> keys
2217 func Test_normal_nvend()
2218 new
2219 call setline(1, map(range(1, 10), '"line" .. v:val'))
2220 exe "normal! \<End>"
2221 call assert_equal(5, col('.'))
2222 exe "normal! 4\<End>"
2223 call assert_equal([4, 5], [line('.'), col('.')])
2224 exe "normal! \<C-End>"
2225 call assert_equal([10, 6], [line('.'), col('.')])
2226 close!
2227 endfunc
2228
2079 " Test for cw cW ce 2229 " Test for cw cW ce
2080 fun! Test_normal39_cw() 2230 func Test_normal39_cw()
2081 " Test for cw and cW on whitespace 2231 " Test for cw and cW on whitespace
2082 " and cpo+=w setting 2232 " and cpo+=w setting
2083 new 2233 new
2084 set tw=0 2234 set tw=0
2085 call append(0, 'here are some words') 2235 call append(0, 'here are some words')
2115 " clean up 2265 " clean up
2116 bw! 2266 bw!
2117 endfunc 2267 endfunc
2118 2268
2119 " Test for CTRL-\ commands 2269 " Test for CTRL-\ commands
2120 fun! Test_normal40_ctrl_bsl() 2270 func Test_normal40_ctrl_bsl()
2121 new 2271 new
2122 call append(0, 'here are some words') 2272 call append(0, 'here are some words')
2123 exe "norm! 1gg0a\<C-\>\<C-N>" 2273 exe "norm! 1gg0a\<C-\>\<C-N>"
2124 call assert_equal('n', mode()) 2274 call assert_equal('n', mode())
2125 call assert_equal(1, col('.')) 2275 call assert_equal(1, col('.'))
2134 set im 2284 set im
2135 exe ":norm! \<c-\>\<c-n>dw" 2285 exe ":norm! \<c-\>\<c-n>dw"
2136 set noim 2286 set noim
2137 call assert_equal('are some words', getline(1)) 2287 call assert_equal('are some words', getline(1))
2138 call assert_false(&insertmode) 2288 call assert_false(&insertmode)
2289 call assert_beeps("normal! \<C-\>\<C-A>", 'xt')
2290
2291 " Using CTRL-\ CTRL-N in cmd window should close the window
2292 call feedkeys("q:\<C-\>\<C-N>", 'xt')
2293 call assert_equal('', getcmdwintype())
2139 2294
2140 " clean up 2295 " clean up
2141 bw! 2296 bw!
2142 endfunc 2297 endfunc
2143 2298
2144 " Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>= in insert mode 2299 " Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>= in insert mode
2145 fun! Test_normal41_insert_reg() 2300 func Test_normal41_insert_reg()
2146 new 2301 new
2147 set sts=2 sw=2 ts=8 tw=0 2302 set sts=2 sw=2 ts=8 tw=0
2148 call append(0, ["aaa\tbbb\tccc", '', '', '']) 2303 call append(0, ["aaa\tbbb\tccc", '', '', ''])
2149 let a=getline(1) 2304 let a=getline(1)
2150 norm! 2gg0 2305 norm! 2gg0
2196 set startofline 2351 set startofline
2197 bw! 2352 bw!
2198 endfunc 2353 endfunc
2199 2354
2200 " Tests for text object aw 2355 " Tests for text object aw
2201 fun! Test_normal43_textobject1() 2356 func Test_normal43_textobject1()
2202 new 2357 new
2203 call append(0, ['foobar,eins,foobar', 'foo,zwei,foo ']) 2358 call append(0, ['foobar,eins,foobar', 'foo,zwei,foo '])
2204 " diw 2359 " diw
2205 norm! 1gg0diw 2360 norm! 1gg0diw
2206 call assert_equal([',eins,foobar', 'foo,zwei,foo ', ''], getline(1,'$')) 2361 call assert_equal([',eins,foobar', 'foo,zwei,foo ', ''], getline(1,'$'))
2432 call assert_equal(18, col('.')) 2587 call assert_equal(18, col('.'))
2433 call feedkeys('h', 'tx') 2588 call feedkeys('h', 'tx')
2434 call assert_equal(19, col('.')) 2589 call assert_equal(19, col('.'))
2435 call feedkeys("\<right>", 'tx') 2590 call feedkeys("\<right>", 'tx')
2436 call assert_equal(18, col('.')) 2591 call assert_equal(18, col('.'))
2592 call feedkeys("\<left>", 'tx')
2593 call assert_equal(19, col('.'))
2437 call feedkeys("\<s-right>", 'tx') 2594 call feedkeys("\<s-right>", 'tx')
2438 call assert_equal(13, col('.')) 2595 call assert_equal(13, col('.'))
2439 call feedkeys("\<c-right>", 'tx') 2596 call feedkeys("\<c-right>", 'tx')
2440 call assert_equal(7, col('.')) 2597 call assert_equal(7, col('.'))
2441 call feedkeys("\<c-left>", 'tx') 2598 call feedkeys("\<c-left>", 'tx')
2555 normal g; 2712 normal g;
2556 call assert_equal([3, 2], [line('.'), col('.')]) 2713 call assert_equal([3, 2], [line('.'), col('.')])
2557 normal g; 2714 normal g;
2558 call assert_equal([2, 2], [line('.'), col('.')]) 2715 call assert_equal([2, 2], [line('.'), col('.')])
2559 call assert_fails('normal g;', 'E662:') 2716 call assert_fails('normal g;', 'E662:')
2717 new
2718 call assert_fails('normal g;', 'E664:')
2560 %bwipe! 2719 %bwipe!
2561 let &ul = save_ul 2720 let &ul = save_ul
2562 endfunc 2721 endfunc
2563 2722
2564 func Test_nv_hat_count() 2723 func Test_nv_hat_count()
2601 2760
2602 " Test for '[m', ']m', '[M' and ']M' 2761 " Test for '[m', ']m', '[M' and ']M'
2603 " Jumping to beginning and end of methods in Java-like languages 2762 " Jumping to beginning and end of methods in Java-like languages
2604 func Test_java_motion() 2763 func Test_java_motion()
2605 new 2764 new
2765 call assert_beeps('normal! [m')
2766 call assert_beeps('normal! ]m')
2767 call assert_beeps('normal! [M')
2768 call assert_beeps('normal! ]M')
2606 a 2769 a
2607 Piece of Java 2770 Piece of Java
2608 { 2771 {
2609 tt m1 { 2772 tt m1 {
2610 t1; 2773 t1;
2675 call assert_equal([2, 2, 2], [line('.'), col('.'), virtcol('.')]) 2838 call assert_equal([2, 2, 2], [line('.'), col('.'), virtcol('.')])
2676 2839
2677 close! 2840 close!
2678 endfunc 2841 endfunc
2679 2842
2680 fun! Test_normal_gdollar_cmd() 2843 func Test_normal_gdollar_cmd()
2681 if !has("jumplist") 2844 if !has("jumplist")
2682 return 2845 return
2683 endif 2846 endif
2684 " Tests for g cmds 2847 " Tests for g cmds
2685 call Setup_NewWindow() 2848 call Setup_NewWindow()
2838 call feedkeys("\<C-W>12n", 'xt') 3001 call feedkeys("\<C-W>12n", 'xt')
2839 call assert_equal(12, winheight(0)) 3002 call assert_equal(12, winheight(0))
2840 endfunc 3003 endfunc
2841 3004
2842 " Test for 'b', 'B' 'ge' and 'gE' commands 3005 " Test for 'b', 'B' 'ge' and 'gE' commands
2843 func Test_backward_motion() 3006 func Test_horiz_motion()
3007 new
2844 normal! gg 3008 normal! gg
2845 call assert_beeps('normal! b') 3009 call assert_beeps('normal! b')
2846 call assert_beeps('normal! B') 3010 call assert_beeps('normal! B')
2847 call assert_beeps('normal! gE') 3011 call assert_beeps('normal! gE')
2848 call assert_beeps('normal! ge') 3012 call assert_beeps('normal! ge')
3013 " <S-Backspace> moves one word left and <C-Backspace> moves one WORD left
3014 call setline(1, 'one ,two ,three')
3015 exe "normal! $\<S-BS>"
3016 call assert_equal(11, col('.'))
3017 exe "normal! $\<C-BS>"
3018 call assert_equal(10, col('.'))
3019 close!
3020 endfunc
3021
3022 " Test for using a : command in operator pending mode
3023 func Test_normal_colon_op()
3024 new
3025 call setline(1, ['one', 'two'])
3026 call assert_beeps("normal! Gc:d\<CR>")
3027 close!
2849 endfunc 3028 endfunc
2850 3029
2851 " vim: shiftwidth=2 sts=2 expandtab 3030 " vim: shiftwidth=2 sts=2 expandtab