To: vim_dev@googlegroups.com Subject: Patch 8.2.0482 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0482 Problem: Channel and sandbox code not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5855) Files: src/option.h, src/testdir/test_channel.vim, src/testdir/test_clientserver.vim, src/testdir/test_cmdline.vim, src/testdir/test_edit.vim, src/testdir/test_excmd.vim, src/testdir/test_normal.vim, src/testdir/test_prompt_buffer.vim, src/testdir/test_restricted.vim, src/testdir/test_smartindent.vim, src/testdir/test_substitute.vim, src/testdir/test_terminal.vim, src/testdir/test_textformat.vim, src/testdir/test_visual.vim *** ../vim-8.2.0481/src/option.h 2020-02-26 16:15:31.072386953 +0100 --- src/option.h 2020-03-30 19:24:35.987073315 +0200 *************** *** 403,409 **** EXTERN char_u *p_bo; // 'belloff' EXTERN unsigned bo_flags; ! // values for the 'beepon' option #define BO_ALL 0x0001 #define BO_BS 0x0002 #define BO_CRSR 0x0004 --- 403,409 ---- EXTERN char_u *p_bo; // 'belloff' EXTERN unsigned bo_flags; ! // values for the 'belloff' option #define BO_ALL 0x0001 #define BO_BS 0x0002 #define BO_CRSR 0x0004 *** ../vim-8.2.0481/src/testdir/test_channel.vim 2020-03-29 16:18:55.226422995 +0200 --- src/testdir/test_channel.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 251,256 **** --- 251,257 ---- call assert_equal('got it', ch_evalexpr(newhandle, 'hello!')) call ch_close(newhandle) + call assert_fails("call ch_close(newhandle)", 'E906:') endfunc func Test_two_channels() *************** *** 497,502 **** --- 498,508 ---- call ch_sendraw(job, "double this\n", {'callback': 'Ch_handler'}) call WaitForAssert({-> assert_equal("this\nAND this\n", substitute(g:Ch_reply, "\r", "", 'g'))}) + call assert_fails("let i = ch_evalraw(job, '2 + 2', {'callback' : 'abc'})", 'E917:') + call assert_fails("let i = ch_evalexpr(job, '2 + 2')", 'E912:') + call assert_fails("let i = ch_evalraw(job, '2 + 2', {'drop' : ''})", 'E475:') + call assert_fails("let i = ch_evalraw(test_null_job(), '2 + 2')", 'E906:') + let reply = job->ch_evalraw("quit\n", {'timeout': 100}) call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g')) finally *************** *** 519,524 **** --- 525,534 ---- endfor call assert_equal(1, found) + call assert_fails("call job_stop('abc')", 'E475:') + call assert_fails("call job_stop(job, [])", 'E474:') + call assert_fails("call job_stop(test_null_job())", 'E916:') + " Try to use the job and channel where a number is expected. This is not " related to testing the raw pipe. This test is here just to reuse the " already created job/channel. *************** *** 620,625 **** --- 630,636 ---- call Stop_g_job() call delete('Xinput') endtry + call assert_fails("echo ch_read(test_null_channel(), {'callback' : 'abc'})", 'E475:') endfunc func Test_nl_write_out_file() *************** *** 1362,1370 **** """""""""" func Test_open_fail() ! silent! let ch = ch_open("noserver") echo ch let d = ch endfunc """""""""" --- 1373,1395 ---- """""""""" func Test_open_fail() ! call assert_fails("let ch = ch_open('noserver')", 'E475:') echo ch let d = ch + call assert_fails("let ch = ch_open('noserver', 10)", 'E474:') + call assert_fails("let ch = ch_open('localhost:-1')", 'E475:') + call assert_fails("let ch = ch_open('localhost:8765', {'timeout' : -1})", + \ 'E474:') + call assert_fails("let ch = ch_open('localhost:8765', {'axby' : 1})", + \ 'E475:') + call assert_fails("let ch = ch_open('localhost:8765', {'mode' : 'abc'})", + \ 'E475:') + call assert_fails("let ch = ch_open('localhost:8765', {'part' : 'out'})", + \ 'E475:') + endfunc + + func Test_ch_info_fail() + call assert_fails("let x = ch_info(10)", 'E475:') endfunc """""""""" *************** *** 1403,1408 **** --- 1428,1437 ---- let g:Ch_call_ret = [] call assert_equal('ok', ch_evalexpr(handle, 'call-func')) call WaitForAssert({-> assert_equal([1, 2, 3], g:Ch_call_ret)}) + + call assert_fails("let i = ch_evalexpr(handle, '2 + 2', {'callback' : 'abc'})", 'E917:') + call assert_fails("let i = ch_evalexpr(handle, '2 + 2', {'drop' : ''})", 'E475:') + call assert_fails("let i = ch_evalexpr(test_null_job(), '2 + 2')", 'E906:') endfunc func Test_call() *************** *** 1520,1528 **** call s:run_server('Ch_test_close_partial') endfunc ! func Test_job_start_invalid() call assert_fails('call job_start($x)', 'E474:') call assert_fails('call job_start("")', 'E474:') endfunc func Test_job_stop_immediately() --- 1549,1616 ---- call s:run_server('Ch_test_close_partial') endfunc ! func Test_job_start_fails() ! " this was leaking memory ! call assert_fails("call job_start([''])", "E474:") call assert_fails('call job_start($x)', 'E474:') call assert_fails('call job_start("")', 'E474:') + call assert_fails('call job_start("ls", {"out_io" : "abc"})', 'E475:') + call assert_fails('call job_start("ls", {"err_io" : "abc"})', 'E475:') + call assert_fails('call job_start("ls", [])', 'E715:') + call assert_fails("call job_start('ls', {'in_top' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'in_bot' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'channel' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'callback' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'out_cb' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'err_cb' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'close_cb' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'exit_cb' : -1})", 'E475:') + call assert_fails("call job_start('ls', {'term_name' : []})", 'E475:') + call assert_fails("call job_start('ls', {'term_finish' : 'run'})", 'E475:') + call assert_fails("call job_start('ls', {'term_api' : []})", 'E475:') + call assert_fails("call job_start('ls', {'stoponexit' : []})", 'E475:') + call assert_fails("call job_start('ls', {'in_io' : 'file'})", 'E920:') + call assert_fails("call job_start('ls', {'out_io' : 'file'})", 'E920:') + call assert_fails("call job_start('ls', {'err_io' : 'file'})", 'E920:') + call assert_fails("call job_start('ls', {'in_mode' : 'abc'})", 'E475:') + call assert_fails("call job_start('ls', {'out_mode' : 'abc'})", 'E475:') + call assert_fails("call job_start('ls', {'err_mode' : 'abc'})", 'E475:') + call assert_fails("call job_start('ls', + \ {'in_io' : 'buffer', 'in_buf' : 99999})", 'E86:') + call assert_fails("call job_start('ls', + \ {'out_io' : 'buffer', 'out_buf' : 99999})", 'E86:') + call assert_fails("call job_start('ls', + \ {'err_io' : 'buffer', 'err_buf' : 99999})", 'E86:') + + call assert_fails("call job_start('ls', + \ {'in_io' : 'buffer', 'in_buf' : -1})", 'E475:') + call assert_fails("call job_start('ls', + \ {'out_io' : 'buffer', 'out_buf' : -1})", 'E475:') + call assert_fails("call job_start('ls', + \ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:') + + set nomodifiable + call assert_fails("call job_start('cmd /c dir', + \ {'out_io' : 'buffer', 'out_buf' :" .. bufnr() .. "})", 'E21:') + call assert_fails("call job_start('cmd /c dir', + \ {'err_io' : 'buffer', 'err_buf' :" .. bufnr() .. "})", 'E21:') + set modifiable + + call assert_fails("call job_start('ls', {'in_io' : 'buffer'})", 'E915:') + + edit! XXX + let bnum = bufnr() + enew + call assert_fails("call job_start('ls', + \ {'in_io' : 'buffer', 'in_buf' : bnum})", 'E918:') + + " Empty job tests + " This was crashing on MS-Windows. + call assert_fails('let job = job_start([""])', 'E474:') + call assert_fails('let job = job_start([" "])', 'E474:') + call assert_fails('let job = job_start("")', 'E474:') + call assert_fails('let job = job_start(" ")', 'E474:') + %bw! endfunc func Test_job_stop_immediately() *************** *** 1986,1999 **** endtry endfunc - func Test_empty_job() - " This was crashing on MS-Windows. - call assert_fails('let job = job_start([""])', 'E474:') - call assert_fails('let job = job_start([" "])', 'E474:') - call assert_fails('let job = job_start("")', 'E474:') - call assert_fails('let job = job_start(" ")', 'E474:') - endfunc - " Do this last, it stops any channel log. func Test_zz_ch_log() call ch_logfile('Xlog', 'w') --- 2074,2079 ---- *************** *** 2003,2016 **** let text = readfile('Xlog') call assert_match("hello there", text[1]) call assert_match("%s%s", text[2]) call delete('Xlog') endfunc - func Test_job_start_fails() - " this was leaking memory - call assert_fails("call job_start([''])", "E474:") - endfunc - func Test_issue_5150() if has('win32') let cmd = 'cmd /c pause' --- 2083,2094 ---- let text = readfile('Xlog') call assert_match("hello there", text[1]) call assert_match("%s%s", text[2]) + call mkdir("Xdir1") + call assert_fails("call ch_logfile('Xdir1')", 'E484:') + cal delete("Xdir1", 'd') call delete('Xlog') endfunc func Test_issue_5150() if has('win32') let cmd = 'cmd /c pause' *************** *** 2048,2051 **** --- 2126,2207 ---- call assert_equal(0, job_info(job).exitval) endfunc + func Test_ch_getbufnr() + let ch = test_null_channel() + call assert_equal(-1, ch_getbufnr(ch, 'in')) + call assert_equal(-1, ch_getbufnr(ch, 'out')) + call assert_equal(-1, ch_getbufnr(ch, 'err')) + call assert_equal(-1, ch_getbufnr(ch, '')) + endfunc + + " Test for unsupported options passed to ch_status() + func Test_invalid_job_chan_options() + let ch = test_null_channel() + let invalid_opts = [ + \ {'in_io' : 'null'}, + \ {'out_io' : 'null'}, + \ {'err_io' : 'null'}, + \ {'mode' : 'json'}, + \ {'out_mode' : 'json'}, + \ {'err_mode' : 'json'}, + \ {'noblock' : 1}, + \ {'in_name' : '/a/b'}, + \ {'pty' : 1}, + \ {'in_buf' : 1}, + \ {'out_buf' : 1}, + \ {'err_buf' : 1}, + \ {'out_modifiable' : 1}, + \ {'err_modifiable' : 1}, + \ {'out_msg' : 1}, + \ {'err_msg' : 1}, + \ {'in_top' : 1}, + \ {'in_bot' : 1}, + \ {'channel' : ch}, + \ {'callback' : ''}, + \ {'out_cb' : ''}, + \ {'err_cb' : ''}, + \ {'close_cb' : ''}, + \ {'exit_cb' : ''}, + \ {'term_opencmd' : ''}, + \ {'eof_chars' : ''}, + \ {'term_rows' : 10}, + \ {'term_cols' : 10}, + \ {'vertical' : 0}, + \ {'curwin' : 1}, + \ {'bufnr' : 1}, + \ {'hidden' : 0}, + \ {'norestore' : 0}, + \ {'term_kill' : 'kill'}, + \ {'tty_type' : ''}, + \ {'term_highlight' : ''}, + \ {'env' : {}}, + \ {'cwd' : ''}, + \ {'timeout' : 0}, + \ {'out_timeout' : 0}, + \ {'err_timeout' : 0}, + \ {'id' : 0}, + \ {'stoponexit' : ''}, + \ {'block_write' : 1} + \ ] + if has('gui') + call add(invalid_opts, {'ansi_colors' : []}) + endif + + for opt in invalid_opts + call assert_fails("let x = ch_status(ch, opt)", 'E475:') + endfor + endfunc + + " Test for passing the command and the arguments as List on MS-Windows + func Test_job_with_list_args() + CheckMSWindows + + enew! + let bnum = bufnr() + let job = job_start(['cmd', '/c', 'echo', 'Hello', 'World'], {'out_io' : 'buffer', 'out_buf' : bnum}) + call WaitForAssert({-> assert_equal("dead", job_status(job))}) + call assert_equal('Hello World', getline(1)) + %bw! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_clientserver.vim 2020-03-25 22:23:41.894363634 +0100 --- src/testdir/test_clientserver.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 39,44 **** --- 39,46 ---- call remote_send(name, ":let testvar = 'yes'\") call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"') call assert_equal('yes', remote_expr(name, "testvar", "", 2)) + call assert_fails("let x=remote_expr(name, '2+x')", 'E449:') + call assert_fails("let x=remote_expr('[], '2+2')", 'E116:') if has('unix') && has('gui') && !has('gui_running') " Running in a terminal and the GUI is available: Tell the server to open *************** *** 66,71 **** --- 68,74 ---- eval 'MYSELF'->remote_startserver() " May get MYSELF1 when running the test again. call assert_match('MYSELF', v:servername) + call assert_fails("call remote_startserver('MYSELF')", 'E941:') endif let g:testvar = 'myself' call assert_equal('myself', remote_expr(v:servername, 'testvar')) *************** *** 100,105 **** --- 103,109 ---- endtry call assert_fails("let x=remote_peek([])", 'E730:') + call assert_fails("let x=remote_read('vim10')", 'E277:') endfunc " Uncomment this line to get a debugging log *** ../vim-8.2.0481/src/testdir/test_cmdline.vim 2020-03-25 22:23:41.898363595 +0100 --- src/testdir/test_cmdline.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 1459,1462 **** --- 1459,1471 ---- call assert_fails('call feedkeys("q:\\", "xt")', 'E11:') endfunc + " Close the Cmd-line window in insert mode using CTRL-C + func Test_cmdwin_insert_mode_close() + %bw! + let s = '' + exe "normal q:a\let s='Hello'\" + call assert_equal('Hello', s) + call assert_equal(1, winnr('$')) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_edit.vim 2020-03-22 14:08:27.321399669 +0100 --- src/testdir/test_edit.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 1542,1549 **** close! endfunc ! " Test for inserting text at the beginning of a line ! func Test_insert_before_first_nonblank() new call setline(1, ' ') normal! Ia --- 1542,1549 ---- close! endfunc ! " Test for inserting text in a line with only spaces ('H' flag in 'cpoptions') ! func Test_edit_cpo_H() new call setline(1, ' ') normal! Ia *************** *** 1556,1559 **** --- 1556,1578 ---- close! endfunc + " Test for inserting tab in virtual replace mode ('L' flag in 'cpoptions') + func Test_edit_cpo_L() + new + call setline(1, 'abcdefghijklmnopqr') + exe "normal 0gR\" + call assert_equal("\ijklmnopqr", getline(1)) + set cpo+=L + set list + call setline(1, 'abcdefghijklmnopqr') + exe "normal 0gR\" + call assert_equal("\cdefghijklmnopqr", getline(1)) + set nolist + call setline(1, 'abcdefghijklmnopqr') + exe "normal 0gR\" + call assert_equal("\ijklmnopqr", getline(1)) + set cpo-=L + %bw! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_excmd.vim 2020-03-28 21:48:51.238858476 +0100 --- src/testdir/test_excmd.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 409,412 **** --- 409,477 ---- close! endfunc + " Test for commands that are blocked in a sandbox + func Sandbox_tests() + call assert_fails("call histadd(':', 'ls')", 'E48:') + call assert_fails("call mkdir('Xdir')", 'E48:') + call assert_fails("call rename('a', 'b')", 'E48:') + call assert_fails("call setbufvar(1, 'myvar', 1)", 'E48:') + call assert_fails("call settabvar(1, 'myvar', 1)", 'E48:') + call assert_fails("call settabwinvar(1, 1, 'myvar', 1)", 'E48:') + call assert_fails("call setwinvar(1, 'myvar', 1)", 'E48:') + call assert_fails("call timer_start(100, '')", 'E48:') + if has('channel') + call assert_fails("call prompt_setcallback(1, '')", 'E48:') + call assert_fails("call prompt_setinterrupt(1, '')", 'E48:') + call assert_fails("call prompt_setprompt(1, '')", 'E48:') + endif + call assert_fails("let $TESTVAR=1", 'E48:') + call assert_fails("call feedkeys('ivim')", 'E48:') + call assert_fails("source! Xfile", 'E48:') + call assert_fails("call delete('Xfile')", 'E48:') + call assert_fails("call writefile([], 'Xfile')", 'E48:') + call assert_fails('!ls', 'E48:') + call assert_fails('shell', 'E48:') + call assert_fails('stop', 'E48:') + call assert_fails('exe "normal \"', 'E48:') + set insertmode + call assert_fails('call feedkeys("\", "xt")', 'E48:') + set insertmode& + call assert_fails('suspend', 'E48:') + call assert_fails('call system("ls")', 'E48:') + call assert_fails('call systemlist("ls")', 'E48:') + if has('clientserver') + call assert_fails('let s=remote_expr("gvim", "2+2")', 'E48:') + if !has('win32') + " remote_foreground() doesn't thrown an error message on MS-Windows + call assert_fails('call remote_foreground("gvim")', 'E48:') + endif + call assert_fails('let s=remote_peek("gvim")', 'E48:') + call assert_fails('let s=remote_read("gvim")', 'E48:') + call assert_fails('let s=remote_send("gvim", "abc")', 'E48:') + call assert_fails('let s=server2client("gvim", "abc")', 'E48:') + endif + if has('terminal') + call assert_fails('terminal', 'E48:') + call assert_fails('call term_start("vim")', 'E48:') + call assert_fails('call term_dumpwrite(1, "Xfile")', 'E48:') + endif + if has('channel') + call assert_fails("call ch_logfile('chlog')", 'E48:') + call assert_fails("call ch_open('localhost:8765')", 'E48:') + endif + if has('job') + call assert_fails("call job_start('vim')", 'E48:') + endif + if has('unix') && has('libcall') + call assert_fails("echo libcall('libc.so', 'getenv', 'HOME')", 'E48:') + endif + if has('unix') + call assert_fails('cd `pwd`', 'E48:') + endif + endfunc + + func Test_sandbox() + sandbox call Sandbox_tests() + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_normal.vim 2020-03-22 14:08:27.321399669 +0100 --- src/testdir/test_normal.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 2,7 **** --- 2,8 ---- source shared.vim source check.vim + source view_util.vim func Setup_NewWindow() 10new *************** *** 2941,2946 **** --- 2942,2969 ---- close! endfunc + " Test for displaying dollar when changing text ('$' flag in 'cpoptions') + func Test_normal_cpo_dollar() + new + let g:Line = '' + func SaveFirstLine() + let g:Line = Screenline(1) + return '' + endfunc + inoremap SaveFirstLine() + call test_override('redraw_flag', 1) + set cpo+=$ + call setline(1, 'one two three') + redraw! + exe "normal c2w\vim" + call assert_equal('one tw$ three', g:Line) + call assert_equal('vim three', getline(1)) + set cpo-=$ + call test_override('ALL', 0) + delfunc SaveFirstLine + %bw! + endfunc + " Test for using : to run a multi-line Ex command in operator pending mode func Test_normal_yank_with_excmd() new *** ../vim-8.2.0481/src/testdir/test_prompt_buffer.vim 2020-03-10 07:48:06.575619533 +0100 --- src/testdir/test_prompt_buffer.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 121,126 **** --- 121,131 ---- call feedkeys("\\", 'xt') call assert_true(v:true) + call assert_fails("call prompt_setcallback(bufnr(), [])", 'E921:') + call assert_equal(0, prompt_setcallback({}, '')) + call assert_fails("call prompt_setinterrupt(bufnr(), [])", 'E921:') + call assert_equal(0, prompt_setinterrupt({}, '')) + delfunc MyPromptCallback bwipe! endfunc *** ../vim-8.2.0481/src/testdir/test_restricted.vim 2020-03-26 14:11:52.903001238 +0100 --- src/testdir/test_restricted.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 78,84 **** call assert_fails("call job_start('vim')", 'E145:') endif ! if has('libcall') call assert_fails("echo libcall('libc.so', 'getenv', 'HOME')", 'E145:') endif call assert_fails("call rename('a', 'b')", 'E145:') --- 78,84 ---- call assert_fails("call job_start('vim')", 'E145:') endif ! if has('unix') && has('libcall') call assert_fails("echo libcall('libc.so', 'getenv', 'HOME')", 'E145:') endif call assert_fails("call rename('a', 'b')", 'E145:') *************** *** 87,95 **** call assert_fails('!ls', 'E145:') call assert_fails('shell', 'E145:') call assert_fails('stop', 'E145:') call assert_fails('suspend', 'E145:') ! call assert_fails('call system("vim")', 'E145:') ! call assert_fails('call systemlist("vim")', 'E145:') if has('unix') call assert_fails('cd `pwd`', 'E145:') endif --- 87,99 ---- call assert_fails('!ls', 'E145:') call assert_fails('shell', 'E145:') call assert_fails('stop', 'E145:') + call assert_fails('exe "normal \"', 'E145:') + set insertmode + call assert_fails('call feedkeys("\", "xt")', 'E145:') + set insertmode& call assert_fails('suspend', 'E145:') ! call assert_fails('call system("ls")', 'E145:') ! call assert_fails('call systemlist("ls")', 'E145:') if has('unix') call assert_fails('cd `pwd`', 'E145:') endif *** ../vim-8.2.0481/src/testdir/test_smartindent.vim 2020-03-06 20:35:46.120669845 +0100 --- src/testdir/test_smartindent.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 21,29 **** func Test_smartindent_has_no_effect() new exe "normal! i\one\" ! set noautoindent ! set smartindent ! set indentexpr= exe "normal! Gotwo\" call assert_equal("\ttwo", getline("$")) --- 21,27 ---- func Test_smartindent_has_no_effect() new exe "normal! i\one\" ! setlocal noautoindent smartindent indentexpr= exe "normal! Gotwo\" call assert_equal("\ttwo", getline("$")) *************** *** 32,47 **** call assert_equal("three", getline("$")) delfunction! MyIndent - set autoindent& - set smartindent& - set indentexpr& bwipe! endfunc " Test for inserting '{' and '} with smartindent func Test_smartindent_braces() new ! set smartindent shiftwidth=4 call setline(1, [' if (a)', "\tif (b)", "\t return 1"]) normal 2ggO{ normal 3ggA { --- 30,42 ---- call assert_equal("three", getline("$")) delfunction! MyIndent bwipe! endfunc " Test for inserting '{' and '} with smartindent func Test_smartindent_braces() new ! setlocal smartindent shiftwidth=4 call setline(1, [' if (a)', "\tif (b)", "\t return 1"]) normal 2ggO{ normal 3ggA { *************** *** 57,63 **** \ "\t}", \ ' }' \ ], getline(1, '$')) ! set si& sw& ai& close! endfunc --- 52,113 ---- \ "\t}", \ ' }' \ ], getline(1, '$')) ! close! ! endfunc ! ! " Test for adding a new line before and after comments with smartindent ! func Test_si_add_line_around_comment() ! new ! setlocal smartindent shiftwidth=4 ! call setline(1, [' A', '# comment1', '# comment2']) ! exe "normal GoC\2GOB" ! call assert_equal([' A', ' B', '# comment1', '# comment2', ' C'], ! \ getline(1, '$')) ! close! ! endfunc ! ! " After a C style comment, indent for a following line should line up with the ! " line containing the start of the comment. ! func Test_si_indent_after_c_comment() ! new ! setlocal smartindent shiftwidth=4 fo+=ro ! exe "normal i\/*\ncomment\n/\n#define FOOBAR\n75\ggOabc" ! normal 3jOcont ! call assert_equal([' abc', ' /*', ' * comment', ' * cont', ! \ ' */', '#define FOOBAR', ' 75'], getline(1, '$')) ! close! ! endfunc ! ! " Test for indenting a statement after a if condition split across lines ! func Test_si_if_cond_split_across_lines() ! new ! setlocal smartindent shiftwidth=4 ! exe "normal i\if (cond1 &&\n\cond2) {\ni = 10;\n}" ! call assert_equal([' if (cond1 &&', "\t cond2) {", "\ti = 10;", ! \ ' }'], getline(1, '$')) ! close! ! endfunc ! ! " Test for inserting lines before and after a one line comment ! func Test_si_one_line_comment() ! new ! setlocal smartindent shiftwidth=4 ! exe "normal i\abc;\n\/* comment */" ! normal oi = 10; ! normal kOj = 1; ! call assert_equal([' abc;', "\tj = 1;", "\t/* comment */", "\ti = 10;"], ! \ getline(1, '$')) ! close! ! endfunc ! ! " Test for smartindent with a comment continued across multiple lines ! func Test_si_comment_line_continuation() ! new ! setlocal smartindent shiftwidth=4 ! call setline(1, ['# com1', '# com2 \', ' contd', '# com3', ' xyz']) ! normal ggOabc ! call assert_equal([' abc', '# com1', '# com2 \', ' contd', '# com3', ! \ ' xyz'], getline(1, '$')) close! endfunc *** ../vim-8.2.0481/src/testdir/test_substitute.vim 2020-03-25 22:23:41.898363595 +0100 --- src/testdir/test_substitute.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 840,843 **** --- 840,847 ---- call delete('Xresult') endfunc + func Test_substitute() + call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g')) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_terminal.vim 2020-03-29 17:50:44.675192346 +0200 --- src/testdir/test_terminal.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 1001,1006 **** --- 1001,1028 ---- call assert_fails(cmd, 'E474') let cmd = "call term_start(0, {'curwin' : 1, 'term_finish' : 'close'})" call assert_fails(cmd, 'E474') + let cmd = "call term_start('', {'term_name' : []})" + call assert_fails(cmd, 'E475') + let cmd = "call term_start('', {'term_finish' : 'axby'})" + call assert_fails(cmd, 'E475') + let cmd = "call term_start('', {'eof_chars' : []})" + call assert_fails(cmd, 'E475:') + let cmd = "call term_start('', {'term_kill' : []})" + call assert_fails(cmd, 'E475:') + let cmd = "call term_start('', {'tty_type' : []})" + call assert_fails(cmd, 'E475:') + let cmd = "call term_start('', {'tty_type' : 'abc'})" + call assert_fails(cmd, 'E475:') + let cmd = "call term_start('', {'term_highlight' : []})" + call assert_fails(cmd, 'E475:') + if has('gui') + let cmd = "call term_start('', {'ansi_colors' : 'abc'})" + call assert_fails(cmd, 'E475:') + let cmd = "call term_start('', {'ansi_colors' : [[]]})" + call assert_fails(cmd, 'E730:') + let cmd = "call term_start('', {'ansi_colors' : repeat(['blue'], 18)})" + call assert_fails(cmd, 'E475:') + endif endfunc func Test_terminal_response_to_control_sequence() *************** *** 1285,1290 **** --- 1307,1313 ---- call assert_equal(1, winnr('$')) call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_popup_command_02.dump', {'curwin': 1}) call assert_equal(1, winnr('$')) + call assert_fails("call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_popup_command_02.dump', {'bufnr': -1})", 'E475:') bwipe set laststatus& *************** *** 1486,1491 **** --- 1509,1516 ---- call assert_equal(['hello', 123], g:called_arg2) call StopVimInTerminal(buf) + call assert_fails("call term_start('ls', {'term_api' : []})", 'E475:') + unlet! g:called_bufnum2 unlet! g:called_arg2 *************** *** 2552,2554 **** --- 2577,2581 ---- exe g:buf0 .. 'bwipe!' set hidden& endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_textformat.vim 2020-02-02 15:32:09.967762406 +0100 --- src/testdir/test_textformat.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 951,958 **** bwipe! endfunc ! func Test_substitute() ! call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g')) endfunc " vim: shiftwidth=2 sts=2 expandtab --- 951,1038 ---- bwipe! endfunc ! " Test for the 'f' flag in 'comments' (only the first line has the comment ! " string) ! func Test_firstline_comment() ! new ! setlocal comments=f:- fo+=ro ! exe "normal i- B\nD\ggoC\ggOA\" ! call assert_equal(['A', '- B', ' C', ' D'], getline(1, '$')) ! %d ! setlocal comments=:- ! exe "normal i- B\nD\ggoC\ggOA\" ! call assert_equal(['- A', '- B', '- C', '- D'], getline(1, '$')) ! %bw! ! endfunc ! ! " Test for the 'r' flag in 'comments' (right align comment) ! func Test_comment_rightalign() ! new ! setlocal comments=sr:/***,m:**,ex-2:******/ fo+=ro ! exe "normal i=\o\t /***\nD\n/" ! exe "normal 2GOA\joB\jOC\joE\GOF\joG" ! let expected =<< trim END ! = ! A ! /*** ! ** B ! ** C ! ** D ! ** E ! ** F ! ******/ ! G ! END ! call assert_equal(expected, getline(1, '$')) ! %bw! ! endfunc ! ! " Test for the 'b' flag in 'comments' ! func Test_comment_blank() ! new ! setlocal comments=b:* fo+=ro ! exe "normal i* E\nF\n\G\nH\ggOC\O\B\OA\2joD" ! let expected =<< trim END ! A ! *B ! * C ! * D ! * E ! * F ! *G ! H ! END ! call assert_equal(expected, getline(1, '$')) ! %bw! ! endfunc ! ! " Test for the 'n' flag in comments ! func Test_comment_nested() ! new ! setlocal comments=n:> fo+=ro ! exe "normal i> B\nD\ggOA\joC\Go\>>> F\nH" ! exe "normal 5GOE\6GoG" ! let expected =<< trim END ! > A ! > B ! > C ! > D ! >>>> E ! >>>> F ! >>>> G ! >>>> H ! END ! call assert_equal(expected, getline(1, '$')) ! %bw! ! endfunc ! ! " Test for 'a' and 'w' flags in 'formatoptions' ! func Test_fo_a_w() ! new ! setlocal fo+=aw tw=10 ! call feedkeys("iabc abc a abc\k0weade", 'xt') ! call assert_equal(['abc abcde ', 'a abc'], getline(1, '$')) ! %bw! endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0481/src/testdir/test_visual.vim 2020-03-22 14:08:27.321399669 +0100 --- src/testdir/test_visual.vim 2020-03-30 19:24:35.987073315 +0200 *************** *** 267,272 **** --- 267,281 ---- call assert_equal(['abcd', \ 'efgh', \ 'ijkl'], getline(1, '$')) + + " Test for truncating spaces in a newly added line using 'autoindent' if + " characters are not added to that line. + %d_ + call setline(1, [' app', ' bee', ' cat']) + setlocal autoindent + exe "normal gg$gRt\n\nr" + call assert_equal([' apt', '', ' rat'], getline(1, '$')) + " clean up %d_ set bs&vim *** ../vim-8.2.0481/src/version.c 2020-03-30 19:13:24.977239954 +0200 --- src/version.c 2020-03-30 19:28:42.049971414 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 482, /**/ -- TALL KNIGHT: Firstly. You must get us another shrubbery! OTHER KNIGHTS: More shrubberies! More shrubberies for the ex-Knights of Ni! ARTHUR: Not another shrubbery - "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///