summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-21 22:19:45 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-21 22:19:45 +0200
commitad48e6c1590842ab6d48e6caba3e9250734dae27 (patch)
treec81fe7bc66f2807223cdf76306dccf5b714f3650 /src/testdir
parentff06f283e3e4b3ec43012dd3b83f8454c98f6639 (diff)
patch 8.2.0615: regexp benchmark stest is old stylev8.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)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/Make_dos.mak9
-rw-r--r--src/testdir/Make_ming.mak8
-rw-r--r--src/testdir/Makefile20
-rw-r--r--src/testdir/bench_re_freeze.in13
-rw-r--r--src/testdir/bench_re_freeze.vim13
-rw-r--r--src/testdir/test_autocmd.vim2
-rw-r--r--src/testdir/test_bench_regexp.vim24
-rw-r--r--src/testdir/test_blob.vim1
-rw-r--r--src/testdir/test_bufline.vim31
-rw-r--r--src/testdir/test_channel.vim4
-rw-r--r--src/testdir/test_cmdline.vim3
-rw-r--r--src/testdir/test_functions.vim26
-rw-r--r--src/testdir/test_ins_complete.vim31
-rw-r--r--src/testdir/test_popupwin.vim14
-rw-r--r--src/testdir/test_prompt_buffer.vim1
-rw-r--r--src/testdir/test_tagjump.vim1
-rw-r--r--src/testdir/test_window_cmd.vim12
17 files changed, 169 insertions, 44 deletions
diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak
index 66839d63bf..0e07ed5c5f 100644
--- a/src/testdir/Make_dos.mak
+++ b/src/testdir/Make_dos.mak
@@ -107,12 +107,13 @@ nolog:
-if exist test_result.log del test_result.log
-if exist messages del messages
-benchmark:
- bench_re_freeze.out
+benchmark: test_bench_regexp.res
-bench_re_freeze.out: bench_re_freeze.vim
+test_bench_regexp.res: test_bench_regexp.vim
-if exist benchmark.out del benchmark.out
- $(VIMPROG) -u dos.vim $(NO_INITS) $*.in
+ @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
diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak
index 671caa24f3..f95f70c88c 100644
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -35,7 +35,7 @@ include Make_all.mak
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
-SCRIPTS_BENCH = bench_re_freeze.out
+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,9 +110,11 @@ nolog:
-@if exist test.log $(DEL) test.log
-@if exist messages $(DEL) messages
-bench_re_freeze.out: bench_re_freeze.vim
+test_bench_regexp.res: test_bench_regexp.vim
-$(DEL) benchmark.out
- $(VIMPROG) -u dos.vim $(NO_INITS) $*.in
+ @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
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
index b2eaecbf40..92506e6f41 100644
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -38,7 +38,7 @@ test49.out: test49.vim
test_options.res test_alot.res: opt_test.vim
-SCRIPTS_BENCH = bench_re_freeze.out
+SCRIPTS_BENCH = test_bench_regexp.res
.SUFFIXES: .in .out .res .vim
@@ -146,15 +146,6 @@ test1.out: test1.in
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
@@ -193,3 +184,12 @@ opt_test.vim: ../optiondefs.h gen_opt_test.vim
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"
diff --git a/src/testdir/bench_re_freeze.in b/src/testdir/bench_re_freeze.in
deleted file mode 100644
index 7b1bfa3459..0000000000
--- a/src/testdir/bench_re_freeze.in
+++ /dev/null
@@ -1,13 +0,0 @@
-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\+\%#\@<!$', '+5')
-:/^" Benchmark/,$w! benchmark.out
-:qa!
-ENDTEST
-
-" Benchmark_results:
diff --git a/src/testdir/bench_re_freeze.vim b/src/testdir/bench_re_freeze.vim
deleted file mode 100644
index ee8443825f..0000000000
--- a/src/testdir/bench_re_freeze.vim
+++ /dev/null
@@ -1,13 +0,0 @@
-"Test for benchmarking the RE engine
-
-so small.vim
-if !has("reltime") | finish | endif
-func! Measure(file, pattern, arg)
- for re in range(3)
- let sstart=reltime()
- let cmd=printf("../vim -u NONE -N --cmd ':set re=%d'".
- \ " -c 'call search(\"%s\", \"\", \"\", 10000)' -c ':q!' %s", re, escape(a:pattern, '\\'), empty(a:arg) ? '' : a:arg)
- call system(cmd. ' '. a:file)
- $put =printf('file: %s, re: %d, time: %s', a:file, re, reltimestr(reltime(sstart)))
- endfor
-endfunc
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index a8648f8c49..b7a523e39a 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -299,6 +299,8 @@ func Test_augroup_warning()
redir END
call assert_true(match(res, "W19:") < 0)
au! VimEnter
+
+ call assert_fails('augroup!', 'E471:')
endfunc
func Test_BufReadCmdHelp()
diff --git a/src/testdir/test_bench_regexp.vim b/src/testdir/test_bench_regexp.vim
new file mode 100644
index 0000000000..eb9f5f8e5a
--- /dev/null
+++ b/src/testdir/test_bench_regexp.vim
@@ -0,0 +1,24 @@
+" Test for benchmarking the RE engine
+
+source check.vim
+CheckFeature reltime
+
+func Measure(file, pattern, arg)
+ for re in range(3)
+ let sstart = reltime()
+ let before = ['set re=' .. re]
+ let after = ['call search("' .. escape(a:pattern, '\\') .. '", "", "", 10000)']
+ let after += ['quit!']
+ let args = empty(a:arg) ? '' : a:arg .. ' ' .. a:file
+ call RunVim(before, after, args)
+ let s = 'file: ' .. a:file .. ', re: ' .. re ..
+ \ ', time: ' .. reltimestr(reltime(sstart))
+ call writefile([s], 'benchmark.out', "a")
+ endfor
+endfunc
+
+func Test_Regex_Benchmark()
+ call Measure('samples/re.freeze.txt', '\s\+\%#\@<!$', '+5')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim
index e2c332a8a6..a29e2e61d9 100644
--- a/src/testdir/test_blob.vim
+++ b/src/testdir/test_blob.vim
@@ -291,6 +291,7 @@ func Test_blob_index()
call assert_equal(3, index(0z11110111, 0x11, -2))
call assert_equal(0, index(0z11110111, 0x11, -10))
call assert_fails("echo index(0z11110111, 0x11, [])", 'E745:')
+ call assert_equal(-1, index(test_null_blob(), 1))
call assert_fails('call index("asdf", 0)', 'E897:')
endfunc
diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim
index a863ba5d3a..d359f205d5 100644
--- a/src/testdir/test_bufline.vim
+++ b/src/testdir/test_bufline.vim
@@ -19,8 +19,19 @@ func Test_setbufline_getbufline()
call setline(1, ['a', 'b', 'c'])
let b = bufnr('%')
wincmd w
+
+ call assert_equal(1, setbufline(b, 5, 'x'))
call assert_equal(1, setbufline(b, 5, ['x']))
+ call assert_equal(1, setbufline(b, 5, []))
+ call assert_equal(1, setbufline(b, 5, test_null_list()))
+
+ call assert_equal(1, 'x'->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,9 +94,29 @@ func Test_appendbufline()
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))
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index af809eceb4..cf51a536b5 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -167,6 +167,8 @@ func Ch_communicate(port)
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,6 +1684,7 @@ func Test_job_start_fails()
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,6 +2270,7 @@ func Test_invalid_job_chan_options()
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
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 8aabaa859d..7d3c0c87d0 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -934,6 +934,9 @@ func Test_verbosefile()
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()
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index f7a438af72..dbd08041f3 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -794,18 +794,41 @@ func Test_mode()
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,6 +936,7 @@ func Test_match_func()
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,6 +1820,7 @@ func Test_call()
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,7 +1987,6 @@ func Test_range()
execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>"
" complete_info()
execute "normal! a\<C-r>=[complete(col('.'), range(10)), ''][1]\<CR>\<C-r>=[complete_info(range(5)), ''][1]\<CR>"
- call assert_fails('call complete(1, ["a"])', 'E785:')
" copy()
call assert_equal([1, 2, 3], copy(range(1, 3)))
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index a1c7b98f18..7ae263909c 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -469,6 +469,7 @@ endfunc
" 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,9 +480,39 @@ func Test_completefunc_error()
set completefunc=CompleteFunc
call setline(1, ['', 'abcd', ''])
call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', '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\<C-X>\<C-U>"', '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\<C-R>=ListColors()\<CR>"', 'E474:')
+ func ListMonths()
+ call complete(col('.'), test_null_list())
+ endfunc
+ call assert_fails('exe "normal i\<C-R>=ListMonths()\<CR>"', 'E474:')
+ delfunc ListColors
+ delfunc ListMonths
+ call assert_fails('call complete_info({})', 'E714:')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 03285f935c..99b4458250 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -853,6 +853,9 @@ func Test_popup_invalid_arguments()
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,6 +905,8 @@ func Test_popup_invalid_arguments()
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,8 +1118,13 @@ func Test_popup_move()
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,7 +2186,11 @@ func Test_set_get_options()
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()
diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim
index 39cce247de..760e1d9798 100644
--- a/src/testdir/test_prompt_buffer.vim
+++ b/src/testdir/test_prompt_buffer.vim
@@ -148,6 +148,7 @@ func Test_prompt_buffer_edit()
call assert_beeps("normal! \<C-A>")
call assert_beeps("normal! \<C-X>")
close!
+ call assert_equal(0, prompt_setprompt([], ''))
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim
index 99526005e6..fa825c7dc0 100644
--- a/src/testdir/test_tagjump.vim
+++ b/src/testdir/test_tagjump.vim
@@ -285,6 +285,7 @@ func Test_getsettagstack()
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//",
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index a28c00a4bd..4927842454 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -1079,4 +1079,16 @@ func Test_split_cmds_with_no_room()
call Run_noroom_for_newwindow_test('v')
endfunc
+" Test for various wincmd failures
+func Test_wincmd_fails()
+ only!
+ call assert_beeps("normal \<C-W>w")
+ call assert_beeps("normal \<C-W>p")
+ call assert_beeps("normal \<C-W>gk")
+ call assert_beeps("normal \<C-W>r")
+ call assert_beeps("normal \<C-W>K")
+ call assert_beeps("normal \<C-W>H")
+ call assert_beeps("normal \<C-W>2gt")
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab