Mirror of the Vim source from https://github.com/vim/vim
リビジョン | 2f4be7ca1b1bbbacd853c4ee11cba75041af76fa (tree) |
---|---|
日時 | 2020-02-16 21:45:04 |
作者 | Bram Moolenaar <Bram@vim....> |
コミッター | Bram Moolenaar |
patch 8.2.0261: some code not covered by tests
Commit: https://github.com/vim/vim/commit/f0cee1971f5258ce61f8a4e6a04d35c1e625bb01
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 16 13:33:56 2020 +0100
@@ -61,6 +61,97 @@ | ||
61 | 61 | call delete('b2') |
62 | 62 | call delete('b3') |
63 | 63 | call delete('b4') |
64 | + | |
65 | + call assert_fails('1,4bunload', 'E16:') | |
66 | + call assert_fails(',100bunload', 'E16:') | |
67 | + | |
68 | + " Use a try-catch for this test. When assert_fails() is used for this | |
69 | + " test, the command fails with E515: instead of E90: | |
70 | + let caught_E90 = 0 | |
71 | + try | |
72 | + $bunload | |
73 | + catch /E90:/ | |
74 | + let caught_E90 = 1 | |
75 | + endtry | |
76 | + call assert_equal(1, caught_E90) | |
77 | + call assert_fails('$bunload', 'E515:') | |
78 | +endfunc | |
79 | + | |
80 | +" Test for :buffer, :bnext, :bprevious, :brewind, :blast and :bmodified | |
81 | +" commands | |
82 | +func Test_buflist_browse() | |
83 | + %bwipe! | |
84 | + call assert_fails('buffer 1000', 'E86:') | |
85 | + | |
86 | + call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xfile1') | |
87 | + call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xfile2') | |
88 | + call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xfile3') | |
89 | + edit Xfile1 | |
90 | + let b1 = bufnr() | |
91 | + edit Xfile2 | |
92 | + let b2 = bufnr() | |
93 | + edit +/baz4 Xfile3 | |
94 | + let b3 = bufnr() | |
95 | + | |
96 | + call assert_fails('buffer ' .. b1 .. ' abc', 'E488:') | |
97 | + call assert_equal(b3, bufnr()) | |
98 | + call assert_equal(4, line('.')) | |
99 | + exe 'buffer +/bar2 ' .. b2 | |
100 | + call assert_equal(b2, bufnr()) | |
101 | + call assert_equal(2, line('.')) | |
102 | + exe 'buffer +/bar1' | |
103 | + call assert_equal(b2, bufnr()) | |
104 | + call assert_equal(1, line('.')) | |
105 | + | |
106 | + brewind +/foo3 | |
107 | + call assert_equal(b1, bufnr()) | |
108 | + call assert_equal(3, line('.')) | |
109 | + | |
110 | + blast +/baz2 | |
111 | + call assert_equal(b3, bufnr()) | |
112 | + call assert_equal(2, line('.')) | |
113 | + | |
114 | + bprevious +/bar4 | |
115 | + call assert_equal(b2, bufnr()) | |
116 | + call assert_equal(4, line('.')) | |
117 | + | |
118 | + bnext +/baz3 | |
119 | + call assert_equal(b3, bufnr()) | |
120 | + call assert_equal(3, line('.')) | |
121 | + | |
122 | + call assert_fails('bmodified', 'E84:') | |
123 | + call setbufvar(b2, '&modified', 1) | |
124 | + exe 'bmodified +/bar3' | |
125 | + call assert_equal(b2, bufnr()) | |
126 | + call assert_equal(3, line('.')) | |
127 | + | |
128 | + " With no listed buffers in the list, :bnext and :bprev should fail | |
129 | + %bwipe! | |
130 | + set nobuflisted | |
131 | + call assert_fails('bnext', 'E85:') | |
132 | + call assert_fails('bprev', 'E85:') | |
133 | + set buflisted | |
134 | + | |
135 | + call assert_fails('sandbox bnext', 'E48:') | |
136 | + | |
137 | + call delete('Xfile1') | |
138 | + call delete('Xfile2') | |
139 | + call delete('Xfile3') | |
140 | + %bwipe! | |
141 | +endfunc | |
142 | + | |
143 | +" Test for :bdelete | |
144 | +func Test_bdelete_cmd() | |
145 | + %bwipe! | |
146 | + call assert_fails('bdelete 5', 'E516:') | |
147 | + | |
148 | + " Deleting a unlisted and unloaded buffer | |
149 | + edit Xfile1 | |
150 | + let bnr = bufnr() | |
151 | + set nobuflisted | |
152 | + enew | |
153 | + call assert_fails('bdelete ' .. bnr, 'E516:') | |
154 | + %bwipe! | |
64 | 155 | endfunc |
65 | 156 | |
66 | 157 | " vim: shiftwidth=2 sts=2 expandtab |
@@ -632,9 +632,32 @@ | ||
632 | 632 | 1,\&s/b/B/ |
633 | 633 | call assert_equal('B', getline(2)) |
634 | 634 | |
635 | + let @/ = 'apple' | |
636 | + call assert_fails('\/print', 'E486:') | |
637 | + | |
635 | 638 | bwipe! |
636 | 639 | endfunc |
637 | 640 | |
641 | +" Test for the tick mark (') in an excmd range | |
642 | +func Test_tick_mark_in_range() | |
643 | + " If only the tick is passed as a range and no command is specified, there | |
644 | + " should not be an error | |
645 | + call feedkeys(":'\<CR>", 'xt') | |
646 | + call assert_equal("'", getreg(':')) | |
647 | + call assert_fails("',print", 'E78:') | |
648 | +endfunc | |
649 | + | |
650 | +" Test for using a line number followed by a search pattern as range | |
651 | +func Test_lnum_and_pattern_as_range() | |
652 | + new | |
653 | + call setline(1, ['foo 1', 'foo 2', 'foo 3']) | |
654 | + let @" = '' | |
655 | + 2/foo/yank | |
656 | + call assert_equal("foo 3\n", @") | |
657 | + call assert_equal(1, line('.')) | |
658 | + close! | |
659 | +endfunc | |
660 | + | |
638 | 661 | " Tests for getcmdline(), getcmdpos() and getcmdtype() |
639 | 662 | func Check_cmdline(cmdtype) |
640 | 663 | call assert_equal('MyCmd a', getcmdline()) |
@@ -934,4 +957,24 @@ | ||
934 | 957 | call assert_fails('e <amatch>', 'E497:') |
935 | 958 | endfunc |
936 | 959 | |
960 | +func Test_cmdwin_jump_to_win() | |
961 | + call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:') | |
962 | + new | |
963 | + set modified | |
964 | + call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', 'E162:') | |
965 | + close! | |
966 | + call feedkeys("q/:close\<CR>", "xt") | |
967 | + call assert_equal(1, winnr('$')) | |
968 | + call feedkeys("q/:exit\<CR>", "xt") | |
969 | + call assert_equal(1, winnr('$')) | |
970 | +endfunc | |
971 | + | |
972 | +" Test for backtick expression in the command line | |
973 | +func Test_cmd_backtick() | |
974 | + %argd | |
975 | + argadd `=['a', 'b', 'c']` | |
976 | + call assert_equal(['a', 'b', 'c'], argv()) | |
977 | + %argd | |
978 | +endfunc | |
979 | + | |
937 | 980 | " vim: shiftwidth=2 sts=2 expandtab |
@@ -94,8 +94,12 @@ | ||
94 | 94 | call assert_equal(0, exists(':edit/a')) |
95 | 95 | " Valid internal command (partial match) |
96 | 96 | call assert_equal(1, exists(':q')) |
97 | + " Valid internal command with a digit | |
98 | + call assert_equal(2, exists(':2match')) | |
97 | 99 | " Non-existing internal command |
98 | 100 | call assert_equal(0, exists(':invalidcmd')) |
101 | + " Internal command with a count | |
102 | + call assert_equal(0, exists(':3buffer')) | |
99 | 103 | |
100 | 104 | " User defined command (full match) |
101 | 105 | command! MyCmd :echo 'My command' |
@@ -146,3 +146,18 @@ | ||
146 | 146 | bwipe! |
147 | 147 | call delete('Xchanged_d') |
148 | 148 | endfunc |
149 | + | |
150 | +" Test for editing a new buffer from a FileChangedShell autocmd | |
151 | +func Test_FileChangedShell_newbuf() | |
152 | + call writefile(['one', 'two'], 'Xfile') | |
153 | + new Xfile | |
154 | + augroup testnewbuf | |
155 | + autocmd FileChangedShell * enew | |
156 | + augroup END | |
157 | + call writefile(['red'], 'Xfile') | |
158 | + call assert_fails('checktime', 'E811:') | |
159 | + au! testnewbuf | |
160 | + call delete('Xfile') | |
161 | +endfunc | |
162 | + | |
163 | +" vim: shiftwidth=2 sts=2 expandtab |
@@ -276,3 +276,23 @@ | ||
276 | 276 | call delete('XXUxDsMc') |
277 | 277 | call delete('Xtest') |
278 | 278 | endfunc |
279 | + | |
280 | +" Test for changing the fileformat using ++read | |
281 | +func Test_fileformat_plusplus_read() | |
282 | + new | |
283 | + call setline(1, ['one', 'two', 'three']) | |
284 | + w ++ff=dos Xfile1 | |
285 | + enew! | |
286 | + r ++fileformat=unix Xfile1 | |
287 | + call assert_equal('unix', &fileformat) | |
288 | + 3r ++edit Xfile1 | |
289 | + call assert_equal('dos', &fileformat) | |
290 | + close! | |
291 | + call delete('Xfile1') | |
292 | + set fileformat& | |
293 | + call assert_fails('e ++fileformat Xfile1', 'E474:') | |
294 | + call assert_fails('e ++ff=abc Xfile1', 'E474:') | |
295 | + call assert_fails('e ++abc1 Xfile1', 'E474:') | |
296 | +endfunc | |
297 | + | |
298 | +" vim: shiftwidth=2 sts=2 expandtab |
@@ -38,6 +38,7 @@ | ||
38 | 38 | |
39 | 39 | abclear |
40 | 40 | call assert_equal("\n\nNo abbreviation found", execute('abbrev')) |
41 | + call assert_fails('%abclear', 'E481:') | |
41 | 42 | endfunc |
42 | 43 | |
43 | 44 | func Test_abclear_buffer() |
@@ -212,4 +212,13 @@ | ||
212 | 212 | bwipe! |
213 | 213 | endfunc |
214 | 214 | |
215 | +" Test for :k command to set a mark | |
216 | +func Test_marks_k_cmd() | |
217 | + new | |
218 | + call setline(1, ['foo', 'bar', 'baz', 'qux']) | |
219 | + 1,3kr | |
220 | + call assert_equal([0, 3, 1, 0], getpos("'r")) | |
221 | + close! | |
222 | +endfunc | |
223 | + | |
215 | 224 | " vim: shiftwidth=2 sts=2 expandtab |
@@ -2705,3 +2705,19 @@ | ||
2705 | 2705 | bw! |
2706 | 2706 | set cpoptions& number& numberwidth& |
2707 | 2707 | endfunc |
2708 | + | |
2709 | +" Test for cursor movement with '-' in 'cpoptions' | |
2710 | +func Test_normal_cpo_minus() | |
2711 | + new | |
2712 | + call setline(1, ['foo', 'bar', 'baz']) | |
2713 | + let save_cpo = &cpo | |
2714 | + set cpo+=- | |
2715 | + call assert_beeps('normal 10j') | |
2716 | + call assert_equal(1, line('.')) | |
2717 | + normal G | |
2718 | + call assert_beeps('normal 10k') | |
2719 | + call assert_equal(3, line('.')) | |
2720 | + call assert_fails(10, 'E16:') | |
2721 | + let &cpo = save_cpo | |
2722 | + close! | |
2723 | +endfunc |
@@ -32,3 +32,16 @@ | ||
32 | 32 | bw! |
33 | 33 | call delete('Xfile') |
34 | 34 | endfunc |
35 | + | |
36 | +" Test for ++bin and ++nobin arguments | |
37 | +func Test_binary_arg() | |
38 | + new | |
39 | + edit ++bin Xfile1 | |
40 | + call assert_equal(1, &binary) | |
41 | + edit ++nobin Xfile2 | |
42 | + call assert_equal(0, &binary) | |
43 | + call assert_fails('edit ++binabc Xfile3', 'E474:') | |
44 | + close! | |
45 | +endfunc | |
46 | + | |
47 | +" vim: shiftwidth=2 sts=2 expandtab |
@@ -538,6 +538,15 @@ | ||
538 | 538 | 10Xcc |
539 | 539 | call assert_equal(11, line('.')) |
540 | 540 | call assert_equal('Xqftestfile2', bufname('%')) |
541 | + Xopen | |
542 | + call cursor(2, 1) | |
543 | + if a:cchar == 'c' | |
544 | + .cc | |
545 | + else | |
546 | + .ll | |
547 | + endif | |
548 | + call assert_equal(6, line('.')) | |
549 | + call assert_equal('Xqftestfile1', bufname('%')) | |
541 | 550 | |
542 | 551 | " Jumping to an error from the error window (when only the error window is |
543 | 552 | " present) |
@@ -743,6 +743,8 @@ | ||
743 | 743 | static int included_patches[] = |
744 | 744 | { /* Add new patch number below this line */ |
745 | 745 | /**/ |
746 | + 261, | |
747 | +/**/ | |
746 | 748 | 260, |
747 | 749 | /**/ |
748 | 750 | 259, |