• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisão67fbe280a502a7f8c5f030e3cbcb7f71bdceccd4 (tree)
Hora2020-02-18 05:45:04
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Mensagem de Log

patch 8.2.0270: some code not covered by tests

Commit: https://github.com/vim/vim/commit/bc2b71d44a0b90b6aeb3534a76912fccbe5577df
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 17 21:33:30 2020 +0100

patch 8.2.0270: 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/5649)

Mudança Sumário

Diff

diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_autocmd.vim
--- a/src/testdir/test_autocmd.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_autocmd.vim Mon Feb 17 21:45:04 2020 +0100
@@ -2357,3 +2357,5 @@
23572357 au! crash
23582358 setglobal spellfile=
23592359 endfunc
2360+
2361+" vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_buffer.vim
--- a/src/testdir/test_buffer.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_buffer.vim Mon Feb 17 21:45:04 2020 +0100
@@ -103,9 +103,9 @@
103103 call assert_equal(b2, bufnr())
104104 call assert_equal(1, line('.'))
105105
106- brewind +/foo3
106+ brewind +
107107 call assert_equal(b1, bufnr())
108- call assert_equal(3, line('.'))
108+ call assert_equal(4, line('.'))
109109
110110 blast +/baz2
111111 call assert_equal(b3, bufnr())
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_edit.vim
--- a/src/testdir/test_edit.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_edit.vim Mon Feb 17 21:45:04 2020 +0100
@@ -1500,6 +1500,22 @@
15001500 bwipe!
15011501 endfunc
15021502
1503+" Test for :startreplace and :startgreplace
1504+func Test_edit_startreplace()
1505+ new
1506+ call setline(1, 'abc')
1507+ call feedkeys("l:startreplace\<CR>xyz\e", 'xt')
1508+ call assert_equal('axyz', getline(1))
1509+ call feedkeys("0:startreplace!\<CR>abc\e", 'xt')
1510+ call assert_equal('axyzabc', getline(1))
1511+ call setline(1, "a\tb")
1512+ call feedkeys("0l:startgreplace\<CR>xyz\e", 'xt')
1513+ call assert_equal("axyz\tb", getline(1))
1514+ call feedkeys("0i\<C-R>=execute('startreplace')\<CR>12\e", 'xt')
1515+ call assert_equal("12axyz\tb", getline(1))
1516+ close!
1517+endfunc
1518+
15031519 func Test_edit_noesckeys()
15041520 CheckNotGui
15051521 new
@@ -1519,3 +1535,5 @@
15191535 bwipe!
15201536 set esckeys
15211537 endfunc
1538+
1539+" vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_ex_mode.vim
--- a/src/testdir/test_ex_mode.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_ex_mode.vim Mon Feb 17 21:45:04 2020 +0100
@@ -55,7 +55,7 @@
5555 let &encoding = encoding_save
5656 endfunc
5757
58-" Test subsittute confirmation prompt :%s/pat/str/c in Ex mode
58+" Test substitute confirmation prompt :%s/pat/str/c in Ex mode
5959 func Test_Ex_substitute()
6060 CheckRunVimInTerminal
6161 let buf = RunVimInTerminal('', {'rows': 6})
@@ -77,6 +77,11 @@
7777 call term_sendkeys(buf, "q\<CR>")
7878 call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
7979
80+ " Pressing enter in ex mode should print the current line
81+ call term_sendkeys(buf, "\<CR>")
82+ call WaitForAssert({-> assert_match(' 3 foo foo',
83+ \ term_getline(buf, 5))}, 1000)
84+
8085 call term_sendkeys(buf, ":vi\<CR>")
8186 call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000)
8287
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_excmd.vim
--- a/src/testdir/test_excmd.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_excmd.vim Mon Feb 17 21:45:04 2020 +0100
@@ -267,6 +267,16 @@
267267 call assert_fails('redir! > Xfile', 'E190:')
268268 call delete('Xfile')
269269 endif
270+
271+ " Test for redirecting to a register
272+ redir @q> | echon 'clean ' | redir END
273+ redir @q>> | echon 'water' | redir END
274+ call assert_equal('clean water', @q)
275+
276+ " Test for redirecting to a variable
277+ redir => color | echon 'blue ' | redir END
278+ redir =>> color | echon 'sky' | redir END
279+ call assert_equal('blue sky', color)
270280 endfunc
271281
272282 " Test for the :filetype command
@@ -279,4 +289,50 @@
279289 call assert_fails('mode abc', 'E359:')
280290 endfunc
281291
292+" Test for the :sleep command
293+func Test_sleep_cmd()
294+ call assert_fails('sleep x', 'E475:')
295+endfunc
296+
297+" Test for the :read command
298+func Test_read_cmd()
299+ call writefile(['one'], 'Xfile')
300+ new
301+ call assert_fails('read', 'E32:')
302+ edit Xfile
303+ read
304+ call assert_equal(['one', 'one'], getline(1, '$'))
305+ close!
306+ new
307+ read Xfile
308+ call assert_equal(['', 'one'], getline(1, '$'))
309+ call deletebufline('', 1, '$')
310+ call feedkeys("Qr Xfile\<CR>visual\<CR>", 'xt')
311+ call assert_equal(['one'], getline(1, '$'))
312+ close!
313+ call delete('Xfile')
314+endfunc
315+
316+" Test for running Ex commands when text is locked.
317+" <C-\>e in the command line is used to lock the text
318+func Test_run_excmd_with_text_locked()
319+ " :quit
320+ let cmd = ":\<C-\>eexecute('quit')\<CR>\<C-C>"
321+ call assert_fails("call feedkeys(cmd, 'xt')", 'E523:')
322+
323+ " :qall
324+ let cmd = ":\<C-\>eexecute('qall')\<CR>\<C-C>"
325+ call assert_fails("call feedkeys(cmd, 'xt')", 'E523:')
326+
327+ " :exit
328+ let cmd = ":\<C-\>eexecute('exit')\<CR>\<C-C>"
329+ call assert_fails("call feedkeys(cmd, 'xt')", 'E523:')
330+
331+ " :close - should be ignored
332+ new
333+ let cmd = ":\<C-\>eexecute('close')\<CR>\<C-C>"
334+ call assert_equal(2, winnr('$'))
335+ close
336+endfunc
337+
282338 " vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_expand.vim
--- a/src/testdir/test_expand.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_expand.vim Mon Feb 17 21:45:04 2020 +0100
@@ -1,5 +1,7 @@
11 " Test for expanding file names
22
3+source shared.vim
4+
35 func Test_with_directories()
46 call mkdir('Xdir1')
57 call mkdir('Xdir2')
@@ -81,3 +83,30 @@
8183 call assert_fails('call expandcmd("make %")', 'E499:')
8284 close
8385 endfunc
86+
87+" Test for expanding <sfile>, <slnum> and <sflnum> outside of sourcing a script
88+func Test_source_sfile()
89+ let lines =<< trim [SCRIPT]
90+ :call assert_fails('echo expandcmd("<sfile>")', 'E498:')
91+ :call assert_fails('echo expandcmd("<slnum>")', 'E842:')
92+ :call assert_fails('echo expandcmd("<sflnum>")', 'E961:')
93+ :call assert_fails('call expandcmd("edit <cfile>")', 'E446:')
94+ :call assert_fails('call expandcmd("edit #")', 'E194:')
95+ :call assert_fails('call expandcmd("edit #<2")', 'E684:')
96+ :call assert_fails('call expandcmd("edit <cword>")', 'E348:')
97+ :call assert_fails('call expandcmd("edit <cexpr>")', 'E348:')
98+ :call assert_fails('autocmd User MyCmd echo "<sfile>"', 'E498:')
99+ :call writefile(v:errors, 'Xresult')
100+ :qall!
101+
102+ [SCRIPT]
103+ call writefile(lines, 'Xscript')
104+ if RunVim([], [], '--clean -s Xscript')
105+ call assert_equal([], readfile('Xresult'))
106+ endif
107+ call delete('Xscript')
108+ call delete('Xresult')
109+endfunc
110+
111+
112+" vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_filetype.vim
--- a/src/testdir/test_filetype.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_filetype.vim Mon Feb 17 21:45:04 2020 +0100
@@ -621,3 +621,25 @@
621621 call feedkeys(":setfiletype java\<C-A>\<C-B>\"\<CR>", 'tx')
622622 call assert_equal('"setfiletype java javacc javascript javascriptreact', @:)
623623 endfunc
624+
625+" Test for ':filetype detect' command for a buffer without a file
626+func Test_emptybuf_ftdetect()
627+ new
628+ call setline(1, '#!/bin/sh')
629+ call assert_equal('', &filetype)
630+ filetype detect
631+ call assert_equal('sh', &filetype)
632+ close!
633+endfunc
634+
635+" Test for ':filetype indent on' and ':filetype indent off' commands
636+func Test_filetype_indent_off()
637+ new Xtest.vim
638+ filetype indent on
639+ call assert_equal(1, g:did_indent_on)
640+ filetype indent off
641+ call assert_equal(0, exists('g:did_indent_on'))
642+ close
643+endfunc
644+
645+" vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_findfile.vim
--- a/src/testdir/test_findfile.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_findfile.vim Mon Feb 17 21:45:04 2020 +0100
@@ -183,3 +183,43 @@
183183 call assert_fails('call finddir("x", "**x")', 'E343:')
184184 call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:')
185185 endfunc
186+
187+" Test for the :find, :sfind and :tabfind commands
188+func Test_find_cmd()
189+ new
190+ let save_path = &path
191+ let save_dir = getcwd()
192+ set path=.,./**/*
193+ call CreateFiles()
194+ cd Xdir1
195+
196+ " Test for :find
197+ find foo
198+ call assert_equal('foo', expand('%:.'))
199+ 2find foo
200+ call assert_equal('Xdir2/foo', expand('%:.'))
201+ call assert_fails('3find foo', 'E347:')
202+
203+ " Test for :sfind
204+ enew
205+ sfind barfoo
206+ call assert_equal('Xdir2/Xdir3/barfoo', expand('%:.'))
207+ call assert_equal(3, winnr('$'))
208+ close
209+ call assert_fails('sfind baz', 'E345:')
210+ call assert_equal(2, winnr('$'))
211+
212+ " Test for :tabfind
213+ enew
214+ tabfind foobar
215+ call assert_equal('Xdir2/foobar', expand('%:.'))
216+ call assert_equal(2, tabpagenr('$'))
217+ tabclose
218+ call assert_fails('tabfind baz', 'E345:')
219+ call assert_equal(1, tabpagenr('$'))
220+
221+ call chdir(save_dir)
222+ call CleanFiles()
223+ let &path = save_path
224+ close
225+endfunc
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_join.vim
--- a/src/testdir/test_join.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_join.vim Mon Feb 17 21:45:04 2020 +0100
@@ -436,5 +436,11 @@
436436 call setline(1, ['a', 'b', '', 'c', 'd'])
437437 normal 5J
438438 call assert_equal('a b c d', getline(1))
439+ call setline(1, ['a', 'b', 'c'])
440+ 2,2join
441+ call assert_equal(['a', 'b', 'c'], getline(1, '$'))
442+ call assert_equal(2, line('.'))
443+ 2join
444+ call assert_equal(['a', 'b c'], getline(1, '$'))
439445 bwipe!
440446 endfunc
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_move.vim
--- a/src/testdir/test_move.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_move.vim Mon Feb 17 21:45:04 2020 +0100
@@ -38,6 +38,7 @@
3838 call assert_fails("move -100", 'E16:')
3939 call assert_fails("move +100", 'E16:')
4040 call assert_fails('move', 'E16:')
41+ call assert_fails("move 'r", 'E20:')
4142
4243 %bwipeout!
4344 endfunc
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_normal.vim
--- a/src/testdir/test_normal.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_normal.vim Mon Feb 17 21:45:04 2020 +0100
@@ -2006,7 +2006,7 @@
20062006 tabclose
20072007 endfor
20082008 " clean up
2009- call assert_fails(':tabclose', 'E784')
2009+ call assert_fails(':tabclose', 'E784:')
20102010 endfunc
20112011
20122012 fun! Test_normal38_nvhome()
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_registers.vim
--- a/src/testdir/test_registers.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_registers.vim Mon Feb 17 21:45:04 2020 +0100
@@ -386,4 +386,15 @@
386386 bwipe!
387387 endfunc
388388
389+" Test for executing a register using :@ command
390+func Test_execute_register()
391+ call setreg('r', [])
392+ call assert_beeps('@r')
393+ let i = 1
394+ let @q = 'let i+= 1'
395+ @q
396+ @
397+ call assert_equal(3, i)
398+endfunc
399+
389400 " vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_source.vim
--- a/src/testdir/test_source.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_source.vim Mon Feb 17 21:45:04 2020 +0100
@@ -66,4 +66,25 @@
6666 call delete('Xfile.vim')
6767 endfunc
6868
69+" Test for expanding <sfile> in a autocmd and for <slnum> and <sflnum>
70+func Test_source_autocmd_sfile()
71+ let code =<< trim [CODE]
72+ let g:SfileName = ''
73+ augroup sfiletest
74+ au!
75+ autocmd User UserAutoCmd let g:Sfile = '<sfile>:t'
76+ augroup END
77+ doautocmd User UserAutoCmd
78+ let g:Slnum = expand('<slnum>')
79+ let g:Sflnum = expand('<sflnum>')
80+ augroup! sfiletest
81+ [CODE]
82+ call writefile(code, 'Xscript.vim')
83+ source Xscript.vim
84+ call assert_equal('Xscript.vim', g:Sfile)
85+ call assert_equal('7', g:Slnum)
86+ call assert_equal('8', g:Sflnum)
87+ call delete('Xscript.vim')
88+endfunc
89+
6990 " vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_tabpage.vim
--- a/src/testdir/test_tabpage.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_tabpage.vim Mon Feb 17 21:45:04 2020 +0100
@@ -139,7 +139,11 @@
139139 call assert_fails("tabmove -99", 'E474:')
140140 call assert_fails("tabmove -3+", 'E474:')
141141 call assert_fails("tabmove $3", 'E474:')
142+ call assert_fails("%tabonly", 'E16:')
142143 1tabonly!
144+ tabnew
145+ call assert_fails("-2tabmove", 'E474:')
146+ tabonly!
143147 endfunc
144148
145149 " Test autocommands
@@ -609,4 +613,14 @@
609613 call delete('XTest_tabpage_cmdheight')
610614 endfunc
611615
616+" Test for closing the tab page from a command window
617+func Test_tabpage_close_cmdwin()
618+ tabnew
619+ call feedkeys("q/:tabclose\<CR>\<Esc>", 'xt')
620+ call assert_equal(2, tabpagenr('$'))
621+ call feedkeys("q/:tabonly\<CR>\<Esc>", 'xt')
622+ call assert_equal(2, tabpagenr('$'))
623+ tabonly
624+endfunc
625+
612626 " vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_tagjump.vim
--- a/src/testdir/test_tagjump.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_tagjump.vim Mon Feb 17 21:45:04 2020 +0100
@@ -893,6 +893,11 @@
893893 tag FIRST
894894 tnext
895895 call assert_equal(2, line('.'))
896+ tlast
897+ tprev
898+ call assert_equal(2, line('.'))
899+ tNext
900+ call assert_equal(1, line('.'))
896901 set ignorecase&
897902
898903 call delete('Xtags')
@@ -1035,4 +1040,200 @@
10351040 %bwipe
10361041 endfunc
10371042
1043+" Test for :isearch, :ilist, :ijump and :isplit commands
1044+" Test for [i, ]i, [I, ]I, [ CTRL-I, ] CTRL-I and CTRL-W i commands
1045+func Test_inc_search()
1046+ new
1047+ call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo'])
1048+ call cursor(3, 1)
1049+
1050+ " Test for [i and ]i
1051+ call assert_equal('1:foo', execute('normal [i'))
1052+ call assert_equal('2:foo', execute('normal 2[i'))
1053+ call assert_fails('normal 3[i', 'E387:')
1054+ call assert_equal('3:foo', execute('normal ]i'))
1055+ call assert_equal('4:foo', execute('normal 2]i'))
1056+ call assert_fails('normal 3]i', 'E389:')
1057+
1058+ " Test for :isearch
1059+ call assert_equal('1:foo', execute('isearch foo'))
1060+ call assert_equal('3:foo', execute('isearch 4 /foo/'))
1061+ call assert_fails('isearch 3 foo', 'E387:')
1062+ call assert_equal('3:foo', execute('+1,$isearch foo'))
1063+ call assert_fails('1,.-1isearch 3 foo', 'E389:')
1064+ call assert_fails('isearch bar', 'E389:')
1065+ call assert_fails('isearch /foo/3', 'E488:')
1066+
1067+ " Test for [I and ]I
1068+ call assert_equal([
1069+ \ ' 1: 1 1:foo',
1070+ \ ' 2: 2 2:foo',
1071+ \ ' 3: 3 foo',
1072+ \ ' 4: 4 3:foo',
1073+ \ ' 5: 5 4:foo'], split(execute('normal [I'), "\n"))
1074+ call assert_equal([
1075+ \ ' 1: 4 3:foo',
1076+ \ ' 2: 5 4:foo'], split(execute('normal ]I'), "\n"))
1077+
1078+ " Test for :ilist
1079+ call assert_equal([
1080+ \ ' 1: 1 1:foo',
1081+ \ ' 2: 2 2:foo',
1082+ \ ' 3: 3 foo',
1083+ \ ' 4: 4 3:foo',
1084+ \ ' 5: 5 4:foo'], split(execute('ilist foo'), "\n"))
1085+ call assert_equal([
1086+ \ ' 1: 4 3:foo',
1087+ \ ' 2: 5 4:foo'], split(execute('+1,$ilist /foo/'), "\n"))
1088+ call assert_fails('ilist bar', 'E389:')
1089+
1090+ " Test for [ CTRL-I and ] CTRL-I
1091+ exe "normal [\t"
1092+ call assert_equal([1, 3], [line('.'), col('.')])
1093+ exe "normal 2j4[\t"
1094+ call assert_equal([4, 3], [line('.'), col('.')])
1095+ call assert_fails("normal k3[\t", 'E387:')
1096+ call assert_fails("normal 6[\t", 'E389:')
1097+ exe "normal ]\t"
1098+ call assert_equal([4, 3], [line('.'), col('.')])
1099+ exe "normal k2]\t"
1100+ call assert_equal([5, 3], [line('.'), col('.')])
1101+ call assert_fails("normal 2k3]\t", 'E389:')
1102+
1103+ " Test for :ijump
1104+ call cursor(3, 1)
1105+ ijump foo
1106+ call assert_equal([1, 3], [line('.'), col('.')])
1107+ call cursor(3, 1)
1108+ ijump 4 /foo/
1109+ call assert_equal([4, 3], [line('.'), col('.')])
1110+ call cursor(3, 1)
1111+ call assert_fails('ijump 3 foo', 'E387:')
1112+ +,$ijump 2 foo
1113+ call assert_equal([5, 3], [line('.'), col('.')])
1114+ call assert_fails('ijump bar', 'E389:')
1115+
1116+ " Test for CTRL-W i
1117+ call cursor(3, 1)
1118+ wincmd i
1119+ call assert_equal([1, 3, 3], [line('.'), col('.'), winnr('$')])
1120+ close
1121+ 5wincmd i
1122+ call assert_equal([5, 3, 3], [line('.'), col('.'), winnr('$')])
1123+ close
1124+ call assert_fails('3wincmd i', 'E387:')
1125+ call assert_fails('6wincmd i', 'E389:')
1126+
1127+ " Test for :isplit
1128+ isplit foo
1129+ call assert_equal([1, 3, 3], [line('.'), col('.'), winnr('$')])
1130+ close
1131+ isplit 5 /foo/
1132+ call assert_equal([5, 3, 3], [line('.'), col('.'), winnr('$')])
1133+ close
1134+ call assert_fails('isplit 3 foo', 'E387:')
1135+ call assert_fails('isplit 6 foo', 'E389:')
1136+ call assert_fails('isplit bar', 'E389:')
1137+
1138+ close!
1139+endfunc
1140+
1141+" Test for :dsearch, :dlist, :djump and :dsplit commands
1142+" Test for [d, ]d, [D, ]D, [ CTRL-D, ] CTRL-D and CTRL-W d commands
1143+func Test_def_search()
1144+ new
1145+ call setline(1, ['#define FOO 1', '#define FOO 2', '#define FOO 3',
1146+ \ '#define FOO 4', '#define FOO 5'])
1147+ call cursor(3, 9)
1148+
1149+ " Test for [d and ]d
1150+ call assert_equal('#define FOO 1', execute('normal [d'))
1151+ call assert_equal('#define FOO 2', execute('normal 2[d'))
1152+ call assert_fails('normal 3[d', 'E387:')
1153+ call assert_equal('#define FOO 4', execute('normal ]d'))
1154+ call assert_equal('#define FOO 5', execute('normal 2]d'))
1155+ call assert_fails('normal 3]d', 'E388:')
1156+
1157+ " Test for :dsearch
1158+ call assert_equal('#define FOO 1', execute('dsearch FOO'))
1159+ call assert_equal('#define FOO 5', execute('dsearch 5 /FOO/'))
1160+ call assert_fails('dsearch 3 FOO', 'E387:')
1161+ call assert_equal('#define FOO 4', execute('+1,$dsearch FOO'))
1162+ call assert_fails('1,.-1dsearch 3 FOO', 'E388:')
1163+ call assert_fails('dsearch BAR', 'E388:')
1164+
1165+ " Test for [D and ]D
1166+ call assert_equal([
1167+ \ ' 1: 1 #define FOO 1',
1168+ \ ' 2: 2 #define FOO 2',
1169+ \ ' 3: 3 #define FOO 3',
1170+ \ ' 4: 4 #define FOO 4',
1171+ \ ' 5: 5 #define FOO 5'], split(execute('normal [D'), "\n"))
1172+ call assert_equal([
1173+ \ ' 1: 4 #define FOO 4',
1174+ \ ' 2: 5 #define FOO 5'], split(execute('normal ]D'), "\n"))
1175+
1176+ " Test for :dlist
1177+ call assert_equal([
1178+ \ ' 1: 1 #define FOO 1',
1179+ \ ' 2: 2 #define FOO 2',
1180+ \ ' 3: 3 #define FOO 3',
1181+ \ ' 4: 4 #define FOO 4',
1182+ \ ' 5: 5 #define FOO 5'], split(execute('dlist FOO'), "\n"))
1183+ call assert_equal([
1184+ \ ' 1: 4 #define FOO 4',
1185+ \ ' 2: 5 #define FOO 5'], split(execute('+1,$dlist /FOO/'), "\n"))
1186+ call assert_fails('dlist BAR', 'E388:')
1187+
1188+ " Test for [ CTRL-D and ] CTRL-D
1189+ exe "normal [\<C-D>"
1190+ call assert_equal([1, 9], [line('.'), col('.')])
1191+ exe "normal 2j4[\<C-D>"
1192+ call assert_equal([4, 9], [line('.'), col('.')])
1193+ call assert_fails("normal k3[\<C-D>", 'E387:')
1194+ call assert_fails("normal 6[\<C-D>", 'E388:')
1195+ exe "normal ]\<C-D>"
1196+ call assert_equal([4, 9], [line('.'), col('.')])
1197+ exe "normal k2]\<C-D>"
1198+ call assert_equal([5, 9], [line('.'), col('.')])
1199+ call assert_fails("normal 2k3]\<C-D>", 'E388:')
1200+
1201+ " Test for :djump
1202+ call cursor(3, 9)
1203+ djump FOO
1204+ call assert_equal([1, 9], [line('.'), col('.')])
1205+ call cursor(3, 9)
1206+ djump 4 /FOO/
1207+ call assert_equal([4, 9], [line('.'), col('.')])
1208+ call cursor(3, 9)
1209+ call assert_fails('djump 3 FOO', 'E387:')
1210+ +,$djump 2 FOO
1211+ call assert_equal([5, 9], [line('.'), col('.')])
1212+ call assert_fails('djump BAR', 'E388:')
1213+
1214+ " Test for CTRL-W d
1215+ call cursor(3, 9)
1216+ wincmd d
1217+ call assert_equal([1, 9, 3], [line('.'), col('.'), winnr('$')])
1218+ close
1219+ 5wincmd d
1220+ call assert_equal([5, 9, 3], [line('.'), col('.'), winnr('$')])
1221+ close
1222+ call assert_fails('3wincmd d', 'E387:')
1223+ call assert_fails('6wincmd d', 'E388:')
1224+
1225+ " Test for :dsplit
1226+ dsplit FOO
1227+ call assert_equal([1, 9, 3], [line('.'), col('.'), winnr('$')])
1228+ close
1229+ dsplit 5 /FOO/
1230+ call assert_equal([5, 9, 3], [line('.'), col('.'), winnr('$')])
1231+ close
1232+ call assert_fails('dsplit 3 FOO', 'E387:')
1233+ call assert_fails('dsplit 6 FOO', 'E388:')
1234+ call assert_fails('dsplit BAR', 'E388:')
1235+
1236+ close!
1237+endfunc
1238+
10381239 " vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_vimscript.vim
--- a/src/testdir/test_vimscript.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_vimscript.vim Mon Feb 17 21:45:04 2020 +0100
@@ -2061,6 +2061,16 @@
20612061 call delete('Xscript')
20622062 endfunc
20632063
2064+" Test for <sfile>, <slnum> in a function {{{1
2065+func Test_sfile_in_function()
2066+ func Xfunc()
2067+ call assert_match('..Test_sfile_in_function\[5]..Xfunc', expand('<sfile>'))
2068+ call assert_equal('2', expand('<slnum>'))
2069+ endfunc
2070+ call Xfunc()
2071+ delfunc Xfunc
2072+endfunc
2073+
20642074 "-------------------------------------------------------------------------------
20652075 " Modelines {{{1
20662076 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_visual.vim
--- a/src/testdir/test_visual.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_visual.vim Mon Feb 17 21:45:04 2020 +0100
@@ -894,4 +894,18 @@
894894 bwipe!
895895 endfunc
896896
897+" Test for * register in :
898+func Test_star_register()
899+ call assert_fails('*bfirst', 'E16:')
900+ new
901+ call setline(1, ['foo', 'bar', 'baz', 'qux'])
902+ exe "normal jVj\<ESC>"
903+ *yank r
904+ call assert_equal("bar\nbaz\n", @r)
905+
906+ delmarks < >
907+ call assert_fails('*yank', 'E20:')
908+ close!
909+endfunc
910+
897911 " vim: shiftwidth=2 sts=2 expandtab
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_window_cmd.vim
--- a/src/testdir/test_window_cmd.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_window_cmd.vim Mon Feb 17 21:45:04 2020 +0100
@@ -940,6 +940,15 @@
940940 new
941941 call assert_fails('only', 'E445:')
942942 only!
943+ " Test for :only with a count
944+ let wid = win_getid()
945+ new
946+ new
947+ 3only
948+ call assert_equal(1, winnr('$'))
949+ call assert_equal(wid, win_getid())
950+ call assert_fails('close', 'E444:')
951+ call assert_fails('%close', 'E16:')
943952 endfunc
944953
945954 " Test for errors with :wincmd
diff -r 38c3f2b16596 -r 67fbe280a502 src/testdir/test_writefile.vim
--- a/src/testdir/test_writefile.vim Mon Feb 17 21:15:05 2020 +0100
+++ b/src/testdir/test_writefile.vim Mon Feb 17 21:45:04 2020 +0100
@@ -215,9 +215,7 @@
215215 close!
216216
217217 call assert_fails('w > Xtest', 'E494:')
218-
219- call assert_fails('w > Xtest', 'E494:')
220-
218+
221219 " Try to overwrite a directory
222220 if has('unix')
223221 call mkdir('Xdir1')
diff -r 38c3f2b16596 -r 67fbe280a502 src/version.c
--- a/src/version.c Mon Feb 17 21:15:05 2020 +0100
+++ b/src/version.c Mon Feb 17 21:45:04 2020 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 270,
747+/**/
746748 269,
747749 /**/
748750 268,
Show on old repository browser