Mercurial > vim
comparison src/testdir/test_normal.vim @ 19613:9c15be376631 v8.2.0363
patch 8.2.0363: some Normal mode commands not tested
Commit: https://github.com/vim/vim/commit/f5f1e10d0d39890298cdf27f664d466c8872b87e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 8 05:13:15 2020 +0100
patch 8.2.0363: some Normal mode commands not tested
Problem: Some Normal mode commands not tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5746)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 08 Mar 2020 05:15:04 +0100 |
parents | cb73f4ae6b7c |
children | f70a3c1000bb |
comparison
equal
deleted
inserted
replaced
19612:a70ee453358e | 19613:9c15be376631 |
---|---|
113 | 113 |
114 " clean up | 114 " clean up |
115 bw! | 115 bw! |
116 endfunc | 116 endfunc |
117 | 117 |
118 " Test for select mode | |
118 func Test_normal02_selectmode() | 119 func Test_normal02_selectmode() |
119 " some basic select mode tests | |
120 call Setup_NewWindow() | 120 call Setup_NewWindow() |
121 50 | 121 50 |
122 norm! gHy | 122 norm! gHy |
123 call assert_equal('y51', getline('.')) | 123 call assert_equal('y51', getline('.')) |
124 call setline(1, range(1,100)) | 124 call setline(1, range(1,100)) |
437 func Test_normal12_nv_error() | 437 func Test_normal12_nv_error() |
438 " Test for nv_error | 438 " Test for nv_error |
439 10new | 439 10new |
440 call setline(1, range(1,5)) | 440 call setline(1, range(1,5)) |
441 " should not do anything, just beep | 441 " should not do anything, just beep |
442 exe "norm! <c-k>" | 442 call assert_beeps('exe "norm! <c-k>"') |
443 call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) | 443 call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) |
444 call assert_beeps('normal! G2dd') | |
445 call assert_beeps("normal! g\<C-A>") | |
446 call assert_beeps("normal! g\<C-X>") | |
447 call assert_beeps("normal! g\<C-B>") | |
444 bw! | 448 bw! |
445 endfunc | 449 endfunc |
446 | 450 |
447 func Test_normal13_help() | 451 func Test_normal13_help() |
448 " Test for F1 | 452 " Test for F1 |
1626 catch /E197:/ | 1630 catch /E197:/ |
1627 " can't use Turkish locale | 1631 " can't use Turkish locale |
1628 throw 'Skipped: Turkish locale not available' | 1632 throw 'Skipped: Turkish locale not available' |
1629 endtry | 1633 endtry |
1630 | 1634 |
1635 call setline(1, ['aaaaaa', 'aaaaaa']) | |
1636 normal! gg10~ | |
1637 call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2)) | |
1638 set whichwrap+=~ | |
1639 normal! gg10~ | |
1640 call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2)) | |
1641 set whichwrap& | |
1642 | |
1631 " clean up | 1643 " clean up |
1632 bw! | 1644 bw! |
1633 endfunc | 1645 endfunc |
1634 | 1646 |
1635 fun! Test_normal31_r_cmd() | 1647 fun! Test_normal31_r_cmd() |
1655 " clean up | 1667 " clean up |
1656 set noautoindent | 1668 set noautoindent |
1657 bw! | 1669 bw! |
1658 endfunc | 1670 endfunc |
1659 | 1671 |
1672 " Test for g*, g# | |
1660 func Test_normal32_g_cmd1() | 1673 func Test_normal32_g_cmd1() |
1661 " Test for g*, g# | |
1662 new | 1674 new |
1663 call append(0, ['abc.x_foo', 'x_foobar.abc']) | 1675 call append(0, ['abc.x_foo', 'x_foobar.abc']) |
1664 1 | 1676 1 |
1665 norm! $g* | 1677 norm! $g* |
1666 call assert_equal('x_foo', @/) | 1678 call assert_equal('x_foo', @/) |
1671 | 1683 |
1672 " clean up | 1684 " clean up |
1673 bw! | 1685 bw! |
1674 endfunc | 1686 endfunc |
1675 | 1687 |
1688 " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G, | |
1689 " gi and gI commands | |
1676 fun! Test_normal33_g_cmd2() | 1690 fun! Test_normal33_g_cmd2() |
1677 if !has("jumplist") | 1691 if !has("jumplist") |
1678 return | 1692 return |
1679 endif | 1693 endif |
1680 " Tests for g cmds | |
1681 call Setup_NewWindow() | 1694 call Setup_NewWindow() |
1682 " Test for g` | 1695 " Test for g` |
1683 clearjumps | 1696 clearjumps |
1684 norm! ma10j | 1697 norm! ma10j |
1685 let a=execute(':jumps') | 1698 let a=execute(':jumps') |
1687 call assert_equal('>', a[-1:]) | 1700 call assert_equal('>', a[-1:]) |
1688 norm! g`a | 1701 norm! g`a |
1689 call assert_equal('>', a[-1:]) | 1702 call assert_equal('>', a[-1:]) |
1690 call assert_equal(1, line('.')) | 1703 call assert_equal(1, line('.')) |
1691 call assert_equal('1', getline('.')) | 1704 call assert_equal('1', getline('.')) |
1705 call cursor(10, 1) | |
1706 norm! g'a | |
1707 call assert_equal('>', a[-1:]) | |
1708 call assert_equal(1, line('.')) | |
1692 | 1709 |
1693 " Test for g; and g, | 1710 " Test for g; and g, |
1694 norm! g; | 1711 norm! g; |
1695 " there is only one change in the changelist | 1712 " there is only one change in the changelist |
1696 " currently, when we setup the window | 1713 " currently, when we setup the window |
1728 exe "norm! G0\<c-v>4k4lgvd" | 1745 exe "norm! G0\<c-v>4k4lgvd" |
1729 call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'], getline(1,'$')) | 1746 call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'], getline(1,'$')) |
1730 exe "norm! G0\<c-v>4k4ly" | 1747 exe "norm! G0\<c-v>4k4ly" |
1731 exe "norm! gvood" | 1748 exe "norm! gvood" |
1732 call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$')) | 1749 call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$')) |
1750 " gv cannot be used in operator pending mode | |
1751 call assert_beeps('normal! cgv') | |
1752 " gv should beep without a previously selected visual area | |
1753 new | |
1754 call assert_beeps('normal! gv') | |
1755 close | |
1733 | 1756 |
1734 " Test for gk/gj | 1757 " Test for gk/gj |
1735 %d | 1758 %d |
1736 15vsp | 1759 15vsp |
1737 set wrap listchars= sbr= | 1760 set wrap listchars= sbr= |
1768 call assert_equal(17, col('.')) | 1791 call assert_equal(17, col('.')) |
1769 call assert_equal('n', getreg(0)) | 1792 call assert_equal('n', getreg(0)) |
1770 norm! g^yl | 1793 norm! g^yl |
1771 call assert_equal(15, col('.')) | 1794 call assert_equal(15, col('.')) |
1772 call assert_equal('l', getreg(0)) | 1795 call assert_equal('l', getreg(0)) |
1773 | 1796 call assert_beeps('normal 5g$') |
1774 norm! 2ggdd | 1797 |
1798 " Test for g_ | |
1799 call assert_beeps('normal! 100g_') | |
1800 call setline(2, [' foo ', ' foobar ']) | |
1801 normal! 2ggg_ | |
1802 call assert_equal(5, col('.')) | |
1803 normal! 2g_ | |
1804 call assert_equal(8, col('.')) | |
1805 | |
1806 norm! 2ggdG | |
1775 $put =lineC | 1807 $put =lineC |
1776 | 1808 |
1777 " Test for gM | 1809 " Test for gM |
1778 norm! gMyl | 1810 norm! gMyl |
1779 call assert_equal(73, col('.')) | 1811 call assert_equal(73, col('.')) |
1803 call setline(1, ['foobar', 'new line']) | 1835 call setline(1, ['foobar', 'new line']) |
1804 norm! A next word | 1836 norm! A next word |
1805 $put ='third line' | 1837 $put ='third line' |
1806 norm! gi another word | 1838 norm! gi another word |
1807 call assert_equal(['foobar next word another word', 'new line', 'third line'], getline(1,'$')) | 1839 call assert_equal(['foobar next word another word', 'new line', 'third line'], getline(1,'$')) |
1808 | 1840 call setline(1, 'foobar') |
1809 " clean up | 1841 normal! Ggifirst line |
1810 bw! | 1842 call assert_equal('foobarfirst line', getline(1)) |
1811 endfunc | 1843 " Test gi in 'virtualedit' mode with cursor after the end of the line |
1812 | 1844 set virtualedit=all |
1845 call setline(1, 'foo') | |
1846 exe "normal! Abar\<Right>\<Right>\<Right>\<Right>" | |
1847 call setline(1, 'foo') | |
1848 normal! Ggifirst line | |
1849 call assert_equal('foo first line', getline(1)) | |
1850 set virtualedit& | |
1851 | |
1852 " clean up | |
1853 bw! | |
1854 endfunc | |
1855 | |
1856 " Test for g CTRL-G | |
1813 func Test_g_ctrl_g() | 1857 func Test_g_ctrl_g() |
1814 new | 1858 new |
1815 | 1859 |
1816 let a = execute(":norm! g\<c-g>") | 1860 let a = execute(":norm! g\<c-g>") |
1817 call assert_equal("\n--No lines in buffer--", a) | 1861 call assert_equal("\n--No lines in buffer--", a) |
1881 | 1925 |
1882 set ff& | 1926 set ff& |
1883 bwipe! | 1927 bwipe! |
1884 endfunc | 1928 endfunc |
1885 | 1929 |
1930 " Test for g8 | |
1886 fun! Test_normal34_g_cmd3() | 1931 fun! Test_normal34_g_cmd3() |
1887 " Test for g8 | |
1888 new | 1932 new |
1889 let a=execute(':norm! 1G0g8') | 1933 let a=execute(':norm! 1G0g8') |
1890 call assert_equal("\nNUL", a) | 1934 call assert_equal("\nNUL", a) |
1891 | 1935 |
1892 call setline(1, 'abcdefghijklmnopqrstuvwxyzäüö') | 1936 call setline(1, 'abcdefghijklmnopqrstuvwxyzäüö') |
1899 | 1943 |
1900 " clean up | 1944 " clean up |
1901 bw! | 1945 bw! |
1902 endfunc | 1946 endfunc |
1903 | 1947 |
1948 " Test 8g8 which finds invalid utf8 at or after the cursor. | |
1904 func Test_normal_8g8() | 1949 func Test_normal_8g8() |
1905 new | 1950 new |
1906 | |
1907 " Test 8g8 which finds invalid utf8 at or after the cursor. | |
1908 | 1951 |
1909 " With invalid byte. | 1952 " With invalid byte. |
1910 call setline(1, "___\xff___") | 1953 call setline(1, "___\xff___") |
1911 norm! 1G08g8g | 1954 norm! 1G08g8g |
1912 call assert_equal([0, 1, 4, 0, 1], getcurpos()) | 1955 call assert_equal([0, 1, 4, 0, 1], getcurpos()) |
1932 call assert_equal([0, 1, 1, 0, 1], getcurpos()) | 1975 call assert_equal([0, 1, 1, 0, 1], getcurpos()) |
1933 | 1976 |
1934 bw! | 1977 bw! |
1935 endfunc | 1978 endfunc |
1936 | 1979 |
1980 " Test for g< | |
1937 fun! Test_normal35_g_cmd4() | 1981 fun! Test_normal35_g_cmd4() |
1938 " Test for g< | |
1939 " Cannot capture its output, | 1982 " Cannot capture its output, |
1940 " probably a bug, therefore, test disabled: | 1983 " probably a bug, therefore, test disabled: |
1941 throw "Skipped: output of g< can't be tested currently" | 1984 throw "Skipped: output of g< can't be tested currently" |
1942 echo "a\nb\nc\nd" | 1985 echo "a\nb\nc\nd" |
1943 let b=execute(':norm! g<') | 1986 let b=execute(':norm! g<') |
1944 call assert_true(!empty(b), 'failed `execute(g<)`') | 1987 call assert_true(!empty(b), 'failed `execute(g<)`') |
1945 endfunc | 1988 endfunc |
1946 | 1989 |
1990 " Test for gp gP go | |
1947 fun! Test_normal36_g_cmd5() | 1991 fun! Test_normal36_g_cmd5() |
1948 new | 1992 new |
1949 call append(0, 'abcdefghijklmnopqrstuvwxyz') | 1993 call append(0, 'abcdefghijklmnopqrstuvwxyz') |
1950 set ff=unix | 1994 set ff=unix |
1951 " Test for gp gP | 1995 " Test for gp gP |
1980 call assert_equal([0, 14, 1, 0, 2147483647], getcurpos()) | 2024 call assert_equal([0, 14, 1, 0, 2147483647], getcurpos()) |
1981 " clean up | 2025 " clean up |
1982 bw! | 2026 bw! |
1983 endfunc | 2027 endfunc |
1984 | 2028 |
2029 " Test for gt and gT | |
1985 fun! Test_normal37_g_cmd6() | 2030 fun! Test_normal37_g_cmd6() |
1986 " basic test for gt and gT | |
1987 tabnew 1.txt | 2031 tabnew 1.txt |
1988 tabnew 2.txt | 2032 tabnew 2.txt |
1989 tabnew 3.txt | 2033 tabnew 3.txt |
1990 norm! 1gt | 2034 norm! 1gt |
1991 call assert_equal(1, tabpagenr()) | 2035 call assert_equal(1, tabpagenr()) |
2007 endfor | 2051 endfor |
2008 " clean up | 2052 " clean up |
2009 call assert_fails(':tabclose', 'E784:') | 2053 call assert_fails(':tabclose', 'E784:') |
2010 endfunc | 2054 endfunc |
2011 | 2055 |
2056 " Test for <Home> and <C-Home> key | |
2012 fun! Test_normal38_nvhome() | 2057 fun! Test_normal38_nvhome() |
2013 " Test for <Home> and <C-Home> key | |
2014 new | 2058 new |
2015 call setline(1, range(10)) | 2059 call setline(1, range(10)) |
2016 $ | 2060 $ |
2017 setl et sw=2 | 2061 setl et sw=2 |
2018 norm! V10>$ | 2062 norm! V10>$ |
2023 call assert_equal([0, 10, 1, 0, 1], getcurpos()) | 2067 call assert_equal([0, 10, 1, 0, 1], getcurpos()) |
2024 exe "norm! 5\<c-home>" | 2068 exe "norm! 5\<c-home>" |
2025 call assert_equal([0, 5, 1, 0, 1], getcurpos()) | 2069 call assert_equal([0, 5, 1, 0, 1], getcurpos()) |
2026 exe "norm! \<c-home>" | 2070 exe "norm! \<c-home>" |
2027 call assert_equal([0, 1, 1, 0, 1], getcurpos()) | 2071 call assert_equal([0, 1, 1, 0, 1], getcurpos()) |
2028 | 2072 exe "norm! G\<c-kHome>" |
2029 " clean up | 2073 call assert_equal([0, 1, 1, 0, 1], getcurpos()) |
2030 bw! | 2074 |
2031 endfunc | 2075 " clean up |
2032 | 2076 bw! |
2077 endfunc | |
2078 | |
2079 " Test for cw cW ce | |
2033 fun! Test_normal39_cw() | 2080 fun! Test_normal39_cw() |
2034 " Test for cw and cW on whitespace | 2081 " Test for cw and cW on whitespace |
2035 " and cpo+=w setting | 2082 " and cpo+=w setting |
2036 new | 2083 new |
2037 set tw=0 | 2084 set tw=0 |
2048 call assert_equal('hereZZZ areYYY some words', getline('.')) | 2095 call assert_equal('hereZZZ areYYY some words', getline('.')) |
2049 set cpo-=w | 2096 set cpo-=w |
2050 norm! 2gg0cwfoo | 2097 norm! 2gg0cwfoo |
2051 call assert_equal('foo', getline('.')) | 2098 call assert_equal('foo', getline('.')) |
2052 | 2099 |
2053 " clean up | 2100 call setline(1, 'one; two') |
2054 bw! | 2101 call cursor(1, 1) |
2055 endfunc | 2102 call feedkeys('cwvim', 'xt') |
2056 | 2103 call assert_equal('vim; two', getline(1)) |
2104 call feedkeys('0cWone', 'xt') | |
2105 call assert_equal('one two', getline(1)) | |
2106 "When cursor is at the end of a word 'ce' will change until the end of the | |
2107 "next word, but 'cw' will change only one character | |
2108 call setline(1, 'one two') | |
2109 call feedkeys('0ecwce', 'xt') | |
2110 call assert_equal('once two', getline(1)) | |
2111 call setline(1, 'one two') | |
2112 call feedkeys('0ecely', 'xt') | |
2113 call assert_equal('only', getline(1)) | |
2114 | |
2115 " clean up | |
2116 bw! | |
2117 endfunc | |
2118 | |
2119 " Test for CTRL-\ commands | |
2057 fun! Test_normal40_ctrl_bsl() | 2120 fun! Test_normal40_ctrl_bsl() |
2058 " Basic test for CTRL-\ commands | |
2059 new | 2121 new |
2060 call append(0, 'here are some words') | 2122 call append(0, 'here are some words') |
2061 exe "norm! 1gg0a\<C-\>\<C-N>" | 2123 exe "norm! 1gg0a\<C-\>\<C-N>" |
2062 call assert_equal('n', mode()) | 2124 call assert_equal('n', mode()) |
2063 call assert_equal(1, col('.')) | 2125 call assert_equal(1, col('.')) |
2077 | 2139 |
2078 " clean up | 2140 " clean up |
2079 bw! | 2141 bw! |
2080 endfunc | 2142 endfunc |
2081 | 2143 |
2144 " Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>= in insert mode | |
2082 fun! Test_normal41_insert_reg() | 2145 fun! Test_normal41_insert_reg() |
2083 " Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>= | |
2084 " in insert mode | |
2085 new | 2146 new |
2086 set sts=2 sw=2 ts=8 tw=0 | 2147 set sts=2 sw=2 ts=8 tw=0 |
2087 call append(0, ["aaa\tbbb\tccc", '', '', '']) | 2148 call append(0, ["aaa\tbbb\tccc", '', '', '']) |
2088 let a=getline(1) | 2149 let a=getline(1) |
2089 norm! 2gg0 | 2150 norm! 2gg0 |
2097 " clean up | 2158 " clean up |
2098 set sts=0 sw=8 ts=8 | 2159 set sts=0 sw=8 ts=8 |
2099 bw! | 2160 bw! |
2100 endfunc | 2161 endfunc |
2101 | 2162 |
2163 " Test for Ctrl-D and Ctrl-U | |
2102 func Test_normal42_halfpage() | 2164 func Test_normal42_halfpage() |
2103 " basic test for Ctrl-D and Ctrl-U | |
2104 call Setup_NewWindow() | 2165 call Setup_NewWindow() |
2105 call assert_equal(5, &scroll) | 2166 call assert_equal(5, &scroll) |
2106 exe "norm! \<c-d>" | 2167 exe "norm! \<c-d>" |
2107 call assert_equal('6', getline('.')) | 2168 call assert_equal('6', getline('.')) |
2108 exe "norm! 2\<c-d>" | 2169 exe "norm! 2\<c-d>" |
2134 " cleanup | 2195 " cleanup |
2135 set startofline | 2196 set startofline |
2136 bw! | 2197 bw! |
2137 endfunc | 2198 endfunc |
2138 | 2199 |
2200 " Tests for text object aw | |
2139 fun! Test_normal43_textobject1() | 2201 fun! Test_normal43_textobject1() |
2140 " basic tests for text object aw | |
2141 new | 2202 new |
2142 call append(0, ['foobar,eins,foobar', 'foo,zwei,foo ']) | 2203 call append(0, ['foobar,eins,foobar', 'foo,zwei,foo ']) |
2143 " diw | 2204 " diw |
2144 norm! 1gg0diw | 2205 norm! 1gg0diw |
2145 call assert_equal([',eins,foobar', 'foo,zwei,foo ', ''], getline(1,'$')) | 2206 call assert_equal([',eins,foobar', 'foo,zwei,foo ', ''], getline(1,'$')) |
2165 | 2226 |
2166 " clean up | 2227 " clean up |
2167 bw! | 2228 bw! |
2168 endfunc | 2229 endfunc |
2169 | 2230 |
2231 " Test for is and as text objects | |
2170 func Test_normal44_textobjects2() | 2232 func Test_normal44_textobjects2() |
2171 " basic testing for is and as text objects | |
2172 new | 2233 new |
2173 call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) | 2234 call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) |
2174 " Test for dis - does not remove trailing whitespace | 2235 " Test for dis - does not remove trailing whitespace |
2175 norm! 1gg0dis | 2236 norm! 1gg0dis |
2176 call assert_equal([' With some sentences!', '', 'Even with a question? And one more. And no sentence here', ''], getline(1,'$')) | 2237 call assert_equal([' With some sentences!', '', 'Even with a question? And one more. And no sentence here', ''], getline(1,'$')) |
2460 undo | 2521 undo |
2461 set cpo+=X | 2522 set cpo+=X |
2462 normal 4gro | 2523 normal 4gro |
2463 call assert_equal('ooooecond line', getline(2)) | 2524 call assert_equal('ooooecond line', getline(2)) |
2464 let &cpo = save_cpo | 2525 let &cpo = save_cpo |
2526 normal! ggvegrx | |
2527 call assert_equal('xxxxx line', getline(1)) | |
2528 exe "normal! gggr\<C-V>122" | |
2529 call assert_equal('zxxxx line', getline(1)) | |
2530 set virtualedit=all | |
2531 normal! 15|grl | |
2532 call assert_equal('zxxxx line l', getline(1)) | |
2533 set virtualedit& | |
2534 set nomodifiable | |
2535 call assert_fails('normal! grx', 'E21:') | |
2536 call assert_fails('normal! gRx', 'E21:') | |
2537 set modifiable& | |
2465 enew! | 2538 enew! |
2466 endfunc | 2539 endfunc |
2467 | 2540 |
2468 " When splitting a window the changelist position is wrong. | 2541 " When splitting a window the changelist position is wrong. |
2469 " Test the changelist position after splitting a window. | 2542 " Test the changelist position after splitting a window. |
2657 call assert_equal(20, col("'>")) | 2730 call assert_equal(20, col("'>")) |
2658 call assert_equal('100 foobar foobar fo', getreg(0)) | 2731 call assert_equal('100 foobar foobar fo', getreg(0)) |
2659 bw! | 2732 bw! |
2660 endfunc | 2733 endfunc |
2661 | 2734 |
2662 func Test_normal_gk() | 2735 func Test_normal_gk_gj() |
2663 " needs 80 column new window | 2736 " needs 80 column new window |
2664 new | 2737 new |
2665 vert 80new | 2738 vert 80new |
2739 call assert_beeps('normal gk') | |
2666 put =[repeat('x',90)..' {{{1', 'x {{{1'] | 2740 put =[repeat('x',90)..' {{{1', 'x {{{1'] |
2667 norm! gk | 2741 norm! gk |
2668 " In a 80 column wide terminal the window will be only 78 char | 2742 " In a 80 column wide terminal the window will be only 78 char |
2669 " (because Vim will leave space for the other window), | 2743 " (because Vim will leave space for the other window), |
2670 " but if the terminal is larger, it will be 80 chars, so verify the | 2744 " but if the terminal is larger, it will be 80 chars, so verify the |
2675 call assert_equal(6, col('.')) | 2749 call assert_equal(6, col('.')) |
2676 call assert_equal(6, virtcol('.')) | 2750 call assert_equal(6, virtcol('.')) |
2677 norm! gk | 2751 norm! gk |
2678 call assert_equal(95, col('.')) | 2752 call assert_equal(95, col('.')) |
2679 call assert_equal(95, virtcol('.')) | 2753 call assert_equal(95, virtcol('.')) |
2680 bw! | 2754 %bw! |
2681 bw! | |
2682 | 2755 |
2683 " needs 80 column new window | 2756 " needs 80 column new window |
2684 new | 2757 new |
2685 vert 80new | 2758 vert 80new |
2759 call assert_beeps('normal gj') | |
2686 set number | 2760 set number |
2687 set numberwidth=10 | 2761 set numberwidth=10 |
2688 set cpoptions+=n | 2762 set cpoptions+=n |
2689 put =[repeat('0',90), repeat('1',90)] | 2763 put =[repeat('0',90), repeat('1',90)] |
2690 norm! 075l | 2764 norm! 075l |
2699 call assert_equal(76, col('.')) | 2773 call assert_equal(76, col('.')) |
2700 norm! gj | 2774 norm! gj |
2701 call assert_equal(1, col('.')) | 2775 call assert_equal(1, col('.')) |
2702 norm! gj | 2776 norm! gj |
2703 call assert_equal(76, col('.')) | 2777 call assert_equal(76, col('.')) |
2704 bw! | 2778 " When 'nowrap' is set, gk and gj behave like k and j |
2705 bw! | 2779 set nowrap |
2706 set cpoptions& number& numberwidth& | 2780 normal! gk |
2781 call assert_equal([2, 76], [line('.'), col('.')]) | |
2782 normal! gj | |
2783 call assert_equal([3, 76], [line('.'), col('.')]) | |
2784 %bw! | |
2785 set cpoptions& number& numberwidth& wrap& | |
2707 endfunc | 2786 endfunc |
2708 | 2787 |
2709 " Test for cursor movement with '-' in 'cpoptions' | 2788 " Test for cursor movement with '-' in 'cpoptions' |
2710 func Test_normal_cpo_minus() | 2789 func Test_normal_cpo_minus() |
2711 new | 2790 new |
2729 let @a = '' | 2808 let @a = '' |
2730 call feedkeys("\"ay:if v:true\<CR>normal l\<CR>endif\<CR>", 'xt') | 2809 call feedkeys("\"ay:if v:true\<CR>normal l\<CR>endif\<CR>", 'xt') |
2731 call assert_equal('f', @a) | 2810 call assert_equal('f', @a) |
2732 close! | 2811 close! |
2733 endfunc | 2812 endfunc |
2813 | |
2814 " Test for supplying a count to a normal-mode command across a cursorhold call | |
2815 func Test_normal_cursorhold_with_count() | |
2816 func s:cHold() | |
2817 let g:cHold_Called += 1 | |
2818 endfunc | |
2819 new | |
2820 augroup normalcHoldTest | |
2821 au! | |
2822 au CursorHold <buffer> call s:cHold() | |
2823 augroup END | |
2824 let g:cHold_Called = 0 | |
2825 call feedkeys("3\<CursorHold>2ix", 'xt') | |
2826 call assert_equal(1, g:cHold_Called) | |
2827 call assert_equal(repeat('x', 32), getline(1)) | |
2828 augroup normalcHoldTest | |
2829 au! | |
2830 augroup END | |
2831 au! normalcHoldTest | |
2832 close! | |
2833 delfunc s:cHold | |
2834 endfunc | |
2835 | |
2836 " Test for using a count and a command with CTRL-W | |
2837 func Test_wincmd_with_count() | |
2838 call feedkeys("\<C-W>12n", 'xt') | |
2839 call assert_equal(12, winheight(0)) | |
2840 endfunc | |
2841 | |
2842 " Test for 'b', 'B' 'ge' and 'gE' commands | |
2843 func Test_backward_motion() | |
2844 normal! gg | |
2845 call assert_beeps('normal! b') | |
2846 call assert_beeps('normal! B') | |
2847 call assert_beeps('normal! gE') | |
2848 call assert_beeps('normal! ge') | |
2849 endfunc | |
2850 | |
2851 " vim: shiftwidth=2 sts=2 expandtab |