• R/O
  • SSH

vim: コミット

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

patch 8.2.0261: some code not covered by tests
Problem: Some code not covered by tests.
Solution: Add test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5645)

変更サマリ

差分

diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_buffer.vim
--- a/src/testdir/test_buffer.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_buffer.vim Sun Feb 16 13:45:04 2020 +0100
@@ -61,6 +61,97 @@
6161 call delete('b2')
6262 call delete('b3')
6363 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!
64155 endfunc
65156
66157 " vim: shiftwidth=2 sts=2 expandtab
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_cmdline.vim
--- a/src/testdir/test_cmdline.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_cmdline.vim Sun Feb 16 13:45:04 2020 +0100
@@ -632,9 +632,32 @@
632632 1,\&s/b/B/
633633 call assert_equal('B', getline(2))
634634
635+ let @/ = 'apple'
636+ call assert_fails('\/print', 'E486:')
637+
635638 bwipe!
636639 endfunc
637640
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+
638661 " Tests for getcmdline(), getcmdpos() and getcmdtype()
639662 func Check_cmdline(cmdtype)
640663 call assert_equal('MyCmd a', getcmdline())
@@ -934,4 +957,24 @@
934957 call assert_fails('e <amatch>', 'E497:')
935958 endfunc
936959
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+
937980 " vim: shiftwidth=2 sts=2 expandtab
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_exists.vim
--- a/src/testdir/test_exists.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_exists.vim Sun Feb 16 13:45:04 2020 +0100
@@ -94,8 +94,12 @@
9494 call assert_equal(0, exists(':edit/a'))
9595 " Valid internal command (partial match)
9696 call assert_equal(1, exists(':q'))
97+ " Valid internal command with a digit
98+ call assert_equal(2, exists(':2match'))
9799 " Non-existing internal command
98100 call assert_equal(0, exists(':invalidcmd'))
101+ " Internal command with a count
102+ call assert_equal(0, exists(':3buffer'))
99103
100104 " User defined command (full match)
101105 command! MyCmd :echo 'My command'
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_filechanged.vim
--- a/src/testdir/test_filechanged.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_filechanged.vim Sun Feb 16 13:45:04 2020 +0100
@@ -146,3 +146,18 @@
146146 bwipe!
147147 call delete('Xchanged_d')
148148 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
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_fileformat.vim
--- a/src/testdir/test_fileformat.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_fileformat.vim Sun Feb 16 13:45:04 2020 +0100
@@ -276,3 +276,23 @@
276276 call delete('XXUxDsMc')
277277 call delete('Xtest')
278278 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
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_mapping.vim
--- a/src/testdir/test_mapping.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_mapping.vim Sun Feb 16 13:45:04 2020 +0100
@@ -38,6 +38,7 @@
3838
3939 abclear
4040 call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
41+ call assert_fails('%abclear', 'E481:')
4142 endfunc
4243
4344 func Test_abclear_buffer()
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_marks.vim
--- a/src/testdir/test_marks.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_marks.vim Sun Feb 16 13:45:04 2020 +0100
@@ -212,4 +212,13 @@
212212 bwipe!
213213 endfunc
214214
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+
215224 " vim: shiftwidth=2 sts=2 expandtab
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_normal.vim
--- a/src/testdir/test_normal.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_normal.vim Sun Feb 16 13:45:04 2020 +0100
@@ -2705,3 +2705,19 @@
27052705 bw!
27062706 set cpoptions& number& numberwidth&
27072707 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
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_plus_arg_edit.vim
--- a/src/testdir/test_plus_arg_edit.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_plus_arg_edit.vim Sun Feb 16 13:45:04 2020 +0100
@@ -32,3 +32,16 @@
3232 bw!
3333 call delete('Xfile')
3434 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
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/testdir/test_quickfix.vim
--- a/src/testdir/test_quickfix.vim Sat Feb 15 23:15:04 2020 +0100
+++ b/src/testdir/test_quickfix.vim Sun Feb 16 13:45:04 2020 +0100
@@ -538,6 +538,15 @@
538538 10Xcc
539539 call assert_equal(11, line('.'))
540540 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('%'))
541550
542551 " Jumping to an error from the error window (when only the error window is
543552 " present)
diff -r 9f499efdf2aa -r 2f4be7ca1b1b src/version.c
--- a/src/version.c Sat Feb 15 23:15:04 2020 +0100
+++ b/src/version.c Sun Feb 16 13:45:04 2020 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 261,
747+/**/
746748 260,
747749 /**/
748750 259,
旧リポジトリブラウザで表示