To: vim_dev@googlegroups.com Subject: Patch 8.2.0615 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0615 Problem: Regexp benchmark stest is old style. Solution: Make it a new style test. Fix using a NULL list. Add more tests. (Yegappan Lakshmanan, closes #5963) Files: src/evalbuffer.c, src/testdir/Make_dos.mak, src/testdir/Make_ming.mak, src/testdir/Makefile, src/testdir/bench_re_freeze.in, src/testdir/bench_re_freeze.vim, src/testdir/test_autocmd.vim, src/testdir/test_bench_regexp.vim, src/testdir/test_blob.vim, src/testdir/test_bufline.vim, src/testdir/test_channel.vim, src/testdir/test_cmdline.vim, src/testdir/test_functions.vim, src/testdir/test_ins_complete.vim, src/testdir/test_popupwin.vim, src/testdir/test_prompt_buffer.vim, src/testdir/test_tagjump.vim, src/testdir/test_window_cmd.vim *** ../vim-8.2.0614/src/evalbuffer.c 2020-04-02 18:50:42.419773128 +0200 --- src/evalbuffer.c 2020-04-21 22:06:14.597104287 +0200 *************** *** 176,181 **** --- 176,188 ---- if (lines->v_type == VAR_LIST) { l = lines->vval.v_list; + if (l == NULL || list_len(l) == 0) + { + // set proper return code + if (lnum > curbuf->b_ml.ml_line_count) + rettv->vval.v_number = 1; // FAIL + goto done; + } range_list_materialize(l); li = l->lv_first; } *************** *** 251,256 **** --- 258,264 ---- update_topline(); } + done: if (!is_curbuf) { curbuf = curbuf_save; *** ../vim-8.2.0614/src/testdir/Make_dos.mak 2019-11-05 22:26:49.000000000 +0100 --- src/testdir/Make_dos.mak 2020-04-21 22:06:14.597104287 +0200 *************** *** 107,118 **** -if exist test_result.log del test_result.log -if exist messages del messages ! benchmark: ! bench_re_freeze.out ! bench_re_freeze.out: bench_re_freeze.vim -if exist benchmark.out del benchmark.out ! $(VIMPROG) -u dos.vim $(NO_INITS) $*.in @IF EXIST benchmark.out ( type benchmark.out ) # New style of tests uses Vim script with assert calls. These are easier --- 107,119 ---- -if exist test_result.log del test_result.log -if exist messages del messages ! benchmark: test_bench_regexp.res ! test_bench_regexp.res: test_bench_regexp.vim -if exist benchmark.out del benchmark.out ! @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim ! @del vimcmd @IF EXIST benchmark.out ( type benchmark.out ) # New style of tests uses Vim script with assert calls. These are easier *** ../vim-8.2.0614/src/testdir/Make_ming.mak 2019-09-14 15:45:22.000000000 +0200 --- src/testdir/Make_ming.mak 2020-04-21 22:06:14.597104287 +0200 *************** *** 35,41 **** SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32) ! SCRIPTS_BENCH = bench_re_freeze.out # Must run test1 first to create small.vim. $(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS_WIN32) $(NEW_TESTS_RES): $(SCRIPTS_FIRST) --- 35,41 ---- SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32) ! SCRIPTS_BENCH = test_bench_regexp.res # Must run test1 first to create small.vim. $(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS_WIN32) $(NEW_TESTS_RES): $(SCRIPTS_FIRST) *************** *** 110,118 **** -@if exist test.log $(DEL) test.log -@if exist messages $(DEL) messages ! bench_re_freeze.out: bench_re_freeze.vim -$(DEL) benchmark.out ! $(VIMPROG) -u dos.vim $(NO_INITS) $*.in $(CAT) benchmark.out # New style of tests uses Vim script with assert calls. These are easier --- 110,120 ---- -@if exist test.log $(DEL) test.log -@if exist messages $(DEL) messages ! test_bench_regexp.res: test_bench_regexp.vim -$(DEL) benchmark.out ! @echo $(VIMPROG) > vimcmd ! $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim ! @$(DEL) vimcmd $(CAT) benchmark.out # New style of tests uses Vim script with assert calls. These are easier *** ../vim-8.2.0614/src/testdir/Makefile 2020-04-07 20:53:35.218912046 +0200 --- src/testdir/Makefile 2020-04-21 22:06:14.597104287 +0200 *************** *** 38,44 **** test_options.res test_alot.res: opt_test.vim ! SCRIPTS_BENCH = bench_re_freeze.out .SUFFIXES: .in .out .res .vim --- 38,44 ---- test_options.res test_alot.res: opt_test.vim ! SCRIPTS_BENCH = test_bench_regexp.res .SUFFIXES: .in .out .res .vim *************** *** 146,160 **** fi" -rm -rf X* test.ok viminfo - bench_re_freeze.out: bench_re_freeze.vim - -rm -rf benchmark.out $(RM_ON_RUN) - # Sleep a moment to avoid that the xterm title is messed up. - # 200 msec is sufficient, but only modern sleep supports a fraction of - # a second, fall back to a second if it fails. - @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" - $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL) - @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi" - nolog: -rm -f test.log messages --- 146,151 ---- *************** *** 193,195 **** --- 184,195 ---- test_xxd.res: XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim + + test_bench_regexp.res: test_bench_regexp.vim + -rm -rf benchmark.out $(RM_ON_RUN) + # Sleep a moment to avoid that the xterm title is messed up. + # 200 msec is sufficient, but only modern sleep supports a fraction of + # a second, fall back to a second if it fails. + @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" + $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL) + @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi" *** ../vim-8.2.0614/src/testdir/bench_re_freeze.in 2014-11-05 14:24:33.000000000 +0100 --- src/testdir/bench_re_freeze.in 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,13 **** - Test for Benchmarking RE engine - - STARTTEST - :so small.vim - :if !has("reltime") | qa! | endif - :set nocp cpo&vim - :so bench_re_freeze.vim - :call Measure('samples/re.freeze.txt', '\s\+\%#\@setbufline(bufnr('$') + 1, 1)) call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1)) + call assert_equal(1, []->setbufline(bufnr('$') + 1, 1)) + call assert_equal(1, test_null_list()->setbufline(bufnr('$') + 1, 1)) + + call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) + call assert_equal(0, setbufline(b, 4, ['d', 'e'])) call assert_equal(['c'], b->getbufline(3)) call assert_equal(['d'], getbufline(b, 4)) *************** *** 83,91 **** --- 94,122 ---- call setline(1, ['a', 'b', 'c']) let b = bufnr('%') wincmd w + + call assert_equal(1, appendbufline(b, -1, 'x')) call assert_equal(1, appendbufline(b, -1, ['x'])) + call assert_equal(1, appendbufline(b, -1, [])) + call assert_equal(1, appendbufline(b, -1, test_null_list())) + + call assert_equal(1, appendbufline(b, 4, 'x')) call assert_equal(1, appendbufline(b, 4, ['x'])) + call assert_equal(1, appendbufline(b, 4, [])) + call assert_equal(1, appendbufline(b, 4, test_null_list())) + + call assert_equal(1, appendbufline(1234, 1, 'x')) call assert_equal(1, appendbufline(1234, 1, ['x'])) + call assert_equal(1, appendbufline(1234, 1, [])) + call assert_equal(1, appendbufline(1234, 1, test_null_list())) + + call assert_equal(0, appendbufline(b, 1, [])) + call assert_equal(0, appendbufline(b, 1, test_null_list())) + call assert_equal(1, appendbufline(b, 3, [])) + call assert_equal(1, appendbufline(b, 3, test_null_list())) + + call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) + call assert_equal(0, appendbufline(b, 3, ['d', 'e'])) call assert_equal(['c'], getbufline(b, 3)) call assert_equal(['d'], getbufline(b, 4)) *** ../vim-8.2.0614/src/testdir/test_channel.vim 2020-04-13 17:44:43.616606625 +0200 --- src/testdir/test_channel.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 167,172 **** --- 167,174 ---- call ch_setoptions(handle, {'drop': 'never'}) call ch_setoptions(handle, {'drop': 'auto'}) call assert_fails("call ch_setoptions(handle, {'drop': 'bad'})", "E475") + call assert_equal(0, ch_setoptions(handle, test_null_dict())) + call assert_equal(0, ch_setoptions(test_null_channel(), {'drop' : 'never'})) " Send an eval request that works. call assert_equal('ok', ch_evalexpr(handle, 'eval-works')) *************** *** 1682,1687 **** --- 1684,1690 ---- call assert_fails('let job = job_start("")', 'E474:') call assert_fails('let job = job_start(" ")', 'E474:') call assert_fails('let job = job_start(["ls", []])', 'E730:') + call assert_fails('call job_setoptions(test_null_job(), {})', 'E916:') %bw! endfunc *************** *** 2267,2272 **** --- 2270,2276 ---- for opt in invalid_opts call assert_fails("let x = ch_status(ch, opt)", 'E475:') endfor + call assert_equal('fail', ch_status(ch, test_null_dict())) endfunc " Test for passing the command and the arguments as List on MS-Windows *** ../vim-8.2.0614/src/testdir/test_cmdline.vim 2020-04-08 21:50:18.872619665 +0200 --- src/testdir/test_cmdline.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 934,939 **** --- 934,942 ---- let log = readfile('Xlog') call assert_match("foo\nbar", join(log, "\n")) call delete('Xlog') + call mkdir('Xdir') + call assert_fails('set verbosefile=Xdir', 'E474:') + call delete('Xdir', 'd') endfunc func Test_verbose_option() *** ../vim-8.2.0614/src/testdir/test_functions.vim 2020-04-20 16:49:56.705830066 +0200 --- src/testdir/test_functions.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 794,811 **** --- 794,834 ---- set complete& endfunc + " Test for append() func Test_append() enew! split call append(0, ["foo"]) + call append(1, []) + call append(1, test_null_list()) + call assert_equal(['foo', ''], getline(1, '$')) split only undo + undo " Using $ instead of '$' must give an error call assert_fails("call append($, 'foobar')", 'E116:') endfunc + " Test for setline() + func Test_setline() + new + call setline(0, ["foo"]) + call setline(0, []) + call setline(0, test_null_list()) + call setline(1, ["bar"]) + call setline(1, []) + call setline(1, test_null_list()) + call setline(2, []) + call setline(2, test_null_list()) + call setline(3, []) + call setline(3, test_null_list()) + call setline(2, ["baz"]) + call assert_equal(['bar', 'baz'], getline(1, '$')) + close! + endfunc + func Test_getbufvar() let bnr = bufnr('%') let b:var_num = '1234' *************** *** 913,918 **** --- 936,942 ---- call assert_equal(-1, match(['a', 'b', 'c', 'a'], 'a', 5)) call assert_equal(4, match('testing', 'ing', -1)) call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:') + call assert_equal(-1, match(test_null_list(), 2)) endfunc func Test_matchend() *************** *** 1796,1801 **** --- 1820,1826 ---- call assert_equal(3, 'len'->call([123])) call assert_fails("call call('len', 123)", 'E714:') call assert_equal(0, call('', [])) + call assert_equal(0, call('len', test_null_list())) function Mylen() dict return len(self.data) *************** *** 1962,1968 **** execute "normal! a\=[complete(col('.'), range(10)), ''][1]\" " complete_info() execute "normal! a\=[complete(col('.'), range(10)), ''][1]\\=[complete_info(range(5)), ''][1]\" - call assert_fails('call complete(1, ["a"])', 'E785:') " copy() call assert_equal([1, 2, 3], copy(range(1, 3))) --- 1987,1992 ---- *** ../vim-8.2.0614/src/testdir/test_ins_complete.vim 2020-04-08 21:50:18.872619665 +0200 --- src/testdir/test_ins_complete.vim 2020-04-21 22:17:20.395909637 +0200 *************** *** 469,474 **** --- 469,475 ---- " Test for 'completefunc' deleting text func Test_completefunc_error() new + " delete text when called for the first time func CompleteFunc(findstart, base) if a:findstart == 1 normal dd *************** *** 479,487 **** --- 480,518 ---- set completefunc=CompleteFunc call setline(1, ['', 'abcd', '']) call assert_fails('exe "normal 2G$a\\"', 'E840:') + + " delete text when called for the second time + func CompleteFunc2(findstart, base) + if a:findstart == 1 + return col('.') - 1 + endif + normal dd + return ['a', 'b'] + endfunc + set completefunc=CompleteFunc2 + call setline(1, ['', 'abcd', '']) + call assert_fails('exe "normal 2G$a\\"', 'E565:') + set completefunc& delfunc CompleteFunc + delfunc CompleteFunc2 close! endfunc + " Test for errors in using complete() function + func Test_complete_func_error() + call assert_fails('call complete(1, ["a"])', 'E785:') + func ListColors() + call complete(col('.'), "blue") + endfunc + call assert_fails('exe "normal i\=ListColors()\"', 'E474:') + func ListMonths() + call complete(col('.'), test_null_list()) + endfunc + call assert_fails('exe "normal i\=ListMonths()\"', 'E474:') + delfunc ListColors + delfunc ListMonths + call assert_fails('call complete_info({})', 'E714:') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0614/src/testdir/test_popupwin.vim 2020-04-08 21:50:18.876619651 +0200 --- src/testdir/test_popupwin.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 853,858 **** --- 853,861 ---- call popup_clear() call assert_fails('call popup_create("text", "none")', 'E715:') call popup_clear() + call assert_fails('call popup_create(test_null_string(), {})', 'E450:') + call assert_fails('call popup_create(test_null_list(), {})', 'E450:') + call popup_clear() call assert_fails('call popup_create("text", #{col: "xxx"})', 'E475:') call popup_clear() *************** *** 902,907 **** --- 905,912 ---- call assert_fails('call popup_create("text", #{mask: test_null_list()})', 'E475:') call assert_fails('call popup_create("text", #{mapping: []})', 'E745:') call popup_clear() + call assert_fails('call popup_create("text", #{tabpage : 4})', 'E997:') + call popup_clear() endfunc func Test_win_execute_closing_curwin() *************** *** 1113,1120 **** --- 1118,1130 ---- let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') call assert_equal('hworld', line) + call assert_fails('call popup_move(winid, [])', 'E715:') + call assert_fails('call popup_move(winid, test_null_dict())', 'E715:') + call popup_close(winid) + call assert_equal(0, popup_move(-1, {})) + bwipe! endfunc *************** *** 2176,2182 **** --- 2186,2196 ---- call assert_equal(1, options.drag) call assert_equal('Another', options.highlight) + call assert_fails('call popup_setoptions(winid, [])', 'E715:') + call assert_fails('call popup_setoptions(winid, test_null_dict())', 'E715:') + call popup_close(winid) + call assert_equal(0, popup_setoptions(winid, options.wrap)) endfunc func Test_popupwin_garbage_collect() *** ../vim-8.2.0614/src/testdir/test_prompt_buffer.vim 2020-03-30 19:30:07.133542905 +0200 --- src/testdir/test_prompt_buffer.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 148,153 **** --- 148,154 ---- call assert_beeps("normal! \") call assert_beeps("normal! \") close! + call assert_equal(0, prompt_setprompt([], '')) endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0614/src/testdir/test_tagjump.vim 2020-04-08 21:50:18.876619651 +0200 --- src/testdir/test_tagjump.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 285,290 **** --- 285,291 ---- call assert_fails("call settagstack(1, {'items' : 10})", 'E714') call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E928') call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962') + call assert_equal(-1, settagstack(0, test_null_dict())) set tags=Xtags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", *** ../vim-8.2.0614/src/testdir/test_window_cmd.vim 2020-04-06 21:35:02.464237765 +0200 --- src/testdir/test_window_cmd.vim 2020-04-21 22:06:14.597104287 +0200 *************** *** 1079,1082 **** --- 1079,1094 ---- call Run_noroom_for_newwindow_test('v') endfunc + " Test for various wincmd failures + func Test_wincmd_fails() + only! + call assert_beeps("normal \w") + call assert_beeps("normal \p") + call assert_beeps("normal \gk") + call assert_beeps("normal \r") + call assert_beeps("normal \K") + call assert_beeps("normal \H") + call assert_beeps("normal \2gt") + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0614/src/version.c 2020-04-21 22:01:11.093499495 +0200 --- src/version.c 2020-04-21 22:08:10.896929877 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 615, /**/ -- Q: What's a light-year? A: One-third less calories than a regular year. /// 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 ///