aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/Makefile28
-rw-r--r--src/nvim/testdir/check.vim11
-rwxr-xr-xsrc/nvim/testdir/runnvim.sh5
-rw-r--r--src/nvim/testdir/runtest.vim37
-rw-r--r--src/nvim/testdir/screendump.vim2
-rw-r--r--src/nvim/testdir/setup.vim1
-rw-r--r--src/nvim/testdir/shared.vim116
-rw-r--r--src/nvim/testdir/summarize.vim9
-rw-r--r--src/nvim/testdir/term_util.vim11
-rw-r--r--src/nvim/testdir/test42.inbin2438 -> 2373 bytes
-rw-r--r--src/nvim/testdir/test48.in82
-rw-r--r--src/nvim/testdir/test48.ok23
-rw-r--r--src/nvim/testdir/test49.vim6
-rw-r--r--src/nvim/testdir/test64.in654
-rw-r--r--src/nvim/testdir/test64.ok1107
-rw-r--r--src/nvim/testdir/test_alot.vim3
-rw-r--r--src/nvim/testdir/test_assert.vim46
-rw-r--r--src/nvim/testdir/test_autocmd.vim199
-rw-r--r--src/nvim/testdir/test_backup.vim58
-rw-r--r--src/nvim/testdir/test_breakindent.vim126
-rw-r--r--src/nvim/testdir/test_bufline.vim2
-rw-r--r--src/nvim/testdir/test_bufwintabinfo.vim17
-rw-r--r--src/nvim/testdir/test_cindent.vim69
-rw-r--r--src/nvim/testdir/test_clientserver.vim13
-rw-r--r--src/nvim/testdir/test_cmdline.vim207
-rw-r--r--src/nvim/testdir/test_compiler.vim19
-rw-r--r--src/nvim/testdir/test_const.vim20
-rw-r--r--src/nvim/testdir/test_cursor_func.vim16
-rw-r--r--src/nvim/testdir/test_debugger.vim58
-rw-r--r--src/nvim/testdir/test_diffmode.vim88
-rw-r--r--src/nvim/testdir/test_digraph.vim25
-rw-r--r--src/nvim/testdir/test_display.vim56
-rw-r--r--src/nvim/testdir/test_edit.vim17
-rw-r--r--src/nvim/testdir/test_escaped_glob.vim2
-rw-r--r--src/nvim/testdir/test_excmd.vim32
-rw-r--r--src/nvim/testdir/test_exit.vim88
-rw-r--r--src/nvim/testdir/test_expr.vim5
-rw-r--r--src/nvim/testdir/test_filetype.vim76
-rw-r--r--src/nvim/testdir/test_flatten.vim81
-rw-r--r--src/nvim/testdir/test_fnamemodify.vim75
-rw-r--r--src/nvim/testdir/test_fold.vim61
-rw-r--r--src/nvim/testdir/test_functions.vim73
-rw-r--r--src/nvim/testdir/test_ga.vim1
-rw-r--r--src/nvim/testdir/test_gf.vim33
-rw-r--r--src/nvim/testdir/test_gn.vim27
-rw-r--r--src/nvim/testdir/test_goto.vim406
-rw-r--r--src/nvim/testdir/test_hardcopy.vim169
-rw-r--r--src/nvim/testdir/test_help.vim6
-rw-r--r--src/nvim/testdir/test_highlight.vim11
-rw-r--r--src/nvim/testdir/test_increment.vim36
-rw-r--r--src/nvim/testdir/test_ins_complete.vim97
-rw-r--r--src/nvim/testdir/test_join.vim406
-rw-r--r--src/nvim/testdir/test_let.vim162
-rw-r--r--src/nvim/testdir/test_listchars.vim20
-rw-r--r--src/nvim/testdir/test_listlbr.vim31
-rw-r--r--src/nvim/testdir/test_maparg.vim15
-rw-r--r--src/nvim/testdir/test_mapping.vim76
-rw-r--r--src/nvim/testdir/test_marks.vim69
-rw-r--r--src/nvim/testdir/test_match.vim97
-rw-r--r--src/nvim/testdir/test_messages.vim34
-rw-r--r--src/nvim/testdir/test_mksession.vim33
-rw-r--r--src/nvim/testdir/test_mksession_utf8.vim57
-rw-r--r--src/nvim/testdir/test_modeline.vim117
-rw-r--r--src/nvim/testdir/test_normal.vim491
-rw-r--r--src/nvim/testdir/test_number.vim11
-rw-r--r--src/nvim/testdir/test_options.vim86
-rw-r--r--src/nvim/testdir/test_plus_arg_edit.vim28
-rw-r--r--src/nvim/testdir/test_popup.vim132
-rw-r--r--src/nvim/testdir/test_profile.vim294
-rw-r--r--src/nvim/testdir/test_python2.vim10
-rw-r--r--src/nvim/testdir/test_python3.vim28
-rw-r--r--src/nvim/testdir/test_pyx2.vim8
-rw-r--r--src/nvim/testdir/test_pyx3.vim8
-rw-r--r--src/nvim/testdir/test_quickfix.vim1299
-rw-r--r--src/nvim/testdir/test_quotestar.vim23
-rw-r--r--src/nvim/testdir/test_recover.vim6
-rw-r--r--src/nvim/testdir/test_regexp_latin.vim668
-rw-r--r--src/nvim/testdir/test_regexp_utf8.vim342
-rw-r--r--src/nvim/testdir/test_registers.vim104
-rw-r--r--src/nvim/testdir/test_restricted.vim103
-rw-r--r--src/nvim/testdir/test_search.vim41
-rw-r--r--src/nvim/testdir/test_signs.vim413
-rw-r--r--src/nvim/testdir/test_spell.vim100
-rw-r--r--src/nvim/testdir/test_startup.vim165
-rw-r--r--src/nvim/testdir/test_startup_utf8.vim2
-rw-r--r--src/nvim/testdir/test_statusline.vim67
-rw-r--r--src/nvim/testdir/test_substitute.vim31
-rw-r--r--src/nvim/testdir/test_suspend.vim3
-rw-r--r--src/nvim/testdir/test_swap.vim84
-rw-r--r--src/nvim/testdir/test_syntax.vim94
-rw-r--r--src/nvim/testdir/test_tabline.vim25
-rw-r--r--src/nvim/testdir/test_tabpage.vim4
-rw-r--r--src/nvim/testdir/test_tagfunc.vim84
-rw-r--r--src/nvim/testdir/test_tagjump.vim138
-rw-r--r--src/nvim/testdir/test_taglist.vim17
-rw-r--r--src/nvim/testdir/test_textformat.vim423
-rw-r--r--src/nvim/testdir/test_textobjects.vim21
-rw-r--r--src/nvim/testdir/test_timers.vim97
-rw-r--r--src/nvim/testdir/test_undo.vim253
-rw-r--r--src/nvim/testdir/test_user_func.vim4
-rw-r--r--src/nvim/testdir/test_utf8.vim43
-rw-r--r--src/nvim/testdir/test_vimscript.vim72
-rw-r--r--src/nvim/testdir/test_virtualedit.vim144
-rw-r--r--src/nvim/testdir/test_window_cmd.vim135
-rw-r--r--src/nvim/testdir/test_writefile.vim7
-rw-r--r--src/nvim/testdir/view_util.vim14
106 files changed, 8370 insertions, 3279 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index d1a449c7cc..e52fd888bd 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -11,12 +11,10 @@ ROOT := ../../..
export SHELL := sh
export NVIM_PRG := $(NVIM_PRG)
-export TMPDIR := $(abspath ../../../Xtest-tmpdir)
+export TMPDIR := $(abspath Xtest-tmpdir)
SCRIPTS_DEFAULT = \
test42.out \
- test48.out \
- test64.out \
ifneq ($(OS),Windows_NT)
SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \
@@ -34,21 +32,23 @@ SCRIPTS ?= $(SCRIPTS_DEFAULT)
# Tests using runtest.vim.
NEW_TESTS_ALOT := test_alot_utf8 test_alot
-NEW_TESTS_IN_ALOT := $(shell sed '/^source/ s/^source //;s/\.vim$$//' test_alot*.vim)
+NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT)))
+NEW_TESTS_IN_ALOT_LATIN := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' test_alot_latin.vim)
# Ignored tests.
# test_alot_latin: Nvim does not allow setting encoding.
# test_autochdir: ported to Lua, but kept for easier merging.
# test_eval_func: used as include in old-style test (test_eval.in).
# test_listlbr: Nvim does not allow setting encoding.
# test_largefile: uses too much resources to run on CI.
-NEW_TESTS_IGNORE := $(NEW_TESTS_IN_ALOT) $(NEW_TESTS_ALOT) \
- test_alot_latin \
+NEW_TESTS_IGNORE := \
+ test_alot_latin $(NEW_TESTS_IN_ALOT_LATIN) \
test_autochdir \
test_eval_func \
test_listlbr \
test_largefile \
-NEW_TESTS ?= $(addsuffix .res,$(sort $(filter-out $(NEW_TESTS_IGNORE),$(basename $(notdir $(wildcard test_*.vim))))) $(NEW_TESTS_ALOT))
+NEW_TESTS := $(sort $(basename $(notdir $(wildcard test_*.vim))))
+NEW_TESTS_RES := $(addsuffix .res,$(filter-out $(NEW_TESTS_ALOT) $(NEW_TESTS_IN_ALOT) $(NEW_TESTS_IGNORE),$(NEW_TESTS)) $(NEW_TESTS_ALOT))
ifdef VALGRIND_GDB
@@ -86,7 +86,7 @@ nongui: nolog $(FIXFF) $(SCRIPTS) newtests report
@echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit
report:
- $(RUN_VIMTEST) $(NO_INITS) -u NONE -S summarize.vim messages
+ $(NVIM_PRG) -u NONE $(NO_INITS) -S summarize.vim messages
@echo
@echo 'Test results:'
@cat test_result.log
@@ -112,6 +112,16 @@ fixff:
-$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \
dotest.in
+# Execute an individual new style test, e.g.:
+# make test_largefile
+$(NEW_TESTS):
+ rm -f $@.res test.log messages
+ @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res
+ @cat messages
+ @if test -f test.log; then \
+ exit 1; \
+ fi
+
RM_ON_RUN := test.out X* viminfo
RM_ON_START := test.ok
RUN_VIM := $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in
@@ -172,7 +182,7 @@ newtests: newtestssilent
cat messages && cat test.log; \
fi"
-newtestssilent: $(NEW_TESTS)
+newtestssilent: $(NEW_TESTS_RES)
%.res: %.vim .gdbinit
@echo "[OLDTEST] Running" $*
diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim
new file mode 100644
index 0000000000..57a8eb57b8
--- /dev/null
+++ b/src/nvim/testdir/check.vim
@@ -0,0 +1,11 @@
+source shared.vim
+source term_util.vim
+
+" Command to check that making screendumps is supported.
+" Caller must source screendump.vim
+command CheckScreendump call CheckScreendump()
+func CheckScreendump()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot make screendumps'
+ endif
+endfunc
diff --git a/src/nvim/testdir/runnvim.sh b/src/nvim/testdir/runnvim.sh
index 2dcd9150be..72f9254635 100755
--- a/src/nvim/testdir/runnvim.sh
+++ b/src/nvim/testdir/runnvim.sh
@@ -82,6 +82,11 @@ main() {(
fi
if test "$FAILED" = 1 ; then
echo "Test $test_name failed, see output above and summary for more details" >> test.log
+ # When Neovim crashed/aborted it might not have created messages.
+ # test.log itself is used as an indicator to exit non-zero in the Makefile.
+ if ! test -f message; then
+ cp -a test.log messages
+ fi
fi
)}
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim
index 593ce6fcdc..2bf61b0719 100644
--- a/src/nvim/testdir/runtest.vim
+++ b/src/nvim/testdir/runtest.vim
@@ -44,6 +44,10 @@ if &lines < 24 || &columns < 80
qa!
endif
+if has('reltime')
+ let s:start_time = reltime()
+endif
+
" Common with all tests on all systems.
source setup.vim
@@ -80,6 +84,11 @@ let &runtimepath .= ','.expand($BUILD_DIR).'/runtime/'
" Always use forward slashes.
set shellslash
+if has('win32')
+ " avoid prompt that is long or contains a line break
+ let $PROMPT = '$P$G'
+endif
+
" Prepare for calling test_garbagecollect_now().
let v:testing = 1
@@ -98,13 +107,11 @@ func GetAllocId(name)
return lnum - top - 1
endfunc
-func CanRunVimInTerminal()
- " Nvim: always false, we use Lua screen-tests instead.
- return 0
-endfunc
-
func RunTheTest(test)
echo 'Executing ' . a:test
+ if has('reltime')
+ let func_start = reltime()
+ endif
" Avoid stopping at the "hit enter" prompt
set nomore
@@ -129,7 +136,11 @@ func RunTheTest(test)
endtry
endif
- call add(s:messages, 'Executing ' . a:test)
+ let message = 'Executed ' . a:test
+ if has('reltime')
+ let message ..= ' in ' .. reltimestr(reltime(func_start)) .. ' seconds'
+ endif
+ call add(s:messages, message)
let s:done += 1
if a:test =~ 'Test_nocatch_'
@@ -235,6 +246,9 @@ func FinishTesting()
else
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test')
endif
+ if has('reltime')
+ let message ..= ' in ' .. reltimestr(reltime(s:start_time)) .. ' seconds'
+ endif
echo message
call add(s:messages, message)
if s:fail > 0
@@ -282,18 +296,23 @@ endif
" Names of flaky tests.
let s:flaky_tests = [
+ \ 'Test_autocmd_SafeState()',
\ 'Test_cursorhold_insert()',
\ 'Test_exit_callback_interval()',
\ 'Test_map_timeout_with_timer_interrupt()',
\ 'Test_oneshot()',
\ 'Test_out_cb()',
\ 'Test_paused()',
+ \ 'Test_popup_and_window_resize()',
\ 'Test_quoteplus()',
\ 'Test_quotestar()',
\ 'Test_reltime()',
\ 'Test_repeat_many()',
\ 'Test_repeat_three()',
+ \ 'Test_state()',
\ 'Test_stop_all_in_callback()',
+ \ 'Test_term_mouse_double_click_to_create_tab',
+ \ 'Test_term_mouse_multiple_clicks_to_visually_select()',
\ 'Test_terminal_composing_unicode()',
\ 'Test_terminal_redir_file()',
\ 'Test_terminal_tmap()',
@@ -314,6 +333,12 @@ if argc() > 1
let s:tests = filter(s:tests, 'v:val =~ argv(1)')
endif
+" If the environment variable $TEST_FILTER is set then filter the function
+" names against it.
+if $TEST_FILTER != ''
+ let s:tests = filter(s:tests, 'v:val =~ $TEST_FILTER')
+endif
+
" Execute the tests in alphabetical order.
for s:test in sort(s:tests)
" Silence, please!
diff --git a/src/nvim/testdir/screendump.vim b/src/nvim/testdir/screendump.vim
index e69de29bb2..8afff1da91 100644
--- a/src/nvim/testdir/screendump.vim
+++ b/src/nvim/testdir/screendump.vim
@@ -0,0 +1,2 @@
+source shared.vim
+source term_util.vim
diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim
index ea28f328ae..d032c9a739 100644
--- a/src/nvim/testdir/setup.vim
+++ b/src/nvim/testdir/setup.vim
@@ -19,6 +19,7 @@ set sidescroll=0
set tags=./tags,tags
set undodir^=.
set wildoptions=
+set startofline
" Prevent Nvim log from writing to stderr.
let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim
index df512e2e3f..41ff9b2bd6 100644
--- a/src/nvim/testdir/shared.vim
+++ b/src/nvim/testdir/shared.vim
@@ -1,10 +1,12 @@
" Functions shared by several tests.
" Only load this script once.
-if exists('*WaitFor')
+if exists('*PythonProg')
finish
endif
+source view_util.vim
+
" {Nvim}
" Filepath captured from output may be truncated, like this:
" /home/va...estdir/Xtest-tmpdir/nvimxbXN4i/10
@@ -69,7 +71,8 @@ endfunc
" Read the port number from the Xportnr file.
func GetPort()
let l = []
- for i in range(200)
+ " with 200 it sometimes failed
+ for i in range(400)
try
let l = readfile("Xportnr")
catch
@@ -135,39 +138,80 @@ endfunc
" Wait for up to five seconds for "expr" to become true. "expr" can be a
" stringified expression to evaluate, or a funcref without arguments.
+" Using a lambda works best. Example:
+" call WaitFor({-> status == "ok"})
"
" A second argument can be used to specify a different timeout in msec.
"
-" Return time slept in milliseconds. With the +reltime feature this can be
-" more than the actual waiting time. Without +reltime it can also be less.
+" When successful the time slept is returned.
+" When running into the timeout an exception is thrown, thus the function does
+" not return.
func WaitFor(expr, ...)
let timeout = get(a:000, 0, 5000)
+ let slept = s:WaitForCommon(a:expr, v:null, timeout)
+ if slept < 0
+ throw 'WaitFor() timed out after ' . timeout . ' msec'
+ endif
+ return slept
+endfunc
+
+" Wait for up to five seconds for "assert" to return zero. "assert" must be a
+" (lambda) function containing one assert function. Example:
+" call WaitForAssert({-> assert_equal("dead", job_status(job)})
+"
+" A second argument can be used to specify a different timeout in msec.
+"
+" Return zero for success, one for failure (like the assert function).
+func WaitForAssert(assert, ...)
+ let timeout = get(a:000, 0, 5000)
+ if s:WaitForCommon(v:null, a:assert, timeout) < 0
+ return 1
+ endif
+ return 0
+endfunc
+
+" Common implementation of WaitFor() and WaitForAssert().
+" Either "expr" or "assert" is not v:null
+" Return the waiting time for success, -1 for failure.
+func s:WaitForCommon(expr, assert, timeout)
" using reltime() is more accurate, but not always available
+ let slept = 0
if has('reltime')
let start = reltime()
- else
- let slept = 0
endif
- if type(a:expr) == v:t_func
- let Test = a:expr
- else
- let Test = {-> eval(a:expr) }
- endif
- for i in range(timeout / 10)
- if Test()
- if has('reltime')
- return float2nr(reltimefloat(reltime(start)) * 1000)
- endif
+
+ while 1
+ if type(a:expr) == v:t_func
+ let success = a:expr()
+ elseif type(a:assert) == v:t_func
+ let success = a:assert() == 0
+ else
+ let success = eval(a:expr)
+ endif
+ if success
return slept
endif
- if !has('reltime')
- let slept += 10
+
+ if slept >= a:timeout
+ break
endif
+ if type(a:assert) == v:t_func
+ " Remove the error added by the assert function.
+ call remove(v:errors, -1)
+ endif
+
sleep 10m
- endfor
- throw 'WaitFor() timed out after ' . timeout . ' msec'
+ if has('reltime')
+ let slept = float2nr(reltimefloat(reltime(start)) * 1000)
+ else
+ let slept += 10
+ endif
+ endwhile
+
+ return -1 " timed out
endfunc
+
" Wait for up to a given milliseconds.
" With the +timers feature this waits for key-input by getchar(), Resume()
" feeds key-input and resumes process. Return time waited in milliseconds.
@@ -211,6 +255,8 @@ func GetVimProg()
endif
endfunc
+let g:valgrind_cnt = 1
+
" Get the command to run Vim, with -u NONE and --headless arguments.
" If there is an argument use it instead of "NONE".
func GetVimCommand(...)
@@ -226,14 +272,25 @@ func GetVimCommand(...)
endif
let cmd .= ' --headless -i NONE'
let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
+
+ " If using valgrind, make sure every run uses a different log file.
+ if cmd =~ 'valgrind.*--log-file='
+ let cmd = substitute(cmd, '--log-file=\(\S*\)', '--log-file=\1.' . g:valgrind_cnt, '')
+ let g:valgrind_cnt += 1
+ endif
+
return cmd
endfunc
-" Get the command to run Vim, with --clean.
+" Get the command to run Vim, with --clean instead of "-u NONE".
func GetVimCommandClean()
let cmd = GetVimCommand()
let cmd = substitute(cmd, '-u NONE', '--clean', '')
let cmd = substitute(cmd, '--headless', '', '')
+
+ " Optionally run Vim under valgrind
+ " let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd
+
return cmd
endfunc
@@ -249,9 +306,6 @@ endfunc
func RunVimPiped(before, after, arguments, pipecmd)
let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
let cmd = GetVimCommand()
- if cmd == ''
- return 0
- endif
let args = ''
if len(a:before) > 0
call writefile(a:before, 'Xbefore.vim')
@@ -262,6 +316,9 @@ func RunVimPiped(before, after, arguments, pipecmd)
let args .= ' -S Xafter.vim'
endif
+ " Optionally run Vim under valgrind
+ " let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd
+
exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments
if len(a:before) > 0
@@ -273,17 +330,6 @@ func RunVimPiped(before, after, arguments, pipecmd)
return 1
endfunc
-" Get line "lnum" as displayed on the screen.
-" Trailing white space is trimmed.
-func! Screenline(lnum)
- let chars = []
- for c in range(1, winwidth(0))
- call add(chars, nr2char(screenchar(a:lnum, c)))
- endfor
- let line = join(chars, '')
- return matchstr(line, '^.\{-}\ze\s*$')
-endfunc
-
func CanRunGui()
return has('gui') && ($DISPLAY != "" || has('gui_running'))
endfunc
diff --git a/src/nvim/testdir/summarize.vim b/src/nvim/testdir/summarize.vim
index 5bbf0b338a..7f8f758a71 100644
--- a/src/nvim/testdir/summarize.vim
+++ b/src/nvim/testdir/summarize.vim
@@ -1,6 +1,7 @@
if 1
" This is executed only with the eval feature
set nocompatible
+ set viminfo=
func Count(match, type)
if a:type ==# 'executed'
let g:executed += (a:match+0)
@@ -8,7 +9,7 @@ if 1
let g:failed += a:match+0
elseif a:type ==# 'skipped'
let g:skipped += 1
- call extend(g:skipped_output, ["\t".a:match])
+ call extend(g:skipped_output, ["\t" .. a:match])
endif
endfunc
@@ -19,11 +20,15 @@ if 1
let g:failed_output = []
let output = [""]
+ if $TEST_FILTER != ''
+ call extend(g:skipped_output, ["\tAll tests not matching $TEST_FILTER: '" .. $TEST_FILTER .. "'"])
+ endif
+
try
" This uses the :s command to just fetch and process the output of the
" tests, it doesn't actually replace anything.
" And it uses "silent" to avoid reporting the number of matches.
- silent %s/^Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn
+ silent %s/Executed\s\+\zs\d\+\ze\s\+tests\?/\=Count(submatch(0),'executed')/egn
silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
diff --git a/src/nvim/testdir/term_util.vim b/src/nvim/testdir/term_util.vim
new file mode 100644
index 0000000000..3a838a3a1f
--- /dev/null
+++ b/src/nvim/testdir/term_util.vim
@@ -0,0 +1,11 @@
+" Functions about terminal shared by several tests
+
+" Only load this script once.
+if exists('*CanRunVimInTerminal')
+ finish
+endif
+
+func CanRunVimInTerminal()
+ " Nvim: always false, we use Lua screen-tests instead.
+ return 0
+endfunc
diff --git a/src/nvim/testdir/test42.in b/src/nvim/testdir/test42.in
index baa6e67d26..d9057e72fb 100644
--- a/src/nvim/testdir/test42.in
+++ b/src/nvim/testdir/test42.in
Binary files differ
diff --git a/src/nvim/testdir/test48.in b/src/nvim/testdir/test48.in
deleted file mode 100644
index 1df5a3c46a..0000000000
--- a/src/nvim/testdir/test48.in
+++ /dev/null
@@ -1,82 +0,0 @@
-This is a test of 'virtualedit'.
-
-STARTTEST
-:set noswf
-:set ve=all
-j-dgg
-:"
-:" Insert "keyword keyw", ESC, C CTRL-N, shows "keyword ykeyword".
-:" Repeating CTRL-N fixes it. (Mary Ellen Foster)
-2/w
-C
-:"
-:" Using "C" then then <CR> moves the last remaining character to the next
-:" line. (Mary Ellen Foster)
-j^/are
-C are belong to vim
-:"
-:" When past the end of a line that ends in a single character "b" skips
-:" that word.
-^$15lbC7
-:"
-:" Make sure 'i' works
-$4li<-- should be 3 ' '
-:"
-:" Make sure 'C' works
-$4lC<-- should be 3 ' '
-:"
-:" Make sure 'a' works
-$4la<-- should be 4 ' '
-:"
-:" Make sure 'A' works
-$4lA<-- should be 0 ' '
-:"
-:" Make sure 'D' works
-$4lDi<-- 'D' should be intact
-:"
-:" Test for yank bug reported by Mark Waggoner.
-:set ve=block
-^2w3jyGp
-:"
-:" Test "r" beyond the end of the line
-:set ve=all
-/^"r"
-$5lrxa<-- should be 'x'
-:"
-:" Test "r" on a tab
-:" Note that for this test, 'ts' must be 8 (the default).
-^5lrxA<-- should be ' x '
-:"
-:" Test to make sure 'x' can delete control characters
-:set display=uhex
-^xxxxxxi[This line should contain only the text between the brackets.]
-:set display=
-:"
-:" Test for ^Y/^E due to bad w_virtcol value, reported by
-:" Roy <royl@netropolis.net>.
-^O3li4li4li <-- should show the name of a noted text editor
-^o4li4li4li <-- and its version number-dd
-:"
-:" Test for yanking and pasting using the small delete register
-gg/^foo
-dewve"-p
-:wq! test.out
-ENDTEST
-foo, bar
-keyword keyw
-all your base are belong to us
-1 2 3 4 5 6
-'i'
-'C'
-'a'
-'A'
-'D'
-this is a test
-this is a test
-this is a test
-"r"
-"r"
-ab sd
-abcv6efi.him0kl
-
-
diff --git a/src/nvim/testdir/test48.ok b/src/nvim/testdir/test48.ok
deleted file mode 100644
index 14cd9b12ec..0000000000
--- a/src/nvim/testdir/test48.ok
+++ /dev/null
@@ -1,23 +0,0 @@
-, foo
-keyword keyword
-all your base
-are belong to vim
-1 2 3 4 5 7
-'i' <-- should be 3 ' '
-'C' <-- should be 3 ' '
-'a' <-- should be 4 ' '
-'A'<-- should be 0 ' '
-'D' <-- 'D' should be intact
-this is a test
-this is a test
-this is a test
-"r" x<-- should be 'x'
-"r" x <-- should be ' x '
-[This line should contain only the text between the brackets.]
- v i m <-- should show the name of a noted text editor
- 6 . 0 <-- and its version number
-
-a
-a
-a
-
diff --git a/src/nvim/testdir/test49.vim b/src/nvim/testdir/test49.vim
index 837e55ebca..c86fdf25ab 100644
--- a/src/nvim/testdir/test49.vim
+++ b/src/nvim/testdir/test49.vim
@@ -1,6 +1,6 @@
" Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
-" Last Change: 2019 May 24
+" Last Change: 2019 Oct 08
"-------------------------------------------------------------------------------
" Test environment {{{1
@@ -178,7 +178,7 @@ endif
" next Xpath value. No new Xnext value is prepared. The argument
" should be 2^(n-1) for the nth Xloop command inside the loop.
" If the loop has only one Xloop command, the argument can be
-" ommitted (default: 1).
+" omitted (default: 1).
"
" - Use XloopNEXT before ":continue" and ":endwhile". This computes a new
" Xnext value for the next execution of the loop by multiplying the old
@@ -456,7 +456,7 @@ function! ExtraVim(...)
" messing up the user's viminfo file.
let redirect = a:0 ?
\ " -c 'au VimLeave * redir END' -c 'redir\\! >" . a:1 . "'" : ""
- exec "!echo '" . debug_quits . "q' | $NVIM_PRG -u NONE -N -es" . redirect .
+ exec "!echo '" . debug_quits . "q' | " .. v:progpath .. " -u NONE -N -es" . redirect .
\ " -c 'debuggreedy|set viminfo+=nviminfo'" .
\ " -c 'let ExtraVimBegin = " . extra_begin . "'" .
\ " -c 'let ExtraVimResult = \"" . resultfile . "\"'" . breakpoints .
diff --git a/src/nvim/testdir/test64.in b/src/nvim/testdir/test64.in
deleted file mode 100644
index ec11e15e35..0000000000
--- a/src/nvim/testdir/test64.in
+++ /dev/null
@@ -1,654 +0,0 @@
-Test for regexp patterns without multi-byte support.
-See test95 for multi-byte tests.
-
-A pattern that gives the expected result produces OK, so that we know it was
-actually tried.
-
-STARTTEST
-:" tl is a List of Lists with:
-:" regexp engine
-:" regexp pattern
-:" text to test the pattern on
-:" expected match (optional)
-:" expected submatch 1 (optional)
-:" expected submatch 2 (optional)
-:" etc.
-:" When there is no match use only the first two items.
-:let tl = []
-:"
-:""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-:"""" Previously written tests """"""""""""""""""""""""""""""""
-:""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-:"
-:set noautoindent
-:call add(tl, [2, 'ab', 'aab', 'ab'])
-:call add(tl, [2, 'b', 'abcdef', 'b'])
-:call add(tl, [2, 'bc*', 'abccccdef', 'bcccc'])
-:call add(tl, [2, 'bc\{-}', 'abccccdef', 'b'])
-:call add(tl, [2, 'bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd'])
-:call add(tl, [2, 'bc*', 'abbdef', 'b'])
-:call add(tl, [2, 'c*', 'ccc', 'ccc'])
-:call add(tl, [2, 'bc*', 'abdef', 'b'])
-:call add(tl, [2, 'c*', 'abdef', ''])
-:call add(tl, [2, 'bc\+', 'abccccdef', 'bcccc'])
-:call add(tl, [2, 'bc\+', 'abdef']) "no match
-:"
-:"operator \|
-:call add(tl, [2, 'a\|ab', 'cabd', 'a']) "alternation is ordered
-:"
-:call add(tl, [2, 'c\?', 'ccb', 'c'])
-:call add(tl, [2, 'bc\?', 'abd', 'b'])
-:call add(tl, [2, 'bc\?', 'abccd', 'bc'])
-:"
-:call add(tl, [2, '\va{1}', 'ab', 'a'])
-:"
-:call add(tl, [2, '\va{2}', 'aa', 'aa'])
-:call add(tl, [2, '\va{2}', 'caad', 'aa'])
-:call add(tl, [2, '\va{2}', 'aba'])
-:call add(tl, [2, '\va{2}', 'ab'])
-:call add(tl, [2, '\va{2}', 'abaa', 'aa'])
-:call add(tl, [2, '\va{2}', 'aaa', 'aa'])
-:"
-:call add(tl, [2, '\vb{1}', 'abca', 'b'])
-:call add(tl, [2, '\vba{2}', 'abaa', 'baa'])
-:call add(tl, [2, '\vba{3}', 'aabaac'])
-:"
-:call add(tl, [2, '\v(ab){1}', 'ab', 'ab', 'ab'])
-:call add(tl, [2, '\v(ab){1}', 'dabc', 'ab', 'ab'])
-:call add(tl, [2, '\v(ab){1}', 'acb'])
-:"
-:call add(tl, [2, '\v(ab){0,2}', 'acb', "", ""])
-:call add(tl, [2, '\v(ab){0,2}', 'ab', 'ab', 'ab'])
-:call add(tl, [2, '\v(ab){1,2}', 'ab', 'ab', 'ab'])
-:call add(tl, [2, '\v(ab){1,2}', 'ababc', 'abab', 'ab'])
-:call add(tl, [2, '\v(ab){2,4}', 'ababcab', 'abab', 'ab'])
-:call add(tl, [2, '\v(ab){2,4}', 'abcababa', 'abab', 'ab'])
-:"
-:call add(tl, [2, '\v(ab){2}', 'abab', 'abab', 'ab'])
-:call add(tl, [2, '\v(ab){2}', 'cdababe', 'abab', 'ab'])
-:call add(tl, [2, '\v(ab){2}', 'abac'])
-:call add(tl, [2, '\v(ab){2}', 'abacabab', 'abab', 'ab'])
-:call add(tl, [2, '\v((ab){2}){2}', 'abababab', 'abababab', 'abab', 'ab'])
-:call add(tl, [2, '\v((ab){2}){2}', 'abacabababab', 'abababab', 'abab', 'ab'])
-:"
-:call add(tl, [2, '\v(a{1}){1}', 'a', 'a', 'a'])
-:call add(tl, [2, '\v(a{2}){1}', 'aa', 'aa', 'aa'])
-:call add(tl, [2, '\v(a{2}){1}', 'aaac', 'aa', 'aa'])
-:call add(tl, [2, '\v(a{2}){1}', 'daaac', 'aa', 'aa'])
-:call add(tl, [2, '\v(a{1}){2}', 'daaac', 'aa', 'a'])
-:call add(tl, [2, '\v(a{1}){2}', 'aaa', 'aa', 'a'])
-:call add(tl, [2, '\v(a{2})+', 'adaac', 'aa', 'aa'])
-:call add(tl, [2, '\v(a{2})+', 'aa', 'aa', 'aa'])
-:call add(tl, [2, '\v(a{2}){1}', 'aa', 'aa', 'aa'])
-:call add(tl, [2, '\v(a{1}){2}', 'aa', 'aa', 'a'])
-:call add(tl, [2, '\v(a{1}){1}', 'a', 'a', 'a'])
-:call add(tl, [2, '\v(a{2}){2}', 'aaaa', 'aaaa', 'aa'])
-:call add(tl, [2, '\v(a{2}){2}', 'aaabaaaa', 'aaaa', 'aa'])
-:"
-:call add(tl, [2, '\v(a+){2}', 'dadaac', 'aa', 'a'])
-:call add(tl, [2, '\v(a{3}){2}', 'aaaaaaa', 'aaaaaa', 'aaa'])
-:"
-:call add(tl, [2, '\v(a{1,2}){2}', 'daaac', 'aaa', 'a'])
-:call add(tl, [2, '\v(a{1,3}){2}', 'daaaac', 'aaaa', 'a'])
-:call add(tl, [2, '\v(a{1,3}){2}', 'daaaaac', 'aaaaa', 'aa'])
-:call add(tl, [2, '\v(a{1,3}){3}', 'daac'])
-:call add(tl, [2, '\v(a{1,2}){2}', 'dac'])
-:call add(tl, [2, '\v(a+)+', 'daac', 'aa', 'aa'])
-:call add(tl, [2, '\v(a+)+', 'aaa', 'aaa', 'aaa'])
-:call add(tl, [2, '\v(a+){1,2}', 'aaa', 'aaa', 'aaa'])
-:call add(tl, [2, '\v(a+)(a+)', 'aaa', 'aaa', 'aa', 'a'])
-:call add(tl, [2, '\v(a{3})+', 'daaaac', 'aaa', 'aaa'])
-:call add(tl, [2, '\v(a|b|c)+', 'aacb', 'aacb', 'b'])
-:call add(tl, [2, '\v(a|b|c){2}', 'abcb', 'ab', 'b'])
-:call add(tl, [2, '\v(abc){2}', 'abcabd', ])
-:call add(tl, [2, '\v(abc){2}', 'abdabcabc','abcabc', 'abc'])
-:"
-:call add(tl, [2, 'a*', 'cc', ''])
-:call add(tl, [2, '\v(a*)+', 'cc', ''])
-:call add(tl, [2, '\v((ab)+)+', 'ab', 'ab', 'ab', 'ab'])
-:call add(tl, [2, '\v(((ab)+)+)+', 'ab', 'ab', 'ab', 'ab', 'ab'])
-:call add(tl, [2, '\v(((ab)+)+)+', 'dababc', 'abab', 'abab', 'abab', 'ab'])
-:call add(tl, [2, '\v(a{0,2})+', 'cc', ''])
-:call add(tl, [2, '\v(a*)+', '', ''])
-:call add(tl, [2, '\v((a*)+)+', '', ''])
-:call add(tl, [2, '\v((ab)*)+', '', ''])
-:call add(tl, [2, '\va{1,3}', 'aab', 'aa'])
-:call add(tl, [2, '\va{2,3}', 'abaa', 'aa'])
-:"
-:call add(tl, [2, '\v((ab)+|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
-:call add(tl, [2, '\v(a{2})|(b{3})', 'bbabbbb', 'bbb', '', 'bbb'])
-:call add(tl, [2, '\va{2}|b{2}', 'abab'])
-:call add(tl, [2, '\v(a)+|(c)+', 'bbacbaacbbb', 'a', 'a'])
-:call add(tl, [2, '\vab{2,3}c', 'aabbccccccccccccc', 'abbc'])
-:call add(tl, [2, '\vab{2,3}c', 'aabbbccccccccccccc', 'abbbc'])
-:call add(tl, [2, '\vab{2,3}cd{2,3}e', 'aabbbcddee', 'abbbcdde'])
-:call add(tl, [2, '\va(bc){2}d', 'aabcbfbc' ])
-:call add(tl, [2, '\va*a{2}', 'a', ])
-:call add(tl, [2, '\va*a{2}', 'aa', 'aa' ])
-:call add(tl, [2, '\va*a{2}', 'aaa', 'aaa' ])
-:call add(tl, [2, '\va*a{2}', 'bbbabcc', ])
-:call add(tl, [2, '\va*b*|a*c*', 'a', 'a'])
-:call add(tl, [2, '\va{1}b{1}|a{1}b{1}', ''])
-:"
-:"submatches
-:call add(tl, [2, '\v(a)', 'ab', 'a', 'a'])
-:call add(tl, [2, '\v(a)(b)', 'ab', 'ab', 'a', 'b'])
-:call add(tl, [2, '\v(ab)(b)(c)', 'abbc', 'abbc', 'ab', 'b', 'c'])
-:call add(tl, [2, '\v((a)(b))', 'ab', 'ab', 'ab', 'a', 'b'])
-:call add(tl, [2, '\v(a)|(b)', 'ab', 'a', 'a'])
-:"
-:call add(tl, [2, '\v(a*)+', 'aaaa', 'aaaa', ''])
-:call add(tl, [2, 'x', 'abcdef'])
-:"
-:""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-:""""" Simple tests """""""""""""""""""""""""""""""""""""""""""
-:""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-:"
-:" Search single groups
-:call add(tl, [2, 'ab', 'aab', 'ab'])
-:call add(tl, [2, 'ab', 'baced'])
-:call add(tl, [2, 'ab', ' ab ', 'ab'])
-:"
-:" Search multi-modifiers
-:call add(tl, [2, 'x*', 'xcd', 'x'])
-:call add(tl, [2, 'x*', 'xxxxxxxxxxxxxxxxsofijiojgf', 'xxxxxxxxxxxxxxxx'])
-:" empty match is good
-:call add(tl, [2, 'x*', 'abcdoij', ''])
-:" no match here
-:call add(tl, [2, 'x\+', 'abcdoin'])
-:call add(tl, [2, 'x\+', 'abcdeoijdfxxiuhfij', 'xx'])
-:call add(tl, [2, 'x\+', 'xxxxx', 'xxxxx'])
-:call add(tl, [2, 'x\+', 'abc x siufhiush xxxxxxxxx', 'x'])
-:call add(tl, [2, 'x\=', 'x sdfoij', 'x'])
-:call add(tl, [2, 'x\=', 'abc sfoij', '']) " empty match is good
-:call add(tl, [2, 'x\=', 'xxxxxxxxx c', 'x'])
-:call add(tl, [2, 'x\?', 'x sdfoij', 'x'])
-:" empty match is good
-:call add(tl, [2, 'x\?', 'abc sfoij', ''])
-:call add(tl, [2, 'x\?', 'xxxxxxxxxx c', 'x'])
-:"
-:call add(tl, [2, 'a\{0,0}', 'abcdfdoij', ''])
-:" same thing as 'a?'
-:call add(tl, [2, 'a\{0,1}', 'asiubid axxxaaa', 'a'])
-:" same thing as 'a\{0,1}'
-:call add(tl, [2, 'a\{1,0}', 'asiubid axxxaaa', 'a'])
-:call add(tl, [2, 'a\{3,6}', 'aa siofuh'])
-:call add(tl, [2, 'a\{3,6}', 'aaaaa asfoij afaa', 'aaaaa'])
-:call add(tl, [2, 'a\{3,6}', 'aaaaaaaa', 'aaaaaa'])
-:call add(tl, [2, 'a\{0}', 'asoiuj', ''])
-:call add(tl, [2, 'a\{2}', 'aaaa', 'aa'])
-:call add(tl, [2, 'a\{2}', 'iuash fiusahfliusah fiushfilushfi uhsaifuh askfj nasfvius afg aaaa sfiuhuhiushf', 'aa'])
-:call add(tl, [2, 'a\{2}', 'abcdefghijklmnopqrestuvwxyz1234567890'])
-:" same thing as 'a*'
-:call add(tl, [2, 'a\{0,}', 'oij sdigfusnf', ''])
-:call add(tl, [2, 'a\{0,}', 'aaaaa aa', 'aaaaa'])
-:call add(tl, [2, 'a\{2,}', 'sdfiougjdsafg'])
-:call add(tl, [2, 'a\{2,}', 'aaaaasfoij ', 'aaaaa'])
-:call add(tl, [2, 'a\{5,}', 'xxaaaaxxx '])
-:call add(tl, [2, 'a\{5,}', 'xxaaaaaxxx ', 'aaaaa'])
-:call add(tl, [2, 'a\{,0}', 'oidfguih iuhi hiu aaaa', ''])
-:call add(tl, [2, 'a\{,5}', 'abcd', 'a'])
-:call add(tl, [2, 'a\{,5}', 'aaaaaaaaaa', 'aaaaa'])
-:" leading star as normal char when \{} follows
-:call add(tl, [2, '^*\{4,}$', '***'])
-:call add(tl, [2, '^*\{4,}$', '****', '****'])
-:call add(tl, [2, '^*\{4,}$', '*****', '*****'])
-:" same thing as 'a*'
-:call add(tl, [2, 'a\{}', 'bbbcddiuhfcd', ''])
-:call add(tl, [2, 'a\{}', 'aaaaioudfh coisf jda', 'aaaa'])
-:"
-:call add(tl, [2, 'a\{-0,0}', 'abcdfdoij', ''])
-:" anti-greedy version of 'a?'
-:call add(tl, [2, 'a\{-0,1}', 'asiubid axxxaaa', ''])
-:call add(tl, [2, 'a\{-3,6}', 'aa siofuh'])
-:call add(tl, [2, 'a\{-3,6}', 'aaaaa asfoij afaa', 'aaa'])
-:call add(tl, [2, 'a\{-3,6}', 'aaaaaaaa', 'aaa'])
-:call add(tl, [2, 'a\{-0}', 'asoiuj', ''])
-:call add(tl, [2, 'a\{-2}', 'aaaa', 'aa'])
-:call add(tl, [2, 'a\{-2}', 'abcdefghijklmnopqrestuvwxyz1234567890'])
-:call add(tl, [2, 'a\{-0,}', 'oij sdigfusnf', ''])
-:call add(tl, [2, 'a\{-0,}', 'aaaaa aa', ''])
-:call add(tl, [2, 'a\{-2,}', 'sdfiougjdsafg'])
-:call add(tl, [2, 'a\{-2,}', 'aaaaasfoij ', 'aa'])
-:call add(tl, [2, 'a\{-,0}', 'oidfguih iuhi hiu aaaa', ''])
-:call add(tl, [2, 'a\{-,5}', 'abcd', ''])
-:call add(tl, [2, 'a\{-,5}', 'aaaaaaaaaa', ''])
-:" anti-greedy version of 'a*'
-:call add(tl, [2, 'a\{-}', 'bbbcddiuhfcd', ''])
-:call add(tl, [2, 'a\{-}', 'aaaaioudfh coisf jda', ''])
-:"
-:" Test groups of characters and submatches
-:call add(tl, [2, '\(abc\)*', 'abcabcabc', 'abcabcabc', 'abc'])
-:call add(tl, [2, '\(ab\)\+', 'abababaaaaa', 'ababab', 'ab'])
-:call add(tl, [2, '\(abaaaaa\)*cd', 'cd', 'cd', ''])
-:call add(tl, [2, '\(test1\)\? \(test2\)\?', 'test1 test3', 'test1 ', 'test1', ''])
-:call add(tl, [2, '\(test1\)\= \(test2\) \(test4443\)\=', ' test2 test4443 yupiiiiiiiiiii', ' test2 test4443', '', 'test2', 'test4443'])
-:call add(tl, [2, '\(\(sub1\) hello \(sub 2\)\)', 'asterix sub1 hello sub 2 obelix', 'sub1 hello sub 2', 'sub1 hello sub 2', 'sub1', 'sub 2'])
-:call add(tl, [2, '\(\(\(yyxxzz\)\)\)', 'abcdddsfiusfyyzzxxyyxxzz', 'yyxxzz', 'yyxxzz', 'yyxxzz', 'yyxxzz'])
-:call add(tl, [2, '\v((ab)+|c+)+', 'abcccaba', 'abcccab', 'ab', 'ab'])
-:call add(tl, [2, '\v((ab)|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
-:call add(tl, [2, '\v(a(c*)+b)+', 'acbababaaa', 'acbabab', 'ab', ''])
-:call add(tl, [2, '\v(a|b*)+', 'aaaa', 'aaaa', ''])
-:call add(tl, [2, '\p*', 'aá ', 'aá '])
-:"
-:" Test greedy-ness and lazy-ness
-:call add(tl, [2, 'a\{-2,7}','aaaaaaaaaaaaa', 'aa'])
-:call add(tl, [2, 'a\{-2,7}x','aaaaaaaaax', 'aaaaaaax'])
-:call add(tl, [2, 'a\{2,7}','aaaaaaaaaaaaaaaaaaaa', 'aaaaaaa'])
-:call add(tl, [2, 'a\{2,7}x','aaaaaaaaax', 'aaaaaaax'])
-:call add(tl, [2, '\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
-:call add(tl, [2, '\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
-:call add(tl, [2, '\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
-:call add(tl, [2, '\v(a{-1,3})+', 'aa', 'aa', 'a'])
-:call add(tl, [2, '^\s\{-}\zs\( x\|x$\)', ' x', ' x', ' x'])
-:call add(tl, [2, '^\s\{-}\zs\(x\| x$\)', ' x', ' x', ' x'])
-:call add(tl, [2, '^\s\{-}\ze\(x\| x$\)', ' x', '', ' x'])
-:call add(tl, [2, '^\(\s\{-}\)\(x\| x$\)', ' x', ' x', '', ' x'])
-:"
-:" Test Character classes
-:call add(tl, [2, '\d\+e\d\d','test 10e23 fd','10e23'])
-:"
-:" Test collections and character range []
-:call add(tl, [2, '\v[a]', 'abcd', 'a'])
-:call add(tl, [2, 'a[bcd]', 'abcd', 'ab'])
-:call add(tl, [2, 'a[b-d]', 'acbd', 'ac'])
-:call add(tl, [2, '[a-d][e-f][x-x]d', 'cexdxx', 'cexd'])
-:call add(tl, [2, '\v[[:alpha:]]+', 'abcdefghijklmnopqrstuvwxyz6','abcdefghijklmnopqrstuvwxyz'])
-:call add(tl, [2, '[[:alpha:]\+]', '6x8','x'])
-:call add(tl, [2, '[^abc]\+','abcabcabc'])
-:call add(tl, [2, '[^abc]','defghiasijvoinasoiunbvb','d'])
-:call add(tl, [2, '[^abc]\+','ddddddda','ddddddd'])
-:call add(tl, [2, '[^a-d]\+','aaaAAAZIHFNCddd','AAAZIHFNC'])
-:call add(tl, [2, '[a-f]*','iiiiiiii',''])
-:call add(tl, [2, '[a-f]*','abcdefgh','abcdef'])
-:call add(tl, [2, '[^a-f]\+','abcdefgh','gh'])
-:call add(tl, [2, '[a-c]\{-3,6}','abcabc','abc'])
-:call add(tl, [2, '[^[:alpha:]]\+','abcccadfoij7787ysf287yrnccdu','7787'])
-:call add(tl, [2, '[-a]', '-', '-'])
-:call add(tl, [2, '[a-]', '-', '-'])
-:call add(tl, [2, '[a-f]*\c','ABCDEFGH','ABCDEF'])
-:call add(tl, [2, '[abc][xyz]\c','-af-AF-BY--','BY'])
-:" filename regexp
-:call add(tl, [2, '[-./[:alnum:]_~]\+', 'log13.file', 'log13.file'])
-:" special chars
-:call add(tl, [2, '[\]\^\-\\]\+', '\^\\\-\---^', '\^\\\-\---^'])
-:" collation elem
-:call add(tl, [2, '[[.a.]]\+', 'aa', 'aa'])
-:" middle of regexp
-:call add(tl, [2, 'abc[0-9]*ddd', 'siuhabc ii'])
-:call add(tl, [2, 'abc[0-9]*ddd', 'adf abc44482ddd oijs', 'abc44482ddd'])
-:call add(tl, [2, '\_[0-9]\+', 'asfi9888u', '9888'])
-:call add(tl, [2, '[0-9\n]\+', 'asfi9888u', '9888'])
-:call add(tl, [2, '\_[0-9]\+', "asfi\n9888u", "\n9888"])
-:call add(tl, [2, '\_f', " \na ", "\n"])
-:call add(tl, [2, '\_f\+', " \na ", "\na"])
-:call add(tl, [2, '[0-9A-Za-z-_.]\+', " @0_a.A-{ ", "0_a.A-"])
-:"
-:"""" Test start/end of line, start/end of file
-:call add(tl, [2, '^a.', "a_\nb ", "a_"])
-:call add(tl, [2, '^a.', "b a \na_"])
-:call add(tl, [2, '.a$', " a\n "])
-:call add(tl, [2, '.a$', " a b\n_a", "_a"])
-:call add(tl, [2, '\%^a.', "a a\na", "a "])
-:call add(tl, [2, '\%^a', " a \na "])
-:call add(tl, [2, '.a\%$', " a\n "])
-:call add(tl, [2, '.a\%$', " a\n_a", "_a"])
-:"
-:"""" Test recognition of character classes
-:call add(tl, [2, '[0-7]\+', 'x0123456789x', '01234567'])
-:call add(tl, [2, '[^0-7]\+', '0a;X+% 897', 'a;X+% 89'])
-:call add(tl, [2, '[0-9]\+', 'x0123456789x', '0123456789'])
-:call add(tl, [2, '[^0-9]\+', '0a;X+% 9', 'a;X+% '])
-:call add(tl, [2, '[0-9a-fA-F]\+', 'x0189abcdefg', '0189abcdef'])
-:call add(tl, [2, '[^0-9A-Fa-f]\+', '0189g;X+% ab', 'g;X+% '])
-:call add(tl, [2, '[a-z_A-Z0-9]\+', ';+aso_SfOij ', 'aso_SfOij'])
-:call add(tl, [2, '[^a-z_A-Z0-9]\+', 'aSo_;+% sfOij', ';+% '])
-:call add(tl, [2, '[a-z_A-Z]\+', '0abyz_ABYZ;', 'abyz_ABYZ'])
-:call add(tl, [2, '[^a-z_A-Z]\+', 'abAB_09;+% yzYZ', '09;+% '])
-:call add(tl, [2, '[a-z]\+', '0abcxyz1', 'abcxyz'])
-:call add(tl, [2, '[a-z]\+', 'AabxyzZ', 'abxyz'])
-:call add(tl, [2, '[^a-z]\+', 'a;X09+% x', ';X09+% '])
-:call add(tl, [2, '[^a-z]\+', 'abX0;%yz', 'X0;%'])
-:call add(tl, [2, '[a-zA-Z]\+', '0abABxzXZ9', 'abABxzXZ'])
-:call add(tl, [2, '[^a-zA-Z]\+', 'ab09_;+ XZ', '09_;+ '])
-:call add(tl, [2, '[A-Z]\+', 'aABXYZz', 'ABXYZ'])
-:call add(tl, [2, '[^A-Z]\+', 'ABx0;%YZ', 'x0;%'])
-:call add(tl, [2, '[a-z]\+\c', '0abxyzABXYZ;', 'abxyzABXYZ'])
-:call add(tl, [2, '[A-Z]\+\c', '0abABxzXZ9', 'abABxzXZ'])
-:call add(tl, [2, '\c[^a-z]\+', 'ab09_;+ XZ', '09_;+ '])
-:call add(tl, [2, '\c[^A-Z]\+', 'ab09_;+ XZ', '09_;+ '])
-:call add(tl, [2, '\C[^A-Z]\+', 'ABCOIJDEOIFNSD jsfoij sa', ' jsfoij sa'])
-:"
-:"""" Tests for \z features
-:" match ends at \ze
-:call add(tl, [2, 'xx \ze test', 'xx '])
-:call add(tl, [2, 'abc\zeend', 'oij abcend', 'abc'])
-:call add(tl, [2, 'aa\zebb\|aaxx', ' aabb ', 'aa'])
-:call add(tl, [2, 'aa\zebb\|aaxx', ' aaxx ', 'aaxx'])
-:call add(tl, [2, 'aabb\|aa\zebb', ' aabb ', 'aabb'])
-:call add(tl, [2, 'aa\zebb\|aaebb', ' aabb ', 'aa'])
-:" match starts at \zs
-:call add(tl, [2, 'abc\zsdd', 'ddabcddxyzt', 'dd'])
-:call add(tl, [2, 'aa \zsax', ' ax'])
-:call add(tl, [2, 'abc \zsmatch\ze abc', 'abc abc abc match abc abc', 'match'])
-:call add(tl, [2, '\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last'])
-:call add(tl, [2, '\>\zs.', 'aword. ', '.'])
-:call add(tl, [2, '\s\+\ze\[/\|\s\zs\s\+', 'is [a t', ' '])
-:"
-:"""" Tests for \@= and \& features
-:call add(tl, [2, 'abc\@=', 'abc', 'ab'])
-:call add(tl, [2, 'abc\@=cd', 'abcd', 'abcd'])
-:call add(tl, [2, 'abc\@=', 'ababc', 'ab'])
-:" will never match, no matter the input text
-:call add(tl, [2, 'abcd\@=e', 'abcd'])
-:" will never match
-:call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
-:call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
-:call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
-:call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
-:call add(tl, [2, '\<\S\+\())\)\@=', '$((i=i+1))', 'i=i+1', '))'])
-:call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
-:call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
-:call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
-:call add(tl, [2, 'foo\(bar\)\@!', 'foobar'])
-:call add(tl, [2, 'foo\(bar\)\@!', 'foo bar', 'foo'])
-:call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if then else'])
-:call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if else ', 'if else ', ' '])
-:call add(tl, [2, '\(foo\)\@!bar', 'foobar', 'bar'])
-:call add(tl, [2, '\(foo\)\@!...bar', 'foobar'])
-:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' bar foo '])
-:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo bar '])
-:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo xxx ', 'foo'])
-:call add(tl, [2, '[ ]\@!\p\%([ ]\@!\p\)*:', 'implicit mappings:', 'mappings:'])
-:call add(tl, [2, '[ ]\@!\p\([ ]\@!\p\)*:', 'implicit mappings:', 'mappings:', 's'])
-:call add(tl, [2, 'm\k\+_\@=\%(_\@!\k\)\@<=\k\+e', 'mx__xe', 'mx__xe'])
-:call add(tl, [2, '\%(\U\@<=S\k*\|S\l\)R', 'SuR', 'SuR'])
-:"
-:"""" Combining different tests and features
-:call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
-:call add(tl, [2, '', 'abcd', ''])
-:call add(tl, [2, '\v(())', 'any possible text', ''])
-:call add(tl, [2, '\v%(ab(xyz)c)', ' abxyzc ', 'abxyzc', 'xyz'])
-:call add(tl, [2, '\v(test|)empty', 'tesempty', 'empty', ''])
-:call add(tl, [2, '\v(a|aa)(a|aa)', 'aaa', 'aa', 'a', 'a'])
-:"
-:"""" \%u and friends
-:call add(tl, [2, '\%d32', 'yes no', ' '])
-:call add(tl, [2, '\%o40', 'yes no', ' '])
-:call add(tl, [2, '\%x20', 'yes no', ' '])
-:call add(tl, [2, '\%u0020', 'yes no', ' '])
-:call add(tl, [2, '\%U00000020', 'yes no', ' '])
-:call add(tl, [2, '\%d0', "yes\x0ano", "\x0a"])
-:"
-:""""" \%[abc]
-:call add(tl, [2, 'foo\%[bar]', 'fobar'])
-:call add(tl, [2, 'foo\%[bar]', 'foobar', 'foobar'])
-:call add(tl, [2, 'foo\%[bar]', 'fooxx', 'foo'])
-:call add(tl, [2, 'foo\%[bar]', 'foobxx', 'foob'])
-:call add(tl, [2, 'foo\%[bar]', 'foobaxx', 'fooba'])
-:call add(tl, [2, 'foo\%[bar]', 'foobarxx', 'foobar'])
-:call add(tl, [2, 'foo\%[bar]x', 'foobxx', 'foobx'])
-:call add(tl, [2, 'foo\%[bar]x', 'foobarxx', 'foobarx'])
-:call add(tl, [2, '\%[bar]x', 'barxx', 'barx'])
-:call add(tl, [2, '\%[bar]x', 'bxx', 'bx'])
-:call add(tl, [2, '\%[bar]x', 'xxx', 'x'])
-:call add(tl, [2, 'b\%[[ao]r]', 'bar bor', 'bar'])
-:call add(tl, [2, 'b\%[[]]r]', 'b]r bor', 'b]r'])
-:call add(tl, [2, '@\%[\w\-]*', '<http://john.net/pandoc/>[@pandoc]', '@pandoc'])
-:"
-:"""" Alternatives, must use first longest match
-:call add(tl, [2, 'goo\|go', 'google', 'goo'])
-:call add(tl, [2, '\<goo\|\<go', 'google', 'goo'])
-:call add(tl, [2, '\<goo\|go', 'google', 'goo'])
-:"
-:"""" Back references
-:call add(tl, [2, '\(\i\+\) \1', ' abc abc', 'abc abc', 'abc'])
-:call add(tl, [2, '\(\i\+\) \1', 'xgoo goox', 'goo goo', 'goo'])
-:call add(tl, [2, '\(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9', 'xabcddefghiabcddefghix', 'abcddefghiabcddefghi', 'a', 'b', 'c', 'dd', 'e', 'f', 'g', 'h', 'i'])
-:call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', ''])
-:call add(tl, [2, '^.\(.\).\_..\1.', "aaa\naaa\nb", "aaa\naaa", 'a'])
-:call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<!$', 'foo.bat/foo.com', 'foo.bat/foo.com', 'bat'])
-:call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<!$', 'foo.bat/foo.bat'])
-:call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<=$', 'foo.bat/foo.bat', 'foo.bat/foo.bat', 'bat', 'bat'])
-:call add(tl, [2, '\\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}', '2013-06-27${0}', '${0}', '0'])
-:call add(tl, [2, '^\(a*\)\1$', 'aaaaaaaa', 'aaaaaaaa', 'aaaa'])
-:call add(tl, [2, '^\(a\{-2,}\)\1\+$', 'aaaaaaaaa', 'aaaaaaaaa', 'aaa'])
-:"
-:"""" Look-behind with limit
-:call add(tl, [2, '<\@<=span.', 'xxspanxx<spanyyy', 'spany'])
-:call add(tl, [2, '<\@1<=span.', 'xxspanxx<spanyyy', 'spany'])
-:call add(tl, [2, '<\@2<=span.', 'xxspanxx<spanyyy', 'spany'])
-:call add(tl, [2, '\(<<\)\@<=span.', 'xxspanxxxx<spanxx<<spanyyy', 'spany', '<<'])
-:call add(tl, [2, '\(<<\)\@1<=span.', 'xxspanxxxx<spanxx<<spanyyy'])
-:call add(tl, [2, '\(<<\)\@2<=span.', 'xxspanxxxx<spanxx<<spanyyy', 'spany', '<<'])
-:call add(tl, [2, '\(foo\)\@<!bar.', 'xx foobar1 xbar2 xx', 'bar2'])
-:"
-:" look-behind match in front of a zero-width item
-:call add(tl, [2, '\v\C%(<Last Changed:\s+)@<=.*$', '" test header'])
-:call add(tl, [2, '\v\C%(<Last Changed:\s+)@<=.*$', '" Last Changed: 1970', '1970'])
-:call add(tl, [2, '\(foo\)\@<=\>', 'foobar'])
-:call add(tl, [2, '\(foo\)\@<=\>', 'barfoo', '', 'foo'])
-:call add(tl, [2, '\(foo\)\@<=.*', 'foobar', 'bar', 'foo'])
-:"
-:" complicated look-behind match
-:call add(tl, [2, '\(r\@<=\|\w\@<!\)\/', 'x = /word/;', '/'])
-:call add(tl, [2, '^[a-z]\+\ze \&\(asdf\)\@<!', 'foo bar', 'foo'])
-:"
-:""""" \@>
-:call add(tl, [2, '\(a*\)\@>a', 'aaaa'])
-:call add(tl, [2, '\(a*\)\@>b', 'aaab', 'aaab', 'aaa'])
-:call add(tl, [2, '^\(.\{-}b\)\@>.', ' abcbd', ' abc', ' ab'])
-:call add(tl, [2, '\(.\{-}\)\(\)\@>$', 'abc', 'abc', 'abc', ''])
-:" TODO: BT engine does not restore submatch after failure
-:call add(tl, [1, '\(a*\)\@>a\|a\+', 'aaaa', 'aaaa'])
-:"
-:"""" "\_" prepended negated collection matches EOL
-:call add(tl, [2, '\_[^8-9]\+', "asfi\n9888", "asfi\n"])
-:call add(tl, [2, '\_[^a]\+', "asfi\n9888", "sfi\n9888"])
-:"
-:"""" Requiring lots of states.
-:call add(tl, [2, '[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}', " 12345678-1234-1234-1234-123456789012 ", "12345678-1234-1234-1234-123456789012", "1234-"])
-:"
-:"""" Skip adding state twice
-:call add(tl, [2, '^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=', "#if FOO", "#if", ' FOO'])
-:"
-:""" Test \%V atom
-:call add(tl, [2, '\%>70vGesamt', 'Jean-Michel Charlier & Victor Hubinon\Gesamtausgabe [Salleck] Buck Danny {Jean-Michel Charlier & Victor Hubinon}\Gesamtausgabe', 'Gesamt'])
-:"
-:"""" Run the tests
-:"
-:for t in tl
-: let re = t[0]
-: let pat = t[1]
-: let text = t[2]
-: let matchidx = 3
-: for engine in [0, 1, 2]
-: if engine == 2 && re == 0 || engine == 1 && re == 1
-: continue
-: endif
-: let &regexpengine = engine
-: try
-: let l = matchlist(text, pat)
-: catch
-: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"'
-: endtry
-:" check the match itself
-: if len(l) == 0 && len(t) > matchidx
-: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"'
-: elseif len(l) > 0 && len(t) == matchidx
-: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match'
-: elseif len(t) > matchidx && l[0] != t[matchidx]
-: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"'
-: else
-: $put ='OK ' . engine . ' - ' . pat
-: endif
-: if len(l) > 0
-:" check all the nine submatches
-: for i in range(1, 9)
-: if len(t) <= matchidx + i
-: let e = ''
-: else
-: let e = t[matchidx + i]
-: endif
-: if l[i] != e
-: $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
-: endif
-: endfor
-: unlet i
-: endif
-: endfor
-:endfor
-:unlet t tl e l
-:"
-:"""""" multi-line tests """"""""""""""""""""
-:let tl = []
-:"
-:"""" back references
-:call add(tl, [2, '^.\(.\).\_..\1.', ['aaa', 'aaa', 'b'], ['XX', 'b']])
-:call add(tl, [2, '\v.*\/(.*)\n.*\/\1$', ['./Dir1/Dir2/zyxwvuts.txt', './Dir1/Dir2/abcdefgh.bat', '', './Dir1/Dir2/file1.txt', './OtherDir1/OtherDir2/file1.txt'], ['./Dir1/Dir2/zyxwvuts.txt', './Dir1/Dir2/abcdefgh.bat', '', 'XX']])
-:"
-:"""" line breaks
-:call add(tl, [2, '\S.*\nx', ['abc', 'def', 'ghi', 'xjk', 'lmn'], ['abc', 'def', 'XXjk', 'lmn']])
-:"
-:" Check that \_[0-9] matching EOL does not break a following \>
-:call add(tl, [2, '\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>', ['', 'localnet/192.168.0.1', ''], ['', 'localnet/XX', '']])
-:"
-:" Check a pattern with a line break and ^ and $
-:call add(tl, [2, 'a\n^b$\n^c', ['a', 'b', 'c'], ['XX']])
-:"
-:call add(tl, [2, '\(^.\+\n\)\1', [' dog', ' dog', 'asdf'], ['XXasdf']])
-:"
-:"""" Run the multi-line tests
-:"
-:$put ='multi-line tests'
-:for t in tl
-: let re = t[0]
-: let pat = t[1]
-: let before = t[2]
-: let after = t[3]
-: for engine in [0, 1, 2]
-: if engine == 2 && re == 0 || engine == 1 && re ==1
-: continue
-: endif
-: let &regexpengine = engine
-: new
-: call setline(1, before)
-: exe '%s/' . pat . '/XX/'
-: let result = getline(1, '$')
-: q!
-: if result != after
-: $put ='ERROR: pat: \"' . pat . '\", text: \"' . string(before) . '\", expected: \"' . string(after) . '\", got: \"' . string(result) . '\"'
-: else
-: $put ='OK ' . engine . ' - ' . pat
-: endif
-: endfor
-:endfor
-:unlet t tl
-:"
-:" Check that using a pattern on two lines doesn't get messed up by using
-:" matchstr() with \ze in between.
-:set re=0
-/^Substitute here
-:.+1,.+2s/""/\='"'.matchstr(getline("."), '\d\+\ze<').'"'
-/^Substitute here
-:.+1,.+2yank
-Gop:"
-:"
-:" Check a pattern with a look beind crossing a line boundary
-/^Behind:
-/\(<\_[xy]\+\)\@3<=start
-:.yank
-Gop:"
-:"
-:" Check matching Visual area
-/^Visual:
-jfxvfx:s/\%Ve/E/g
-jV:s/\%Va/A/g
-jfxfxj:s/\%Vo/O/g
-:/^Visual/+1,/^Visual/+4yank
-Gop:"
-:"
-:" Check matching marks
-/^Marks:
-jfSmsfEme:.-4,.+6s/.\%>'s.*\%<'e../here/
-jfSmsj0fEme:.-4,.+6s/.\%>'s\_.*\%<'e../again/
-:/^Marks:/+1,/^Marks:/+3yank
-Gop:"
-:"
-:" Check patterns matching cursor position.
-:func! Postest()
- new
- call setline(1, ['ffooooo', 'boboooo', 'zoooooo', 'koooooo', 'moooooo', "\t\t\tfoo", 'abababababababfoo', 'bababababababafoo', '********_', ' xxxxxxxxxxxx xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx'])
- call setpos('.', [0, 1, 0, 0])
- s/\%>3c.//g
- call setpos('.', [0, 2, 4, 0])
- s/\%#.*$//g
- call setpos('.', [0, 3, 0, 0])
- s/\%<3c./_/g
- %s/\%4l\%>5c./_/g
- %s/\%6l\%>25v./_/g
- %s/\%>6l\%3c./!/g
- %s/\%>7l\%12c./?/g
- %s/\%>7l\%<9l\%>5v\%<8v./#/g
- $s/\%(|\u.*\)\@<=[^|\t]\+$//ge
- 1,$yank
- quit!
-endfunc
-Go-0-:set re=0
-:call Postest()
-:put
-o-1-:set re=1
-:call Postest()
-:put
-o-2-:set re=2
-:call Postest()
-:put
-:"
-:" start and end of buffer
-/\%^
-yeGop:"
-50%/\%^..
-yeGopA END:"
-50%/\%$
-"ayb20gg/..\%$
-"bybGo"apo"bp:"
-:"
-:" Check for detecting error
-:set regexpengine=2
-:for pat in [' \ze*', ' \zs*']
-: try
-: let l = matchlist('x x', pat)
-: $put ='E888 NOT detected for ' . pat
-: catch
-: $put ='E888 detected for ' . pat
-: endtry
-:endfor
-:"
-:""""" Write the results """""""""""""
-:/\%#=1^Results/,$wq! test.out
-ENDTEST
-
-Substitute here:
-<T="">Ta 5</Title>
-<T="">Ac 7</Title>
-
-Behind:
-asdfasd<yyy
-xxstart1
-asdfasd<yy
-xxxstart2
-asdfasd<yy
-xxstart3
-
-Visual:
-thexe the thexethe
-andaxand andaxand
-oooxofor foroxooo
-oooxofor foroxooo
-
-Marks:
-asdfSasdfsadfEasdf
-asdfSas
-dfsadfEasdf
-
-Results of test64:
diff --git a/src/nvim/testdir/test64.ok b/src/nvim/testdir/test64.ok
deleted file mode 100644
index c218f8ea17..0000000000
--- a/src/nvim/testdir/test64.ok
+++ /dev/null
@@ -1,1107 +0,0 @@
-Results of test64:
-OK 0 - ab
-OK 1 - ab
-OK 2 - ab
-OK 0 - b
-OK 1 - b
-OK 2 - b
-OK 0 - bc*
-OK 1 - bc*
-OK 2 - bc*
-OK 0 - bc\{-}
-OK 1 - bc\{-}
-OK 2 - bc\{-}
-OK 0 - bc\{-}\(d\)
-OK 1 - bc\{-}\(d\)
-OK 2 - bc\{-}\(d\)
-OK 0 - bc*
-OK 1 - bc*
-OK 2 - bc*
-OK 0 - c*
-OK 1 - c*
-OK 2 - c*
-OK 0 - bc*
-OK 1 - bc*
-OK 2 - bc*
-OK 0 - c*
-OK 1 - c*
-OK 2 - c*
-OK 0 - bc\+
-OK 1 - bc\+
-OK 2 - bc\+
-OK 0 - bc\+
-OK 1 - bc\+
-OK 2 - bc\+
-OK 0 - a\|ab
-OK 1 - a\|ab
-OK 2 - a\|ab
-OK 0 - c\?
-OK 1 - c\?
-OK 2 - c\?
-OK 0 - bc\?
-OK 1 - bc\?
-OK 2 - bc\?
-OK 0 - bc\?
-OK 1 - bc\?
-OK 2 - bc\?
-OK 0 - \va{1}
-OK 1 - \va{1}
-OK 2 - \va{1}
-OK 0 - \va{2}
-OK 1 - \va{2}
-OK 2 - \va{2}
-OK 0 - \va{2}
-OK 1 - \va{2}
-OK 2 - \va{2}
-OK 0 - \va{2}
-OK 1 - \va{2}
-OK 2 - \va{2}
-OK 0 - \va{2}
-OK 1 - \va{2}
-OK 2 - \va{2}
-OK 0 - \va{2}
-OK 1 - \va{2}
-OK 2 - \va{2}
-OK 0 - \va{2}
-OK 1 - \va{2}
-OK 2 - \va{2}
-OK 0 - \vb{1}
-OK 1 - \vb{1}
-OK 2 - \vb{1}
-OK 0 - \vba{2}
-OK 1 - \vba{2}
-OK 2 - \vba{2}
-OK 0 - \vba{3}
-OK 1 - \vba{3}
-OK 2 - \vba{3}
-OK 0 - \v(ab){1}
-OK 1 - \v(ab){1}
-OK 2 - \v(ab){1}
-OK 0 - \v(ab){1}
-OK 1 - \v(ab){1}
-OK 2 - \v(ab){1}
-OK 0 - \v(ab){1}
-OK 1 - \v(ab){1}
-OK 2 - \v(ab){1}
-OK 0 - \v(ab){0,2}
-OK 1 - \v(ab){0,2}
-OK 2 - \v(ab){0,2}
-OK 0 - \v(ab){0,2}
-OK 1 - \v(ab){0,2}
-OK 2 - \v(ab){0,2}
-OK 0 - \v(ab){1,2}
-OK 1 - \v(ab){1,2}
-OK 2 - \v(ab){1,2}
-OK 0 - \v(ab){1,2}
-OK 1 - \v(ab){1,2}
-OK 2 - \v(ab){1,2}
-OK 0 - \v(ab){2,4}
-OK 1 - \v(ab){2,4}
-OK 2 - \v(ab){2,4}
-OK 0 - \v(ab){2,4}
-OK 1 - \v(ab){2,4}
-OK 2 - \v(ab){2,4}
-OK 0 - \v(ab){2}
-OK 1 - \v(ab){2}
-OK 2 - \v(ab){2}
-OK 0 - \v(ab){2}
-OK 1 - \v(ab){2}
-OK 2 - \v(ab){2}
-OK 0 - \v(ab){2}
-OK 1 - \v(ab){2}
-OK 2 - \v(ab){2}
-OK 0 - \v(ab){2}
-OK 1 - \v(ab){2}
-OK 2 - \v(ab){2}
-OK 0 - \v((ab){2}){2}
-OK 1 - \v((ab){2}){2}
-OK 2 - \v((ab){2}){2}
-OK 0 - \v((ab){2}){2}
-OK 1 - \v((ab){2}){2}
-OK 2 - \v((ab){2}){2}
-OK 0 - \v(a{1}){1}
-OK 1 - \v(a{1}){1}
-OK 2 - \v(a{1}){1}
-OK 0 - \v(a{2}){1}
-OK 1 - \v(a{2}){1}
-OK 2 - \v(a{2}){1}
-OK 0 - \v(a{2}){1}
-OK 1 - \v(a{2}){1}
-OK 2 - \v(a{2}){1}
-OK 0 - \v(a{2}){1}
-OK 1 - \v(a{2}){1}
-OK 2 - \v(a{2}){1}
-OK 0 - \v(a{1}){2}
-OK 1 - \v(a{1}){2}
-OK 2 - \v(a{1}){2}
-OK 0 - \v(a{1}){2}
-OK 1 - \v(a{1}){2}
-OK 2 - \v(a{1}){2}
-OK 0 - \v(a{2})+
-OK 1 - \v(a{2})+
-OK 2 - \v(a{2})+
-OK 0 - \v(a{2})+
-OK 1 - \v(a{2})+
-OK 2 - \v(a{2})+
-OK 0 - \v(a{2}){1}
-OK 1 - \v(a{2}){1}
-OK 2 - \v(a{2}){1}
-OK 0 - \v(a{1}){2}
-OK 1 - \v(a{1}){2}
-OK 2 - \v(a{1}){2}
-OK 0 - \v(a{1}){1}
-OK 1 - \v(a{1}){1}
-OK 2 - \v(a{1}){1}
-OK 0 - \v(a{2}){2}
-OK 1 - \v(a{2}){2}
-OK 2 - \v(a{2}){2}
-OK 0 - \v(a{2}){2}
-OK 1 - \v(a{2}){2}
-OK 2 - \v(a{2}){2}
-OK 0 - \v(a+){2}
-OK 1 - \v(a+){2}
-OK 2 - \v(a+){2}
-OK 0 - \v(a{3}){2}
-OK 1 - \v(a{3}){2}
-OK 2 - \v(a{3}){2}
-OK 0 - \v(a{1,2}){2}
-OK 1 - \v(a{1,2}){2}
-OK 2 - \v(a{1,2}){2}
-OK 0 - \v(a{1,3}){2}
-OK 1 - \v(a{1,3}){2}
-OK 2 - \v(a{1,3}){2}
-OK 0 - \v(a{1,3}){2}
-OK 1 - \v(a{1,3}){2}
-OK 2 - \v(a{1,3}){2}
-OK 0 - \v(a{1,3}){3}
-OK 1 - \v(a{1,3}){3}
-OK 2 - \v(a{1,3}){3}
-OK 0 - \v(a{1,2}){2}
-OK 1 - \v(a{1,2}){2}
-OK 2 - \v(a{1,2}){2}
-OK 0 - \v(a+)+
-OK 1 - \v(a+)+
-OK 2 - \v(a+)+
-OK 0 - \v(a+)+
-OK 1 - \v(a+)+
-OK 2 - \v(a+)+
-OK 0 - \v(a+){1,2}
-OK 1 - \v(a+){1,2}
-OK 2 - \v(a+){1,2}
-OK 0 - \v(a+)(a+)
-OK 1 - \v(a+)(a+)
-OK 2 - \v(a+)(a+)
-OK 0 - \v(a{3})+
-OK 1 - \v(a{3})+
-OK 2 - \v(a{3})+
-OK 0 - \v(a|b|c)+
-OK 1 - \v(a|b|c)+
-OK 2 - \v(a|b|c)+
-OK 0 - \v(a|b|c){2}
-OK 1 - \v(a|b|c){2}
-OK 2 - \v(a|b|c){2}
-OK 0 - \v(abc){2}
-OK 1 - \v(abc){2}
-OK 2 - \v(abc){2}
-OK 0 - \v(abc){2}
-OK 1 - \v(abc){2}
-OK 2 - \v(abc){2}
-OK 0 - a*
-OK 1 - a*
-OK 2 - a*
-OK 0 - \v(a*)+
-OK 1 - \v(a*)+
-OK 2 - \v(a*)+
-OK 0 - \v((ab)+)+
-OK 1 - \v((ab)+)+
-OK 2 - \v((ab)+)+
-OK 0 - \v(((ab)+)+)+
-OK 1 - \v(((ab)+)+)+
-OK 2 - \v(((ab)+)+)+
-OK 0 - \v(((ab)+)+)+
-OK 1 - \v(((ab)+)+)+
-OK 2 - \v(((ab)+)+)+
-OK 0 - \v(a{0,2})+
-OK 1 - \v(a{0,2})+
-OK 2 - \v(a{0,2})+
-OK 0 - \v(a*)+
-OK 1 - \v(a*)+
-OK 2 - \v(a*)+
-OK 0 - \v((a*)+)+
-OK 1 - \v((a*)+)+
-OK 2 - \v((a*)+)+
-OK 0 - \v((ab)*)+
-OK 1 - \v((ab)*)+
-OK 2 - \v((ab)*)+
-OK 0 - \va{1,3}
-OK 1 - \va{1,3}
-OK 2 - \va{1,3}
-OK 0 - \va{2,3}
-OK 1 - \va{2,3}
-OK 2 - \va{2,3}
-OK 0 - \v((ab)+|c*)+
-OK 1 - \v((ab)+|c*)+
-OK 2 - \v((ab)+|c*)+
-OK 0 - \v(a{2})|(b{3})
-OK 1 - \v(a{2})|(b{3})
-OK 2 - \v(a{2})|(b{3})
-OK 0 - \va{2}|b{2}
-OK 1 - \va{2}|b{2}
-OK 2 - \va{2}|b{2}
-OK 0 - \v(a)+|(c)+
-OK 1 - \v(a)+|(c)+
-OK 2 - \v(a)+|(c)+
-OK 0 - \vab{2,3}c
-OK 1 - \vab{2,3}c
-OK 2 - \vab{2,3}c
-OK 0 - \vab{2,3}c
-OK 1 - \vab{2,3}c
-OK 2 - \vab{2,3}c
-OK 0 - \vab{2,3}cd{2,3}e
-OK 1 - \vab{2,3}cd{2,3}e
-OK 2 - \vab{2,3}cd{2,3}e
-OK 0 - \va(bc){2}d
-OK 1 - \va(bc){2}d
-OK 2 - \va(bc){2}d
-OK 0 - \va*a{2}
-OK 1 - \va*a{2}
-OK 2 - \va*a{2}
-OK 0 - \va*a{2}
-OK 1 - \va*a{2}
-OK 2 - \va*a{2}
-OK 0 - \va*a{2}
-OK 1 - \va*a{2}
-OK 2 - \va*a{2}
-OK 0 - \va*a{2}
-OK 1 - \va*a{2}
-OK 2 - \va*a{2}
-OK 0 - \va*b*|a*c*
-OK 1 - \va*b*|a*c*
-OK 2 - \va*b*|a*c*
-OK 0 - \va{1}b{1}|a{1}b{1}
-OK 1 - \va{1}b{1}|a{1}b{1}
-OK 2 - \va{1}b{1}|a{1}b{1}
-OK 0 - \v(a)
-OK 1 - \v(a)
-OK 2 - \v(a)
-OK 0 - \v(a)(b)
-OK 1 - \v(a)(b)
-OK 2 - \v(a)(b)
-OK 0 - \v(ab)(b)(c)
-OK 1 - \v(ab)(b)(c)
-OK 2 - \v(ab)(b)(c)
-OK 0 - \v((a)(b))
-OK 1 - \v((a)(b))
-OK 2 - \v((a)(b))
-OK 0 - \v(a)|(b)
-OK 1 - \v(a)|(b)
-OK 2 - \v(a)|(b)
-OK 0 - \v(a*)+
-OK 1 - \v(a*)+
-OK 2 - \v(a*)+
-OK 0 - x
-OK 1 - x
-OK 2 - x
-OK 0 - ab
-OK 1 - ab
-OK 2 - ab
-OK 0 - ab
-OK 1 - ab
-OK 2 - ab
-OK 0 - ab
-OK 1 - ab
-OK 2 - ab
-OK 0 - x*
-OK 1 - x*
-OK 2 - x*
-OK 0 - x*
-OK 1 - x*
-OK 2 - x*
-OK 0 - x*
-OK 1 - x*
-OK 2 - x*
-OK 0 - x\+
-OK 1 - x\+
-OK 2 - x\+
-OK 0 - x\+
-OK 1 - x\+
-OK 2 - x\+
-OK 0 - x\+
-OK 1 - x\+
-OK 2 - x\+
-OK 0 - x\+
-OK 1 - x\+
-OK 2 - x\+
-OK 0 - x\=
-OK 1 - x\=
-OK 2 - x\=
-OK 0 - x\=
-OK 1 - x\=
-OK 2 - x\=
-OK 0 - x\=
-OK 1 - x\=
-OK 2 - x\=
-OK 0 - x\?
-OK 1 - x\?
-OK 2 - x\?
-OK 0 - x\?
-OK 1 - x\?
-OK 2 - x\?
-OK 0 - x\?
-OK 1 - x\?
-OK 2 - x\?
-OK 0 - a\{0,0}
-OK 1 - a\{0,0}
-OK 2 - a\{0,0}
-OK 0 - a\{0,1}
-OK 1 - a\{0,1}
-OK 2 - a\{0,1}
-OK 0 - a\{1,0}
-OK 1 - a\{1,0}
-OK 2 - a\{1,0}
-OK 0 - a\{3,6}
-OK 1 - a\{3,6}
-OK 2 - a\{3,6}
-OK 0 - a\{3,6}
-OK 1 - a\{3,6}
-OK 2 - a\{3,6}
-OK 0 - a\{3,6}
-OK 1 - a\{3,6}
-OK 2 - a\{3,6}
-OK 0 - a\{0}
-OK 1 - a\{0}
-OK 2 - a\{0}
-OK 0 - a\{2}
-OK 1 - a\{2}
-OK 2 - a\{2}
-OK 0 - a\{2}
-OK 1 - a\{2}
-OK 2 - a\{2}
-OK 0 - a\{2}
-OK 1 - a\{2}
-OK 2 - a\{2}
-OK 0 - a\{0,}
-OK 1 - a\{0,}
-OK 2 - a\{0,}
-OK 0 - a\{0,}
-OK 1 - a\{0,}
-OK 2 - a\{0,}
-OK 0 - a\{2,}
-OK 1 - a\{2,}
-OK 2 - a\{2,}
-OK 0 - a\{2,}
-OK 1 - a\{2,}
-OK 2 - a\{2,}
-OK 0 - a\{5,}
-OK 1 - a\{5,}
-OK 2 - a\{5,}
-OK 0 - a\{5,}
-OK 1 - a\{5,}
-OK 2 - a\{5,}
-OK 0 - a\{,0}
-OK 1 - a\{,0}
-OK 2 - a\{,0}
-OK 0 - a\{,5}
-OK 1 - a\{,5}
-OK 2 - a\{,5}
-OK 0 - a\{,5}
-OK 1 - a\{,5}
-OK 2 - a\{,5}
-OK 0 - ^*\{4,}$
-OK 1 - ^*\{4,}$
-OK 2 - ^*\{4,}$
-OK 0 - ^*\{4,}$
-OK 1 - ^*\{4,}$
-OK 2 - ^*\{4,}$
-OK 0 - ^*\{4,}$
-OK 1 - ^*\{4,}$
-OK 2 - ^*\{4,}$
-OK 0 - a\{}
-OK 1 - a\{}
-OK 2 - a\{}
-OK 0 - a\{}
-OK 1 - a\{}
-OK 2 - a\{}
-OK 0 - a\{-0,0}
-OK 1 - a\{-0,0}
-OK 2 - a\{-0,0}
-OK 0 - a\{-0,1}
-OK 1 - a\{-0,1}
-OK 2 - a\{-0,1}
-OK 0 - a\{-3,6}
-OK 1 - a\{-3,6}
-OK 2 - a\{-3,6}
-OK 0 - a\{-3,6}
-OK 1 - a\{-3,6}
-OK 2 - a\{-3,6}
-OK 0 - a\{-3,6}
-OK 1 - a\{-3,6}
-OK 2 - a\{-3,6}
-OK 0 - a\{-0}
-OK 1 - a\{-0}
-OK 2 - a\{-0}
-OK 0 - a\{-2}
-OK 1 - a\{-2}
-OK 2 - a\{-2}
-OK 0 - a\{-2}
-OK 1 - a\{-2}
-OK 2 - a\{-2}
-OK 0 - a\{-0,}
-OK 1 - a\{-0,}
-OK 2 - a\{-0,}
-OK 0 - a\{-0,}
-OK 1 - a\{-0,}
-OK 2 - a\{-0,}
-OK 0 - a\{-2,}
-OK 1 - a\{-2,}
-OK 2 - a\{-2,}
-OK 0 - a\{-2,}
-OK 1 - a\{-2,}
-OK 2 - a\{-2,}
-OK 0 - a\{-,0}
-OK 1 - a\{-,0}
-OK 2 - a\{-,0}
-OK 0 - a\{-,5}
-OK 1 - a\{-,5}
-OK 2 - a\{-,5}
-OK 0 - a\{-,5}
-OK 1 - a\{-,5}
-OK 2 - a\{-,5}
-OK 0 - a\{-}
-OK 1 - a\{-}
-OK 2 - a\{-}
-OK 0 - a\{-}
-OK 1 - a\{-}
-OK 2 - a\{-}
-OK 0 - \(abc\)*
-OK 1 - \(abc\)*
-OK 2 - \(abc\)*
-OK 0 - \(ab\)\+
-OK 1 - \(ab\)\+
-OK 2 - \(ab\)\+
-OK 0 - \(abaaaaa\)*cd
-OK 1 - \(abaaaaa\)*cd
-OK 2 - \(abaaaaa\)*cd
-OK 0 - \(test1\)\? \(test2\)\?
-OK 1 - \(test1\)\? \(test2\)\?
-OK 2 - \(test1\)\? \(test2\)\?
-OK 0 - \(test1\)\= \(test2\) \(test4443\)\=
-OK 1 - \(test1\)\= \(test2\) \(test4443\)\=
-OK 2 - \(test1\)\= \(test2\) \(test4443\)\=
-OK 0 - \(\(sub1\) hello \(sub 2\)\)
-OK 1 - \(\(sub1\) hello \(sub 2\)\)
-OK 2 - \(\(sub1\) hello \(sub 2\)\)
-OK 0 - \(\(\(yyxxzz\)\)\)
-OK 1 - \(\(\(yyxxzz\)\)\)
-OK 2 - \(\(\(yyxxzz\)\)\)
-OK 0 - \v((ab)+|c+)+
-OK 1 - \v((ab)+|c+)+
-OK 2 - \v((ab)+|c+)+
-OK 0 - \v((ab)|c*)+
-OK 1 - \v((ab)|c*)+
-OK 2 - \v((ab)|c*)+
-OK 0 - \v(a(c*)+b)+
-OK 1 - \v(a(c*)+b)+
-OK 2 - \v(a(c*)+b)+
-OK 0 - \v(a|b*)+
-OK 1 - \v(a|b*)+
-OK 2 - \v(a|b*)+
-OK 0 - \p*
-OK 1 - \p*
-OK 2 - \p*
-OK 0 - a\{-2,7}
-OK 1 - a\{-2,7}
-OK 2 - a\{-2,7}
-OK 0 - a\{-2,7}x
-OK 1 - a\{-2,7}x
-OK 2 - a\{-2,7}x
-OK 0 - a\{2,7}
-OK 1 - a\{2,7}
-OK 2 - a\{2,7}
-OK 0 - a\{2,7}x
-OK 1 - a\{2,7}x
-OK 2 - a\{2,7}x
-OK 0 - \vx(.{-,8})yz(.*)
-OK 1 - \vx(.{-,8})yz(.*)
-OK 2 - \vx(.{-,8})yz(.*)
-OK 0 - \vx(.*)yz(.*)
-OK 1 - \vx(.*)yz(.*)
-OK 2 - \vx(.*)yz(.*)
-OK 0 - \v(a{1,2}){-2,3}
-OK 1 - \v(a{1,2}){-2,3}
-OK 2 - \v(a{1,2}){-2,3}
-OK 0 - \v(a{-1,3})+
-OK 1 - \v(a{-1,3})+
-OK 2 - \v(a{-1,3})+
-OK 0 - ^\s\{-}\zs\( x\|x$\)
-OK 1 - ^\s\{-}\zs\( x\|x$\)
-OK 2 - ^\s\{-}\zs\( x\|x$\)
-OK 0 - ^\s\{-}\zs\(x\| x$\)
-OK 1 - ^\s\{-}\zs\(x\| x$\)
-OK 2 - ^\s\{-}\zs\(x\| x$\)
-OK 0 - ^\s\{-}\ze\(x\| x$\)
-OK 1 - ^\s\{-}\ze\(x\| x$\)
-OK 2 - ^\s\{-}\ze\(x\| x$\)
-OK 0 - ^\(\s\{-}\)\(x\| x$\)
-OK 1 - ^\(\s\{-}\)\(x\| x$\)
-OK 2 - ^\(\s\{-}\)\(x\| x$\)
-OK 0 - \d\+e\d\d
-OK 1 - \d\+e\d\d
-OK 2 - \d\+e\d\d
-OK 0 - \v[a]
-OK 1 - \v[a]
-OK 2 - \v[a]
-OK 0 - a[bcd]
-OK 1 - a[bcd]
-OK 2 - a[bcd]
-OK 0 - a[b-d]
-OK 1 - a[b-d]
-OK 2 - a[b-d]
-OK 0 - [a-d][e-f][x-x]d
-OK 1 - [a-d][e-f][x-x]d
-OK 2 - [a-d][e-f][x-x]d
-OK 0 - \v[[:alpha:]]+
-OK 1 - \v[[:alpha:]]+
-OK 2 - \v[[:alpha:]]+
-OK 0 - [[:alpha:]\+]
-OK 1 - [[:alpha:]\+]
-OK 2 - [[:alpha:]\+]
-OK 0 - [^abc]\+
-OK 1 - [^abc]\+
-OK 2 - [^abc]\+
-OK 0 - [^abc]
-OK 1 - [^abc]
-OK 2 - [^abc]
-OK 0 - [^abc]\+
-OK 1 - [^abc]\+
-OK 2 - [^abc]\+
-OK 0 - [^a-d]\+
-OK 1 - [^a-d]\+
-OK 2 - [^a-d]\+
-OK 0 - [a-f]*
-OK 1 - [a-f]*
-OK 2 - [a-f]*
-OK 0 - [a-f]*
-OK 1 - [a-f]*
-OK 2 - [a-f]*
-OK 0 - [^a-f]\+
-OK 1 - [^a-f]\+
-OK 2 - [^a-f]\+
-OK 0 - [a-c]\{-3,6}
-OK 1 - [a-c]\{-3,6}
-OK 2 - [a-c]\{-3,6}
-OK 0 - [^[:alpha:]]\+
-OK 1 - [^[:alpha:]]\+
-OK 2 - [^[:alpha:]]\+
-OK 0 - [-a]
-OK 1 - [-a]
-OK 2 - [-a]
-OK 0 - [a-]
-OK 1 - [a-]
-OK 2 - [a-]
-OK 0 - [a-f]*\c
-OK 1 - [a-f]*\c
-OK 2 - [a-f]*\c
-OK 0 - [abc][xyz]\c
-OK 1 - [abc][xyz]\c
-OK 2 - [abc][xyz]\c
-OK 0 - [-./[:alnum:]_~]\+
-OK 1 - [-./[:alnum:]_~]\+
-OK 2 - [-./[:alnum:]_~]\+
-OK 0 - [\]\^\-\\]\+
-OK 1 - [\]\^\-\\]\+
-OK 2 - [\]\^\-\\]\+
-OK 0 - [[.a.]]\+
-OK 1 - [[.a.]]\+
-OK 2 - [[.a.]]\+
-OK 0 - abc[0-9]*ddd
-OK 1 - abc[0-9]*ddd
-OK 2 - abc[0-9]*ddd
-OK 0 - abc[0-9]*ddd
-OK 1 - abc[0-9]*ddd
-OK 2 - abc[0-9]*ddd
-OK 0 - \_[0-9]\+
-OK 1 - \_[0-9]\+
-OK 2 - \_[0-9]\+
-OK 0 - [0-9\n]\+
-OK 1 - [0-9\n]\+
-OK 2 - [0-9\n]\+
-OK 0 - \_[0-9]\+
-OK 1 - \_[0-9]\+
-OK 2 - \_[0-9]\+
-OK 0 - \_f
-OK 1 - \_f
-OK 2 - \_f
-OK 0 - \_f\+
-OK 1 - \_f\+
-OK 2 - \_f\+
-OK 0 - [0-9A-Za-z-_.]\+
-OK 1 - [0-9A-Za-z-_.]\+
-OK 2 - [0-9A-Za-z-_.]\+
-OK 0 - ^a.
-OK 1 - ^a.
-OK 2 - ^a.
-OK 0 - ^a.
-OK 1 - ^a.
-OK 2 - ^a.
-OK 0 - .a$
-OK 1 - .a$
-OK 2 - .a$
-OK 0 - .a$
-OK 1 - .a$
-OK 2 - .a$
-OK 0 - \%^a.
-OK 1 - \%^a.
-OK 2 - \%^a.
-OK 0 - \%^a
-OK 1 - \%^a
-OK 2 - \%^a
-OK 0 - .a\%$
-OK 1 - .a\%$
-OK 2 - .a\%$
-OK 0 - .a\%$
-OK 1 - .a\%$
-OK 2 - .a\%$
-OK 0 - [0-7]\+
-OK 1 - [0-7]\+
-OK 2 - [0-7]\+
-OK 0 - [^0-7]\+
-OK 1 - [^0-7]\+
-OK 2 - [^0-7]\+
-OK 0 - [0-9]\+
-OK 1 - [0-9]\+
-OK 2 - [0-9]\+
-OK 0 - [^0-9]\+
-OK 1 - [^0-9]\+
-OK 2 - [^0-9]\+
-OK 0 - [0-9a-fA-F]\+
-OK 1 - [0-9a-fA-F]\+
-OK 2 - [0-9a-fA-F]\+
-OK 0 - [^0-9A-Fa-f]\+
-OK 1 - [^0-9A-Fa-f]\+
-OK 2 - [^0-9A-Fa-f]\+
-OK 0 - [a-z_A-Z0-9]\+
-OK 1 - [a-z_A-Z0-9]\+
-OK 2 - [a-z_A-Z0-9]\+
-OK 0 - [^a-z_A-Z0-9]\+
-OK 1 - [^a-z_A-Z0-9]\+
-OK 2 - [^a-z_A-Z0-9]\+
-OK 0 - [a-z_A-Z]\+
-OK 1 - [a-z_A-Z]\+
-OK 2 - [a-z_A-Z]\+
-OK 0 - [^a-z_A-Z]\+
-OK 1 - [^a-z_A-Z]\+
-OK 2 - [^a-z_A-Z]\+
-OK 0 - [a-z]\+
-OK 1 - [a-z]\+
-OK 2 - [a-z]\+
-OK 0 - [a-z]\+
-OK 1 - [a-z]\+
-OK 2 - [a-z]\+
-OK 0 - [^a-z]\+
-OK 1 - [^a-z]\+
-OK 2 - [^a-z]\+
-OK 0 - [^a-z]\+
-OK 1 - [^a-z]\+
-OK 2 - [^a-z]\+
-OK 0 - [a-zA-Z]\+
-OK 1 - [a-zA-Z]\+
-OK 2 - [a-zA-Z]\+
-OK 0 - [^a-zA-Z]\+
-OK 1 - [^a-zA-Z]\+
-OK 2 - [^a-zA-Z]\+
-OK 0 - [A-Z]\+
-OK 1 - [A-Z]\+
-OK 2 - [A-Z]\+
-OK 0 - [^A-Z]\+
-OK 1 - [^A-Z]\+
-OK 2 - [^A-Z]\+
-OK 0 - [a-z]\+\c
-OK 1 - [a-z]\+\c
-OK 2 - [a-z]\+\c
-OK 0 - [A-Z]\+\c
-OK 1 - [A-Z]\+\c
-OK 2 - [A-Z]\+\c
-OK 0 - \c[^a-z]\+
-OK 1 - \c[^a-z]\+
-OK 2 - \c[^a-z]\+
-OK 0 - \c[^A-Z]\+
-OK 1 - \c[^A-Z]\+
-OK 2 - \c[^A-Z]\+
-OK 0 - \C[^A-Z]\+
-OK 1 - \C[^A-Z]\+
-OK 2 - \C[^A-Z]\+
-OK 0 - xx \ze test
-OK 1 - xx \ze test
-OK 2 - xx \ze test
-OK 0 - abc\zeend
-OK 1 - abc\zeend
-OK 2 - abc\zeend
-OK 0 - aa\zebb\|aaxx
-OK 1 - aa\zebb\|aaxx
-OK 2 - aa\zebb\|aaxx
-OK 0 - aa\zebb\|aaxx
-OK 1 - aa\zebb\|aaxx
-OK 2 - aa\zebb\|aaxx
-OK 0 - aabb\|aa\zebb
-OK 1 - aabb\|aa\zebb
-OK 2 - aabb\|aa\zebb
-OK 0 - aa\zebb\|aaebb
-OK 1 - aa\zebb\|aaebb
-OK 2 - aa\zebb\|aaebb
-OK 0 - abc\zsdd
-OK 1 - abc\zsdd
-OK 2 - abc\zsdd
-OK 0 - aa \zsax
-OK 1 - aa \zsax
-OK 2 - aa \zsax
-OK 0 - abc \zsmatch\ze abc
-OK 1 - abc \zsmatch\ze abc
-OK 2 - abc \zsmatch\ze abc
-OK 0 - \v(a \zsif .*){2}
-OK 1 - \v(a \zsif .*){2}
-OK 2 - \v(a \zsif .*){2}
-OK 0 - \>\zs.
-OK 1 - \>\zs.
-OK 2 - \>\zs.
-OK 0 - \s\+\ze\[/\|\s\zs\s\+
-OK 1 - \s\+\ze\[/\|\s\zs\s\+
-OK 2 - \s\+\ze\[/\|\s\zs\s\+
-OK 0 - abc\@=
-OK 1 - abc\@=
-OK 2 - abc\@=
-OK 0 - abc\@=cd
-OK 1 - abc\@=cd
-OK 2 - abc\@=cd
-OK 0 - abc\@=
-OK 1 - abc\@=
-OK 2 - abc\@=
-OK 0 - abcd\@=e
-OK 1 - abcd\@=e
-OK 2 - abcd\@=e
-OK 0 - abcd\@=e
-OK 1 - abcd\@=e
-OK 2 - abcd\@=e
-OK 0 - \v(abc)@=..
-OK 1 - \v(abc)@=..
-OK 2 - \v(abc)@=..
-OK 0 - \(.*John\)\@=.*Bob
-OK 1 - \(.*John\)\@=.*Bob
-OK 2 - \(.*John\)\@=.*Bob
-OK 0 - \(John.*\)\@=.*Bob
-OK 1 - \(John.*\)\@=.*Bob
-OK 2 - \(John.*\)\@=.*Bob
-OK 0 - \<\S\+\())\)\@=
-OK 1 - \<\S\+\())\)\@=
-OK 2 - \<\S\+\())\)\@=
-OK 0 - .*John\&.*Bob
-OK 1 - .*John\&.*Bob
-OK 2 - .*John\&.*Bob
-OK 0 - .*John\&.*Bob
-OK 1 - .*John\&.*Bob
-OK 2 - .*John\&.*Bob
-OK 0 - \v(test1)@=.*yep
-OK 1 - \v(test1)@=.*yep
-OK 2 - \v(test1)@=.*yep
-OK 0 - foo\(bar\)\@!
-OK 1 - foo\(bar\)\@!
-OK 2 - foo\(bar\)\@!
-OK 0 - foo\(bar\)\@!
-OK 1 - foo\(bar\)\@!
-OK 2 - foo\(bar\)\@!
-OK 0 - if \(\(then\)\@!.\)*$
-OK 1 - if \(\(then\)\@!.\)*$
-OK 2 - if \(\(then\)\@!.\)*$
-OK 0 - if \(\(then\)\@!.\)*$
-OK 1 - if \(\(then\)\@!.\)*$
-OK 2 - if \(\(then\)\@!.\)*$
-OK 0 - \(foo\)\@!bar
-OK 1 - \(foo\)\@!bar
-OK 2 - \(foo\)\@!bar
-OK 0 - \(foo\)\@!...bar
-OK 1 - \(foo\)\@!...bar
-OK 2 - \(foo\)\@!...bar
-OK 0 - ^\%(.*bar\)\@!.*\zsfoo
-OK 1 - ^\%(.*bar\)\@!.*\zsfoo
-OK 2 - ^\%(.*bar\)\@!.*\zsfoo
-OK 0 - ^\%(.*bar\)\@!.*\zsfoo
-OK 1 - ^\%(.*bar\)\@!.*\zsfoo
-OK 2 - ^\%(.*bar\)\@!.*\zsfoo
-OK 0 - ^\%(.*bar\)\@!.*\zsfoo
-OK 1 - ^\%(.*bar\)\@!.*\zsfoo
-OK 2 - ^\%(.*bar\)\@!.*\zsfoo
-OK 0 - [ ]\@!\p\%([ ]\@!\p\)*:
-OK 1 - [ ]\@!\p\%([ ]\@!\p\)*:
-OK 2 - [ ]\@!\p\%([ ]\@!\p\)*:
-OK 0 - [ ]\@!\p\([ ]\@!\p\)*:
-OK 1 - [ ]\@!\p\([ ]\@!\p\)*:
-OK 2 - [ ]\@!\p\([ ]\@!\p\)*:
-OK 0 - m\k\+_\@=\%(_\@!\k\)\@<=\k\+e
-OK 1 - m\k\+_\@=\%(_\@!\k\)\@<=\k\+e
-OK 2 - m\k\+_\@=\%(_\@!\k\)\@<=\k\+e
-OK 0 - \%(\U\@<=S\k*\|S\l\)R
-OK 1 - \%(\U\@<=S\k*\|S\l\)R
-OK 2 - \%(\U\@<=S\k*\|S\l\)R
-OK 0 - [[:alpha:]]\{-2,6}
-OK 1 - [[:alpha:]]\{-2,6}
-OK 2 - [[:alpha:]]\{-2,6}
-OK 0 -
-OK 1 -
-OK 2 -
-OK 0 - \v(())
-OK 1 - \v(())
-OK 2 - \v(())
-OK 0 - \v%(ab(xyz)c)
-OK 1 - \v%(ab(xyz)c)
-OK 2 - \v%(ab(xyz)c)
-OK 0 - \v(test|)empty
-OK 1 - \v(test|)empty
-OK 2 - \v(test|)empty
-OK 0 - \v(a|aa)(a|aa)
-OK 1 - \v(a|aa)(a|aa)
-OK 2 - \v(a|aa)(a|aa)
-OK 0 - \%d32
-OK 1 - \%d32
-OK 2 - \%d32
-OK 0 - \%o40
-OK 1 - \%o40
-OK 2 - \%o40
-OK 0 - \%x20
-OK 1 - \%x20
-OK 2 - \%x20
-OK 0 - \%u0020
-OK 1 - \%u0020
-OK 2 - \%u0020
-OK 0 - \%U00000020
-OK 1 - \%U00000020
-OK 2 - \%U00000020
-OK 0 - \%d0
-OK 1 - \%d0
-OK 2 - \%d0
-OK 0 - foo\%[bar]
-OK 1 - foo\%[bar]
-OK 2 - foo\%[bar]
-OK 0 - foo\%[bar]
-OK 1 - foo\%[bar]
-OK 2 - foo\%[bar]
-OK 0 - foo\%[bar]
-OK 1 - foo\%[bar]
-OK 2 - foo\%[bar]
-OK 0 - foo\%[bar]
-OK 1 - foo\%[bar]
-OK 2 - foo\%[bar]
-OK 0 - foo\%[bar]
-OK 1 - foo\%[bar]
-OK 2 - foo\%[bar]
-OK 0 - foo\%[bar]
-OK 1 - foo\%[bar]
-OK 2 - foo\%[bar]
-OK 0 - foo\%[bar]x
-OK 1 - foo\%[bar]x
-OK 2 - foo\%[bar]x
-OK 0 - foo\%[bar]x
-OK 1 - foo\%[bar]x
-OK 2 - foo\%[bar]x
-OK 0 - \%[bar]x
-OK 1 - \%[bar]x
-OK 2 - \%[bar]x
-OK 0 - \%[bar]x
-OK 1 - \%[bar]x
-OK 2 - \%[bar]x
-OK 0 - \%[bar]x
-OK 1 - \%[bar]x
-OK 2 - \%[bar]x
-OK 0 - b\%[[ao]r]
-OK 1 - b\%[[ao]r]
-OK 2 - b\%[[ao]r]
-OK 0 - b\%[[]]r]
-OK 1 - b\%[[]]r]
-OK 2 - b\%[[]]r]
-OK 0 - @\%[\w\-]*
-OK 1 - @\%[\w\-]*
-OK 2 - @\%[\w\-]*
-OK 0 - goo\|go
-OK 1 - goo\|go
-OK 2 - goo\|go
-OK 0 - \<goo\|\<go
-OK 1 - \<goo\|\<go
-OK 2 - \<goo\|\<go
-OK 0 - \<goo\|go
-OK 1 - \<goo\|go
-OK 2 - \<goo\|go
-OK 0 - \(\i\+\) \1
-OK 1 - \(\i\+\) \1
-OK 2 - \(\i\+\) \1
-OK 0 - \(\i\+\) \1
-OK 1 - \(\i\+\) \1
-OK 2 - \(\i\+\) \1
-OK 0 - \(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9
-OK 1 - \(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9
-OK 2 - \(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9
-OK 0 - \(\d*\)a \1b
-OK 1 - \(\d*\)a \1b
-OK 2 - \(\d*\)a \1b
-OK 0 - ^.\(.\).\_..\1.
-OK 1 - ^.\(.\).\_..\1.
-OK 2 - ^.\(.\).\_..\1.
-OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
-OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
-OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
-OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
-OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
-OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
-OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
-OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
-OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
-OK 0 - \\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}
-OK 1 - \\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}
-OK 2 - \\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}
-OK 0 - ^\(a*\)\1$
-OK 1 - ^\(a*\)\1$
-OK 2 - ^\(a*\)\1$
-OK 0 - ^\(a\{-2,}\)\1\+$
-OK 1 - ^\(a\{-2,}\)\1\+$
-OK 2 - ^\(a\{-2,}\)\1\+$
-OK 0 - <\@<=span.
-OK 1 - <\@<=span.
-OK 2 - <\@<=span.
-OK 0 - <\@1<=span.
-OK 1 - <\@1<=span.
-OK 2 - <\@1<=span.
-OK 0 - <\@2<=span.
-OK 1 - <\@2<=span.
-OK 2 - <\@2<=span.
-OK 0 - \(<<\)\@<=span.
-OK 1 - \(<<\)\@<=span.
-OK 2 - \(<<\)\@<=span.
-OK 0 - \(<<\)\@1<=span.
-OK 1 - \(<<\)\@1<=span.
-OK 2 - \(<<\)\@1<=span.
-OK 0 - \(<<\)\@2<=span.
-OK 1 - \(<<\)\@2<=span.
-OK 2 - \(<<\)\@2<=span.
-OK 0 - \(foo\)\@<!bar.
-OK 1 - \(foo\)\@<!bar.
-OK 2 - \(foo\)\@<!bar.
-OK 0 - \v\C%(<Last Changed:\s+)@<=.*$
-OK 1 - \v\C%(<Last Changed:\s+)@<=.*$
-OK 2 - \v\C%(<Last Changed:\s+)@<=.*$
-OK 0 - \v\C%(<Last Changed:\s+)@<=.*$
-OK 1 - \v\C%(<Last Changed:\s+)@<=.*$
-OK 2 - \v\C%(<Last Changed:\s+)@<=.*$
-OK 0 - \(foo\)\@<=\>
-OK 1 - \(foo\)\@<=\>
-OK 2 - \(foo\)\@<=\>
-OK 0 - \(foo\)\@<=\>
-OK 1 - \(foo\)\@<=\>
-OK 2 - \(foo\)\@<=\>
-OK 0 - \(foo\)\@<=.*
-OK 1 - \(foo\)\@<=.*
-OK 2 - \(foo\)\@<=.*
-OK 0 - \(r\@<=\|\w\@<!\)\/
-OK 1 - \(r\@<=\|\w\@<!\)\/
-OK 2 - \(r\@<=\|\w\@<!\)\/
-OK 0 - ^[a-z]\+\ze \&\(asdf\)\@<!
-OK 1 - ^[a-z]\+\ze \&\(asdf\)\@<!
-OK 2 - ^[a-z]\+\ze \&\(asdf\)\@<!
-OK 0 - \(a*\)\@>a
-OK 1 - \(a*\)\@>a
-OK 2 - \(a*\)\@>a
-OK 0 - \(a*\)\@>b
-OK 1 - \(a*\)\@>b
-OK 2 - \(a*\)\@>b
-OK 0 - ^\(.\{-}b\)\@>.
-OK 1 - ^\(.\{-}b\)\@>.
-OK 2 - ^\(.\{-}b\)\@>.
-OK 0 - \(.\{-}\)\(\)\@>$
-OK 1 - \(.\{-}\)\(\)\@>$
-OK 2 - \(.\{-}\)\(\)\@>$
-OK 0 - \(a*\)\@>a\|a\+
-OK 2 - \(a*\)\@>a\|a\+
-OK 0 - \_[^8-9]\+
-OK 1 - \_[^8-9]\+
-OK 2 - \_[^8-9]\+
-OK 0 - \_[^a]\+
-OK 1 - \_[^a]\+
-OK 2 - \_[^a]\+
-OK 0 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
-OK 1 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
-OK 2 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
-OK 0 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
-OK 1 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
-OK 2 - ^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=
-OK 0 - \%>70vGesamt
-OK 1 - \%>70vGesamt
-OK 2 - \%>70vGesamt
-multi-line tests
-OK 0 - ^.\(.\).\_..\1.
-OK 1 - ^.\(.\).\_..\1.
-OK 2 - ^.\(.\).\_..\1.
-OK 0 - \v.*\/(.*)\n.*\/\1$
-OK 1 - \v.*\/(.*)\n.*\/\1$
-OK 2 - \v.*\/(.*)\n.*\/\1$
-OK 0 - \S.*\nx
-OK 1 - \S.*\nx
-OK 2 - \S.*\nx
-OK 0 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
-OK 1 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
-OK 2 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
-OK 0 - a\n^b$\n^c
-OK 1 - a\n^b$\n^c
-OK 2 - a\n^b$\n^c
-OK 0 - \(^.\+\n\)\1
-OK 1 - \(^.\+\n\)\1
-OK 2 - \(^.\+\n\)\1
-
-<T="5">Ta 5</Title>
-<T="7">Ac 7</Title>
-
-xxstart3
-
-thexE thE thExethe
-AndAxAnd AndAxAnd
-oooxOfOr fOrOxooo
-oooxOfOr fOrOxooo
-
-asdfhereasdf
-asdfagainasdf
-
--0-
-ffo
-bob
-__ooooo
-koooo__
-moooooo
- f__
-ab!babababababfoo
-ba!ab##abab?bafoo
-**!*****_
- ! xxx?xxxxxxxx xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx
--1-
-ffo
-bob
-__ooooo
-koooo__
-moooooo
- f__
-ab!babababababfoo
-ba!ab##abab?bafoo
-**!*****_
- ! xxx?xxxxxxxx xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx
--2-
-ffo
-bob
-__ooooo
-koooo__
-moooooo
- f__
-ab!babababababfoo
-ba!ab##abab?bafoo
-**!*****_
- ! xxx?xxxxxxxx xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx
-Test
-Test END
-EN
-E
-E888 detected for \ze*
-E888 detected for \zs*
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index 6bf2e8329c..5668f45dea 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -2,6 +2,7 @@
" This makes testing go faster, since Vim doesn't need to restart.
source test_assign.vim
+source test_backup.vim
source test_behave.vim
source test_cd.vim
source test_changedtick.vim
@@ -27,7 +28,6 @@ source test_jumps.vim
source test_fileformat.vim
source test_filetype.vim
source test_lambda.vim
-source test_mapping.vim
source test_menu.vim
source test_messages.vim
source test_modeline.vim
@@ -45,6 +45,7 @@ source test_syn_attr.vim
source test_tabline.vim
source test_tabpage.vim
source test_tagcase.vim
+source test_tagfunc.vim
source test_tagjump.vim
source test_taglist.vim
source test_true_false.vim
diff --git a/src/nvim/testdir/test_assert.vim b/src/nvim/testdir/test_assert.vim
index a4c8ce7e43..b4f7478807 100644
--- a/src/nvim/testdir/test_assert.vim
+++ b/src/nvim/testdir/test_assert.vim
@@ -1,5 +1,51 @@
" Test that the methods used for testing work.
+func Test_assert_equalfile()
+ call assert_equal(1, assert_equalfile('abcabc', 'xyzxyz'))
+ call assert_match("E485: Can't read file abcabc", v:errors[0])
+ call remove(v:errors, 0)
+
+ let goodtext = ["one", "two", "three"]
+ call writefile(goodtext, 'Xone')
+ call assert_equal(1, assert_equalfile('Xone', 'xyzxyz'))
+ call assert_match("E485: Can't read file xyzxyz", v:errors[0])
+ call remove(v:errors, 0)
+
+ call writefile(goodtext, 'Xtwo')
+ call assert_equal(0, assert_equalfile('Xone', 'Xtwo'))
+
+ call writefile([goodtext[0]], 'Xone')
+ call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
+ call assert_match("first file is shorter", v:errors[0])
+ call remove(v:errors, 0)
+
+ call writefile(goodtext, 'Xone')
+ call writefile([goodtext[0]], 'Xtwo')
+ call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
+ call assert_match("second file is shorter", v:errors[0])
+ call remove(v:errors, 0)
+
+ call writefile(['1234X89'], 'Xone')
+ call writefile(['1234Y89'], 'Xtwo')
+ call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
+ call assert_match('difference at byte 4, line 1 after "1234X" vs "1234Y"', v:errors[0])
+ call remove(v:errors, 0)
+
+ call writefile([repeat('x', 234) .. 'X'], 'Xone')
+ call writefile([repeat('x', 234) .. 'Y'], 'Xtwo')
+ call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
+ let xes = repeat('x', 134)
+ call assert_match('difference at byte 234, line 1 after "' .. xes .. 'X" vs "' .. xes .. 'Y"', v:errors[0])
+ call remove(v:errors, 0)
+
+ call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message'))
+ call assert_match("a message: difference at byte 234, line 1 after", v:errors[0])
+ call remove(v:errors, 0)
+
+ call delete('Xone')
+ call delete('Xtwo')
+endfunc
+
func Test_assert_fails_in_try_block()
try
call assert_equal(0, assert_fails('throw "error"'))
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 5848940a2b..d116246ef3 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -52,7 +52,7 @@ if has('timers')
au CursorHoldI * let g:triggered += 1
set updatetime=500
call job_start(has('win32') ? 'cmd /c echo:' : 'echo',
- \ {'exit_cb': {j, s -> timer_start(1000, 'ExitInsertMode')}})
+ \ {'exit_cb': {-> timer_start(1000, 'ExitInsertMode')}})
call feedkeys('a', 'x!')
call assert_equal(1, g:triggered)
unlet g:triggered
@@ -425,18 +425,20 @@ func Test_autocmd_bufwipe_in_SessLoadPost()
set noswapfile
mksession!
- let content = ['set nocp noswapfile',
- \ 'let v:swapchoice="e"',
- \ 'augroup test_autocmd_sessionload',
- \ 'autocmd!',
- \ 'autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"',
- \ 'augroup END',
- \ '',
- \ 'func WriteErrors()',
- \ ' call writefile([execute("messages")], "Xerrors")',
- \ 'endfunc',
- \ 'au VimLeave * call WriteErrors()',
- \ ]
+ let content =<< trim [CODE]
+ set nocp noswapfile
+ let v:swapchoice="e"
+ augroup test_autocmd_sessionload
+ autocmd!
+ autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"
+ augroup END
+
+ func WriteErrors()
+ call writefile([execute("messages")], "Xerrors")
+ endfunc
+ au VimLeave * call WriteErrors()
+ [CODE]
+
call writefile(content, 'Xvimrc')
call system(v:progpath. ' --headless -i NONE -u Xvimrc --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors'))
@@ -454,27 +456,29 @@ func Test_autocmd_bufwipe_in_SessLoadPost2()
set noswapfile
mksession!
- let content = ['set nocp noswapfile',
- \ 'function! DeleteInactiveBufs()',
- \ ' tabfirst',
- \ ' let tabblist = []',
- \ ' for i in range(1, tabpagenr(''$''))',
- \ ' call extend(tabblist, tabpagebuflist(i))',
- \ ' endfor',
- \ ' for b in range(1, bufnr(''$''))',
- \ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')',
- \ ' exec ''bwipeout '' . b',
- \ ' endif',
- \ ' endfor',
- \ ' echomsg "SessionLoadPost DONE"',
- \ 'endfunction',
- \ 'au SessionLoadPost * call DeleteInactiveBufs()',
- \ '',
- \ 'func WriteErrors()',
- \ ' call writefile([execute("messages")], "Xerrors")',
- \ 'endfunc',
- \ 'au VimLeave * call WriteErrors()',
- \ ]
+ let content =<< trim [CODE]
+ set nocp noswapfile
+ function! DeleteInactiveBufs()
+ tabfirst
+ let tabblist = []
+ for i in range(1, tabpagenr(''$''))
+ call extend(tabblist, tabpagebuflist(i))
+ endfor
+ for b in range(1, bufnr(''$''))
+ if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')
+ exec ''bwipeout '' . b
+ endif
+ endfor
+ echomsg "SessionLoadPost DONE"
+ endfunction
+ au SessionLoadPost * call DeleteInactiveBufs()
+
+ func WriteErrors()
+ call writefile([execute("messages")], "Xerrors")
+ endfunc
+ au VimLeave * call WriteErrors()
+ [CODE]
+
call writefile(content, 'Xvimrc')
call system(v:progpath. ' --headless -i NONE -u Xvimrc --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors'))
@@ -936,21 +940,23 @@ func Test_bufunload_all()
call writefile(['Test file Xxx1'], 'Xxx1')"
call writefile(['Test file Xxx2'], 'Xxx2')"
- let content = [
- \ "func UnloadAllBufs()",
- \ " let i = 1",
- \ " while i <= bufnr('$')",
- \ " if i != bufnr('%') && bufloaded(i)",
- \ " exe i . 'bunload'",
- \ " endif",
- \ " let i += 1",
- \ " endwhile",
- \ "endfunc",
- \ "au BufUnload * call UnloadAllBufs()",
- \ "au VimLeave * call writefile(['Test Finished'], 'Xout')",
- \ "edit Xxx1",
- \ "split Xxx2",
- \ "q"]
+ let content =<< trim [CODE]
+ func UnloadAllBufs()
+ let i = 1
+ while i <= bufnr('$')
+ if i != bufnr('%') && bufloaded(i)
+ exe i . 'bunload'
+ endif
+ let i += 1
+ endwhile
+ endfunc
+ au BufUnload * call UnloadAllBufs()
+ au VimLeave * call writefile(['Test Finished'], 'Xout')
+ edit Xxx1
+ split Xxx2
+ q
+ [CODE]
+
call writefile(content, 'Xtest')
call delete('Xout')
@@ -1066,6 +1072,40 @@ func Test_Cmd_Autocmds()
enew!
endfunc
+func s:ReadFile()
+ setl noswapfile nomodified
+ let filename = resolve(expand("<afile>:p"))
+ execute 'read' fnameescape(filename)
+ 1d_
+ exe 'file' fnameescape(filename)
+ setl buftype=acwrite
+endfunc
+
+func s:WriteFile()
+ let filename = resolve(expand("<afile>:p"))
+ setl buftype=
+ noautocmd execute 'write' fnameescape(filename)
+ setl buftype=acwrite
+ setl nomodified
+endfunc
+
+func Test_BufReadCmd()
+ autocmd BufReadCmd *.test call s:ReadFile()
+ autocmd BufWriteCmd *.test call s:WriteFile()
+
+ call writefile(['one', 'two', 'three'], 'Xcmd.test')
+ edit Xcmd.test
+ call assert_match('Xcmd.test" line 1 of 3', execute('file'))
+ normal! Gofour
+ write
+ call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test'))
+
+ bwipe!
+ call delete('Xcmd.test')
+ au! BufReadCmd
+ au! BufWriteCmd
+endfunc
+
func SetChangeMarks(start, end)
exe a:start. 'mark ['
exe a:end. 'mark ]'
@@ -1206,23 +1246,27 @@ func Test_TextYankPost()
norm "ayiw
call assert_equal(
- \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'a', 'operator': 'y', 'regtype': 'v'},
+ \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'a', 'operator': 'y', 'visual': v:false, 'regtype': 'v'},
\g:event)
norm y_
call assert_equal(
- \{'regcontents': ['foo'], 'inclusive': v:false, 'regname': '', 'operator': 'y', 'regtype': 'V'},
+ \{'regcontents': ['foo'], 'inclusive': v:false, 'regname': '', 'operator': 'y', 'visual': v:false, 'regtype': 'V'},
+ \g:event)
+ norm Vy
+ call assert_equal(
+ \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'visual': v:true, 'regtype': 'V'},
\g:event)
call feedkeys("\<C-V>y", 'x')
call assert_equal(
- \{'regcontents': ['f'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'regtype': "\x161"},
+ \{'regcontents': ['f'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'visual': v:true, 'regtype': "\x161"},
\g:event)
norm "xciwbar
call assert_equal(
- \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'x', 'operator': 'c', 'regtype': 'v'},
+ \{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'x', 'operator': 'c', 'visual': v:false, 'regtype': 'v'},
\g:event)
norm "bdiw
call assert_equal(
- \{'regcontents': ['bar'], 'inclusive': v:true, 'regname': 'b', 'operator': 'd', 'regtype': 'v'},
+ \{'regcontents': ['bar'], 'inclusive': v:true, 'regname': 'b', 'operator': 'd', 'visual': v:false, 'regtype': 'v'},
\g:event)
call assert_equal({}, v:event)
@@ -1344,11 +1388,11 @@ func Test_Changed_FirstTime()
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3})
call assert_equal('running', term_getstatus(buf))
" Wait for the ruler (in the status line) to be shown.
- call WaitFor({-> term_getline(buf, 3) =~# '\<All$'})
+ call WaitForAssert({-> assert_match('\<All$', term_getline(buf, 3))})
" It's only adding autocmd, so that no event occurs.
call term_sendkeys(buf, ":au! TextChanged <buffer> call writefile(['No'], 'Xchanged.txt')\<cr>")
call term_sendkeys(buf, "\<C-\\>\<C-N>:qa!\<cr>")
- call WaitFor({-> term_getstatus(buf) == 'finished'})
+ call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
call assert_equal([''], readfile('Xchanged.txt'))
" clean up
@@ -1780,3 +1824,46 @@ func Test_FileChangedShell_reload()
bwipe!
call delete('Xchanged')
endfunc
+
+" Test for FileReadCmd autocmd
+func Test_autocmd_FileReadCmd()
+ func ReadFileCmd()
+ call append(line('$'), "v:cmdarg = " .. v:cmdarg)
+ endfunc
+ augroup FileReadCmdTest
+ au!
+ au FileReadCmd Xtest call ReadFileCmd()
+ augroup END
+
+ new
+ read ++bin Xtest
+ read ++nobin Xtest
+ read ++edit Xtest
+ read ++bad=keep Xtest
+ read ++bad=drop Xtest
+ read ++bad=- Xtest
+ read ++ff=unix Xtest
+ read ++ff=dos Xtest
+ read ++ff=mac Xtest
+ read ++enc=utf-8 Xtest
+
+ call assert_equal(['',
+ \ 'v:cmdarg = ++bin',
+ \ 'v:cmdarg = ++nobin',
+ \ 'v:cmdarg = ++edit',
+ \ 'v:cmdarg = ++bad=keep',
+ \ 'v:cmdarg = ++bad=drop',
+ \ 'v:cmdarg = ++bad=-',
+ \ 'v:cmdarg = ++ff=unix',
+ \ 'v:cmdarg = ++ff=dos',
+ \ 'v:cmdarg = ++ff=mac',
+ \ 'v:cmdarg = ++enc=utf-8'], getline(1, '$'))
+
+ close!
+ augroup FileReadCmdTest
+ au!
+ augroup END
+ delfunc ReadFileCmd
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_backup.vim b/src/nvim/testdir/test_backup.vim
new file mode 100644
index 0000000000..ce2bfe72bc
--- /dev/null
+++ b/src/nvim/testdir/test_backup.vim
@@ -0,0 +1,58 @@
+" Tests for the backup function
+
+func Test_backup()
+ set backup backupdir=. backupskip=
+ new
+ call setline(1, ['line1', 'line2'])
+ :f Xbackup.txt
+ :w! Xbackup.txt
+ " backup file is only created after
+ " writing a second time (before overwriting)
+ :w! Xbackup.txt
+ let l = readfile('Xbackup.txt~')
+ call assert_equal(['line1', 'line2'], l)
+ bw!
+ set backup&vim backupdir&vim backupskip&vim
+ call delete('Xbackup.txt')
+ call delete('Xbackup.txt~')
+endfunc
+
+func Test_backup2()
+ set backup backupdir=.// backupskip=
+ new
+ call setline(1, ['line1', 'line2', 'line3'])
+ :f Xbackup.txt
+ :w! Xbackup.txt
+ " backup file is only created after
+ " writing a second time (before overwriting)
+ :w! Xbackup.txt
+ sp *Xbackup.txt~
+ call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
+ let f=expand('%')
+ call assert_match('%testdir%Xbackup.txt\~', f)
+ bw!
+ bw!
+ call delete('Xbackup.txt')
+ call delete(f)
+ set backup&vim backupdir&vim backupskip&vim
+endfunc
+
+func Test_backup2_backupcopy()
+ set backup backupdir=.// backupcopy=yes backupskip=
+ new
+ call setline(1, ['line1', 'line2', 'line3'])
+ :f Xbackup.txt
+ :w! Xbackup.txt
+ " backup file is only created after
+ " writing a second time (before overwriting)
+ :w! Xbackup.txt
+ sp *Xbackup.txt~
+ call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
+ let f=expand('%')
+ call assert_match('%testdir%Xbackup.txt\~', f)
+ bw!
+ bw!
+ call delete('Xbackup.txt')
+ call delete(f)
+ set backup&vim backupdir&vim backupcopy&vim backupskip&vim
+endfunc
diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim
index 4b34420cab..a4c1f62a43 100644
--- a/src/nvim/testdir/test_breakindent.vim
+++ b/src/nvim/testdir/test_breakindent.vim
@@ -296,3 +296,129 @@ function Test_breakindent16()
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
+
+func Test_breakindent17_vartabs()
+ if !has("vartabs")
+ return
+ endif
+ let s:input = ""
+ call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++')
+ call setline(1, "\t" . repeat('a', 63))
+ vert resize 30
+ norm! 1gg$
+ redraw!
+ let lines = s:screen_lines(1, 30)
+ let expect = [
+ \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
+ \ " +++aaaaaaaaaaaaaaaaaaaaaaa",
+ \ " +++aaaaaaaaaaaaaa ",
+ \ ]
+ call s:compare_lines(expect, lines)
+ call s:close_windows('set breakindent& list& listchars& showbreak&')
+endfunc
+
+func Test_breakindent18_vartabs()
+ if !has("vartabs")
+ return
+ endif
+ let s:input = ""
+ call s:test_windows('setl breakindent list listchars=tab:<->')
+ call setline(1, "\t" . repeat('a', 63))
+ vert resize 30
+ norm! 1gg$
+ redraw!
+ let lines = s:screen_lines(1, 30)
+ let expect = [
+ \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaa ",
+ \ ]
+ call s:compare_lines(expect, lines)
+ call s:close_windows('set breakindent& list& listchars&')
+endfunc
+
+func Test_breakindent19_sbr_nextpage()
+ let s:input = ""
+ call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>')
+ call setline(1, repeat('a', 200))
+ norm! 1gg
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ "aaaaaaaaaaaaaaaaaaaa",
+ \ "> aaaaaaaaaaaaaaaaaa",
+ \ "> aaaaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+ " Scroll down one screen line
+ setl scrolloff=5
+ norm! 5gj
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ "> aaaaaaaaaaaaaaaaaa",
+ \ "> aaaaaaaaaaaaaaaaaa",
+ \ "> aaaaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+
+ setl breakindent briopt=min:18 sbr=>
+ norm! 5gj
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ ">aaaaaaaaaaaaaaaaaaa",
+ \ ">aaaaaaaaaaaaaaaaaaa",
+ \ ">aaaaaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+ call s:close_windows('set breakindent& briopt& sbr&')
+endfunc
+
+func Test_breakindent20_cpo_n_nextpage()
+ let s:input = ""
+ call s:test_windows('setl breakindent briopt=min:14 cpo+=n number')
+ call setline(1, repeat('a', 200))
+ norm! 1gg
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ " 1 aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+ " Scroll down one screen line
+ setl scrolloff=5
+ norm! 5gj
+ redraw!
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ "--1 aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+
+ setl briopt+=shift:2
+ norm! 1gg
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ " 1 aaaaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+ " Scroll down one screen line
+ norm! 5gj
+ let lines = s:screen_lines(1, 20)
+ let expect = [
+ \ "--1 aaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ " aaaaaaaaaaaaaa",
+ \ ]
+ call s:compare_lines(expect, lines)
+
+ call s:close_windows('set breakindent& briopt& cpo& number&')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim
index a924ce0002..076f03fdd8 100644
--- a/src/nvim/testdir/test_bufline.vim
+++ b/src/nvim/testdir/test_bufline.vim
@@ -1,7 +1,7 @@
" Tests for setbufline(), getbufline(), appendbufline(), deletebufline()
source shared.vim
-" source screendump.vim
+source screendump.vim
func Test_setbufline_getbufline()
new
diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim
index 0e8c7d1dc1..cb7ab44798 100644
--- a/src/nvim/testdir/test_bufwintabinfo.vim
+++ b/src/nvim/testdir/test_bufwintabinfo.vim
@@ -139,3 +139,20 @@ function Test_get_win_options()
set foldlevel=0
endif
endfunc
+
+func Test_getbufinfo_lines()
+ new Xfoo
+ call setline(1, ['a', 'bc', 'd'])
+ let bn = bufnr('%')
+ hide
+ call assert_equal(3, getbufinfo(bn)[0]["linecount"])
+ edit Xfoo
+ bw!
+endfunc
+
+function Test_getbufinfo_lastused()
+ new Xfoo
+ let info = getbufinfo('Xfoo')[0]
+ call assert_equal(has_key(info, 'lastused'), 1)
+ call assert_equal(type(info.lastused), type(0))
+endfunc
diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim
index 7c2c5e341c..debc9da46d 100644
--- a/src/nvim/testdir/test_cindent.vim
+++ b/src/nvim/testdir/test_cindent.vim
@@ -18,25 +18,25 @@ endfunc
func Test_cino_extern_c()
" Test for cino-E
- let without_ind = [
- \ '#ifdef __cplusplus',
- \ 'extern "C" {',
- \ '#endif',
- \ 'int func_a(void);',
- \ '#ifdef __cplusplus',
- \ '}',
- \ '#endif'
- \ ]
+ let without_ind =<< trim [CODE]
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ int func_a(void);
+ #ifdef __cplusplus
+ }
+ #endif
+ [CODE]
- let with_ind = [
- \ '#ifdef __cplusplus',
- \ 'extern "C" {',
- \ '#endif',
- \ "\tint func_a(void);",
- \ '#ifdef __cplusplus',
- \ '}',
- \ '#endif'
- \ ]
+ let with_ind =<< trim [CODE]
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ int func_a(void);
+ #ifdef __cplusplus
+ }
+ #endif
+ [CODE]
new
setlocal cindent cinoptions=E0
call setline(1, without_ind)
@@ -89,17 +89,42 @@ func Test_cindent_expr()
return v:lnum == 1 ? shiftwidth() : 0
endfunc
setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction()
- call setline(1, ['var_a = something()', 'b = something()'])
+ let testinput =<< trim [CODE]
+ var_a = something()
+ b = something()
+ [CODE]
+ call setline(1, testinput)
call cursor(1, 1)
call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
- call assert_equal([' var_a = something();', 'b = something();'], getline(1, '$'))
+ let expected =<< [CODE]
+ var_a = something();
+b = something();
+[CODE]
+ call assert_equal(expected, getline(1, '$'))
%d
- call setline(1, [' var_a = something()', ' b = something()'])
+ let testinput =<< [CODE]
+ var_a = something()
+ b = something()
+[CODE]
+ call setline(1, testinput)
call cursor(1, 1)
call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
- call assert_equal([' var_a = something();', ' b = something()'], getline(1, '$'))
+ let expected =<< [CODE]
+ var_a = something();
+ b = something()
+[CODE]
+ call assert_equal(expected, getline(1, '$'))
bw!
endfunc
+" this was going beyond the end of the line.
+func Test_cindent_case()
+ new
+ call setline(1, "case x: // x")
+ set cindent
+ norm! f:a:
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim
index 813cb338a5..3377f86126 100644
--- a/src/nvim/testdir/test_clientserver.vim
+++ b/src/nvim/testdir/test_clientserver.vim
@@ -28,12 +28,11 @@ func Test_client_server()
let name = 'XVIMTEST'
let cmd .= ' --servername ' . name
let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
- call WaitFor({-> job_status(job) == "run"})
+ call WaitForAssert({-> assert_equal("run", job_status(job))})
" Takes a short while for the server to be active.
" When using valgrind it takes much longer.
- call WaitFor('serverlist() =~ "' . name . '"')
- call assert_match(name, serverlist())
+ call WaitForAssert({-> assert_match(name, serverlist())})
call remote_foreground(name)
@@ -54,12 +53,10 @@ func Test_client_server()
endif
" Wait for the server to be up and answering requests.
sleep 100m
- call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""')
- call assert_true(remote_expr(name, "v:version", "", 1) != "")
+ call WaitForAssert({-> assert_true(remote_expr(name, "v:version", "", 1) != "")})
call remote_send(name, ":let testvar = 'maybe'\<CR>")
- call WaitFor('remote_expr("' . name . '", "testvar", "", 1) == "maybe"')
- call assert_equal('maybe', remote_expr(name, "testvar", "", 2))
+ call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})
endif
call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241')
@@ -94,7 +91,7 @@ func Test_client_server()
call remote_send(name, ":qa!\<CR>")
try
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
if job_status(job) != 'dead'
call assert_report('Server did not exit')
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index e6aafd964b..f8d84f1a49 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -1,6 +1,5 @@
" Tests for editing the command line.
-
func Test_complete_tab()
call writefile(['testfile'], 'Xtestfile')
call feedkeys(":e Xtestf\t\r", "tx")
@@ -79,26 +78,45 @@ func Test_map_completion()
call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <silent> <special>', getreg(':'))
+ map <Middle>x middle
+
map ,f commaf
map ,g commaf
+ map <Left> left
+ map <A-Left>x shiftleft
call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map ,f', getreg(':'))
call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map ,g', getreg(':'))
+ call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal('"map <Left>', getreg(':'))
+ call feedkeys(":map <A-Left>\<Tab>\<Home>\"\<CR>", 'xt')
+ call assert_equal("\"map <A-Left>\<Tab>", getreg(':'))
unmap ,f
unmap ,g
+ unmap <Left>
+ unmap <A-Left>x
set cpo-=< cpo-=B cpo-=k
map <Left> left
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <Left>', getreg(':'))
+ call feedkeys(":map <M\<Tab>\<Home>\"\<CR>", 'xt')
+ " call assert_equal("\"map <M\<Tab>", getreg(':'))
unmap <Left>
" set cpo+=<
map <Left> left
+ exe "set t_k6=\<Esc>[17~"
+ call feedkeys(":map \<Esc>[17~x f6x\<CR>", 'xt')
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <Left>', getreg(':'))
+ if !has('gui_running')
+ call feedkeys(":map \<Esc>[17~\<Tab>\<Home>\"\<CR>", 'xt')
+ " call assert_equal("\"map <F6>x", getreg(':'))
+ endif
unmap <Left>
+ call feedkeys(":unmap \<Esc>[17~x\<CR>", 'xt')
set cpo-=<
set cpo+=B
@@ -114,6 +132,9 @@ func Test_map_completion()
call assert_equal('"map <Left>', getreg(':'))
unmap <Left>
" set cpo-=k
+
+ unmap <Middle>x
+ set cpo&vim
endfunc
func Test_match_completion()
@@ -160,6 +181,7 @@ func Test_expr_completion()
endif
for cmd in [
\ 'let a = ',
+ \ 'const a = ',
\ 'if',
\ 'elseif',
\ 'while',
@@ -302,7 +324,7 @@ func Test_getcompletion()
call assert_equal([], l)
let l = getcompletion('.', 'shellcmd')
- call assert_equal(['./', '../'], l[0:1])
+ call assert_equal(['./', '../'], filter(l, 'v:val =~ "\\./"'))
call assert_equal(-1, match(l[2:], '^\.\.\?/$'))
let root = has('win32') ? 'C:\\' : '/'
let l = getcompletion(root, 'shellcmd')
@@ -376,6 +398,29 @@ func Test_getcompletion()
call assert_fails('call getcompletion("", "burp")', 'E475:')
endfunc
+func Test_shellcmd_completion()
+ let save_path = $PATH
+
+ call mkdir('Xpathdir/Xpathsubdir', 'p')
+ call writefile([''], 'Xpathdir/Xfile.exe')
+ call setfperm('Xpathdir/Xfile.exe', 'rwx------')
+
+ " Set PATH to example directory without trailing slash.
+ let $PATH = getcwd() . '/Xpathdir'
+
+ " Test for the ":!<TAB>" case. Previously, this would include subdirs of
+ " dirs in the PATH, even though they won't be executed. We check that only
+ " subdirs of the PWD and executables from the PATH are included in the
+ " suggestions.
+ let actual = getcompletion('X', 'shellcmd')
+ let expected = map(filter(glob('*', 0, 1), 'isdirectory(v:val) && v:val[0] == "X"'), 'v:val . "/"')
+ call insert(expected, 'Xfile.exe')
+ call assert_equal(expected, actual)
+
+ call delete('Xpathdir', 'rf')
+ let $PATH = save_path
+endfunc
+
func Test_expand_star_star()
call mkdir('a/b', 'p')
call writefile(['asdfasdf'], 'a/b/fileXname')
@@ -477,6 +522,51 @@ func Test_cmdline_complete_user_cmd()
delcommand Foo
endfunc
+func Test_cmdline_complete_user_names()
+ if has('unix') && executable('whoami')
+ let whoami = systemlist('whoami')[0]
+ let first_letter = whoami[0]
+ if len(first_letter) > 0
+ " Trying completion of :e ~x where x is the first letter of
+ " the user name should complete to at least the user name.
+ call feedkeys(':e ~' . first_letter . "\<c-a>\<c-B>\"\<cr>", 'tx')
+ call assert_match('^"e \~.*\<' . whoami . '\>', @:)
+ endif
+ endif
+ if has('win32')
+ " Just in case: check that the system has an Administrator account.
+ let names = system('net user')
+ if names =~ 'Administrator'
+ " Trying completion of :e ~A should complete to Administrator.
+ " There could be other names starting with "A" before Administrator.
+ call feedkeys(':e ~A' . "\<c-a>\<c-B>\"\<cr>", 'tx')
+ call assert_match('^"e \~.*Administrator', @:)
+ endif
+ endif
+endfunc
+
+funct Test_cmdline_complete_languages()
+ let lang = substitute(execute('language messages'), '.*"\(.*\)"$', '\1', '')
+
+ call feedkeys(":language \<c-a>\<c-b>\"\<cr>", 'tx')
+ call assert_match('^"language .*\<ctype\>.*\<messages\>.*\<time\>', @:)
+
+ if has('unix')
+ " TODO: these tests don't work on Windows. lang appears to be 'C'
+ " but C does not appear in the completion. Why?
+ call assert_match('^"language .*\<' . lang . '\>', @:)
+
+ call feedkeys(":language messages \<c-a>\<c-b>\"\<cr>", 'tx')
+ call assert_match('^"language .*\<' . lang . '\>', @:)
+
+ call feedkeys(":language ctype \<c-a>\<c-b>\"\<cr>", 'tx')
+ call assert_match('^"language .*\<' . lang . '\>', @:)
+
+ call feedkeys(":language time \<c-a>\<c-b>\"\<cr>", 'tx')
+ call assert_match('^"language .*\<' . lang . '\>', @:)
+ endif
+endfunc
+
func Test_cmdline_write_alternatefile()
new
call setline('.', ['one', 'two'])
@@ -529,6 +619,8 @@ func Check_cmdline(cmdtype)
return ''
endfunc
+set cpo&
+
func Test_getcmdtype()
call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt")
@@ -569,6 +661,53 @@ func Test_getcmdwintype()
call assert_equal('', getcmdwintype())
endfunc
+func Test_getcmdwin_autocmd()
+ let s:seq = []
+ augroup CmdWin
+ au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid())
+ au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid())
+ au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr())
+ au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr())
+ au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid())
+ au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid())
+
+ let org_winid = win_getid()
+ let org_bufnr = bufnr()
+ call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!')
+ call assert_equal(':', a)
+ call assert_equal([
+ \ 'WinLeave ' .. org_winid,
+ \ 'WinEnter ' .. s:cmd_winid,
+ \ 'BufLeave ' .. org_bufnr,
+ \ 'BufEnter ' .. s:cmd_bufnr,
+ \ 'CmdWinEnter ' .. s:cmd_winid,
+ \ 'CmdWinLeave ' .. s:cmd_winid,
+ \ 'BufLeave ' .. s:cmd_bufnr,
+ \ 'WinLeave ' .. s:cmd_winid,
+ \ 'WinEnter ' .. org_winid,
+ \ 'BufEnter ' .. org_bufnr,
+ \ ], s:seq)
+
+ au!
+ augroup END
+endfunc
+
+" Test error: "E135: *Filter* Autocommands must not change current buffer"
+func Test_cmd_bang_E135()
+ new
+ call setline(1, ['a', 'b', 'c', 'd'])
+ augroup test_cmd_filter_E135
+ au!
+ autocmd FilterReadPost * help
+ augroup END
+ call assert_fails('2,3!echo "x"', 'E135:')
+
+ augroup test_cmd_filter_E135
+ au!
+ augroup END
+ %bwipe!
+endfunc
+
func Test_verbosefile()
set verbosefile=Xlog
echomsg 'foo'
@@ -628,4 +767,66 @@ func Test_cmdline_overstrike()
let &encoding = encoding_save
endfunc
-set cpo&
+func Test_cmdwin_feedkeys()
+ " This should not generate E488
+ call feedkeys("q:\<CR>", 'x')
+endfunc
+
+func Test_buffers_lastused()
+ " check that buffers are sorted by time when wildmode has lastused
+ edit bufc " oldest
+
+ sleep 1200m
+ enew
+ edit bufa " middle
+
+ sleep 1200m
+ enew
+ edit bufb " newest
+
+ enew
+
+ call assert_equal(['bufc', 'bufa', 'bufb'],
+ \ getcompletion('', 'buffer'))
+
+ let save_wildmode = &wildmode
+ set wildmode=full:lastused
+
+ let cap = "\<c-r>=execute('let X=getcmdline()')\<cr>"
+ call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt')
+ call assert_equal('b bufb', X)
+ call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt')
+ call assert_equal('b bufa', X)
+ call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt')
+ call assert_equal('b bufc', X)
+ enew
+
+ sleep 1200m
+ edit other
+ call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt')
+ call assert_equal('b bufb', X)
+ call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt')
+ call assert_equal('b bufa', X)
+ call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt')
+ call assert_equal('b bufc', X)
+ enew
+
+ let &wildmode = save_wildmode
+
+ bwipeout bufa
+ bwipeout bufb
+ bwipeout bufc
+endfunc
+
+" test that ";" works to find a match at the start of the first line
+func Test_zero_line_search()
+ new
+ call setline(1, ["1, pattern", "2, ", "3, pattern"])
+ call cursor(1,1)
+ 0;/pattern/d
+ call assert_equal(["2, ", "3, pattern"], getline(1,'$'))
+ q!
+endfunc
+
+
+" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_compiler.vim b/src/nvim/testdir/test_compiler.vim
index 46c14d8bc3..6bb602717f 100644
--- a/src/nvim/testdir/test_compiler.vim
+++ b/src/nvim/testdir/test_compiler.vim
@@ -10,6 +10,10 @@ func Test_compiler()
unlet $LANG
endif
+ " %:S does not work properly with 'shellslash' set
+ let save_shellslash = &shellslash
+ set noshellslash
+
e Xfoo.pl
compiler perl
call assert_equal('perl', b:current_compiler)
@@ -24,18 +28,21 @@ func Test_compiler()
w!
call feedkeys(":make\<CR>\<CR>", 'tx')
let a=execute('clist')
- call assert_match("\n 1 Xfoo.pl:3: Global symbol \"\$foo\" "
- \ . "requires explicit package name", a)
+ call assert_match('\n \d\+ Xfoo.pl:3: Global symbol "$foo" '
+ \ . 'requires explicit package name', a)
+
+ let &shellslash = save_shellslash
call delete('Xfoo.pl')
bw!
endfunc
func Test_compiler_without_arg()
- let a=split(execute('compiler'))
- call assert_match('^.*runtime/compiler/ant.vim$', a[0])
- call assert_match('^.*runtime/compiler/bcc.vim$', a[1])
- call assert_match('^.*runtime/compiler/xmlwf.vim$', a[-1])
+ let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
+ let a = split(execute('compiler'))
+ call assert_match(runtime .. '/compiler/ant.vim$', a[0])
+ call assert_match(runtime .. '/compiler/bcc.vim$', a[1])
+ call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1])
endfunc
func Test_compiler_completion()
diff --git a/src/nvim/testdir/test_const.vim b/src/nvim/testdir/test_const.vim
index 06062c5e58..eaf200e9bb 100644
--- a/src/nvim/testdir/test_const.vim
+++ b/src/nvim/testdir/test_const.vim
@@ -176,6 +176,26 @@ func Test_cannot_modify_existing_variable()
call assert_fails('const [i2, f2, s2] = [1, 1.1, "vim"]', 'E995:')
endfunc
+func Test_const_with_condition()
+ const x = 0
+ if 0 | const x = 1 | endif
+ call assert_equal(0, x)
+endfunc
+
+func Test_lockvar()
+ let x = 'hello'
+ lockvar x
+ call assert_fails('let x = "there"', 'E741')
+ if 0 | unlockvar x | endif
+ call assert_fails('let x = "there"', 'E741')
+ unlockvar x
+ let x = 'there'
+
+ if 0 | lockvar x | endif
+ let x = 'again'
+endfunc
+
+
func Test_const_with_index_access()
let l = [1, 2, 3]
call assert_fails('const l[0] = 4', 'E996:')
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim
index 037918fa31..2e190911b2 100644
--- a/src/nvim/testdir/test_cursor_func.vim
+++ b/src/nvim/testdir/test_cursor_func.vim
@@ -66,6 +66,7 @@ func Test_curswant_with_cursorline()
endfunc
func Test_screenpos()
+ throw 'skipped: TODO: '
rightbelow new
rightbelow 20vsplit
call setline(1, ["\tsome text", "long wrapping line here", "next line"])
@@ -92,3 +93,18 @@ func Test_screenpos()
close
bwipe!
endfunc
+
+func Test_screenpos_number()
+ rightbelow new
+ rightbelow 73vsplit
+ call setline (1, repeat('x', 66))
+ setlocal number
+ redraw
+ let winid = win_getid()
+ let [winrow, wincol] = win_screenpos(winid)
+ let pos = screenpos(winid, 1, 66)
+ call assert_equal(winrow, pos.row)
+ call assert_equal(wincol + 66 + 3, pos.col)
+ close
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_debugger.vim b/src/nvim/testdir/test_debugger.vim
index 3ef460b4fe..811717208e 100644
--- a/src/nvim/testdir/test_debugger.vim
+++ b/src/nvim/testdir/test_debugger.vim
@@ -1,7 +1,7 @@
" Tests for the Vim script debug commands
source shared.vim
-" source screendump.vim
+source screendump.vim
" Run a Vim debugger command
" If the expected output argument is supplied, then check for it.
@@ -26,27 +26,29 @@ func Test_Debugger()
endif
" Create a Vim script with some functions
- call writefile([
- \ 'func Foo()',
- \ ' let var1 = 1',
- \ ' let var2 = Bar(var1) + 9',
- \ ' return var2',
- \ 'endfunc',
- \ 'func Bar(var)',
- \ ' let var1 = 2 + a:var',
- \ ' let var2 = Bazz(var1) + 4',
- \ ' return var2',
- \ 'endfunc',
- \ 'func Bazz(var)',
- \ ' try',
- \ ' let var1 = 3 + a:var',
- \ ' let var3 = "another var"',
- \ ' let var3 = "value2"',
- \ ' catch',
- \ ' let var4 = "exception"',
- \ ' endtry',
- \ ' return var1',
- \ 'endfunc'], 'Xtest.vim')
+ let lines =<< trim END
+ func Foo()
+ let var1 = 1
+ let var2 = Bar(var1) + 9
+ return var2
+ endfunc
+ func Bar(var)
+ let var1 = 2 + a:var
+ let var2 = Bazz(var1) + 4
+ return var2
+ endfunc
+ func Bazz(var)
+ try
+ let var1 = 3 + a:var
+ let var3 = "another var"
+ let var3 = "value2"
+ catch
+ let var4 = "exception"
+ endtry
+ return var1
+ endfunc
+ END
+ call writefile(lines, 'Xtest.vim')
" Start Vim in a terminal
let buf = RunVimInTerminal('-S Xtest.vim', {})
@@ -294,11 +296,13 @@ func Test_Debugger()
" Tests for :breakadd file and :breakadd here
" Breakpoints should be set before sourcing the file
- call writefile([
- \ 'let var1 = 10',
- \ 'let var2 = 20',
- \ 'let var3 = 30',
- \ 'let var4 = 40'], 'Xtest.vim')
+ let lines =<< trim END
+ let var1 = 10
+ let var2 = 20
+ let var3 = 30
+ let var4 = 40
+ END
+ call writefile(lines, 'Xtest.vim')
" Start Vim in a terminal
let buf = RunVimInTerminal('Xtest.vim', {})
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 57b19aa817..a1f1dd3bab 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -1,4 +1,7 @@
" Tests for diff mode
+source shared.vim
+source screendump.vim
+source check.vim
func Test_diff_fold_sync()
enew!
@@ -67,7 +70,7 @@ func Common_vert_split()
set foldmethod=marker foldcolumn=4
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
- call assert_equal(4, &foldcolumn)
+ call assert_equal('4', &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)
@@ -76,7 +79,7 @@ func Common_vert_split()
vert diffsplit Xtest2
call assert_equal(1, &diff)
call assert_equal('diff', &foldmethod)
- call assert_equal(2, &foldcolumn)
+ call assert_equal('2', &foldcolumn)
call assert_equal(1, &scrollbind)
call assert_equal(1, &cursorbind)
call assert_equal(0, &wrap)
@@ -142,7 +145,7 @@ func Common_vert_split()
1wincmd w
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
- call assert_equal(4, &foldcolumn)
+ call assert_equal('4', &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)
@@ -150,7 +153,7 @@ func Common_vert_split()
wincmd w
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
- call assert_equal(4, &foldcolumn)
+ call assert_equal('4', &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)
@@ -158,7 +161,7 @@ func Common_vert_split()
wincmd w
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
- call assert_equal(4, &foldcolumn)
+ call assert_equal('4', &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)
@@ -773,3 +776,78 @@ func Test_diff_of_diff()
call StopVimInTerminal(buf)
call delete('Xtest_diff_diff')
endfunc
+
+func CloseoffSetup()
+ enew
+ call setline(1, ['one', 'two', 'three'])
+ diffthis
+ new
+ call setline(1, ['one', 'tow', 'three'])
+ diffthis
+ call assert_equal(1, &diff)
+ only!
+endfunc
+
+func Test_diff_closeoff()
+ " "closeoff" included by default: last diff win gets 'diff' reset'
+ call CloseoffSetup()
+ call assert_equal(0, &diff)
+ enew!
+
+ " "closeoff" excluded: last diff win keeps 'diff' set'
+ set diffopt-=closeoff
+ call CloseoffSetup()
+ call assert_equal(1, &diff)
+ diffoff!
+ enew!
+endfunc
+
+func Test_diff_rnu()
+ CheckScreendump
+
+ let content =<< trim END
+ call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
+ vnew
+ call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
+ call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
+ vnew
+ call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
+ windo diffthis
+ setlocal number rnu foldcolumn=0
+ END
+ call writefile(content, 'Xtest_diff_rnu')
+ let buf = RunVimInTerminal('-S Xtest_diff_rnu', {})
+
+ call VerifyScreenDump(buf, 'Test_diff_rnu_01', {})
+
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_diff_rnu_02', {})
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_diff_rnu_03', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('Xtest_diff_rnu')
+endfunc
+
+func Test_diff_and_scroll()
+ " this was causing an ml_get error
+ set ls=2
+ for i in range(winheight(0) * 2)
+ call setline(i, i < winheight(0) - 10 ? i : i + 10)
+ endfor
+ vnew
+ for i in range(winheight(0)*2 + 10)
+ call setline(i, i < winheight(0) - 10 ? 0 : i)
+ endfor
+ diffthis
+ wincmd p
+ diffthis
+ execute 'normal ' . winheight(0) . "\<C-d>"
+
+ bwipe!
+ bwipe!
+ set ls&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_digraph.vim b/src/nvim/testdir/test_digraph.vim
index 62a5da33df..1792dcc00b 100644
--- a/src/nvim/testdir/test_digraph.vim
+++ b/src/nvim/testdir/test_digraph.vim
@@ -433,6 +433,18 @@ func Test_digraphs_output()
call assert_equal('Z% Ж 1046', matchstr(out, '\C\<Z%\D*1046\>'))
call assert_equal('u- ū 363', matchstr(out, '\C\<u-\D*363\>'))
call assert_equal('SH ^A 1', matchstr(out, '\C\<SH\D*1\>'))
+ call assert_notmatch('Latin supplement', out)
+
+ let out_bang_without_custom = execute(':digraph!')
+ digraph lt 60
+ let out_bang_with_custom = execute(':digraph!')
+ call assert_notmatch('lt', out_bang_without_custom)
+ call assert_match("^\n"
+ \ .. "NU ^@ 10 .*\n"
+ \ .. "Latin supplement\n"
+ \ .. "!I ¡ 161 .*\n"
+ \ .. ".*\n"
+ \ .. 'Custom\n.*\<lt < 60\>', out_bang_with_custom)
bw!
endfunc
@@ -465,4 +477,17 @@ func Test_show_digraph()
bwipe!
endfunc
+func Test_show_digraph_cp1251()
+ throw 'skipped: Nvim supports ''utf8'' encoding only'
+ if !has('multi_byte')
+ return
+ endif
+ new
+ set encoding=cp1251
+ call Put_Dig("='")
+ call assert_equal("\n<\xfa> <|z> <M-z> 250, Hex fa, Oct 372, Digr ='", execute('ascii'))
+ set encoding=utf-8
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim
index 5feb59eef1..1c2f5a05ff 100644
--- a/src/nvim/testdir/test_display.vim
+++ b/src/nvim/testdir/test_display.vim
@@ -69,3 +69,59 @@ func! Test_display_foldtext_mbyte()
set foldtext& fillchars& foldmethod& fdc&
bw!
endfunc
+
+func Test_display_listchars_precedes()
+ set fillchars+=vert:\|
+ call NewWindow(10, 10)
+ " Need a physical line that wraps over the complete
+ " window size
+ call append(0, repeat('aaa aaa aa ', 10))
+ call append(1, repeat(['bbb bbb bbb bbb'], 2))
+ " remove blank trailing line
+ $d
+ set list nowrap
+ call cursor(1, 1)
+ " move to end of line and scroll 2 characters back
+ norm! $2zh
+ let lines=ScreenLines([1,4], winwidth(0)+1)
+ let expect = [
+ \ " aaa aa $ |",
+ \ "$ |",
+ \ "$ |",
+ \ "~ |",
+ \ ]
+ call assert_equal(expect, lines)
+ set list listchars+=precedes:< nowrap
+ call cursor(1, 1)
+ " move to end of line and scroll 2 characters back
+ norm! $2zh
+ let lines = ScreenLines([1,4], winwidth(0)+1)
+ let expect = [
+ \ "<aaa aa $ |",
+ \ "< |",
+ \ "< |",
+ \ "~ |",
+ \ ]
+ call assert_equal(expect, lines)
+ set wrap
+ call cursor(1, 1)
+ " the complete line should be displayed in the window
+ norm! $
+
+ let lines = ScreenLines([1,10], winwidth(0)+1)
+ let expect = [
+ \ "<aaa aaa a|",
+ \ "a aaa aaa |",
+ \ "aa aaa aaa|",
+ \ " aa aaa aa|",
+ \ "a aa aaa a|",
+ \ "aa aa aaa |",
+ \ "aaa aa aaa|",
+ \ " aaa aa aa|",
+ \ "a aaa aa a|",
+ \ "aa aaa aa |",
+ \ ]
+ call assert_equal(expect, lines)
+ set list& listchars& wrap&
+ bw!
+endfunc
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index 98fa9a3c47..12d5d9790e 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -1439,7 +1439,7 @@ func Test_edit_alt()
call delete('XAltFile')
endfunc
-func Test_leave_insert_autocmd()
+func Test_edit_InsertLeave()
new
au InsertLeave * let g:did_au = 1
let g:did_au = 0
@@ -1469,6 +1469,21 @@ func Test_leave_insert_autocmd()
iunmap x
endfunc
+func Test_edit_InsertLeave_undo()
+ new XtestUndo
+ set undofile
+ au InsertLeave * wall
+ exe "normal ofoo\<Esc>"
+ call assert_equal(2, line('$'))
+ normal u
+ call assert_equal(1, line('$'))
+
+ bwipe!
+ au! InsertLeave
+ call delete('XtestUndo')
+ set undofile&
+endfunc
+
" Test for inserting characters using CTRL-V followed by a number.
func Test_edit_special_chars()
new
diff --git a/src/nvim/testdir/test_escaped_glob.vim b/src/nvim/testdir/test_escaped_glob.vim
index aad3a1e835..2bfd82c296 100644
--- a/src/nvim/testdir/test_escaped_glob.vim
+++ b/src/nvim/testdir/test_escaped_glob.vim
@@ -17,7 +17,7 @@ function Test_glob()
" Setting 'shell' to an invalid name causes a memory leak.
sandbox call assert_equal("", glob('Xxx\{'))
sandbox call assert_equal("", glob('Xxx\$'))
- w! Xxx{
+ w! Xxx\{
" } to fix highlighting
w! Xxx\$
sandbox call assert_equal("Xxx{", glob('Xxx\{'))
diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim
index f5ce979208..4a027c3864 100644
--- a/src/nvim/testdir/test_excmd.vim
+++ b/src/nvim/testdir/test_excmd.vim
@@ -8,3 +8,35 @@ func Test_ex_delete()
.dl
call assert_equal(['a', 'c'], getline(1, 2))
endfunc
+
+func Test_buffers_lastused()
+ edit bufc " oldest
+
+ sleep 1200m
+ edit bufa " middle
+
+ sleep 1200m
+ edit bufb " newest
+
+ enew
+
+ let ls = split(execute('buffers t', 'silent!'), '\n')
+ let bufs = []
+ for line in ls
+ let bufs += [split(line, '"\s*')[1:2]]
+ endfor
+
+ let names = []
+ for buf in bufs
+ if buf[0] !=# '[No Name]'
+ let names += [buf[0]]
+ endif
+ endfor
+
+ call assert_equal(['bufb', 'bufa', 'bufc'], names)
+ call assert_match('[0-2] seconds ago', bufs[1][1])
+
+ bwipeout bufa
+ bwipeout bufb
+ bwipeout bufc
+endfunc
diff --git a/src/nvim/testdir/test_exit.vim b/src/nvim/testdir/test_exit.vim
index 8f02fd29e3..99a401d4a4 100644
--- a/src/nvim/testdir/test_exit.vim
+++ b/src/nvim/testdir/test_exit.vim
@@ -3,52 +3,78 @@
source shared.vim
func Test_exiting()
- let after = [
- \ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
- \ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
- \ 'quit',
- \ ]
+ let after =<< trim [CODE]
+ au QuitPre * call writefile(["QuitPre"], "Xtestout")
+ au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
+ quit
+ [CODE]
+
if RunVim([], after, '')
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
endif
call delete('Xtestout')
- let after = [
- \ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
- \ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
- \ 'help',
- \ 'wincmd w',
- \ 'quit',
- \ ]
+ let after =<< trim [CODE]
+ au QuitPre * call writefile(["QuitPre"], "Xtestout")
+ au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
+ help
+ wincmd w
+ quit
+ [CODE]
+
if RunVim([], after, '')
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
endif
call delete('Xtestout')
- let after = [
- \ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
- \ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
- \ 'split',
- \ 'new',
- \ 'qall',
- \ ]
+ let after =<< trim [CODE]
+ au QuitPre * call writefile(["QuitPre"], "Xtestout")
+ au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
+ split
+ new
+ qall
+ [CODE]
+
if RunVim([], after, '')
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
endif
call delete('Xtestout')
- let after = [
- \ 'au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")',
- \ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
- \ 'augroup nasty',
- \ ' au ExitPre * split',
- \ 'augroup END',
- \ 'quit',
- \ 'augroup nasty',
- \ ' au! ExitPre',
- \ 'augroup END',
- \ 'quit',
- \ ]
+ " ExitPre autocommand splits the window, so that it's no longer the last one.
+ let after =<< trim [CODE]
+ au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
+ au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
+ augroup nasty
+ au ExitPre * split
+ augroup END
+ quit
+ augroup nasty
+ au! ExitPre
+ augroup END
+ quit
+ [CODE]
+
+ if RunVim([], after, '')
+ call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
+ \ readfile('Xtestout'))
+ endif
+ call delete('Xtestout')
+
+ " ExitPre autocommand splits and closes the window, so that there is still
+ " one window but it's a different one.
+ let after =<< trim [CODE]
+ au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
+ au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
+ augroup nasty
+ au ExitPre * split | only
+ augroup END
+ quit
+ augroup nasty
+ au! ExitPre
+ augroup END
+ quit
+ [CODE]
+
if RunVim([], after, '')
call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
\ readfile('Xtestout'))
diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim
index 4f99625e73..264d8b000f 100644
--- a/src/nvim/testdir/test_expr.vim
+++ b/src/nvim/testdir/test_expr.vim
@@ -279,6 +279,9 @@ function Test_printf_misc()
call assert_equal('abc ', printf('%-4s', 'abc'))
call assert_equal('abc ', printf('%-4S', 'abc'))
+ call assert_equal('🐍', printf('%.2S', '🐍🐍'))
+ call assert_equal('', printf('%.1S', '🐍🐍'))
+
call assert_equal('1%', printf('%d%%', 1))
endfunc
@@ -472,6 +475,8 @@ func Test_funcref()
let OneByRef = funcref('One')
call assert_equal(2, OneByRef())
call assert_fails('echo funcref("{")', 'E475:')
+ let OneByRef = funcref("One", repeat(["foo"], 20))
+ call assert_fails('let OneByRef = funcref("One", repeat(["foo"], 21))', 'E118:')
endfunc
func Test_empty_concatenate()
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 7512d599b8..2e280417ae 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -54,6 +54,7 @@ let s:filename_checks = {
\ 'acedb': ['file.wrm'],
\ 'ada': ['file.adb', 'file.ads', 'file.ada', 'file.gpr'],
\ 'ahdl': ['file.tdf'],
+ \ 'aidl': ['file.aidl'],
\ 'alsaconf': ['.asoundrc', '/usr/share/alsa/alsa.conf', '/etc/asound.conf'],
\ 'aml': ['file.aml'],
\ 'ampl': ['file.run'],
@@ -79,6 +80,7 @@ let s:filename_checks = {
\ 'bib': ['file.bib'],
\ 'bindzone': ['named.root'],
\ 'blank': ['file.bl'],
+ \ 'bsdl': ['file.bsd', 'file.bsdl'],
\ 'bst': ['file.bst'],
\ 'bzr': ['bzr_log.any'],
\ 'c': ['enlightenment/file.cfg', 'file.qc', 'file.c'],
@@ -122,6 +124,7 @@ let s:filename_checks = {
\ 'cvs': ['cvs123'],
\ 'cvsrc': ['.cvsrc'],
\ 'cynpp': ['file.cyn'],
+ \ 'dart': ['file.dart', 'file.drt'],
\ 'datascript': ['file.ds'],
\ 'dcd': ['file.dcd'],
\ 'debcontrol': ['/debian/control'],
@@ -129,7 +132,7 @@ let s:filename_checks = {
\ 'def': ['file.def'],
\ 'denyhosts': ['denyhosts.conf'],
\ 'desc': ['file.desc'],
- \ 'desktop': ['file.desktop', '.directory'],
+ \ 'desktop': ['file.desktop', '.directory', 'file.directory'],
\ 'dictconf': ['dict.conf', '.dictrc'],
\ 'dictdconf': ['dictd.conf'],
\ 'diff': ['file.diff', 'file.rej'],
@@ -137,8 +140,8 @@ let s:filename_checks = {
\ 'dnsmasq': ['/etc/dnsmasq.conf'],
\ 'dockerfile': ['Dockerfile', 'file.Dockerfile'],
\ 'dosbatch': ['file.bat', 'file.sys'],
- \ 'dosini': ['.editorconfig', '/etc/yum.conf', 'file.ini'],
- \ 'dot': ['file.dot'],
+ \ 'dosini': ['.editorconfig', '/etc/pacman.conf', '/etc/yum.conf', 'file.ini'],
+ \ 'dot': ['file.dot', 'file.gv'],
\ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe'],
\ 'dsl': ['file.dsl'],
\ 'dtd': ['file.dtd'],
@@ -148,7 +151,8 @@ let s:filename_checks = {
\ 'dylanlid': ['file.lid'],
\ 'ecd': ['file.ecd'],
\ 'edif': ['file.edf', 'file.edif', 'file.edo'],
- \ 'elinks': ['/etc/elinks.conf', '/.elinks/elinks.conf'],
+ \ 'elinks': ['elinks.conf'],
+ \ 'elm': ['file.elm'],
\ 'elmfilt': ['filter-rules'],
\ 'erlang': ['file.erl', 'file.hrl', 'file.yaws'],
\ 'eruby': ['file.erb', 'file.rhtml'],
@@ -201,6 +205,7 @@ let s:filename_checks = {
\ 'hex': ['file.hex', 'file.h32'],
\ 'hgcommit': ['hg-editor-file.txt'],
\ 'hog': ['file.hog', 'snort.conf', 'vision.conf'],
+ \ 'hollywood': ['file.hws'],
\ 'hostconf': ['/etc/host.conf'],
\ 'hostsaccess': ['/etc/hosts.allow', '/etc/hosts.deny'],
\ 'template': ['file.tmpl'],
@@ -221,7 +226,7 @@ let s:filename_checks = {
\ 'jam': ['file.jpl', 'file.jpr'],
\ 'java': ['file.java', 'file.jav'],
\ 'javacc': ['file.jj', 'file.jjt'],
- \ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.mjs'],
+ \ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.mjs', 'file.cjs'],
\ 'javascriptreact': ['file.jsx'],
\ 'jess': ['file.clp'],
\ 'jgraph': ['file.jgr'],
@@ -232,6 +237,7 @@ let s:filename_checks = {
\ 'kconfig': ['Kconfig', 'Kconfig.debug'],
\ 'kivy': ['file.kv'],
\ 'kix': ['file.kix'],
+ \ 'kotlin': ['file.kt', 'file.ktm', 'file.kts'],
\ 'kscript': ['file.ks'],
\ 'kwt': ['file.k'],
\ 'lace': ['file.ace', 'file.ACE'],
@@ -247,7 +253,7 @@ let s:filename_checks = {
\ 'lilo': ['lilo.conf'],
\ 'limits': ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf'],
\ 'liquid': ['file.liquid'],
- \ 'lisp': ['sbclrc', '.sbclrc'],
+ \ 'lisp': ['file.lsp', 'file.lisp', 'file.el', 'file.cl', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc'],
\ 'lite': ['file.lite', 'file.lt'],
\ 'litestep': ['/LiteStep/any/file.rc'],
\ 'loginaccess': ['/etc/login.access'],
@@ -273,6 +279,7 @@ let s:filename_checks = {
\ 'mason': ['file.mason', 'file.mhtml', 'file.comp'],
\ 'master': ['file.mas', 'file.master'],
\ 'mel': ['file.mel'],
+ \ 'meson': ['meson.build', 'meson_options.txt'],
\ 'messages': ['/log/auth', '/log/cron', '/log/daemon', '/log/debug', '/log/kern', '/log/lpr', '/log/mail', '/log/messages', '/log/news/news', '/log/syslog', '/log/user',
\ '/log/auth.log', '/log/cron.log', '/log/daemon.log', '/log/debug.log', '/log/kern.log', '/log/lpr.log', '/log/mail.log', '/log/messages.log', '/log/news/news.log', '/log/syslog.log', '/log/user.log',
\ '/log/auth.err', '/log/cron.err', '/log/daemon.err', '/log/debug.err', '/log/kern.err', '/log/lpr.err', '/log/mail.err', '/log/messages.err', '/log/news/news.err', '/log/syslog.err', '/log/user.err',
@@ -316,13 +323,14 @@ let s:filename_checks = {
\ 'openroad': ['file.or'],
\ 'ora': ['file.ora'],
\ 'pamconf': ['/etc/pam.conf'],
+ \ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment'],
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
\ 'pascal': ['file.pas', 'file.dpr'],
\ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak'],
\ 'pccts': ['file.g'],
\ 'pdf': ['file.pdf'],
\ 'perl': ['file.plx', 'file.al', 'file.psgi', 'gitolite.rc', '.gitolite.rc', 'example.gitolite.rc'],
- \ 'perl6': ['file.p6', 'file.pm6', 'file.pl6'],
+ \ 'perl6': ['file.p6', 'file.pm6', 'file.pl6', 'file.raku', 'file.rakumod'],
\ 'pf': ['pf.conf'],
\ 'pfmain': ['main.cf'],
\ 'php': ['file.php', 'file.php9', 'file.phtml', 'file.ctp'],
@@ -353,7 +361,7 @@ let s:filename_checks = {
\ 'protocols': ['/etc/protocols'],
\ 'psf': ['file.psf'],
\ 'pyrex': ['file.pyx', 'file.pxd'],
- \ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi'],
+ \ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi', 'SConstruct'],
\ 'quake': ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg'],
\ 'radiance': ['file.rad', 'file.mat'],
\ 'ratpoison': ['.ratpoisonrc', 'ratpoisonrc'],
@@ -361,6 +369,7 @@ let s:filename_checks = {
\ 'rcs': ['file,v'],
\ 'readline': ['.inputrc', 'inputrc'],
\ 'remind': ['.reminders', 'file.remind', 'file.rem'],
+ \ 'rego': ['file.rego'],
\ 'resolv': ['resolv.conf'],
\ 'reva': ['file.frt'],
\ 'rexx': ['file.rex', 'file.orx', 'file.rxo', 'file.rxj', 'file.jrexx', 'file.rexxj', 'file.rexx', 'file.testGroup', 'file.testUnit'],
@@ -419,16 +428,19 @@ let s:filename_checks = {
\ 'sqr': ['file.sqr', 'file.sqi'],
\ 'squid': ['squid.conf'],
\ 'srec': ['file.s19', 'file.s28', 'file.s37', 'file.mot', 'file.srec'],
- \ 'sshconfig': ['ssh_config', '/.ssh/config'],
- \ 'sshdconfig': ['sshd_config'],
+ \ 'sshconfig': ['ssh_config', '/.ssh/config', '/etc/ssh/ssh_config.d/file.conf', 'any/etc/ssh/ssh_config.d/file.conf'],
+ \ 'sshdconfig': ['sshd_config', '/etc/ssh/sshd_config.d/file.conf', 'any/etc/ssh/sshd_config.d/file.conf'],
\ 'st': ['file.st'],
\ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'],
\ 'stp': ['file.stp'],
\ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp'],
\ 'svg': ['file.svg'],
\ 'svn': ['svn-commitfile.tmp'],
+ \ 'swift': ['file.swift'],
+ \ 'swiftgyb': ['file.swift.gyb'],
+ \ 'sil': ['file.sil'],
\ 'sysctl': ['/etc/sysctl.conf', '/etc/sysctl.d/file.conf'],
- \ 'systemd': ['any/systemd/file.automount', 'any/systemd/file.mount', 'any/systemd/file.path', 'any/systemd/file.service', 'any/systemd/file.socket', 'any/systemd/file.swap', 'any/systemd/file.target', 'any/systemd/file.timer', '/etc/systemd/system/some.d/file.conf', '/etc/systemd/system/some.d/.#file'],
+ \ 'systemd': ['any/systemd/file.automount', 'any/systemd/file.dnssd', 'any/systemd/file.link', 'any/systemd/file.mount', 'any/systemd/file.netdev', 'any/systemd/file.network', 'any/systemd/file.nspawn', 'any/systemd/file.path', 'any/systemd/file.service', 'any/systemd/file.slice', 'any/systemd/file.socket', 'any/systemd/file.swap', 'any/systemd/file.target', 'any/systemd/file.timer', '/etc/systemd/some.conf.d/file.conf', '/etc/systemd/system/some.d/file.conf', '/etc/systemd/system/some.d/.#file', '/etc/systemd/system/.#otherfile', '/home/user/.config/systemd/user/some.d/mine.conf', '/home/user/.config/systemd/user/some.d/.#file', '/home/user/.config/systemd/user/.#otherfile'],
\ 'systemverilog': ['file.sv', 'file.svh'],
\ 'tags': ['tags'],
\ 'tak': ['file.tak'],
@@ -472,7 +484,7 @@ let s:filename_checks = {
\ 'verilog': ['file.v'],
\ 'verilogams': ['file.va', 'file.vams'],
\ 'vgrindefs': ['vgrindefs'],
- \ 'vhdl': ['file.hdl', 'file.vhd', 'file.vhdl', 'file.vbe', 'file.vst', 'file.vhdl_123'],
+ \ 'vhdl': ['file.hdl', 'file.vhd', 'file.vhdl', 'file.vbe', 'file.vst', 'file.vhdl_123', 'file.vho'],
\ 'vim': ['file.vim', 'file.vba', '.exrc', '_exrc'],
\ 'viminfo': ['.viminfo', '_viminfo'],
\ 'vmasm': ['file.mar'],
@@ -592,11 +604,22 @@ let s:script_checks = {
\ 'haskell': [['#!/path/haskell']],
\ 'cpp': [['// Standard iostream objects -*- C++ -*-'],
\ ['// -*- C++ -*-']],
+ \ 'yaml': [['%YAML 1.2']],
\ }
-func Test_script_detection()
+" Various forms of "env" optional arguments.
+let s:script_env_checks = {
+ \ 'perl': [['#!/usr/bin/env VAR=val perl']],
+ \ 'scala': [['#!/usr/bin/env VAR=val VVAR=vval scala']],
+ \ 'awk': [['#!/usr/bin/env VAR=val -i awk']],
+ \ 'scheme': [['#!/usr/bin/env VAR=val --ignore-environment scheme']],
+ \ 'python': [['#!/usr/bin/env VAR=val -S python -w -T']],
+ \ 'wml': [['#!/usr/bin/env VAR=val --split-string wml']],
+ \ }
+
+func Run_script_detection(test_dict)
filetype on
- for [ft, files] in items(s:script_checks)
+ for [ft, files] in items(a:test_dict)
for file in files
call writefile(file, 'Xtest')
split Xtest
@@ -608,7 +631,32 @@ func Test_script_detection()
filetype off
endfunc
+func Test_script_detection()
+ call Run_script_detection(s:script_checks)
+ call Run_script_detection(s:script_env_checks)
+endfunc
+
func Test_setfiletype_completion()
call feedkeys(":setfiletype java\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"setfiletype java javacc javascript javascriptreact', @:)
endfunc
+
+func Test_hook_file()
+ filetype on
+
+ call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook')
+ split Xfile.hook
+ call assert_equal('dosini', &filetype)
+ bwipe!
+
+ call writefile(['not pacman'], 'Xfile.hook')
+ split Xfile.hook
+ call assert_notequal('dosini', &filetype)
+ bwipe!
+
+ call delete('Xfile.hook')
+ filetype off
+endfunc
+
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_flatten.vim b/src/nvim/testdir/test_flatten.vim
new file mode 100644
index 0000000000..99086611e1
--- /dev/null
+++ b/src/nvim/testdir/test_flatten.vim
@@ -0,0 +1,81 @@
+" Test for flatting list.
+func Test_flatten()
+ call assert_fails('call flatten(1)', 'E686:')
+ call assert_fails('call flatten({})', 'E686:')
+ call assert_fails('call flatten("string")', 'E686:')
+ call assert_fails('call flatten([], [])', 'E745:')
+ call assert_fails('call flatten([], -1)', 'E900: maxdepth')
+
+ call assert_equal([], flatten([]))
+ call assert_equal([], flatten([[]]))
+ call assert_equal([], flatten([[[]]]))
+
+ call assert_equal([1, 2, 3], flatten([1, 2, 3]))
+ call assert_equal([1, 2, 3], flatten([[1], 2, 3]))
+ call assert_equal([1, 2, 3], flatten([1, [2], 3]))
+ call assert_equal([1, 2, 3], flatten([1, 2, [3]]))
+ call assert_equal([1, 2, 3], flatten([[1], [2], 3]))
+ call assert_equal([1, 2, 3], flatten([1, [2], [3]]))
+ call assert_equal([1, 2, 3], flatten([[1], 2, [3]]))
+ call assert_equal([1, 2, 3], flatten([[1], [2], [3]]))
+
+ call assert_equal([1, 2, 3], flatten([[1, 2, 3], []]))
+ call assert_equal([1, 2, 3], flatten([[], [1, 2, 3]]))
+ call assert_equal([1, 2, 3], flatten([[1, 2], [], [3]]))
+ call assert_equal([1, 2, 3], flatten([[], [1, 2, 3], []]))
+ call assert_equal([1, 2, 3, 4], flatten(range(1, 4)))
+
+ " example in the help
+ call assert_equal([1, 2, 3, 4, 5], flatten([1, [2, [3, 4]], 5]))
+ call assert_equal([1, 2, [3, 4], 5], flatten([1, [2, [3, 4]], 5], 1))
+
+ call assert_equal([0, [1], 2, [3], 4], flatten([[0, [1]], 2, [[3], 4]], 1))
+ call assert_equal([1, 2, 3], flatten([[[[1]]], [2], [3]], 3))
+ call assert_equal([[1], [2], [3]], flatten([[[1], [2], [3]]], 1))
+ call assert_equal([[1]], flatten([[1]], 0))
+
+ " Make it flatten if the given maxdepth is larger than actual depth.
+ call assert_equal([1, 2, 3], flatten([[1, 2, 3]], 1))
+ call assert_equal([1, 2, 3], flatten([[1, 2, 3]], 2))
+
+ let l:list = [[1], [2], [3]]
+ call assert_equal([1, 2, 3], flatten(l:list))
+ call assert_equal([1, 2, 3], l:list)
+
+ " Tests for checking reference counter works well.
+ let l:x = {'foo': 'bar'}
+ call assert_equal([1, 2, l:x, 3], flatten([1, [2, l:x], 3]))
+ call test_garbagecollect_now()
+ call assert_equal('bar', l:x.foo)
+
+ let l:list = [[1], [2], [3]]
+ call assert_equal([1, 2, 3], flatten(l:list))
+ call test_garbagecollect_now()
+ call assert_equal([1, 2, 3], l:list)
+
+ " Tests for checking circular reference list can be flatten.
+ let l:x = [1]
+ let l:y = [x]
+ let l:z = flatten(l:y)
+ call assert_equal([1], l:z)
+ call test_garbagecollect_now()
+ let l:x[0] = 2
+ call assert_equal([2], l:x)
+ call assert_equal([1], l:z) " NOTE: primitive types are copied.
+ call assert_equal([1], l:y)
+
+ let l:x = [2]
+ let l:y = [1, [l:x], 3] " [1, [[2]], 3]
+ let l:z = flatten(l:y, 1)
+ call assert_equal([1, [2], 3], l:z)
+ let l:x[0] = 9
+ call assert_equal([1, [9], 3], l:z) " Reference to l:x is kept.
+ call assert_equal([1, [9], 3], l:y)
+
+ let l:x = [1]
+ let l:y = [2]
+ call add(x, y) " l:x = [1, [2]]
+ call add(y, x) " l:y = [2, [1, [...]]]
+ call assert_equal([1, 2, 1, 2], flatten(l:x, 2))
+ call assert_equal([2, l:x], l:y)
+endfunc
diff --git a/src/nvim/testdir/test_fnamemodify.vim b/src/nvim/testdir/test_fnamemodify.vim
new file mode 100644
index 0000000000..116d23ba88
--- /dev/null
+++ b/src/nvim/testdir/test_fnamemodify.vim
@@ -0,0 +1,75 @@
+" Test filename modifiers.
+
+func Test_fnamemodify()
+ let save_home = $HOME
+ let save_shell = &shell
+ let $HOME = fnamemodify('.', ':p:h:h')
+ set shell=sh
+
+ call assert_equal('/', fnamemodify('.', ':p')[-1:])
+ call assert_equal('r', fnamemodify('.', ':p:h')[-1:])
+ call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
+ call assert_equal('test.out', fnamemodify('test.out', ':.'))
+ call assert_equal('a', fnamemodify('../testdir/a', ':.'))
+ call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
+ call assert_equal('~/testdir/a', fnamemodify('../testdir/a', ':~'))
+ call assert_equal('a', fnamemodify('../testdir/a', ':t'))
+ call assert_equal('', fnamemodify('.', ':p:t'))
+ call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
+ call assert_equal('out', fnamemodify('test.out', ':p:e'))
+ call assert_equal('out', fnamemodify('test.out', ':p:t:e'))
+ call assert_equal('abc.fb2.tar', fnamemodify('abc.fb2.tar.gz', ':r'))
+ call assert_equal('abc.fb2', fnamemodify('abc.fb2.tar.gz', ':r:r'))
+ call assert_equal('abc', fnamemodify('abc.fb2.tar.gz', ':r:r:r'))
+ call assert_equal('testdir/abc.fb2', substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', ''))
+ call assert_equal('gz', fnamemodify('abc.fb2.tar.gz', ':e'))
+ call assert_equal('tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e'))
+ call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e'))
+ call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e:e'))
+ call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r'))
+
+ call assert_equal('''abc def''', fnamemodify('abc def', ':S'))
+ call assert_equal('''abc" "def''', fnamemodify('abc" "def', ':S'))
+ call assert_equal('''abc"%"def''', fnamemodify('abc"%"def', ':S'))
+ call assert_equal('''abc''\'''' ''\''''def''', fnamemodify('abc'' ''def', ':S'))
+ call assert_equal('''abc''\''''%''\''''def''', fnamemodify('abc''%''def', ':S'))
+ sp test_alot.vim
+ call assert_equal(expand('%:r:S'), shellescape(expand('%:r')))
+ call assert_equal('test_alot,''test_alot'',test_alot.vim', join([expand('%:r'), expand('%:r:S'), expand('%')], ','))
+ quit
+
+ call assert_equal("'abc\ndef'", fnamemodify("abc\ndef", ':S'))
+ set shell=tcsh
+ call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
+
+ let $HOME = save_home
+ let &shell = save_shell
+endfunc
+
+func Test_fnamemodify_er()
+ call assert_equal("with", fnamemodify("path/to/file.with.extensions", ':e:e:r:r'))
+
+ call assert_equal('c', fnamemodify('a.c', ':e'))
+ call assert_equal('c', fnamemodify('a.c', ':e:e'))
+ call assert_equal('c', fnamemodify('a.c', ':e:e:r'))
+ call assert_equal('c', fnamemodify('a.c', ':e:e:r:r'))
+
+ call assert_equal('rb', fnamemodify('a.spec.rb', ':e:r'))
+ call assert_equal('rb', fnamemodify('a.spec.rb', ':e:r'))
+ call assert_equal('spec.rb', fnamemodify('a.spec.rb', ':e:e'))
+ call assert_equal('spec', fnamemodify('a.spec.rb', ':e:e:r'))
+ call assert_equal('spec', fnamemodify('a.spec.rb', ':e:e:r:r'))
+ call assert_equal('spec', fnamemodify('a.b.spec.rb', ':e:e:r'))
+ call assert_equal('b.spec', fnamemodify('a.b.spec.rb', ':e:e:e:r'))
+ call assert_equal('b', fnamemodify('a.b.spec.rb', ':e:e:e:r:r'))
+
+ call assert_equal('spec', fnamemodify('a.b.spec.rb', ':r:e'))
+ call assert_equal('b', fnamemodify('a.b.spec.rb', ':r:r:e'))
+
+ call assert_equal('c', fnamemodify('a.b.c.d.e', ':r:r:e'))
+ call assert_equal('b.c', fnamemodify('a.b.c.d.e', ':r:r:e:e'))
+
+ " :e never includes the whole filename, so "a.b":e:e:e --> "b"
+ call assert_equal('b.c', fnamemodify('a.b.c.d.e', ':r:r:e:e:e'))
+ call assert_equal('b.c', fnamemodify('a.b.c.d.e', ':r:r:e:e:e:e'))
+endfunc
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index 3cb42579be..692f6e4780 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -1,6 +1,7 @@
" Test for folding
source view_util.vim
+source screendump.vim
func PrepIndent(arg)
return [a:arg] + repeat(["\t".a:arg], 5)
@@ -520,17 +521,18 @@ func Test_fold_create_marker_in_C()
set fdm=marker fdl=9
set filetype=c
- let content = [
- \ '/*',
- \ ' * comment',
- \ ' * ',
- \ ' *',
- \ ' */',
- \ 'int f(int* p) {',
- \ ' *p = 3;',
- \ ' return 0;',
- \ '}'
- \]
+ let content =<< trim [CODE]
+ /*
+ * comment
+ *
+ *
+ */
+ int f(int* p) {
+ *p = 3;
+ return 0;
+ }
+ [CODE]
+
for c in range(len(content) - 1)
bw!
call append(0, content)
@@ -756,3 +758,40 @@ func Test_fold_delete_with_marker()
bwipe!
bwipe!
endfunc
+
+func Test_fold_delete_with_marker_and_whichwrap()
+ new
+ let content1 = ['']
+ let content2 = ['folded line 1 "{{{1', ' test', ' test2', ' test3', '', 'folded line 2 "{{{1', ' test', ' test2', ' test3']
+ call setline(1, content1 + content2)
+ set fdm=marker ww+=l
+ normal! x
+ call assert_equal(content2, getline(1, '$'))
+ set fdm& ww&
+ bwipe!
+endfunc
+
+func Test_fold_delete_first_line()
+ new
+ call setline(1, [
+ \ '" x {{{1',
+ \ '" a',
+ \ '" aa',
+ \ '" x {{{1',
+ \ '" b',
+ \ '" bb',
+ \ '" x {{{1',
+ \ '" c',
+ \ '" cc',
+ \ ])
+ set foldmethod=marker
+ 1
+ normal dj
+ call assert_equal([
+ \ '" x {{{1',
+ \ '" c',
+ \ '" cc',
+ \ ], getline(1,'$'))
+ bwipe!
+ set foldmethod&
+endfunc
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index a36c51f56f..51689db9c4 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -186,6 +186,32 @@ func Test_strftime()
call assert_fails('call strftime([])', 'E730:')
call assert_fails('call strftime("%Y", [])', 'E745:')
+
+ " Check that the time changes after we change the timezone
+ " Save previous timezone value, if any
+ if exists('$TZ')
+ let tz = $TZ
+ endif
+
+ " Force EST and then UTC, save the current hour (24-hour clock) for each
+ let $TZ = 'EST' | let est = strftime('%H')
+ let $TZ = 'UTC' | let utc = strftime('%H')
+
+ " Those hours should be two bytes long, and should not be the same; if they
+ " are, a tzset(3) call may have failed somewhere
+ call assert_equal(strlen(est), 2)
+ call assert_equal(strlen(utc), 2)
+ " TODO: this fails on MS-Windows
+ if has('unix')
+ call assert_notequal(est, utc)
+ endif
+
+ " If we cached a timezone value, put it back, otherwise clear it
+ if exists('tz')
+ let $TZ = tz
+ else
+ unlet $TZ
+ endif
endfunc
func Test_resolve()
@@ -640,6 +666,16 @@ func Test_getbufvar()
call assert_equal('iso-8859-2', getbufvar(bufnr('%'), '&fenc'))
close
+ " Get the b: dict.
+ let b:testvar = 'one'
+ new
+ let b:testvar = 'two'
+ let thebuf = bufnr()
+ wincmd w
+ call assert_equal('two', getbufvar(thebuf, 'testvar'))
+ call assert_equal('two', getbufvar(thebuf, '').testvar)
+ bwipe!
+
set fileformats&
endfunc
@@ -1132,6 +1168,13 @@ func Test_reg_executing_and_recording()
" :normal command saves and restores reg_executing
let s:reg_stat = ''
+ let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>"
+ func TestFunc() abort
+ normal! ia
+ endfunc
+ call feedkeys("@q", 'xt')
+ call assert_equal(':q', s:reg_stat)
+ delfunc TestFunc
" getchar() command saves and restores reg_executing
map W :call TestFunc()<CR>
@@ -1264,3 +1307,33 @@ func Test_bufadd_bufload()
bwipe otherName
call assert_equal(0, bufexists('someName'))
endfunc
+
+func Test_readdir()
+ call mkdir('Xdir')
+ call writefile([], 'Xdir/foo.txt')
+ call writefile([], 'Xdir/bar.txt')
+ call mkdir('Xdir/dir')
+
+ " All results
+ let files = readdir('Xdir')
+ call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
+
+ " Only results containing "f"
+ let files = readdir('Xdir', { x -> stridx(x, 'f') !=- 1 })
+ call assert_equal(['foo.txt'], sort(files))
+
+ " Only .txt files
+ let files = readdir('Xdir', { x -> x =~ '.txt$' })
+ call assert_equal(['bar.txt', 'foo.txt'], sort(files))
+
+ " Only .txt files with string
+ let files = readdir('Xdir', 'v:val =~ ".txt$"')
+ call assert_equal(['bar.txt', 'foo.txt'], sort(files))
+
+ " Limit to 1 result.
+ let l = []
+ let files = readdir('Xdir', {x -> len(add(l, x)) == 2 ? -1 : 1})
+ call assert_equal(1, len(files))
+
+ call delete('Xdir', 'rf')
+endfunc
diff --git a/src/nvim/testdir/test_ga.vim b/src/nvim/testdir/test_ga.vim
index ea3d211aeb..87f1382342 100644
--- a/src/nvim/testdir/test_ga.vim
+++ b/src/nvim/testdir/test_ga.vim
@@ -24,6 +24,7 @@ func Test_ga_command()
" Test a few multi-bytes characters.
call assert_equal("\n<é> 233, Hex 00e9, Oct 351, Digr e'", Do_ga('é'))
call assert_equal("\n<ẻ> 7867, Hex 1ebb, Oct 17273, Digr e2", Do_ga('ẻ'))
+ call assert_equal("\n<\U00012345> 74565, Hex 00012345, Octal 221505", Do_ga("\U00012345"))
" Test with combining characters.
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401", Do_ga("e\u0301"))
diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim
index accd21e9a3..4a4ffcefa1 100644
--- a/src/nvim/testdir/test_gf.vim
+++ b/src/nvim/testdir/test_gf.vim
@@ -58,6 +58,14 @@ func Test_gF()
call assert_equal('Xfile', bufname('%'))
call assert_equal(3, getcurpos()[1])
+ enew!
+ call setline(1, ['one', 'the Xfile line 2, and more', 'three'])
+ w! Xfile2
+ normal 2GfX
+ normal gF
+ call assert_equal('Xfile', bufname('%'))
+ call assert_equal(2, getcurpos()[1])
+
set isfname&
call delete('Xfile')
call delete('Xfile2')
@@ -99,3 +107,28 @@ func Test_gf()
call delete('Xtest1')
call delete('Xtestgf')
endfunc
+
+func Test_gf_visual()
+ call writefile([], "Xtest_gf_visual")
+ new
+ call setline(1, 'XXXtest_gf_visualXXX')
+ set hidden
+
+ " Visually select Xtest_gf_visual and use gf to go to that file
+ norm! ttvtXgf
+ call assert_equal('Xtest_gf_visual', bufname('%'))
+
+ bwipe!
+ call delete('Xtest_gf_visual')
+ set hidden&
+endfunc
+
+func Test_gf_error()
+ new
+ call assert_fails('normal gf', 'E446:')
+ call assert_fails('normal gF', 'E446:')
+ call setline(1, '/doesnotexist')
+ call assert_fails('normal gf', 'E447:')
+ call assert_fails('normal gF', 'E447:')
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_gn.vim b/src/nvim/testdir/test_gn.vim
index 5e74289b00..d41675be0c 100644
--- a/src/nvim/testdir/test_gn.vim
+++ b/src/nvim/testdir/test_gn.vim
@@ -129,6 +129,33 @@ func Test_gn_command()
call assert_equal([' nnoremap', '', 'match'], getline(1,'$'))
sil! %d_
+ " make sure it works correctly for one-char wide search items
+ call setline('.', ['abcdefghi'])
+ let @/ = 'a'
+ exe "norm! 0fhvhhgNgU"
+ call assert_equal(['ABCDEFGHi'], getline(1,'$'))
+ call setline('.', ['abcdefghi'])
+ let @/ = 'b'
+ " this gn wraps around the end of the file
+ exe "norm! 0fhvhhgngU"
+ call assert_equal(['aBCDEFGHi'], getline(1,'$'))
+ sil! %d _
+ call setline('.', ['abcdefghi'])
+ let @/ = 'f'
+ exe "norm! 0vllgngU"
+ call assert_equal(['ABCDEFghi'], getline(1,'$'))
+ sil! %d _
+ call setline('.', ['12345678'])
+ let @/ = '5'
+ norm! gg0f7vhhhhgnd
+ call assert_equal(['12348'], getline(1,'$'))
+ sil! %d _
+ call setline('.', ['12345678'])
+ let @/ = '5'
+ norm! gg0f2vf7gNd
+ call assert_equal(['1678'], getline(1,'$'))
+ sil! %d _
+
set wrapscan&vim
set belloff&vim
endfu
diff --git a/src/nvim/testdir/test_goto.vim b/src/nvim/testdir/test_goto.vim
index c0235b1707..19513b315a 100644
--- a/src/nvim/testdir/test_goto.vim
+++ b/src/nvim/testdir/test_goto.vim
@@ -15,262 +15,283 @@ func XTest_goto_decl(cmd, lines, line, col)
endfunc
func Test_gD()
- let lines = [
- \ 'int x;',
- \ '',
- \ 'int func(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int x;
+
+ int func(void)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gD', lines, 1, 5)
endfunc
func Test_gD_too()
- let lines = [
- \ 'Filename x;',
- \ '',
- \ 'int Filename',
- \ 'int func() {',
- \ ' Filename x;',
- \ ' return x;',
- \ ]
+ let lines =<< trim [CODE]
+ Filename x;
+
+ int Filename
+ int func() {
+ Filename x;
+ return x;
+ [CODE]
+
call XTest_goto_decl('gD', lines, 1, 10)
endfunc
func Test_gD_comment()
- let lines = [
- \ '/* int x; */',
- \ 'int x;',
- \ '',
- \ 'int func(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ /* int x; */
+ int x;
+
+ int func(void)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gD', lines, 2, 5)
endfunc
func Test_gD_inline_comment()
- let lines = [
- \ 'int y /* , x */;',
- \ 'int x;',
- \ '',
- \ 'int func(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int y /* , x */;
+ int x;
+
+ int func(void)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gD', lines, 2, 5)
endfunc
func Test_gD_string()
- let lines = [
- \ 'char *s[] = "x";',
- \ 'int x = 1;',
- \ '',
- \ 'int func(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ char *s[] = "x";
+ int x = 1;
+
+ int func(void)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gD', lines, 2, 5)
endfunc
func Test_gD_string_same_line()
- let lines = [
- \ 'char *s[] = "x", int x = 1;',
- \ '',
- \ 'int func(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ char *s[] = "x", int x = 1;
+
+ int func(void)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gD', lines, 1, 22)
endfunc
func Test_gD_char()
- let lines = [
- \ "char c = 'x';",
- \ 'int x = 1;',
- \ '',
- \ 'int func(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ char c = 'x';
+ int x = 1;
+
+ int func(void)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gD', lines, 2, 5)
endfunc
func Test_gd()
- let lines = [
- \ 'int x;',
- \ '',
- \ 'int func(int x)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int x;
+
+ int func(int x)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 3, 14)
endfunc
func Test_gd_not_local()
- let lines = [
- \ 'int func1(void)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ '',
- \ 'int func2(int x)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func1(void)
+ {
+ return x;
+ }
+
+ int func2(int x)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 3, 10)
endfunc
func Test_gd_kr_style()
- let lines = [
- \ 'int func(x)',
- \ ' int x;',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(x)
+ int x;
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 2, 7)
endfunc
func Test_gd_missing_braces()
- let lines = [
- \ 'def func1(a)',
- \ ' a + 1',
- \ 'end',
- \ '',
- \ 'a = 1',
- \ '',
- \ 'def func2()',
- \ ' return a',
- \ 'end',
- \ ]
+ let lines =<< trim [CODE]
+ def func1(a)
+ a + 1
+ end
+
+ a = 1
+
+ def func2()
+ return a
+ end
+ [CODE]
+
call XTest_goto_decl('gd', lines, 1, 11)
endfunc
func Test_gd_comment()
- let lines = [
- \ 'int func(void)',
- \ '{',
- \ ' /* int x; */',
- \ ' int x;',
- \ ' return x;',
- \ '}',
- \]
+ let lines =<< trim [CODE]
+ int func(void)
+ {
+ /* int x; */
+ int x;
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 4, 7)
endfunc
func Test_gd_comment_in_string()
- let lines = [
- \ 'int func(void)',
- \ '{',
- \ ' char *s ="//"; int x;',
- \ ' int x;',
- \ ' return x;',
- \ '}',
- \]
+ let lines =<< trim [CODE]
+ int func(void)
+ {
+ char *s ="//"; int x;
+ int x;
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 3, 22)
endfunc
func Test_gd_string_in_comment()
set comments=
- let lines = [
- \ 'int func(void)',
- \ '{',
- \ ' /* " */ int x;',
- \ ' int x;',
- \ ' return x;',
- \ '}',
- \]
+ let lines =<< trim [CODE]
+ int func(void)
+ {
+ /* " */ int x;
+ int x;
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 3, 15)
set comments&
endfunc
func Test_gd_inline_comment()
- let lines = [
- \ 'int func(/* x is an int */ int x)',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(/* x is an int */ int x)
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 1, 32)
endfunc
func Test_gd_inline_comment_only()
- let lines = [
- \ 'int func(void) /* one lonely x */',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(void) /* one lonely x */
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 3, 10)
endfunc
func Test_gd_inline_comment_body()
- let lines = [
- \ 'int func(void)',
- \ '{',
- \ ' int y /* , x */;',
- \ '',
- \ ' for (/* int x = 0 */; y < 2; y++);',
- \ '',
- \ ' int x = 0;',
- \ '',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(void)
+ {
+ int y /* , x */;
+
+ for (/* int x = 0 */; y < 2; y++);
+
+ int x = 0;
+
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 7, 7)
endfunc
func Test_gd_trailing_multiline_comment()
- let lines = [
- \ 'int func(int x) /* x is an int */',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(int x) /* x is an int */
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 1, 14)
endfunc
func Test_gd_trailing_comment()
- let lines = [
- \ 'int func(int x) // x is an int',
- \ '{',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(int x) // x is an int
+ {
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 1, 14)
endfunc
func Test_gd_string()
- let lines = [
- \ 'int func(void)',
- \ '{',
- \ ' char *s = "x";',
- \ ' int x = 1;',
- \ '',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(void)
+ {
+ char *s = "x";
+ int x = 1;
+
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 4, 7)
endfunc
func Test_gd_string_only()
- let lines = [
- \ 'int func(void)',
- \ '{',
- \ ' char *s = "x";',
- \ '',
- \ ' return x;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int func(void)
+ {
+ char *s = "x";
+
+ return x;
+ }
+ [CODE]
+
call XTest_goto_decl('gd', lines, 5, 10)
endfunc
@@ -289,24 +310,25 @@ func Test_cursorline_keep_col()
endfunc
func Test_gd_local_block()
- let lines = [
- \ ' int main()',
- \ '{',
- \ ' char *a = "NOT NULL";',
- \ ' if(a)',
- \ ' {',
- \ ' char *b = a;',
- \ ' printf("%s\n", b);',
- \ ' }',
- \ ' else',
- \ ' {',
- \ ' char *b = "NULL";',
- \ ' return b;',
- \ ' }',
- \ '',
- \ ' return 0;',
- \ '}',
- \ ]
+ let lines =<< trim [CODE]
+ int main()
+ {
+ char *a = "NOT NULL";
+ if(a)
+ {
+ char *b = a;
+ printf("%s\n", b);
+ }
+ else
+ {
+ char *b = "NULL";
+ return b;
+ }
+
+ return 0;
+ }
+ [CODE]
+
call XTest_goto_decl('1gd', lines, 11, 11)
endfunc
diff --git a/src/nvim/testdir/test_hardcopy.vim b/src/nvim/testdir/test_hardcopy.vim
index ced13b107c..6125f9b993 100644
--- a/src/nvim/testdir/test_hardcopy.vim
+++ b/src/nvim/testdir/test_hardcopy.vim
@@ -1,39 +1,137 @@
" Test :hardcopy
-func Test_printoptions_parsing()
- " Only test that this doesn't throw an error.
- set printoptions=left:5in,right:10pt,top:8mm,bottom:2pc
- set printoptions=left:2in,top:30pt,right:16mm,bottom:3pc
- set printoptions=header:3,syntax:y,number:7,wrap:n
- set printoptions=duplex:short,collate:n,jobsplit:y,portrait:n
- set printoptions=paper:10x14
- set printoptions=paper:A3
- set printoptions=paper:A4
- set printoptions=paper:A5
- set printoptions=paper:B4
- set printoptions=paper:B5
- set printoptions=paper:executive
- set printoptions=paper:folio
- set printoptions=paper:ledger
- set printoptions=paper:legal
- set printoptions=paper:letter
- set printoptions=paper:quarto
- set printoptions=paper:statement
- set printoptions=paper:tabloid
- set printoptions=formfeed:y
- set printoptions=
- set printoptions&
+func Test_printoptions()
+ edit test_hardcopy.vim
+ syn on
+
+ for opt in ['left:5in,right:10pt,top:8mm,bottom:2pc',
+ \ 'left:2in,top:30pt,right:16mm,bottom:3pc',
+ \ 'header:3,syntax:y,number:y,wrap:n',
+ \ 'header:3,syntax:n,number:y,wrap:y',
+ \ 'duplex:short,collate:n,jobsplit:y,portrait:n',
+ \ 'duplex:long,collate:y,jobsplit:n,portrait:y',
+ \ 'paper:10x14',
+ \ 'paper:A3',
+ \ 'paper:A4',
+ \ 'paper:A5',
+ \ 'paper:B4',
+ \ 'paper:B5',
+ \ 'paper:executive',
+ \ 'paper:folio',
+ \ 'paper:ledger',
+ \ 'paper:legal',
+ \ 'paper:letter',
+ \ 'paper:quarto',
+ \ 'paper:statement',
+ \ 'paper:tabloid',
+ \ 'formfeed:y',
+ \ '']
+ exe 'set printoptions=' .. opt
+ if has('postscript')
+ hardcopy > Xhardcopy_printoptions
+ let lines = readfile('Xhardcopy_printoptions')
+ call assert_true(len(lines) > 20, opt)
+ call assert_true(lines[0] =~ 'PS-Adobe', opt)
+ call delete('Xhardcopy_printoptions')
+ endif
+ endfor
call assert_fails('set printoptions=paper', 'E550:')
call assert_fails('set printoptions=shredder:on', 'E551:')
call assert_fails('set printoptions=left:no', 'E552:')
+ set printoptions&
+ bwipe
endfunc
-func Test_printmbfont_parsing()
- " Only test that this doesn't throw an error.
- set printmbfont=r:WadaMin-Regular,b:WadaMin-Bold,i:WadaMin-Italic,o:WadaMin-Bold-Italic,c:yes,a:no
- set printmbfont=
+func Test_printmbfont()
+ " Print a small help page which contains tabs to cover code that expands tabs to spaces.
+ help help
+ syn on
+
+ for opt in [':WadaMin-Regular,b:WadaMin-Bold,i:WadaMin-Italic,o:WadaMin-Bold-Italic,c:yes,a:no',
+ \ '']
+ exe 'set printmbfont=' .. opt
+ if has('postscript')
+ hardcopy > Xhardcopy_printmbfont
+ let lines = readfile('Xhardcopy_printmbfont')
+ call assert_true(len(lines) > 20, opt)
+ call assert_true(lines[0] =~ 'PS-Adobe', opt)
+ call delete('Xhardcopy_printmbfont')
+ endif
+ endfor
set printmbfont&
+ bwipe
+endfunc
+
+func Test_printexpr()
+ if !has('unix')
+ return
+ endif
+
+ " Not a very useful printexpr value, but enough to test
+ " hardcopy with 'printexpr'.
+ function PrintFile(fname)
+ call writefile(['Test printexpr: ' .. v:cmdarg],
+ \ 'Xhardcopy_printexpr')
+ call delete(a:fname)
+ return 0
+ endfunc
+ set printexpr=PrintFile(v:fname_in)
+
+ help help
+ hardcopy dummy args
+ call assert_equal(['Test printexpr: dummy args'],
+ \ readfile('Xhardcopy_printexpr'))
+ call delete('Xhardcopy_printexpr')
+
+ " Function return 1 to test print failure.
+ function PrintFails(fname)
+ call delete(a:fname)
+ return 1
+ endfunc
+ set printexpr=PrintFails(v:fname_in)
+ call assert_fails('hardcopy', 'E365:')
+
+ set printexpr&
+ bwipe
+endfunc
+
+func Test_errors()
+ " FIXME: Windows fails differently than Unix.
+ if has('unix')
+ edit test_hardcopy.vim
+ call assert_fails('hardcopy >', 'E324:')
+ bwipe
+ endif
+endfunc
+
+func Test_dark_background()
+ edit test_hardcopy.vim
+ syn on
+
+ for bg in ['dark', 'light']
+ exe 'set background=' .. bg
+
+ if has('postscript')
+ hardcopy > Xhardcopy_dark_background
+ let lines = readfile('Xhardcopy_dark_background')
+ call assert_true(len(lines) > 20)
+ call assert_true(lines[0] =~ 'PS-Adobe')
+ call delete('Xhardcopy_dark_background')
+ endif
+ endfor
+
+ set background&
+ bwipe
+endfun
+
+func Test_empty_buffer()
+ " FIXME: Unclear why this fails on Windows.
+ if has('unix')
+ new
+ call assert_equal("\nNo text to be printed", execute('hardcopy'))
+ bwipe
+ endif
endfunc
func Test_printheader_parsing()
@@ -46,22 +144,6 @@ func Test_printheader_parsing()
set printheader&
endfunc
-" Test that :hardcopy produces a non-empty file.
-" We don't check much of the contents.
-func Test_with_syntax()
- if has('postscript')
- edit test_hardcopy.vim
- set printoptions=syntax:y
- syn on
- hardcopy > Xhardcopy
- let lines = readfile('Xhardcopy')
- call assert_true(len(lines) > 20)
- call assert_true(lines[0] =~ 'PS-Adobe')
- call delete('Xhardcopy')
- set printoptions&
- endif
-endfunc
-
func Test_fname_with_spaces()
if !has('postscript')
return
@@ -86,4 +168,3 @@ func Test_illegal_byte()
bwipe!
call delete('Xpstest')
endfunc
-
diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim
index ed3181564c..01fb9917e9 100644
--- a/src/nvim/testdir/test_help.vim
+++ b/src/nvim/testdir/test_help.vim
@@ -21,6 +21,12 @@ func Test_help_errors()
bwipe!
endfunc
+func Test_help_expr()
+ help expr-!~?
+ call assert_equal('eval.txt', expand('%:t'))
+ close
+endfunc
+
func Test_help_keyword()
new
set keywordprg=:help
diff --git a/src/nvim/testdir/test_highlight.vim b/src/nvim/testdir/test_highlight.vim
index d94eb7c3a2..6aa187b17e 100644
--- a/src/nvim/testdir/test_highlight.vim
+++ b/src/nvim/testdir/test_highlight.vim
@@ -1,6 +1,7 @@
" Tests for ":highlight" and highlighting.
source view_util.vim
+source screendump.vim
func Test_highlight()
" basic test if ":highlight" doesn't crash
@@ -591,3 +592,13 @@ func Test_cursorline_with_visualmode()
call StopVimInTerminal(buf)
call delete('Xtest_cursorline_with_visualmode')
endfunc
+
+" This test must come before the Test_cursorline test, as it appears this
+" defines the Normal highlighting group anyway.
+func Test_1_highlight_Normalgroup_exists()
+ " MS-Windows GUI sets the font
+ if !has('win32') || !has('gui_running')
+ let hlNormal = HighlightArgs('Normal')
+ call assert_match('hi Normal\s*clear', hlNormal)
+ endif
+endfunc
diff --git a/src/nvim/testdir/test_increment.vim b/src/nvim/testdir/test_increment.vim
index ab11d943d9..f81f8edbde 100644
--- a/src/nvim/testdir/test_increment.vim
+++ b/src/nvim/testdir/test_increment.vim
@@ -779,4 +779,40 @@ func Test_increment_empty_line()
bwipe!
endfunc
+func Test_normal_increment_with_virtualedit()
+ set virtualedit=all
+
+ call setline(1, ["\<TAB>1"])
+ exec "norm! 0\<C-A>"
+ call assert_equal("\<TAB>2", getline(1))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+
+ call setline(1, ["\<TAB>1"])
+ exec "norm! 0l\<C-A>"
+ call assert_equal("\<TAB>2", getline(1))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+
+ call setline(1, ["\<TAB>1"])
+ exec "norm! 07l\<C-A>"
+ call assert_equal("\<TAB>2", getline(1))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+
+ call setline(1, ["\<TAB>1"])
+ exec "norm! 0w\<C-A>"
+ call assert_equal("\<TAB>2", getline(1))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+
+ call setline(1, ["\<TAB>1"])
+ exec "norm! 0wl\<C-A>"
+ call assert_equal("\<TAB>1", getline(1))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+
+ call setline(1, ["\<TAB>1"])
+ exec "norm! 0w30l\<C-A>"
+ call assert_equal("\<TAB>1", getline(1))
+ call assert_equal([0, 1, 3, 29], getpos('.'))
+
+ set virtualedit&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim
index 7f52481ba8..1c275d5bd1 100644
--- a/src/nvim/testdir/test_ins_complete.vim
+++ b/src/nvim/testdir/test_ins_complete.vim
@@ -98,6 +98,15 @@ func Test_ins_complete()
call delete('Xdir', 'rf')
endfunc
+func s:CompleteDone_CompleteFuncNone( findstart, base )
+ throw 'skipped: Nvim does not support v:none'
+ if a:findstart
+ return 0
+ endif
+
+ return v:none
+endfunc
+
function! s:CompleteDone_CompleteFuncDict( findstart, base )
if a:findstart
return 0
@@ -111,32 +120,58 @@ function! s:CompleteDone_CompleteFuncDict( findstart, base )
\ 'menu': 'extra text',
\ 'info': 'words are cool',
\ 'kind': 'W',
- \ 'user_data': 'test'
+ \ 'user_data': ['one', 'two']
\ }
\ ]
\ }
endfunction
-function! s:CompleteDone_CheckCompletedItemDict()
+func s:CompleteDone_CheckCompletedItemNone()
+ let s:called_completedone = 1
+endfunc
+
+func s:CompleteDone_CheckCompletedItemDict(pre)
call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
call assert_equal( 'words are cool', v:completed_item[ 'info' ] )
call assert_equal( 'W', v:completed_item[ 'kind' ] )
- call assert_equal( 'test', v:completed_item[ 'user_data' ] )
+ call assert_equal( ['one', 'two'], v:completed_item[ 'user_data' ] )
+
+ if a:pre
+ call assert_equal('function', complete_info().mode)
+ endif
let s:called_completedone = 1
-endfunction
+endfunc
-function Test_CompleteDoneDict()
- au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict()
+func Test_CompleteDoneNone()
+ throw 'skipped: Nvim does not support v:none'
+ au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemNone()
+ let oldline = join(map(range(&columns), 'nr2char(screenchar(&lines-1, v:val+1))'), '')
+
+ set completefunc=<SID>CompleteDone_CompleteFuncNone
+ execute "normal a\<C-X>\<C-U>\<C-Y>"
+ set completefunc&
+ let newline = join(map(range(&columns), 'nr2char(screenchar(&lines-1, v:val+1))'), '')
+
+ call assert_true(s:called_completedone)
+ call assert_equal(oldline, newline)
+
+ let s:called_completedone = 0
+ au! CompleteDone
+endfunc
+
+func Test_CompleteDoneDict()
+ au CompleteDonePre * :call <SID>CompleteDone_CheckCompletedItemDict(1)
+ au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict(0)
set completefunc=<SID>CompleteDone_CompleteFuncDict
execute "normal a\<C-X>\<C-U>\<C-Y>"
set completefunc&
- call assert_equal( 'test', v:completed_item[ 'user_data' ] )
- call assert_true( s:called_completedone )
+ call assert_equal(['one', 'two'], v:completed_item[ 'user_data' ])
+ call assert_true(s:called_completedone)
let s:called_completedone = 0
au! CompleteDone
@@ -155,7 +190,7 @@ func Test_CompleteDone_undo()
au! CompleteDone
endfunc
-function! s:CompleteDone_CompleteFuncDictNoUserData( findstart, base )
+func s:CompleteDone_CompleteFuncDictNoUserData(findstart, base)
if a:findstart
return 0
endif
@@ -171,9 +206,9 @@ function! s:CompleteDone_CompleteFuncDictNoUserData( findstart, base )
\ }
\ ]
\ }
-endfunction
+endfunc
-function! s:CompleteDone_CheckCompletedItemDictNoUserData()
+func s:CompleteDone_CheckCompletedItemDictNoUserData()
call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
@@ -182,31 +217,31 @@ function! s:CompleteDone_CheckCompletedItemDictNoUserData()
call assert_equal( '', v:completed_item[ 'user_data' ] )
let s:called_completedone = 1
-endfunction
+endfunc
-function Test_CompleteDoneDictNoUserData()
+func Test_CompleteDoneDictNoUserData()
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDictNoUserData()
set completefunc=<SID>CompleteDone_CompleteFuncDictNoUserData
execute "normal a\<C-X>\<C-U>\<C-Y>"
set completefunc&
- call assert_equal( '', v:completed_item[ 'user_data' ] )
- call assert_true( s:called_completedone )
+ call assert_equal('', v:completed_item[ 'user_data' ])
+ call assert_true(s:called_completedone)
let s:called_completedone = 0
au! CompleteDone
endfunc
-function! s:CompleteDone_CompleteFuncList( findstart, base )
+func s:CompleteDone_CompleteFuncList(findstart, base)
if a:findstart
return 0
endif
return [ 'aword' ]
-endfunction
+endfunc
-function! s:CompleteDone_CheckCompletedItemList()
+func s:CompleteDone_CheckCompletedItemList()
call assert_equal( 'aword', v:completed_item[ 'word' ] )
call assert_equal( '', v:completed_item[ 'abbr' ] )
call assert_equal( '', v:completed_item[ 'menu' ] )
@@ -215,17 +250,17 @@ function! s:CompleteDone_CheckCompletedItemList()
call assert_equal( '', v:completed_item[ 'user_data' ] )
let s:called_completedone = 1
-endfunction
+endfunc
-function Test_CompleteDoneList()
+func Test_CompleteDoneList()
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemList()
set completefunc=<SID>CompleteDone_CompleteFuncList
execute "normal a\<C-X>\<C-U>\<C-Y>"
set completefunc&
- call assert_equal( '', v:completed_item[ 'user_data' ] )
- call assert_true( s:called_completedone )
+ call assert_equal('', v:completed_item[ 'user_data' ])
+ call assert_true(s:called_completedone)
let s:called_completedone = 0
au! CompleteDone
@@ -285,3 +320,21 @@ func Test_compl_feedkeys()
bwipe!
set completeopt&
endfunc
+
+func Test_compl_in_cmdwin()
+ set wildmenu wildchar=<Tab>
+ com! -nargs=1 -complete=command GetInput let input = <q-args>
+ com! -buffer TestCommand echo 'TestCommand'
+
+ let input = ''
+ call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!')
+ call assert_equal('TestCommand', input)
+
+ let input = ''
+ call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!')
+ call assert_equal('T', input)
+
+ delcom TestCommand
+ delcom GetInput
+ set wildmenu& wildchar&
+endfunc
diff --git a/src/nvim/testdir/test_join.vim b/src/nvim/testdir/test_join.vim
index 1c97414164..ac6ef8f29f 100644
--- a/src/nvim/testdir/test_join.vim
+++ b/src/nvim/testdir/test_join.vim
@@ -9,6 +9,27 @@ func Test_join_with_count()
call setline(1, ['one', 'two', 'three', 'four'])
normal 10J
call assert_equal('one two three four', getline(1))
+
+ call setline(1, ['one', '', 'two'])
+ normal J
+ call assert_equal('one', getline(1))
+
+ call setline(1, ['one', ' ', 'two'])
+ normal J
+ call assert_equal('one', getline(1))
+
+ call setline(1, ['one', '', '', 'two'])
+ normal JJ
+ call assert_equal('one', getline(1))
+
+ call setline(1, ['one', ' ', ' ', 'two'])
+ normal JJ
+ call assert_equal('one', getline(1))
+
+ call setline(1, ['one', '', '', 'two'])
+ normal 2J
+ call assert_equal('one', getline(1))
+
quit!
endfunc
@@ -33,3 +54,388 @@ func Test_join_marks()
call assert_equal([0, 4, 67, 0], getpos("']"))
enew!
endfunc
+
+" Test for joining lines and marks in them
+" in compatible and nocompatible modes
+" and with 'joinspaces' set or not
+" and with 'cpoptions' flag 'j' set or not
+func Test_join_spaces_marks()
+ new
+ " Text used for the test
+ insert
+asdfasdf.
+asdf
+asdfasdf.
+asdf
+asdfasdf.
+asdf
+asdfasdf.
+asdf
+asdfasdf.
+asdf
+asdfasdf.
+asdf
+asdfasdf.
+asdf
+asdfasdf
+asdf
+asdfasdf
+asdf
+asdfasdf
+asdf
+asdfasdf
+asdf
+asdfasdf
+asdf
+asdfasdf
+asdf
+asdfasdf
+asdf
+zx cvn.
+as dfg?
+hjkl iop!
+ert
+zx cvn.
+as dfg?
+hjkl iop!
+ert
+.
+ let text = getline(1, '$')
+ normal gg
+
+ set nojoinspaces
+ set cpoptions-=j
+ normal JjJjJjJjJjJjJjJjJjJjJjJjJjJ
+ normal j05lmx
+ normal 2j06lmy
+ normal 2k4Jy3l$p
+ normal `xyl$p
+ normal `yy2l$p
+
+ " set cpoptions+=j
+ normal j05lmx
+ normal 2j06lmy
+ normal 2k4Jy3l$p
+ normal `xyl$p
+ normal `yy2l$p
+
+ " Expected output
+ let expected =<< trim [DATA]
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ zx cvn. as dfg? hjkl iop! ert ernop
+ zx cvn. as dfg? hjkl iop! ert ernop
+ [DATA]
+
+ call assert_equal(expected, getline(1, '$'))
+ throw 'skipped: Nvim does not support "set compatible" or "set cpoptions+=j"'
+
+ enew!
+ call append(0, text)
+ normal gg
+
+ set cpoptions-=j
+ set joinspaces
+ normal JjJjJjJjJjJjJjJjJjJjJjJjJjJ
+ normal j05lmx
+ normal 2j06lmy
+ normal 2k4Jy3l$p
+ normal `xyl$p
+ normal `yy2l$p
+
+ set cpoptions+=j
+ normal j05lmx
+ normal 2j06lmy
+ normal 2k4Jy3l$p
+ normal `xyl$p
+ normal `yy2l$p
+
+ " Expected output
+ let expected =<< trim [DATA]
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ zx cvn. as dfg? hjkl iop! ert enop
+ zx cvn. as dfg? hjkl iop! ert ernop
+
+ [DATA]
+
+ call assert_equal(expected, getline(1, '$'))
+
+ enew!
+ call append(0, text)
+ normal gg
+
+ set cpoptions-=j
+ set nojoinspaces
+ set compatible
+
+ normal JjJjJjJjJjJjJjJjJjJjJjJjJjJ
+ normal j4Jy3l$pjdG
+
+ " Expected output
+ let expected =<< trim [DATA]
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf. asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ asdfasdf asdf
+ zx cvn. as dfg? hjkl iop! ert a
+ [DATA]
+
+ call assert_equal(expected, getline(1, '$'))
+
+ set nocompatible
+ set cpoptions&vim
+ set joinspaces&vim
+ close!
+endfunc
+
+" Test for joining lines with comments
+func Test_join_lines_with_comments()
+ new
+
+ " Text used by the test
+ insert
+{
+
+/*
+* Make sure the previous comment leader is not removed.
+*/
+
+/*
+* Make sure the previous comment leader is not removed.
+*/
+
+// Should the next comment leader be left alone?
+// Yes.
+
+// Should the next comment leader be left alone?
+// Yes.
+
+/* Here the comment leader should be left intact. */
+// And so should this one.
+
+/* Here the comment leader should be left intact. */
+// And so should this one.
+
+if (condition) // Remove the next comment leader!
+// OK, I will.
+action();
+
+if (condition) // Remove the next comment leader!
+// OK, I will.
+action();
+}
+.
+
+ call cursor(2, 1)
+ set comments=s1:/*,mb:*,ex:*/,://
+ set nojoinspaces fo=j
+ set backspace=eol,start
+
+ .,+3join
+ exe "normal j4J\<CR>"
+ .,+2join
+ exe "normal j3J\<CR>"
+ .,+2join
+ exe "normal j3J\<CR>"
+ .,+2join
+ exe "normal jj3J\<CR>"
+
+ " Expected output
+ let expected =<< trim [CODE]
+ {
+ /* Make sure the previous comment leader is not removed. */
+ /* Make sure the previous comment leader is not removed. */
+ // Should the next comment leader be left alone? Yes.
+ // Should the next comment leader be left alone? Yes.
+ /* Here the comment leader should be left intact. */ // And so should this one.
+ /* Here the comment leader should be left intact. */ // And so should this one.
+ if (condition) // Remove the next comment leader! OK, I will.
+ action();
+ if (condition) // Remove the next comment leader! OK, I will.
+ action();
+ }
+ [CODE]
+
+ call assert_equal(expected, getline(1, '$'))
+
+ set comments&vim
+ set joinspaces&vim
+ set fo&vim
+ set backspace&vim
+ close!
+endfunc
+
+" Test for joining lines with different comment leaders
+func Test_join_comments_2()
+ new
+
+ insert
+{
+
+/*
+ * Make sure the previous comment leader is not removed.
+ */
+
+/*
+ * Make sure the previous comment leader is not removed.
+ */
+
+/* List:
+ * - item1
+ * foo bar baz
+ * foo bar baz
+ * - item2
+ * foo bar baz
+ * foo bar baz
+ */
+
+/* List:
+ * - item1
+ * foo bar baz
+ * foo bar baz
+ * - item2
+ * foo bar baz
+ * foo bar baz
+ */
+
+// Should the next comment leader be left alone?
+// Yes.
+
+// Should the next comment leader be left alone?
+// Yes.
+
+/* Here the comment leader should be left intact. */
+// And so should this one.
+
+/* Here the comment leader should be left intact. */
+// And so should this one.
+
+if (condition) // Remove the next comment leader!
+ // OK, I will.
+ action();
+
+if (condition) // Remove the next comment leader!
+ // OK, I will.
+ action();
+
+int i = 7 /* foo *// 3
+ // comment
+ ;
+
+int i = 7 /* foo *// 3
+ // comment
+ ;
+
+># Note that the last character of the ending comment leader (left angle
+ # bracket) is a comment leader itself. Make sure that this comment leader is
+ # not removed from the next line #<
+< On this line a new comment is opened which spans 2 lines. This comment should
+< retain its comment leader.
+
+># Note that the last character of the ending comment leader (left angle
+ # bracket) is a comment leader itself. Make sure that this comment leader is
+ # not removed from the next line #<
+< On this line a new comment is opened which spans 2 lines. This comment should
+< retain its comment leader.
+
+}
+.
+
+ call cursor(2, 1)
+ set comments=sO:*\ -,mO:*\ \ ,exO:*/
+ set comments+=s1:/*,mb:*,ex:*/,://
+ set comments+=s1:>#,mb:#,ex:#<,:<
+ set cpoptions-=j joinspaces fo=j
+ set backspace=eol,start
+
+ .,+3join
+ exe "normal j4J\<CR>"
+ .,+8join
+ exe "normal j9J\<CR>"
+ .,+2join
+ exe "normal j3J\<CR>"
+ .,+2join
+ exe "normal j3J\<CR>"
+ .,+2join
+ exe "normal jj3J\<CR>j"
+ .,+2join
+ exe "normal jj3J\<CR>j"
+ .,+5join
+ exe "normal j6J\<CR>"
+ exe "normal oSome code!\<CR>// Make sure backspacing does not remove this comment leader.\<Esc>0i\<C-H>\<Esc>"
+
+ " Expected output
+ let expected =<< trim [CODE]
+ {
+ /* Make sure the previous comment leader is not removed. */
+ /* Make sure the previous comment leader is not removed. */
+ /* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
+ /* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
+ // Should the next comment leader be left alone? Yes.
+ // Should the next comment leader be left alone? Yes.
+ /* Here the comment leader should be left intact. */ // And so should this one.
+ /* Here the comment leader should be left intact. */ // And so should this one.
+ if (condition) // Remove the next comment leader! OK, I will.
+ action();
+ if (condition) // Remove the next comment leader! OK, I will.
+ action();
+ int i = 7 /* foo *// 3 // comment
+ ;
+ int i = 7 /* foo *// 3 // comment
+ ;
+ ># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
+ ># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
+
+ Some code!// Make sure backspacing does not remove this comment leader.
+ }
+ [CODE]
+
+ call assert_equal(expected, getline(1, '$'))
+ close!
+endfunc
+
+func Test_join_lines()
+ new
+ call setline(1, ['a', 'b', '', 'c', 'd'])
+ %join
+ call assert_equal('a b c d', getline(1))
+ call setline(1, ['a', 'b', '', 'c', 'd'])
+ normal 5J
+ call assert_equal('a b c d', getline(1))
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_let.vim b/src/nvim/testdir/test_let.vim
index 8a6f1bc320..0b9331ee38 100644
--- a/src/nvim/testdir/test_let.vim
+++ b/src/nvim/testdir/test_let.vim
@@ -24,6 +24,10 @@ func Test_let()
let out = execute('let a {0 == 1 ? "a" : "b"}')
let s = "\na #1\nb #2"
call assert_equal(s, out)
+
+ let x = 0
+ if 0 | let x = 1 | endif
+ call assert_equal(0, x)
endfunc
func s:set_arg1(a) abort
@@ -140,3 +144,161 @@ func Test_let_varg_fail()
call assert_fails('call s:set_varg7(1)', 'E742:')
call s:set_varg8([0])
endfunction
+
+func Test_let_utf8_environment()
+ let $a = 'ĀĒĪŌŪあいうえお'
+ call assert_equal('ĀĒĪŌŪあいうえお', $a)
+endfunc
+
+func Test_let_heredoc_fails()
+ call assert_fails('let v =<< marker', 'E991:')
+
+ let text =<< trim END
+ func WrongSyntax()
+ let v =<< that there
+ endfunc
+ END
+ call writefile(text, 'XheredocFail')
+ call assert_fails('source XheredocFail', 'E126:')
+ call delete('XheredocFail')
+
+ let text =<< trim CodeEnd
+ func MissingEnd()
+ let v =<< END
+ endfunc
+ CodeEnd
+ call writefile(text, 'XheredocWrong')
+ call assert_fails('source XheredocWrong', 'E126:')
+ call delete('XheredocWrong')
+
+ let text =<< trim TEXTend
+ let v =<< " comment
+ TEXTend
+ call writefile(text, 'XheredocNoMarker')
+ call assert_fails('source XheredocNoMarker', 'E172:')
+ call delete('XheredocNoMarker')
+
+ let text =<< trim TEXTend
+ let v =<< text
+ TEXTend
+ call writefile(text, 'XheredocBadMarker')
+ call assert_fails('source XheredocBadMarker', 'E221:')
+ call delete('XheredocBadMarker')
+endfunc
+
+func Test_let_heredoc_trim_no_indent_marker()
+ let text =<< trim END
+ Text
+ with
+ indent
+END
+ call assert_equal(['Text', 'with', 'indent'], text)
+endfunc
+
+" Test for the setting a variable using the heredoc syntax
+func Test_let_heredoc()
+ let var1 =<< END
+Some sample text
+ Text with indent
+ !@#$%^&*()-+_={}|[]\~`:";'<>?,./
+END
+
+ call assert_equal(["Some sample text", "\tText with indent", " !@#$%^&*()-+_={}|[]\\~`:\";'<>?,./"], var1)
+
+ let var2 =<< XXX
+Editor
+XXX
+ call assert_equal(['Editor'], var2)
+
+ let var3 =<<END
+END
+ call assert_equal([], var3)
+
+ let var3 =<<END
+vim
+
+end
+ END
+END
+END
+ call assert_equal(['vim', '', 'end', ' END', 'END '], var3)
+
+ let var1 =<< trim END
+ Line1
+ Line2
+ Line3
+ END
+ END
+ call assert_equal(['Line1', ' Line2', "\tLine3", ' END'], var1)
+
+ let var1 =<< trim !!!
+ Line1
+ line2
+ Line3
+ !!!
+ !!!
+ call assert_equal(['Line1', ' line2', "\tLine3", '!!!',], var1)
+
+ let var1 =<< trim XX
+ Line1
+ XX
+ call assert_equal(['Line1'], var1)
+
+ " ignore "endfunc"
+ let var1 =<< END
+something
+endfunc
+END
+ call assert_equal(['something', 'endfunc'], var1)
+
+ " ignore "endfunc" with trim
+ let var1 =<< trim END
+ something
+ endfunc
+ END
+ call assert_equal(['something', 'endfunc'], var1)
+
+ " ignore "python << xx"
+ let var1 =<<END
+something
+python << xx
+END
+ call assert_equal(['something', 'python << xx'], var1)
+
+ " ignore "python << xx" with trim
+ let var1 =<< trim END
+ something
+ python << xx
+ END
+ call assert_equal(['something', 'python << xx'], var1)
+
+ " ignore "append"
+ let var1 =<< E
+something
+app
+E
+ call assert_equal(['something', 'app'], var1)
+
+ " ignore "append" with trim
+ let var1 =<< trim END
+ something
+ app
+ END
+ call assert_equal(['something', 'app'], var1)
+
+ let check = []
+ if 0
+ let check =<< trim END
+ from heredoc
+ END
+ endif
+ call assert_equal([], check)
+
+ " unpack assignment
+ let [a, b, c] =<< END
+ x
+ \y
+ z
+END
+ call assert_equal([' x', ' \y', ' z'], [a, b, c])
+endfunc
diff --git a/src/nvim/testdir/test_listchars.vim b/src/nvim/testdir/test_listchars.vim
index 57cfaa298e..dcc588120c 100644
--- a/src/nvim/testdir/test_listchars.vim
+++ b/src/nvim/testdir/test_listchars.vim
@@ -58,6 +58,26 @@ func Test_listchars()
call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
endfor
+ " tab with 3rd character and linebreak set
+ set listchars-=tab:<=>
+ set listchars+=tab:<·>
+ set linebreak
+ let expected = [
+ \ '<······>aa<····>$',
+ \ '..bb<··>--$',
+ \ '...cccc>-$',
+ \ 'dd........ee--<>$',
+ \ '-$'
+ \ ]
+ redraw!
+ for i in range(1, 5)
+ call cursor(i, 1)
+ call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+ endfor
+ set nolinebreak
+ set listchars-=tab:<·>
+ set listchars+=tab:<=>
+
set listchars-=trail:-
let expected = [
\ '<======>aa<====>$',
diff --git a/src/nvim/testdir/test_listlbr.vim b/src/nvim/testdir/test_listlbr.vim
index d28dbc444c..cdc5e4cc7c 100644
--- a/src/nvim/testdir/test_listlbr.vim
+++ b/src/nvim/testdir/test_listlbr.vim
@@ -103,6 +103,37 @@ func Test_linebreak_with_conceal()
call s:close_windows()
endfunc
+func Test_linebreak_with_visual_operations()
+ call s:test_windows()
+ let line = '1234567890 2234567890 3234567890'
+ call setline(1, line)
+
+ " yank
+ exec "norm! ^w\<C-V>ey"
+ call assert_equal('2234567890', @@)
+ exec "norm! w\<C-V>ey"
+ call assert_equal('3234567890', @@)
+
+ " increment / decrement
+ exec "norm! ^w\<C-V>\<C-A>w\<C-V>\<C-X>"
+ call assert_equal('1234567890 3234567890 2234567890', getline(1))
+
+ " replace
+ exec "norm! ^w\<C-V>3lraw\<C-V>3lrb"
+ call assert_equal('1234567890 aaaa567890 bbbb567890', getline(1))
+
+ " tilde
+ exec "norm! ^w\<C-V>2l~w\<C-V>2l~"
+ call assert_equal('1234567890 AAAa567890 BBBb567890', getline(1))
+
+ " delete and insert
+ exec "norm! ^w\<C-V>3lc2345\<Esc>w\<C-V>3lc3456\<Esc>"
+ call assert_equal('1234567890 2345567890 3456567890', getline(1))
+ call assert_equal('BBBb', @@)
+
+ call s:close_windows()
+endfunc
+
func Test_virtual_block()
call s:test_windows('setl sbr=+')
call setline(1, [
diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim
index 0b941d51ec..238d2f900d 100644
--- a/src/nvim/testdir/test_maparg.vim
+++ b/src/nvim/testdir/test_maparg.vim
@@ -15,23 +15,23 @@ function Test_maparg()
map foo<C-V> is<F4>foo
vnoremap <script> <buffer> <expr> <silent> bar isbar
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
\ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
\ 'rhs': 'is<F4>foo', 'buffer': 0},
\ maparg('foo<C-V>', '', 0, 1))
- call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v',
+ call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v',
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
\ 'rhs': 'isbar', 'buffer': 1},
\ maparg('bar', '', 0, 1))
let lnum = expand('<sflnum>')
map <buffer> <nowait> foo bar
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ',
\ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
\ 'buffer': 1},
\ maparg('foo', '', 0, 1))
let lnum = expand('<sflnum>')
tmap baz foo
- call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'baz', 'mode': 't',
+ call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', 'mode': 't',
\ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
\ 'buffer': 0},
\ maparg('baz', 't', 0, 1))
@@ -41,6 +41,11 @@ function Test_maparg()
map abc y<S-char-114>y
call assert_equal("yRy", maparg('abc'))
+ omap { w
+ let d = maparg('{', 'o', 0, 1)
+ call assert_equal(['{', 'w', 'o'], [d.lhs, d.rhs, d.mode])
+ ounmap {
+
map abc <Nop>
call assert_equal("<Nop>", maparg('abc'))
unmap abc
@@ -62,3 +67,5 @@ function Test_range_map()
execute "normal a\uf040\<Esc>"
call assert_equal("abcd", getline(1))
endfunction
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index 34e62e80e8..82562339f6 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -287,7 +287,7 @@ func Test_map_timeout_with_timer_interrupt()
set timeout timeoutlen=200
func ExitCb(job, status)
- let g:timer = timer_start(1, {_ -> feedkeys("3\<Esc>", 't')})
+ let g:timer = timer_start(1, {-> feedkeys("3\<Esc>", 't')})
endfunc
call job_start([&shell, &shellcmdflag, 'echo'], {'exit_cb': 'ExitCb'})
@@ -390,3 +390,77 @@ func Test_motionforce_omap()
delfunc Select
delfunc GetCommand
endfunc
+
+" Test for mapping errors
+func Test_map_error()
+ call assert_fails('unmap', 'E474:')
+ call assert_fails("exe 'map ' .. repeat('a', 51) .. ' :ls'", 'E474:')
+ call assert_fails('unmap abc', 'E31:')
+ call assert_fails('unabbr abc', 'E24:')
+ call assert_equal('', maparg(''))
+ call assert_fails('echo maparg("abc", [])', 'E730:')
+
+ " unique map
+ map ,w /[#&!]<CR>
+ call assert_fails("map <unique> ,w /[#&!]<CR>", 'E227:')
+ " unique buffer-local map
+ call assert_fails("map <buffer> <unique> ,w /[.,;]<CR>", 'E225:')
+ unmap ,w
+
+ " unique abbreviation
+ abbr SP special
+ call assert_fails("abbr <unique> SP special", 'E226:')
+ " unique buffer-local map
+ call assert_fails("abbr <buffer> <unique> SP special", 'E224:')
+ unabbr SP
+
+ call assert_fails('mapclear abc', 'E474:')
+ call assert_fails('abclear abc', 'E474:')
+endfunc
+
+" Test for <special> key mapping
+func Test_map_special()
+ throw 'skipped: Nvim does not support cpoptions flag "<"'
+ new
+ let old_cpo = &cpo
+ set cpo+=<
+ imap <F12> Blue
+ call feedkeys("i\<F12>", "x")
+ call assert_equal("<F12>", getline(1))
+ call feedkeys("ddi<F12>", "x")
+ call assert_equal("Blue", getline(1))
+ iunmap <F12>
+ imap <special> <F12> Green
+ call feedkeys("ddi\<F12>", "x")
+ call assert_equal("Green", getline(1))
+ call feedkeys("ddi<F12>", "x")
+ call assert_equal("<F12>", getline(1))
+ iunmap <special> <F12>
+ let &cpo = old_cpo
+ %bwipe!
+endfunc
+
+" Test for hasmapto()
+func Test_hasmapto()
+ call assert_equal(0, hasmapto('/^\k\+ ('))
+ call assert_equal(0, hasmapto('/^\k\+ (', 'n'))
+ nmap ,f /^\k\+ (<CR>
+ call assert_equal(1, hasmapto('/^\k\+ ('))
+ call assert_equal(1, hasmapto('/^\k\+ (', 'n'))
+ call assert_equal(0, hasmapto('/^\k\+ (', 'v'))
+
+ call assert_equal(0, hasmapto('/^\k\+ (', 'n', 1))
+endfunc
+
+" Test for command-line completion of maps
+func Test_mapcomplete()
+ call assert_equal(['<buffer>', '<expr>', '<nowait>', '<script>',
+ \ '<silent>', '<special>', '<unique>'],
+ \ getcompletion('', 'mapping'))
+ call assert_equal([], getcompletion(',d', 'mapping'))
+
+ call feedkeys(":abbr! \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match("abbr! \x01", @:)
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_marks.vim b/src/nvim/testdir/test_marks.vim
index 272553c29f..66df57ea39 100644
--- a/src/nvim/testdir/test_marks.vim
+++ b/src/nvim/testdir/test_marks.vim
@@ -26,11 +26,11 @@ function! Test_Incr_Marks()
endfunction
func Test_setpos()
- new one
+ new Xone
let onebuf = bufnr('%')
let onewin = win_getid()
call setline(1, ['aaa', 'bbb', 'ccc'])
- new two
+ new Xtwo
let twobuf = bufnr('%')
let twowin = win_getid()
call setline(1, ['aaa', 'bbb', 'ccc'])
@@ -63,7 +63,24 @@ func Test_setpos()
call setpos("'N", [onebuf, 1, 3, 0])
call assert_equal([onebuf, 1, 3, 0], getpos("'N"))
+ " try invalid column and check virtcol()
call win_gotoid(onewin)
+ call setpos("'a", [0, 1, 2, 0])
+ call assert_equal([0, 1, 2, 0], getpos("'a"))
+ call setpos("'a", [0, 1, -5, 0])
+ call assert_equal([0, 1, 2, 0], getpos("'a"))
+ call setpos("'a", [0, 1, 0, 0])
+ call assert_equal([0, 1, 1, 0], getpos("'a"))
+ call setpos("'a", [0, 1, 4, 0])
+ call assert_equal([0, 1, 4, 0], getpos("'a"))
+ call assert_equal(4, virtcol("'a"))
+ call setpos("'a", [0, 1, 5, 0])
+ call assert_equal([0, 1, 5, 0], getpos("'a"))
+ call assert_equal(4, virtcol("'a"))
+ call setpos("'a", [0, 1, 21341234, 0])
+ call assert_equal([0, 1, 21341234, 0], getpos("'a"))
+ call assert_equal(4, virtcol("'a"))
+
bwipe!
call win_gotoid(twowin)
bwipe!
@@ -77,33 +94,43 @@ func Test_marks_cmd()
new Xtwo
call setline(1, ['ccc', 'ddd'])
norm! $mcGmD
+ exe "norm! GVgg\<Esc>G"
w!
b Xone
let a = split(execute('marks'), "\n")
call assert_equal(9, len(a))
- call assert_equal('mark line col file/text', a[0])
- call assert_equal(" ' 2 0 bbb", a[1])
- call assert_equal(' a 1 0 aaa', a[2])
- call assert_equal(' B 2 2 bbb', a[3])
- call assert_equal(' D 2 0 Xtwo', a[4])
- call assert_equal(' " 1 0 aaa', a[5])
- call assert_equal(' [ 1 0 aaa', a[6])
- call assert_equal(' ] 2 0 bbb', a[7])
- call assert_equal(' . 2 0 bbb', a[8])
+ call assert_equal(['mark line col file/text',
+ \ " ' 2 0 bbb",
+ \ ' a 1 0 aaa',
+ \ ' B 2 2 bbb',
+ \ ' D 2 0 Xtwo',
+ \ ' " 1 0 aaa',
+ \ ' [ 1 0 aaa',
+ \ ' ] 2 0 bbb',
+ \ ' . 2 0 bbb'], a)
b Xtwo
let a = split(execute('marks'), "\n")
- call assert_equal(9, len(a))
- call assert_equal('mark line col file/text', a[0])
- call assert_equal(" ' 1 0 ccc", a[1])
- call assert_equal(' c 1 2 ccc', a[2])
- call assert_equal(' B 2 2 Xone', a[3])
- call assert_equal(' D 2 0 ddd', a[4])
- call assert_equal(' " 2 0 ddd', a[5])
- call assert_equal(' [ 1 0 ccc', a[6])
- call assert_equal(' ] 2 0 ddd', a[7])
- call assert_equal(' . 2 0 ddd', a[8])
+ call assert_equal(11, len(a))
+ call assert_equal(['mark line col file/text',
+ \ " ' 1 0 ccc",
+ \ ' c 1 2 ccc',
+ \ ' B 2 2 Xone',
+ \ ' D 2 0 ddd',
+ \ ' " 2 0 ddd',
+ \ ' [ 1 0 ccc',
+ \ ' ] 2 0 ddd',
+ \ ' . 2 0 ddd',
+ \ ' < 1 0 ccc',
+ \ ' > 2 0 ddd'], a)
+ norm! Gdd
+ w!
+ let a = split(execute('marks <>'), "\n")
+ call assert_equal(3, len(a))
+ call assert_equal(['mark line col file/text',
+ \ ' < 1 0 ccc',
+ \ ' > 2 0 -invalid-'], a)
b Xone
delmarks aB
diff --git a/src/nvim/testdir/test_match.vim b/src/nvim/testdir/test_match.vim
index 90dfcf952d..09448ca71b 100644
--- a/src/nvim/testdir/test_match.vim
+++ b/src/nvim/testdir/test_match.vim
@@ -1,6 +1,8 @@
" Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
" matchaddpos(), matcharg(), matchdelete(), and setmatches().
+source screendump.vim
+
function Test_match()
highlight MyGroup1 term=bold ctermbg=red guibg=red
highlight MyGroup2 term=italic ctermbg=green guibg=green
@@ -147,6 +149,21 @@ function Test_match()
highlight MyGroup3 NONE
endfunc
+func Test_match_error()
+ call assert_fails('match Error', 'E475:')
+ call assert_fails('match Error /', 'E475:')
+ call assert_fails('4match Error /x/', 'E476:')
+ call assert_fails('match Error /x/ x', 'E488:')
+endfunc
+
+func Test_matchadd_error()
+ call assert_fails("call matchadd('GroupDoesNotExist', 'X')", 'E28:')
+ call assert_fails("call matchadd('Search', '\\(')", 'E475:')
+ call assert_fails("call matchadd('Search', 'XXX', 1, 123, 1)", 'E715:')
+ call assert_fails("call matchadd('Error', 'XXX', 1, 3)", 'E798:')
+ call assert_fails("call matchadd('Error', 'XXX', 1, 0)", 'E799:')
+endfunc
+
func Test_matchaddpos()
syntax on
set hlsearch
@@ -215,6 +232,19 @@ func Test_matchaddpos_otherwin()
call assert_equal(screenattr(1,2), screenattr(2,2))
call assert_notequal(screenattr(1,2), screenattr(1,4))
+ let savematches = getmatches(winid)
+ let expect = [
+ \ {'group': 'Search', 'pattern': '4', 'priority': 10, 'id': 4},
+ \ {'group': 'Error', 'id': 5, 'priority': 10, 'pos1': [1, 2, 1], 'pos2': [2, 2, 1]},
+ \]
+ call assert_equal(expect, savematches)
+
+ call clearmatches(winid)
+ call assert_equal([], getmatches(winid))
+
+ call setmatches(savematches, winid)
+ call assert_equal(expect, savematches)
+
wincmd w
bwipe!
call clearmatches()
@@ -248,4 +278,71 @@ func Test_matchaddpos_using_negative_priority()
set hlsearch&
endfunc
+func Test_matchaddpos_error()
+ call assert_fails("call matchaddpos('Error', 1)", 'E686:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 1)", 'E798:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 2)", 'E798:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 0)", 'E799:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 123, 1)", 'E715:')
+ call assert_fails("call matchaddpos('Error', [1], 1, 5, {'window':12345})", 'E957:')
+ " Why doesn't the following error have an error code E...?
+ call assert_fails("call matchaddpos('Error', [{}])", 'E5031:')
+endfunc
+
+func OtherWindowCommon()
+ let lines =<< trim END
+ call setline(1, 'Hello Vim world')
+ let mid = matchadd('Error', 'world', 1)
+ let winid = win_getid()
+ new
+ END
+ call writefile(lines, 'XscriptMatchCommon')
+ let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 12})
+ call term_wait(buf)
+ return buf
+endfunc
+
+func Test_matchdelete_other_window()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot make screendumps'
+ endif
+ let buf = OtherWindowCommon()
+ call term_sendkeys(buf, ":call matchdelete(mid, winid)\<CR>")
+ call VerifyScreenDump(buf, 'Test_matchdelete_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XscriptMatchCommon')
+endfunc
+
+func Test_matchdelete_error()
+ call assert_fails("call matchdelete(0)", 'E802:')
+ call assert_fails("call matchdelete(1, -1)", 'E957:')
+endfunc
+
+func Test_matchclear_other_window()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot make screendumps'
+ endif
+ let buf = OtherWindowCommon()
+ call term_sendkeys(buf, ":call clearmatches(winid)\<CR>")
+ call VerifyScreenDump(buf, 'Test_matchclear_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XscriptMatchCommon')
+endfunc
+
+func Test_matchadd_other_window()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot make screendumps'
+ endif
+ let buf = OtherWindowCommon()
+ call term_sendkeys(buf, ":call matchadd('Search', 'Hello', 1, -1, #{window: winid})\<CR>")
+ call term_sendkeys(buf, ":\<CR>")
+ call VerifyScreenDump(buf, 'Test_matchadd_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XscriptMatchCommon')
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim
index 265dee66ce..7fbf04311d 100644
--- a/src/nvim/testdir/test_messages.vim
+++ b/src/nvim/testdir/test_messages.vim
@@ -1,4 +1,4 @@
-" Tests for :messages
+" Tests for :messages, :echomsg, :echoerr
function Test_messages()
let oldmore = &more
@@ -6,6 +6,9 @@ function Test_messages()
set nomore
" Avoid the "message maintainer" line.
let $LANG = ''
+ let $LC_ALL = ''
+ let $LC_MESSAGES = ''
+ let $LC_COLLATE = ''
let arr = map(range(10), '"hello" . v:val')
for s in arr
@@ -65,6 +68,35 @@ func Test_message_completion()
call assert_equal('"message clear', @:)
endfunc
+func Test_echomsg()
+ call assert_equal("\nhello", execute(':echomsg "hello"'))
+ call assert_equal("\n", execute(':echomsg ""'))
+ call assert_equal("\n12345", execute(':echomsg 12345'))
+ call assert_equal("\n[]", execute(':echomsg []'))
+ call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]'))
+ call assert_equal("\n{}", execute(':echomsg {}'))
+ call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}'))
+ if has('float')
+ call assert_equal("\n1.23", execute(':echomsg 1.23'))
+ endif
+ call assert_match("function('<lambda>\\d*')", execute(':echomsg {-> 1234}'))
+endfunc
+
+func Test_echoerr()
+ throw 'skipped: Nvim does not support test_ignore_error()'
+ call test_ignore_error('IgNoRe')
+ call assert_equal("\nIgNoRe hello", execute(':echoerr "IgNoRe hello"'))
+ call assert_equal("\n12345 IgNoRe", execute(':echoerr 12345 "IgNoRe"'))
+ call assert_equal("\n[1, 2, 'IgNoRe']", execute(':echoerr [1, 2, "IgNoRe"]'))
+ call assert_equal("\n{'IgNoRe': 2, 'a': 1}", execute(':echoerr {"a": 1, "IgNoRe": 2}'))
+ if has('float')
+ call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
+ endif
+ call test_ignore_error('<lambda>')
+ call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
+ call test_ignore_error('RESET')
+endfunc
+
func Test_echospace()
set noruler noshowcmd laststatus=1
call assert_equal(&columns - 1, v:echospace)
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
index b7169444d1..9c9e04be07 100644
--- a/src/nvim/testdir/test_mksession.vim
+++ b/src/nvim/testdir/test_mksession.vim
@@ -2,10 +2,13 @@
scriptencoding latin1
-if !has('multi_byte') || !has('mksession')
+if !has('mksession')
finish
endif
+source shared.vim
+source term_util.vim
+
func Test_mksession()
tabnew
let wrap_save = &wrap
@@ -122,6 +125,34 @@ func Test_mksession_large_winheight()
call delete('Xtest_mks_winheight.out')
endfunc
+func Test_mksession_rtp()
+ if has('win32')
+ " TODO: fix problem with backslashes
+ return
+ endif
+ new
+ set sessionoptions+=options
+ let _rtp=&rtp
+ " Make a real long (invalid) runtimepath value,
+ " that should exceed PATH_MAX (hopefully)
+ let newrtp=&rtp.',~'.repeat('/foobar', 1000)
+ let newrtp.=",".expand("$HOME")."/.vim"
+ let &rtp=newrtp
+
+ " determine expected value
+ let expected=split(&rtp, ',')
+ let expected = map(expected, '"set runtimepath+=".v:val')
+ let expected = ['set runtimepath='] + expected
+ let expected = map(expected, {v,w -> substitute(w, $HOME, "~", "g")})
+
+ mksession! Xtest_mks.out
+ let &rtp=_rtp
+ let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "runtimepath"')
+ call assert_equal(expected, li)
+
+ call delete('Xtest_mks.out')
+endfunc
+
" Verify that arglist is stored correctly to the session file.
func Test_mksession_arglist()
argdel *
diff --git a/src/nvim/testdir/test_mksession_utf8.vim b/src/nvim/testdir/test_mksession_utf8.vim
index 67af3a9ca2..722fd28beb 100644
--- a/src/nvim/testdir/test_mksession_utf8.vim
+++ b/src/nvim/testdir/test_mksession_utf8.vim
@@ -65,34 +65,35 @@ func Test_mksession_utf8()
call wincol()
mksession! test_mks.out
let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"')
- let expected = [
- \ 'normal! 016|',
- \ 'normal! 016|',
- \ 'normal! 016|',
- \ 'normal! 08|',
- \ 'normal! 08|',
- \ 'normal! 016|',
- \ 'normal! 016|',
- \ 'normal! 016|',
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|",
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|",
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|",
- \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'",
- \ " normal! 08|",
- \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'",
- \ " normal! 08|",
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|",
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|",
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|",
- \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
- \ " normal! 016|"
- \ ]
+ let expected =<< trim [DATA]
+ normal! 016|
+ normal! 016|
+ normal! 016|
+ normal! 08|
+ normal! 08|
+ normal! 016|
+ normal! 016|
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 8 . '|'
+ normal! 08|
+ exe 'normal! ' . s:c . '|zs' . 8 . '|'
+ normal! 08|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ exe 'normal! ' . s:c . '|zs' . 16 . '|'
+ normal! 016|
+ [DATA]
+
call assert_equal(expected, li)
tabclose!
diff --git a/src/nvim/testdir/test_modeline.vim b/src/nvim/testdir/test_modeline.vim
index 1e196e07f0..9bdada616c 100644
--- a/src/nvim/testdir/test_modeline.vim
+++ b/src/nvim/testdir/test_modeline.vim
@@ -5,12 +5,30 @@ func Test_modeline_invalid()
call writefile(['vi:0', 'nothing'], 'Xmodeline')
let modeline = &modeline
set modeline
- call assert_fails('set Xmodeline', 'E518:')
+ call assert_fails('split Xmodeline', 'E518:')
+
+ " Missing end colon (ignored).
+ call writefile(['// vim: set ts=2'], 'Xmodeline')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ " Missing colon at beginning (ignored).
+ call writefile(['// vim set ts=2:'], 'Xmodeline')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ " Missing space after vim (ignored).
+ call writefile(['// vim:ts=2:'], 'Xmodeline')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
let &modeline = modeline
bwipe!
call delete('Xmodeline')
- endfunc
+endfunc
func Test_modeline_filetype()
call writefile(['vim: set ft=c :', 'nothing'], 'Xmodeline_filetype')
@@ -60,8 +78,99 @@ func Test_modeline_keymap()
set keymap= iminsert=0 imsearch=-1
endfunc
+func Test_modeline_version()
+ let modeline = &modeline
+ set modeline
+
+ " Test with vim:{vers}: (version {vers} or later).
+ call writefile(['// vim' .. v:version .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(2, &ts)
+ bwipe!
+
+ call writefile(['// vim' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(2, &ts)
+ bwipe!
+
+ call writefile(['// vim' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bw!
+
+ " Test with vim>{vers}: (version after {vers}).
+ call writefile(['// vim>' .. v:version .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ call writefile(['// vim>' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(2, &ts)
+ bwipe!
+
+ call writefile(['// vim>' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ " Test with vim<{vers}: (version before {vers}).
+ call writefile(['// vim<' .. v:version .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ call writefile(['// vim<' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ call writefile(['// vim<' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(2, &ts)
+ bwipe!
+
+ " Test with vim={vers}: (version {vers} only).
+ call writefile(['// vim=' .. v:version .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(2, &ts)
+ bwipe!
+
+ call writefile(['// vim=' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ call writefile(['// vim=' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
+ edit Xmodeline_version
+ call assert_equal(8, &ts)
+ bwipe!
+
+ let &modeline = modeline
+ call delete('Xmodeline_version')
+endfunc
+
+func Test_modeline_colon()
+ let modeline = &modeline
+ set modeline
+
+ call writefile(['// vim: set showbreak=\: ts=2: sw=2'], 'Xmodeline_colon')
+ edit Xmodeline_colon
+
+ " backlash colon should become colon.
+ call assert_equal(':', &showbreak)
+
+ " 'ts' should be set.
+ " 'sw' should be ignored because it is after the end colon.
+ call assert_equal(2, &ts)
+ call assert_equal(8, &sw)
+
+ let &modeline = modeline
+ call delete('Xmodeline_colon')
+endfunc
+
func s:modeline_fails(what, text, error)
- if !exists('+' . a:what)
+ if !exists('+' .. a:what)
return
endif
let fname = "Xmodeline_fails_" . a:what
@@ -119,7 +228,7 @@ func Test_modeline_fails_always()
call s:modeline_fails('mkspellmem', 'mkspellmem=Something()', 'E520:')
call s:modeline_fails('mzschemedll', 'mzschemedll=Something()', 'E520:')
call s:modeline_fails('mzschemegcdll', 'mzschemegcdll=Something()', 'E520:')
- call s:modeline_fails('modelineexpr', 'modelineexpr=Something()', 'E520:')
+ call s:modeline_fails('modelineexpr', 'modelineexpr', 'E520:')
call s:modeline_fails('omnifunc', 'omnifunc=Something()', 'E520:')
call s:modeline_fails('operatorfunc', 'operatorfunc=Something()', 'E520:')
call s:modeline_fails('perldll', 'perldll=Something()', 'E520:')
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index 532beb9c39..ad6d325510 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -2,12 +2,12 @@
source shared.vim
-func! Setup_NewWindow()
+func Setup_NewWindow()
10new
call setline(1, range(1,100))
endfunc
-func! MyFormatExpr()
+func MyFormatExpr()
" Adds '->$' at lines having numbers followed by trailing whitespace
for ln in range(v:lnum, v:lnum+v:count-1)
let line = getline(ln)
@@ -17,7 +17,7 @@ func! MyFormatExpr()
endfor
endfunc
-func! CountSpaces(type, ...)
+func CountSpaces(type, ...)
" for testing operatorfunc
" will count the number of spaces
" and return the result in g:a
@@ -37,7 +37,7 @@ func! CountSpaces(type, ...)
let @@ = reg_save
endfunc
-func! OpfuncDummy(type, ...)
+func OpfuncDummy(type, ...)
" for testing operatorfunc
let g:opt=&linebreak
@@ -81,7 +81,7 @@ fun! Test_normal00_optrans()
bw!
endfunc
-func! Test_normal01_keymodel()
+func Test_normal01_keymodel()
call Setup_NewWindow()
" Test 1: depending on 'keymodel' <s-down> does something different
50
@@ -115,7 +115,7 @@ func! Test_normal01_keymodel()
bw!
endfunc
-func! Test_normal02_selectmode()
+func Test_normal02_selectmode()
" some basic select mode tests
call Setup_NewWindow()
50
@@ -129,7 +129,7 @@ func! Test_normal02_selectmode()
bw!
endfunc
-func! Test_normal02_selectmode2()
+func Test_normal02_selectmode2()
" some basic select mode tests
call Setup_NewWindow()
50
@@ -139,7 +139,7 @@ func! Test_normal02_selectmode2()
bw!
endfunc
-func! Test_normal03_join()
+func Test_normal03_join()
" basic join test
call Setup_NewWindow()
50
@@ -159,7 +159,7 @@ func! Test_normal03_join()
bw!
endfunc
-func! Test_normal04_filter()
+func Test_normal04_filter()
" basic filter test
" only test on non windows platform
if has('win32')
@@ -185,7 +185,7 @@ func! Test_normal04_filter()
bw!
endfunc
-func! Test_normal05_formatexpr()
+func Test_normal05_formatexpr()
" basic formatexpr test
call Setup_NewWindow()
%d_
@@ -222,7 +222,7 @@ func Test_normal05_formatexpr_setopt()
set formatexpr=
endfunc
-func! Test_normal06_formatprg()
+func Test_normal06_formatprg()
" basic test for formatprg
" only test on non windows platform
if has('win32')
@@ -256,7 +256,7 @@ func! Test_normal06_formatprg()
call delete('Xsed_format.sh')
endfunc
-func! Test_normal07_internalfmt()
+func Test_normal07_internalfmt()
" basic test for internal formmatter to textwidth of 12
let list=range(1,11)
call map(list, 'v:val." "')
@@ -270,7 +270,7 @@ func! Test_normal07_internalfmt()
bw!
endfunc
-func! Test_normal08_fold()
+func Test_normal08_fold()
" basic tests for foldopen/folddelete
if !has("folding")
return
@@ -329,7 +329,7 @@ func! Test_normal08_fold()
bw!
endfunc
-func! Test_normal09_operatorfunc()
+func Test_normal09_operatorfunc()
" Test operatorfunc
call Setup_NewWindow()
" Add some spaces for counting
@@ -359,7 +359,7 @@ func! Test_normal09_operatorfunc()
bw!
endfunc
-func! Test_normal09a_operatorfunc()
+func Test_normal09a_operatorfunc()
" Test operatorfunc
call Setup_NewWindow()
" Add some spaces for counting
@@ -385,7 +385,7 @@ func! Test_normal09a_operatorfunc()
unlet! g:opt
endfunc
-func! Test_normal10_expand()
+func Test_normal10_expand()
" Test for expand()
10new
call setline(1, ['1', 'ifooar,,cbar'])
@@ -420,7 +420,7 @@ func! Test_normal10_expand()
bw!
endfunc
-func! Test_normal11_showcmd()
+func Test_normal11_showcmd()
" test for 'showcmd'
10new
exe "norm! ofoobar\<esc>"
@@ -435,7 +435,7 @@ func! Test_normal11_showcmd()
bw!
endfunc
-func! Test_normal12_nv_error()
+func Test_normal12_nv_error()
" Test for nv_error
10new
call setline(1, range(1,5))
@@ -445,7 +445,7 @@ func! Test_normal12_nv_error()
bw!
endfunc
-func! Test_normal13_help()
+func Test_normal13_help()
" Test for F1
call assert_equal(1, winnr())
call feedkeys("\<f1>", 'txi')
@@ -454,7 +454,7 @@ func! Test_normal13_help()
bw!
endfunc
-func! Test_normal14_page()
+func Test_normal14_page()
" basic test for Ctrl-F and Ctrl-B
call Setup_NewWindow()
exe "norm! \<c-f>"
@@ -488,7 +488,7 @@ func! Test_normal14_page()
bw!
endfunc
-func! Test_normal14_page_eol()
+func Test_normal14_page_eol()
10new
norm oxxxxxxx
exe "norm 2\<c-f>"
@@ -497,7 +497,7 @@ func! Test_normal14_page_eol()
bw!
endfunc
-func! Test_normal15_z_scroll_vert()
+func Test_normal15_z_scroll_vert()
" basic test for z commands that scroll the window
call Setup_NewWindow()
100
@@ -586,7 +586,7 @@ func! Test_normal15_z_scroll_vert()
bw!
endfunc
-func! Test_normal16_z_scroll_hor()
+func Test_normal16_z_scroll_hor()
" basic test for z commands that scroll the window
10new
15vsp
@@ -652,7 +652,7 @@ func! Test_normal16_z_scroll_hor()
bw!
endfunc
-func! Test_normal17_z_scroll_hor2()
+func Test_normal17_z_scroll_hor2()
" basic test for z commands that scroll the window
" using 'sidescrolloff' setting
10new
@@ -719,7 +719,7 @@ func! Test_normal17_z_scroll_hor2()
bw!
endfunc
-func! Test_normal18_z_fold()
+func Test_normal18_z_fold()
" basic tests for foldopen/folddelete
if !has("folding")
return
@@ -1090,7 +1090,7 @@ func! Test_normal18_z_fold()
bw!
endfunc
-func! Test_normal19_z_spell()
+func Test_normal19_z_spell()
if !has("spell") || !has('syntax')
return
endif
@@ -1245,7 +1245,7 @@ func! Test_normal19_z_spell()
bw!
endfunc
-func! Test_normal20_exmode()
+func Test_normal20_exmode()
if !has("unix")
" Reading from redirected file doesn't work on MS-Windows
return
@@ -1263,24 +1263,38 @@ func! Test_normal20_exmode()
bw!
endfunc
-func! Test_normal21_nv_hat()
- set hidden
- new
- " to many buffers opened already, will not work
- "call assert_fails(":b#", 'E23')
- "call assert_equal('', @#)
- e Xfoobar
- e Xfile2
- call feedkeys("\<c-^>", 't')
- call assert_equal("Xfile2", fnamemodify(bufname('%'), ':t'))
- call feedkeys("f\<c-^>", 't')
- call assert_equal("Xfile2", fnamemodify(bufname('%'), ':t'))
- " clean up
- set nohidden
- bw!
+func Test_normal21_nv_hat()
+
+ " Edit a fresh file and wipe the buffer list so that there is no alternate
+ " file present. Next, check for the expected command failures.
+ edit Xfoo | %bw
+ call assert_fails(':buffer #', 'E86')
+ call assert_fails(':execute "normal! \<C-^>"', 'E23')
+
+ " Test for the expected behavior when switching between two named buffers.
+ edit Xfoo | edit Xbar
+ call feedkeys("\<C-^>", 'tx')
+ call assert_equal('Xfoo', fnamemodify(bufname('%'), ':t'))
+ call feedkeys("\<C-^>", 'tx')
+ call assert_equal('Xbar', fnamemodify(bufname('%'), ':t'))
+
+ " Test for the expected behavior when only one buffer is named.
+ enew | let l:nr = bufnr('%')
+ call feedkeys("\<C-^>", 'tx')
+ call assert_equal('Xbar', fnamemodify(bufname('%'), ':t'))
+ call feedkeys("\<C-^>", 'tx')
+ call assert_equal('', bufname('%'))
+ call assert_equal(l:nr, bufnr('%'))
+
+ " Test that no action is taken by "<C-^>" when an operator is pending.
+ edit Xfoo
+ call feedkeys("ci\<C-^>", 'tx')
+ call assert_equal('Xfoo', fnamemodify(bufname('%'), ':t'))
+
+ %bw!
endfunc
-func! Test_normal22_zet()
+func Test_normal22_zet()
" Test for ZZ
" let shell = &shell
" let &shell = 'sh'
@@ -1308,7 +1322,7 @@ func! Test_normal22_zet()
" let &shell = shell
endfunc
-func! Test_normal23_K()
+func Test_normal23_K()
" Test for K command
new
call append(0, ['helphelp.txt', 'man', 'aa%bb', 'cc|dd'])
@@ -1353,8 +1367,9 @@ func! Test_normal23_K()
return
endif
- if has('mac')
- " In MacOS, the option for specifying a pager is different
+ let not_gnu_man = has('mac') || has('bsd')
+ if not_gnu_man
+ " In MacOS and BSD, the option for specifying a pager is different
set keywordprg=man\ -P\ cat
else
set keywordprg=man\ --pager=cat
@@ -1362,7 +1377,7 @@ func! Test_normal23_K()
" Test for using man
2
let a = execute('unsilent norm! K')
- if has('mac')
+ if not_gnu_man
call assert_match("man -P cat 'man'", a)
else
call assert_match("man --pager=cat 'man'", a)
@@ -1373,7 +1388,7 @@ func! Test_normal23_K()
bw!
endfunc
-func! Test_normal24_rot13()
+func Test_normal24_rot13()
" Testing for g?? g?g?
new
call append(0, 'abcdefghijklmnopqrstuvwxyzäüö')
@@ -1387,7 +1402,7 @@ func! Test_normal24_rot13()
bw!
endfunc
-func! Test_normal25_tag()
+func Test_normal25_tag()
" Testing for CTRL-] g CTRL-] g]
" CTRL-W g] CTRL-W CTRL-] CTRL-W g CTRL-]
h
@@ -1454,7 +1469,7 @@ func! Test_normal25_tag()
helpclose
endfunc
-func! Test_normal26_put()
+func Test_normal26_put()
" Test for ]p ]P [p and [P
new
call append(0, ['while read LINE', 'do', ' ((count++))', ' if [ $? -ne 0 ]; then', " echo 'Error writing file'", ' fi', 'done'])
@@ -1473,7 +1488,7 @@ func! Test_normal26_put()
bw!
endfunc
-func! Test_normal27_bracket()
+func Test_normal27_bracket()
" Test for [' [` ]' ]`
call Setup_NewWindow()
1,21s/.\+/ & b/
@@ -1524,7 +1539,7 @@ func! Test_normal27_bracket()
bw!
endfunc
-func! Test_normal28_parenthesis()
+func Test_normal28_parenthesis()
" basic testing for ( and )
new
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
@@ -1549,52 +1564,94 @@ endfunc
fun! Test_normal29_brace()
" basic test for { and } movements
- let text= ['A paragraph begins after each empty line, and also at each of a set of',
- \ 'paragraph macros, specified by the pairs of characters in the ''paragraphs''',
- \ 'option. The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to',
- \ 'the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in',
- \ 'the first column). A section boundary is also a paragraph boundary.',
- \ 'Note that a blank line (only containing white space) is NOT a paragraph',
- \ 'boundary.',
- \ '',
- \ '',
- \ 'Also note that this does not include a ''{'' or ''}'' in the first column. When',
- \ 'the ''{'' flag is in ''cpoptions'' then ''{'' in the first column is used as a',
- \ 'paragraph boundary |posix|.',
- \ '{',
- \ 'This is no paragraph',
- \ 'unless the ''{'' is set',
- \ 'in ''cpoptions''',
- \ '}',
- \ '.IP',
- \ 'The nroff macros IP separates a paragraph',
- \ 'That means, it must be a ''.''',
- \ 'followed by IP',
- \ '.LPIt does not matter, if afterwards some',
- \ 'more characters follow.',
- \ '.SHAlso section boundaries from the nroff',
- \ 'macros terminate a paragraph. That means',
- \ 'a character like this:',
- \ '.NH',
- \ 'End of text here']
+ let text =<< trim [DATA]
+ A paragraph begins after each empty line, and also at each of a set of
+ paragraph macros, specified by the pairs of characters in the 'paragraphs'
+ option. The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to
+ the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in
+ the first column). A section boundary is also a paragraph boundary.
+ Note that a blank line (only containing white space) is NOT a paragraph
+ boundary.
+
+
+ Also note that this does not include a '{' or '}' in the first column. When
+ the '{' flag is in 'cpoptions' then '{' in the first column is used as a
+ paragraph boundary |posix|.
+ {
+ This is no paragraph
+ unless the '{' is set
+ in 'cpoptions'
+ }
+ .IP
+ The nroff macros IP separates a paragraph
+ That means, it must be a '.'
+ followed by IP
+ .LPIt does not matter, if afterwards some
+ more characters follow.
+ .SHAlso section boundaries from the nroff
+ macros terminate a paragraph. That means
+ a character like this:
+ .NH
+ End of text here
+ [DATA]
+
new
call append(0, text)
1
norm! 0d2}
- call assert_equal(['.IP',
- \ 'The nroff macros IP separates a paragraph', 'That means, it must be a ''.''', 'followed by IP',
- \ '.LPIt does not matter, if afterwards some', 'more characters follow.', '.SHAlso section boundaries from the nroff',
- \ 'macros terminate a paragraph. That means', 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
+
+ let expected =<< trim [DATA]
+ .IP
+ The nroff macros IP separates a paragraph
+ That means, it must be a '.'
+ followed by IP
+ .LPIt does not matter, if afterwards some
+ more characters follow.
+ .SHAlso section boundaries from the nroff
+ macros terminate a paragraph. That means
+ a character like this:
+ .NH
+ End of text here
+
+ [DATA]
+ call assert_equal(expected, getline(1, '$'))
+
norm! 0d}
- call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.',
- \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
- \ 'a character like this:', '.NH', 'End of text here', ''], getline(1, '$'))
+
+ let expected =<< trim [DATA]
+ .LPIt does not matter, if afterwards some
+ more characters follow.
+ .SHAlso section boundaries from the nroff
+ macros terminate a paragraph. That means
+ a character like this:
+ .NH
+ End of text here
+
+ [DATA]
+ call assert_equal(expected, getline(1, '$'))
+
$
norm! d{
- call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.',
- \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means', 'a character like this:', ''], getline(1, '$'))
+
+ let expected =<< trim [DATA]
+ .LPIt does not matter, if afterwards some
+ more characters follow.
+ .SHAlso section boundaries from the nroff
+ macros terminate a paragraph. That means
+ a character like this:
+
+ [DATA]
+ call assert_equal(expected, getline(1, '$'))
+
norm! d{
- call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.', ''], getline(1,'$'))
+
+ let expected =<< trim [DATA]
+ .LPIt does not matter, if afterwards some
+ more characters follow.
+
+ [DATA]
+ call assert_equal(expected, getline(1, '$'))
+
" Test with { in cpooptions
%d
call append(0, text)
@@ -1602,21 +1659,62 @@ fun! Test_normal29_brace()
" set cpo+={
" 1
" norm! 0d2}
- " call assert_equal(['{', 'This is no paragraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}',
- " \ '.IP', 'The nroff macros IP separates a paragraph', 'That means, it must be a ''.''',
- " \ 'followed by IP', '.LPIt does not matter, if afterwards some', 'more characters follow.',
- " \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
- " \ 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
+ " let expected =<< trim [DATA]
+ " {
+ " This is no paragraph
+ " unless the '{' is set
+ " in 'cpoptions'
+ " }
+ " .IP
+ " The nroff macros IP separates a paragraph
+ " That means, it must be a '.'
+ " followed by IP
+ " .LPIt does not matter, if afterwards some
+ " more characters follow.
+ " .SHAlso section boundaries from the nroff
+ " macros terminate a paragraph. That means
+ " a character like this:
+ " .NH
+ " End of text here
+ "
+ " [DATA]
+ " call assert_equal(expected, getline(1, '$'))
+ "
" $
" norm! d}
- " call assert_equal(['{', 'This is no paragraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}',
- " \ '.IP', 'The nroff macros IP separates a paragraph', 'That means, it must be a ''.''',
- " \ 'followed by IP', '.LPIt does not matter, if afterwards some', 'more characters follow.',
- " \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
- " \ 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
+ " let expected =<< trim [DATA]
+ " {
+ " This is no paragraph
+ " unless the '{' is set
+ " in 'cpoptions'
+ " }
+ " .IP
+ " The nroff macros IP separates a paragraph
+ " That means, it must be a '.'
+ " followed by IP
+ " .LPIt does not matter, if afterwards some
+ " more characters follow.
+ " .SHAlso section boundaries from the nroff
+ " macros terminate a paragraph. That means
+ " a character like this:
+ " .NH
+ " End of text here
+ "
+ " [DATA]
+ " call assert_equal(expected, getline(1, '$'))
+ "
" norm! gg}
" norm! d5}
- " call assert_equal(['{', 'This is no paragraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}', ''], getline(1,'$'))
+ "
+ " let expected =<< trim [DATA]
+ " {
+ " This is no paragraph
+ " unless the '{' is set
+ " in 'cpoptions'
+ " }
+
+ " [DATA]
+ " call assert_equal(expected, getline(1, '$'))
" clean up
set cpo-={
@@ -1718,7 +1816,7 @@ fun! Test_normal31_r_cmd()
bw!
endfunc
-func! Test_normal32_g_cmd1()
+func Test_normal32_g_cmd1()
" Test for g*, g#
new
call append(0, ['abc.x_foo', 'x_foobar.abc'])
@@ -1798,6 +1896,7 @@ fun! Test_normal33_g_cmd2()
set wrap listchars= sbr=
let lineA='abcdefghijklmnopqrstuvwxyz'
let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ let lineC='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
$put =lineA
$put =lineB
@@ -1831,9 +1930,30 @@ fun! Test_normal33_g_cmd2()
call assert_equal(15, col('.'))
call assert_equal('l', getreg(0))
+ norm! 2ggdd
+ $put =lineC
+
+ " Test for gM
+ norm! gMyl
+ call assert_equal(73, col('.'))
+ call assert_equal('0', getreg(0))
+ " Test for 20gM
+ norm! 20gMyl
+ call assert_equal(29, col('.'))
+ call assert_equal('S', getreg(0))
+ " Test for 60gM
+ norm! 60gMyl
+ call assert_equal(87, col('.'))
+ call assert_equal('E', getreg(0))
+
+ " Test for g Ctrl-G
+ set ff=unix
+ let a=execute(":norm! g\<c-g>")
+ call assert_match('Col 87 of 144; Line 2 of 2; Word 1 of 1; Byte 88 of 146', a)
+
" Test for gI
norm! gIfoo
- call assert_equal(['', 'fooabcdefghijk lmno0123456789AMNOPQRSTUVWXYZ'], getline(1,'$'))
+ call assert_equal(['', 'foo0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'], getline(1,'$'))
" Test for gi
wincmd c
@@ -1849,7 +1969,7 @@ fun! Test_normal33_g_cmd2()
bw!
endfunc
-func! Test_g_ctrl_g()
+func Test_g_ctrl_g()
new
let a = execute(":norm! g\<c-g>")
@@ -2139,7 +2259,7 @@ fun! Test_normal41_insert_reg()
bw!
endfunc
-func! Test_normal42_halfpage()
+func Test_normal42_halfpage()
" basic test for Ctrl-D and Ctrl-U
call Setup_NewWindow()
call assert_equal(5, &scroll)
@@ -2207,7 +2327,7 @@ fun! Test_normal43_textobject1()
bw!
endfunc
-func! Test_normal44_textobjects2()
+func Test_normal44_textobjects2()
" basic testing for is and as text objects
new
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
@@ -2262,7 +2382,7 @@ func! Test_normal44_textobjects2()
bw!
endfunc
-func! Test_normal45_drop()
+func Test_normal45_drop()
if !has('dnd')
" The ~ register does not exist
call assert_beeps('norm! "~')
@@ -2280,7 +2400,7 @@ func! Test_normal45_drop()
bw!
endfunc
-func! Test_normal46_ignore()
+func Test_normal46_ignore()
new
" How to test this?
" let's just for now test, that the buffer
@@ -2299,7 +2419,7 @@ func! Test_normal46_ignore()
bw!
endfunc
-func! Test_normal47_visual_buf_wipe()
+func Test_normal47_visual_buf_wipe()
" This was causing a crash or ml_get error.
enew!
call setline(1,'xxx')
@@ -2313,7 +2433,7 @@ func! Test_normal47_visual_buf_wipe()
set nomodified
endfunc
-func! Test_normal47_autocmd()
+func Test_normal47_autocmd()
" disabled, does not seem to be possible currently
throw "Skipped: not possible to test cursorhold autocmd while waiting for input in normal_cmd"
new
@@ -2331,14 +2451,14 @@ func! Test_normal47_autocmd()
bw!
endfunc
-func! Test_normal48_wincmd()
+func Test_normal48_wincmd()
new
exe "norm! \<c-w>c"
call assert_equal(1, winnr('$'))
call assert_fails(":norm! \<c-w>c", "E444")
endfunc
-func! Test_normal49_counts()
+func Test_normal49_counts()
new
call setline(1, 'one two three four five six seven eight nine ten')
1
@@ -2347,7 +2467,7 @@ func! Test_normal49_counts()
bw!
endfunc
-func! Test_normal50_commandline()
+func Test_normal50_commandline()
if !has("timers") || !has("cmdline_hist") || !has("vertsplit")
return
endif
@@ -2378,7 +2498,7 @@ func! Test_normal50_commandline()
bw!
endfunc
-func! Test_normal51_FileChangedRO()
+func Test_normal51_FileChangedRO()
if !has("autocmd")
return
endif
@@ -2395,7 +2515,7 @@ func! Test_normal51_FileChangedRO()
call delete("Xreadonly.log")
endfunc
-func! Test_normal52_rl()
+func Test_normal52_rl()
if !has("rightleft")
return
endif
@@ -2428,7 +2548,7 @@ func! Test_normal52_rl()
bw!
endfunc
-func! Test_normal53_digraph()
+func Test_normal53_digraph()
if !has('digraphs')
return
endif
@@ -2474,6 +2594,15 @@ func Test_normal_large_count()
bwipe!
endfunc
+func Test_delete_until_paragraph()
+ new
+ normal grádv}
+ call assert_equal('á', getline(1))
+ normal grád}
+ call assert_equal('', getline(1))
+ bwipe!
+endfunc
+
" Test for the gr (virtual replace) command
" Test for the bug fixed by 7.4.387
func Test_gr_command()
@@ -2516,13 +2645,27 @@ func Test_changelist()
let &ul = save_ul
endfunc
-func Test_delete_until_paragraph()
- new
- normal grádv}
- call assert_equal('á', getline(1))
- normal grád}
- call assert_equal('', getline(1))
- bwipe!
+func Test_nv_hat_count()
+ %bwipeout!
+ let l:nr = bufnr('%') + 1
+ call assert_fails(':execute "normal! ' . l:nr . '\<C-^>"', 'E92')
+
+ edit Xfoo
+ let l:foo_nr = bufnr('Xfoo')
+
+ edit Xbar
+ let l:bar_nr = bufnr('Xbar')
+
+ " Make sure we are not just using the alternate file.
+ edit Xbaz
+
+ call feedkeys(l:foo_nr . "\<C-^>", 'tx')
+ call assert_equal('Xfoo', fnamemodify(bufname('%'), ':t'))
+
+ call feedkeys(l:bar_nr . "\<C-^>", 'tx')
+ call assert_equal('Xbar', fnamemodify(bufname('%'), ':t'))
+
+ %bwipeout!
endfunc
func Test_message_when_using_ctrl_c()
@@ -2617,3 +2760,105 @@ Piece of Java
close!
endfunc
+
+fun! Test_normal_gdollar_cmd()
+ if !has("jumplist")
+ return
+ endif
+ " Tests for g cmds
+ call Setup_NewWindow()
+ " Make long lines that will wrap
+ %s/$/\=repeat(' foobar', 10)/
+ 20vsp
+ set wrap
+ " Test for g$ with count
+ norm! gg
+ norm! 0vg$y
+ call assert_equal(20, col("'>"))
+ call assert_equal('1 foobar foobar foob', getreg(0))
+ norm! gg
+ norm! 0v4g$y
+ call assert_equal(72, col("'>"))
+ call assert_equal('1 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.."\n", getreg(0))
+ norm! gg
+ norm! 0v6g$y
+ call assert_equal(40, col("'>"))
+ call assert_equal('1 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '2 foobar foobar foobar foobar foobar foo', getreg(0))
+ set nowrap
+ " clean up
+ norm! gg
+ norm! 0vg$y
+ call assert_equal(20, col("'>"))
+ call assert_equal('1 foobar foobar foob', getreg(0))
+ norm! gg
+ norm! 0v4g$y
+ call assert_equal(20, col("'>"))
+ call assert_equal('1 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '2 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '3 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '4 foobar foobar foob', getreg(0))
+ norm! gg
+ norm! 0v6g$y
+ call assert_equal(20, col("'>"))
+ call assert_equal('1 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '2 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '3 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '4 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '5 foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar'.. "\n"..
+ \ '6 foobar foobar foob', getreg(0))
+ " Move to last line, also down movement is not possible, should still move
+ " the cursor to the last visible char
+ norm! G
+ norm! 0v6g$y
+ call assert_equal(20, col("'>"))
+ call assert_equal('100 foobar foobar fo', getreg(0))
+ bw!
+endfunc
+
+func Test_normal_gk()
+ " needs 80 column new window
+ new
+ vert 80new
+ put =[repeat('x',90)..' {{{1', 'x {{{1']
+ norm! gk
+ " In a 80 column wide terminal the window will be only 78 char
+ " (because Vim will leave space for the other window),
+ " but if the terminal is larger, it will be 80 chars, so verify the
+ " cursor column correctly.
+ call assert_equal(winwidth(0)+1, col('.'))
+ call assert_equal(winwidth(0)+1, virtcol('.'))
+ norm! j
+ call assert_equal(6, col('.'))
+ call assert_equal(6, virtcol('.'))
+ norm! gk
+ call assert_equal(95, col('.'))
+ call assert_equal(95, virtcol('.'))
+ bw!
+ bw!
+
+ " needs 80 column new window
+ new
+ vert 80new
+ set number
+ set numberwidth=10
+ set cpoptions+=n
+ put =[repeat('0',90), repeat('1',90)]
+ norm! 075l
+ call assert_equal(76, col('.'))
+ norm! gk
+ call assert_equal(1, col('.'))
+ norm! gk
+ call assert_equal(76, col('.'))
+ norm! gk
+ call assert_equal(1, col('.'))
+ norm! gj
+ call assert_equal(76, col('.'))
+ norm! gj
+ call assert_equal(1, col('.'))
+ norm! gj
+ call assert_equal(76, col('.'))
+ bw!
+ bw!
+ set cpoptions& number& numberwidth&
+endfunc
diff --git a/src/nvim/testdir/test_number.vim b/src/nvim/testdir/test_number.vim
index 59debcea0d..3c9afc41d5 100644
--- a/src/nvim/testdir/test_number.vim
+++ b/src/nvim/testdir/test_number.vim
@@ -252,3 +252,14 @@ func Test_numberwidth_adjusted()
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
+
+" This was causing a memcheck error
+func Test_relativenumber_uninitialised()
+ new
+ set rnu
+ call setline(1, ["a", "b"])
+ redraw
+ call feedkeys("j", 'xt')
+ redraw
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index f4f5cbca61..04a5c62f66 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -42,6 +42,13 @@ function Test_wildchar()
set wildchar&
endfunction
+func Test_wildoptions()
+ set wildoptions=
+ set wildoptions+=tagfile
+ set wildoptions+=tagfile
+ call assert_equal('tagfile', &wildoptions)
+endfunc
+
function! Test_options()
let caught = 'ok'
try
@@ -277,6 +284,21 @@ func Test_set_errors()
call assert_fails('set t_foo=', 'E846:')
endfunc
+" Must be executed before other tests that set 'term'.
+func Test_000_term_option_verbose()
+ if has('nvim') || has('gui_running')
+ return
+ endif
+ let verb_cm = execute('verbose set t_cm')
+ call assert_notmatch('Last set from', verb_cm)
+
+ let term_save = &term
+ set term=ansi
+ let verb_cm = execute('verbose set t_cm')
+ call assert_match('Last set from.*test_options.vim', verb_cm)
+ let &term = term_save
+endfunc
+
func Test_set_ttytype()
" Nvim does not support 'ttytype'.
if !has('nvim') && !has('gui_running') && has('unix')
@@ -476,13 +498,19 @@ func Test_shortmess_F2()
call assert_match('file2', execute('bn', ''))
set shortmess+=F
call assert_true(empty(execute('bn', '')))
+ " call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', '')))
+ " call assert_false(test_getvalue('need_fileinfo'))
set hidden
call assert_true(empty(execute('bn', '')))
+ " call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', '')))
+ " call assert_false(test_getvalue('need_fileinfo'))
set nohidden
call assert_true(empty(execute('bn', '')))
+ " call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', '')))
+ " call assert_false(test_getvalue('need_fileinfo'))
" Accommodate Nvim default.
set shortmess-=F
call assert_match('file1', execute('bn', ''))
@@ -490,3 +518,61 @@ func Test_shortmess_F2()
bwipe
bwipe
endfunc
+
+func Test_local_scrolloff()
+ set so=5
+ set siso=7
+ split
+ call assert_equal(5, &so)
+ setlocal so=3
+ call assert_equal(3, &so)
+ wincmd w
+ call assert_equal(5, &so)
+ wincmd w
+ setlocal so<
+ call assert_equal(5, &so)
+ setlocal so=0
+ call assert_equal(0, &so)
+ setlocal so=-1
+ call assert_equal(5, &so)
+
+ call assert_equal(7, &siso)
+ setlocal siso=3
+ call assert_equal(3, &siso)
+ wincmd w
+ call assert_equal(7, &siso)
+ wincmd w
+ setlocal siso<
+ call assert_equal(7, &siso)
+ setlocal siso=0
+ call assert_equal(0, &siso)
+ setlocal siso=-1
+ call assert_equal(7, &siso)
+
+ close
+ set so&
+ set siso&
+endfunc
+
+func Test_visualbell()
+ set belloff=
+ set visualbell
+ call assert_beeps('normal 0h')
+ set novisualbell
+ set belloff=all
+endfunc
+
+" Test for setting option values using v:false and v:true
+func Test_opt_boolean()
+ set number&
+ set number
+ call assert_equal(1, &nu)
+ set nonu
+ call assert_equal(0, &nu)
+ let &nu = v:true
+ call assert_equal(1, &nu)
+ let &nu = v:false
+ call assert_equal(0, &nu)
+ set number&
+endfunc
+
diff --git a/src/nvim/testdir/test_plus_arg_edit.vim b/src/nvim/testdir/test_plus_arg_edit.vim
index f6d31e7626..e91a6e467a 100644
--- a/src/nvim/testdir/test_plus_arg_edit.vim
+++ b/src/nvim/testdir/test_plus_arg_edit.vim
@@ -8,3 +8,31 @@ function Test_edit()
call delete('Xfile1')
call delete('Xfile2')
endfunction
+
+func Test_edit_bad()
+ if !has('multi_byte')
+ finish
+ endif
+
+ " Test loading a utf8 file with bad utf8 sequences.
+ call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xfile")
+ new
+
+ " Without ++bad=..., the default behavior is like ++bad=?
+ e! ++enc=utf8 Xfile
+ call assert_equal('[?][?][???][??]', getline(1))
+
+ e! ++enc=utf8 ++bad=_ Xfile
+ call assert_equal('[_][_][___][__]', getline(1))
+
+ e! ++enc=utf8 ++bad=drop Xfile
+ call assert_equal('[][][][]', getline(1))
+
+ e! ++enc=utf8 ++bad=keep Xfile
+ call assert_equal("[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]", getline(1))
+
+ call assert_fails('e! ++enc=utf8 ++bad=foo Xfile', 'E474:')
+
+ bw!
+ call delete('Xfile')
+endfunc
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 53df30bb19..bb0ed6e00c 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -1,6 +1,7 @@
" Test for completion menu
source shared.vim
+source screendump.vim
let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
let g:setting = ''
@@ -680,18 +681,15 @@ func Test_popup_and_window_resize()
call term_sendkeys(buf, "\<c-v>")
call term_wait(buf, 100)
" popup first entry "!" must be at the top
- call WaitFor({-> term_getline(buf, 1) =~ "^!"})
- call assert_match('^!\s*$', term_getline(buf, 1))
+ call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, 1))})
exe 'resize +' . (h - 1)
call term_wait(buf, 100)
redraw!
" popup shifted down, first line is now empty
- call WaitFor({-> term_getline(buf, 1) == ""})
- call assert_equal('', term_getline(buf, 1))
+ call WaitForAssert({-> assert_equal('', term_getline(buf, 1))})
sleep 100m
" popup is below cursor line and shows first match "!"
- call WaitFor({-> term_getline(buf, term_getcursor(buf)[0] + 1) =~ "^!"})
- call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))
+ call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))})
" cursor line also shows !
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0]))
bwipe!
@@ -735,6 +733,70 @@ func Test_popup_and_preview_autocommand()
bw!
endfunc
+func Test_popup_and_previewwindow_dump()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ call writefile([
+ \ 'set previewheight=9',
+ \ 'silent! pedit',
+ \ 'call setline(1, map(repeat(["ab"], 10), "v:val. v:key"))',
+ \ 'exec "norm! G\<C-E>\<C-E>"',
+ \ ], 'Xscript')
+ let buf = RunVimInTerminal('-S Xscript', {})
+
+ " Test that popup and previewwindow do not overlap.
+ call term_sendkeys(buf, "o\<C-X>\<C-N>")
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_popup_and_previewwindow_01', {})
+
+ call term_sendkeys(buf, "\<Esc>u")
+ call StopVimInTerminal(buf)
+ call delete('Xscript')
+endfunc
+
+func Test_popup_position()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ let lines =<< trim END
+ 123456789_123456789_123456789_a
+ 123456789_123456789_123456789_b
+ 123
+ END
+ call writefile(lines, 'Xtest')
+ let buf = RunVimInTerminal('Xtest', {})
+ call term_sendkeys(buf, ":vsplit\<CR>")
+
+ " default pumwidth in left window: overlap in right window
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_01', {'rows': 8})
+ call term_sendkeys(buf, "\<Esc>u")
+
+ " default pumwidth: fill until right of window
+ call term_sendkeys(buf, "\<C-W>l")
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_02', {'rows': 8})
+
+ " larger pumwidth: used as minimum width
+ call term_sendkeys(buf, "\<Esc>u")
+ call term_sendkeys(buf, ":set pumwidth=30\<CR>")
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_03', {'rows': 8})
+
+ " completed text wider than the window and 'pumwidth' smaller than available
+ " space
+ call term_sendkeys(buf, "\<Esc>u")
+ call term_sendkeys(buf, ":set pumwidth=20\<CR>")
+ call term_sendkeys(buf, "ggI123456789_\<Esc>")
+ call term_sendkeys(buf, "jI123456789_\<Esc>")
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_04', {'rows': 10})
+
+ call term_sendkeys(buf, "\<Esc>u")
+ call StopVimInTerminal(buf)
+ call delete('Xtest')
+endfunc
func Test_popup_complete_backwards()
new
@@ -746,6 +808,16 @@ func Test_popup_complete_backwards()
bwipe!
endfunc
+func Test_popup_complete_backwards_ctrl_p()
+ new
+ call setline(1, ['Post', 'Port', 'Po'])
+ let expected=['Post', 'Port', 'Port']
+ call cursor(3,2)
+ call feedkeys("A\<C-P>\<C-N>rt\<cr>", 'tx')
+ call assert_equal(expected, getline(1,'$'))
+ bwipe!
+endfunc
+
fun! Test_complete_o_tab()
throw 'skipped: Nvim does not support test_override()'
let s:o_char_pressed = 0
@@ -877,6 +949,20 @@ func Test_popup_complete_info_02()
bwipe!
endfunc
+func Test_popup_complete_info_no_pum()
+ new
+ call assert_false( pumvisible() )
+ let no_pum_info = complete_info()
+ let d = {
+ \ 'mode': '',
+ \ 'pum_visible': 0,
+ \ 'items': [],
+ \ 'selected': -1,
+ \ }
+ call assert_equal( d, complete_info() )
+ bwipe!
+endfunc
+
func Test_CompleteChanged()
new
call setline(1, ['foo', 'bar', 'foobar', ''])
@@ -893,9 +979,9 @@ func Test_CompleteChanged()
call cursor(4, 1)
call feedkeys("Sf\<C-N>", 'tx')
- call assert_equal({'completed_item': {}, 'width': 15,
- \ 'height': 2, 'size': 2,
- \ 'col': 0, 'row': 4, 'scrollbar': v:false}, g:event)
+ call assert_equal({'completed_item': {}, 'width': 15.0,
+ \ 'height': 2.0, 'size': 2,
+ \ 'col': 0.0, 'row': 4.0, 'scrollbar': v:false}, g:event)
call feedkeys("a\<C-N>\<C-N>\<C-E>", 'tx')
call assert_equal('foo', g:word)
call feedkeys("a\<C-N>\<C-N>\<C-N>\<C-E>", 'tx')
@@ -911,4 +997,32 @@ func Test_CompleteChanged()
bw!
endfunc
+function! GetPumPosition()
+ call assert_true( pumvisible() )
+ let g:pum_pos = pum_getpos()
+ return ''
+endfunction
+
+func Test_pum_getpos()
+ new
+ inoremap <buffer><F5> <C-R>=GetPumPosition()<CR>
+ setlocal completefunc=UserDefinedComplete
+
+ let d = {
+ \ 'height': 5.0,
+ \ 'width': 15.0,
+ \ 'row': 1.0,
+ \ 'col': 0.0,
+ \ 'size': 5,
+ \ 'scrollbar': v:false,
+ \ }
+ call feedkeys("i\<C-X>\<C-U>\<F5>", 'tx')
+ call assert_equal(d, g:pum_pos)
+
+ call assert_false( pumvisible() )
+ call assert_equal( {}, pum_getpos() )
+ bw!
+ unlet g:pum_pos
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim
index 7e853eeac3..4b0097617e 100644
--- a/src/nvim/testdir/test_profile.vim
+++ b/src/nvim/testdir/test_profile.vim
@@ -6,34 +6,35 @@ endif
source screendump.vim
func Test_profile_func()
- let lines = [
- \ 'profile start Xprofile_func.log',
- \ 'profile func Foo*"',
- \ "func! Foo1()",
- \ "endfunc",
- \ "func! Foo2()",
- \ " let l:count = 100",
- \ " while l:count > 0",
- \ " let l:count = l:count - 1",
- \ " endwhile",
- \ "endfunc",
- \ "func! Foo3()",
- \ "endfunc",
- \ "func! Bar()",
- \ "endfunc",
- \ "call Foo1()",
- \ "call Foo1()",
- \ "profile pause",
- \ "call Foo1()",
- \ "profile continue",
- \ "call Foo2()",
- \ "call Foo3()",
- \ "call Bar()",
- \ "if !v:profiling",
- \ " delfunc Foo2",
- \ "endif",
- \ "delfunc Foo3",
- \ ]
+ let lines =<< trim [CODE]
+ profile start Xprofile_func.log
+ profile func Foo*
+ func! Foo1()
+ endfunc
+ func! Foo2()
+ let l:count = 100
+ while l:count > 0
+ let l:count = l:count - 1
+ endwhile
+ sleep 1m
+ endfunc
+ func! Foo3()
+ endfunc
+ func! Bar()
+ endfunc
+ call Foo1()
+ call Foo1()
+ profile pause
+ call Foo1()
+ profile continue
+ call Foo2()
+ call Foo3()
+ call Bar()
+ if !v:profiling
+ delfunc Foo2
+ endif
+ delfunc Foo3
+ [CODE]
call writefile(lines, 'Xprofile_func.vim')
call system(v:progpath
@@ -51,10 +52,10 @@ func Test_profile_func()
" - Unlike Foo3(), Foo2() should not be deleted since there is a check
" for v:profiling.
" - Bar() is not reported since it does not match "profile func Foo*".
- call assert_equal(30, len(lines))
+ call assert_equal(31, len(lines))
call assert_equal('FUNCTION Foo1()', lines[0])
- call assert_match('Defined:.*Xprofile_func.vim', lines[1])
+ call assert_match('Defined:.*Xprofile_func.vim:3', lines[1])
call assert_equal('Called 2 times', lines[2])
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
@@ -71,55 +72,56 @@ func Test_profile_func()
call assert_match('^\s*101\s\+.*\swhile l:count > 0$', lines[16])
call assert_match('^\s*100\s\+.*\s let l:count = l:count - 1$', lines[17])
call assert_match('^\s*101\s\+.*\sendwhile$', lines[18])
- call assert_equal('', lines[19])
- call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[20])
- call assert_equal('count total (s) self (s) function', lines[21])
- call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[22])
- call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[23])
- call assert_equal('', lines[24])
- call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[25])
- call assert_equal('count total (s) self (s) function', lines[26])
- call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[27])
- call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[28])
- call assert_equal('', lines[29])
+ call assert_match('^\s*1\s\+.\+sleep 1m$', lines[19])
+ call assert_equal('', lines[20])
+ call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[21])
+ call assert_equal('count total (s) self (s) function', lines[22])
+ call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[23])
+ call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[24])
+ call assert_equal('', lines[25])
+ call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[26])
+ call assert_equal('count total (s) self (s) function', lines[27])
+ call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[28])
+ call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[29])
+ call assert_equal('', lines[30])
call delete('Xprofile_func.vim')
call delete('Xprofile_func.log')
endfunc
func Test_profile_func_with_ifelse()
- let lines = [
- \ "func! Foo1()",
- \ " if 1",
- \ " let x = 0",
- \ " elseif 1",
- \ " let x = 1",
- \ " else",
- \ " let x = 2",
- \ " endif",
- \ "endfunc",
- \ "func! Foo2()",
- \ " if 0",
- \ " let x = 0",
- \ " elseif 1",
- \ " let x = 1",
- \ " else",
- \ " let x = 2",
- \ " endif",
- \ "endfunc",
- \ "func! Foo3()",
- \ " if 0",
- \ " let x = 0",
- \ " elseif 0",
- \ " let x = 1",
- \ " else",
- \ " let x = 2",
- \ " endif",
- \ "endfunc",
- \ "call Foo1()",
- \ "call Foo2()",
- \ "call Foo3()",
- \ ]
+ let lines =<< trim [CODE]
+ func! Foo1()
+ if 1
+ let x = 0
+ elseif 1
+ let x = 1
+ else
+ let x = 2
+ endif
+ endfunc
+ func! Foo2()
+ if 0
+ let x = 0
+ elseif 1
+ let x = 1
+ else
+ let x = 2
+ endif
+ endfunc
+ func! Foo3()
+ if 0
+ let x = 0
+ elseif 0
+ let x = 1
+ else
+ let x = 2
+ endif
+ endfunc
+ call Foo1()
+ call Foo2()
+ call Foo3()
+ [CODE]
call writefile(lines, 'Xprofile_func.vim')
call system(v:progpath
@@ -198,41 +200,41 @@ func Test_profile_func_with_ifelse()
endfunc
func Test_profile_func_with_trycatch()
- let lines = [
- \ "func! Foo1()",
- \ " try",
- \ " let x = 0",
- \ " catch",
- \ " let x = 1",
- \ " finally",
- \ " let x = 2",
- \ " endtry",
- \ "endfunc",
- \ "func! Foo2()",
- \ " try",
- \ " throw 0",
- \ " catch",
- \ " let x = 1",
- \ " finally",
- \ " let x = 2",
- \ " endtry",
- \ "endfunc",
- \ "func! Foo3()",
- \ " try",
- \ " throw 0",
- \ " catch",
- \ " throw 1",
- \ " finally",
- \ " let x = 2",
- \ " endtry",
- \ "endfunc",
- \ "call Foo1()",
- \ "call Foo2()",
- \ "try",
- \ " call Foo3()",
- \ "catch",
- \ "endtry",
- \ ]
+ let lines =<< trim [CODE]
+ func! Foo1()
+ try
+ let x = 0
+ catch
+ let x = 1
+ finally
+ let x = 2
+ endtry
+ endfunc
+ func! Foo2()
+ try
+ throw 0
+ catch
+ let x = 1
+ finally
+ let x = 2
+ endtry
+ endfunc
+ func! Foo3()
+ try
+ throw 0
+ catch
+ throw 1
+ finally
+ let x = 2
+ endtry
+ endfunc
+ call Foo1()
+ call Foo2()
+ try
+ call Foo3()
+ catch
+ endtry
+ [CODE]
call writefile(lines, 'Xprofile_func.vim')
call system(v:progpath
@@ -311,15 +313,15 @@ func Test_profile_func_with_trycatch()
endfunc
func Test_profile_file()
- let lines = [
- \ 'func! Foo()',
- \ 'endfunc',
- \ 'for i in range(10)',
- \ ' " a comment',
- \ ' call Foo()',
- \ 'endfor',
- \ 'call Foo()',
- \ ]
+ let lines =<< trim [CODE]
+ func! Foo()
+ endfunc
+ for i in range(10)
+ " a comment
+ call Foo()
+ endfor
+ call Foo()
+ [CODE]
call writefile(lines, 'Xprofile_file.vim')
call system(v:progpath
@@ -450,26 +452,27 @@ func Test_profile_truncate_mbyte()
endfunc
func Test_profdel_func()
- let lines = [
- \ 'profile start Xprofile_file.log',
- \ 'func! Foo1()',
- \ 'endfunc',
- \ 'func! Foo2()',
- \ 'endfunc',
- \ 'func! Foo3()',
- \ 'endfunc',
- \ '',
- \ 'profile func Foo1',
- \ 'profile func Foo2',
- \ 'call Foo1()',
- \ 'call Foo2()',
- \ '',
- \ 'profile func Foo3',
- \ 'profdel func Foo2',
- \ 'profdel func Foo3',
- \ 'call Foo1()',
- \ 'call Foo2()',
- \ 'call Foo3()' ]
+ let lines =<< trim [CODE]
+ profile start Xprofile_file.log
+ func! Foo1()
+ endfunc
+ func! Foo2()
+ endfunc
+ func! Foo3()
+ endfunc
+
+ profile func Foo1
+ profile func Foo2
+ call Foo1()
+ call Foo2()
+
+ profile func Foo3
+ profdel func Foo2
+ profdel func Foo3
+ call Foo1()
+ call Foo2()
+ call Foo3()
+ [CODE]
call writefile(lines, 'Xprofile_file.vim')
call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
call assert_equal(0, v:shell_error)
@@ -496,14 +499,15 @@ endfunc
func Test_profdel_star()
" Foo() is invoked once before and once after 'profdel *'.
" So profiling should report it only once.
- let lines = [
- \ 'profile start Xprofile_file.log',
- \ 'func! Foo()',
- \ 'endfunc',
- \ 'profile func Foo',
- \ 'call Foo()',
- \ 'profdel *',
- \ 'call Foo()' ]
+ let lines =<< trim [CODE]
+ profile start Xprofile_file.log
+ func! Foo()
+ endfunc
+ profile func Foo
+ call Foo()
+ profdel *
+ call Foo()
+ [CODE]
call writefile(lines, 'Xprofile_file.vim')
call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
call assert_equal(0, v:shell_error)
diff --git a/src/nvim/testdir/test_python2.vim b/src/nvim/testdir/test_python2.vim
index 8d55b59c31..5895ac85a8 100644
--- a/src/nvim/testdir/test_python2.vim
+++ b/src/nvim/testdir/test_python2.vim
@@ -1,5 +1,5 @@
" Test for python 2 commands.
-" TODO: move tests from test87.in here.
+" TODO: move tests from test86.in here.
if !has('python')
finish
@@ -164,3 +164,11 @@ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
bwipe!
endfunction
+
+func Test_Catch_Exception_Message()
+ try
+ py raise RuntimeError( 'TEST' )
+ catch /.*/
+ call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception )
+ endtry
+endfunc
diff --git a/src/nvim/testdir/test_python3.vim b/src/nvim/testdir/test_python3.vim
index cd07b0883f..637648817c 100644
--- a/src/nvim/testdir/test_python3.vim
+++ b/src/nvim/testdir/test_python3.vim
@@ -1,5 +1,5 @@
" Test for python 3 commands.
-" TODO: move tests from test88.in here.
+" TODO: move tests from test87.in here.
if !has('python3')
finish
@@ -164,3 +164,29 @@ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
bwipe!
endfunction
+
+func Test_Catch_Exception_Message()
+ try
+ py3 raise RuntimeError( 'TEST' )
+ catch /.*/
+ call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception )
+ endtry
+endfunc
+
+func Test_unicode()
+ " this crashed Vim once
+ throw "Skipped: nvim does not support changing 'encoding'"
+
+ set encoding=utf32
+ py3 print('hello')
+
+ if !has('win32')
+ set encoding=debug
+ py3 print('hello')
+
+ set encoding=euc-tw
+ py3 print('hello')
+ endif
+
+ set encoding=utf8
+endfunc
diff --git a/src/nvim/testdir/test_pyx2.vim b/src/nvim/testdir/test_pyx2.vim
index 50e57c3bfb..10ff3b6e58 100644
--- a/src/nvim/testdir/test_pyx2.vim
+++ b/src/nvim/testdir/test_pyx2.vim
@@ -72,3 +72,11 @@ func Test_pyxfile()
call assert_match(s:py3pattern, split(var)[0])
endif
endfunc
+
+func Test_Catch_Exception_Message()
+ try
+ pyx raise RuntimeError( 'TEST' )
+ catch /.*/
+ call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception )
+ endtry
+endfunc
diff --git a/src/nvim/testdir/test_pyx3.vim b/src/nvim/testdir/test_pyx3.vim
index 64546b4688..2044af3abe 100644
--- a/src/nvim/testdir/test_pyx3.vim
+++ b/src/nvim/testdir/test_pyx3.vim
@@ -72,3 +72,11 @@ func Test_pyxfile()
call assert_match(s:py2pattern, split(var)[0])
endif
endfunc
+
+func Test_Catch_Exception_Message()
+ try
+ pyx raise RuntimeError( 'TEST' )
+ catch /.*/
+ call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception )
+ endtry
+endfunc
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index b7f45aeeb1..926103b69f 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -37,6 +37,8 @@ func s:setup_commands(cchar)
command! -nargs=* Xgrepadd <mods> grepadd <args>
command! -nargs=* Xhelpgrep helpgrep <args>
command! -nargs=0 -count Xcc <count>cc
+ command! -count=1 -nargs=0 Xbelow <mods><count>cbelow
+ command! -count=1 -nargs=0 Xabove <mods><count>cabove
let g:Xgetlist = function('getqflist')
let g:Xsetlist = function('setqflist')
call setqflist([], 'f')
@@ -70,6 +72,8 @@ func s:setup_commands(cchar)
command! -nargs=* Xgrepadd <mods> lgrepadd <args>
command! -nargs=* Xhelpgrep lhelpgrep <args>
command! -nargs=0 -count Xcc <count>ll
+ command! -count=1 -nargs=0 Xbelow <mods><count>lbelow
+ command! -count=1 -nargs=0 Xabove <mods><count>labove
let g:Xgetlist = function('getloclist', [0])
let g:Xsetlist = function('setloclist', [0])
call setloclist(0, [], 'f')
@@ -163,6 +167,12 @@ endfunc
func XageTests(cchar)
call s:setup_commands(a:cchar)
+ if a:cchar == 'l'
+ " No location list for the current window
+ call assert_fails('lolder', 'E776:')
+ call assert_fails('lnewer', 'E776:')
+ endif
+
let list = [{'bufnr': bufnr('%'), 'lnum': 1}]
call g:Xsetlist(list)
@@ -273,6 +283,27 @@ func Test_cwindow()
call XwindowTests('l')
endfunc
+func Test_copenHeight()
+ copen
+ wincmd H
+ let height = winheight(0)
+ copen 10
+ call assert_equal(height, winheight(0))
+ quit
+endfunc
+
+func Test_copenHeight_tabline()
+ set tabline=foo showtabline=2
+ copen
+ wincmd H
+ let height = winheight(0)
+ copen 10
+ call assert_equal(height, winheight(0))
+ quit
+ set tabline& showtabline&
+endfunc
+
+
" Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile
" commands.
func XfileTests(cchar)
@@ -523,6 +554,33 @@ func s:test_xhelpgrep(cchar)
" This wipes out the buffer, make sure that doesn't cause trouble.
Xclose
+ " When the current window is vertically split, jumping to a help match
+ " should open the help window at the top.
+ only | enew
+ let w1 = win_getid()
+ vert new
+ let w2 = win_getid()
+ Xnext
+ let w3 = win_getid()
+ call assert_true(&buftype == 'help')
+ call assert_true(winnr() == 1)
+ " See jump_to_help_window() for details
+ let w2_width = winwidth(w2)
+ if w2_width != &columns && w2_width < 80
+ call assert_equal(['col', [['leaf', w3],
+ \ ['row', [['leaf', w2], ['leaf', w1]]]]], winlayout())
+ else
+ call assert_equal(['row', [['col', [['leaf', w3], ['leaf', w2]]],
+ \ ['leaf', w1]]] , winlayout())
+ endif
+
+ new | only
+ set buftype=help
+ set modified
+ call assert_fails('Xnext', 'E37:')
+ set nomodified
+ new | only
+
if a:cchar == 'l'
" When a help window is present, running :lhelpgrep should reuse the
" help window and not the current window
@@ -540,6 +598,8 @@ func s:test_xhelpgrep(cchar)
" Search for non existing help string
call assert_fails('Xhelpgrep a1b2c3', 'E480:')
+ " Invalid regular expression
+ call assert_fails('Xhelpgrep \@<!', 'E480:')
endfunc
func Test_helpgrep()
@@ -775,68 +835,68 @@ func Test_efm1()
return
endif
- let l = [
- \ '"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.',
- \ '"Xtestfile", line 6 col 19; this is an error',
- \ 'gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c',
- \ 'Xtestfile:9: parse error before `asd''',
- \ 'make: *** [vim] Error 1',
- \ 'in file "Xtestfile" linenr 10: there is an error',
- \ '',
- \ '2 returned',
- \ '"Xtestfile", line 11 col 1; this is an error',
- \ '"Xtestfile", line 12 col 2; this is another error',
- \ '"Xtestfile", line 14:10; this is an error in column 10',
- \ '=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time',
- \ '"Xtestfile", linenr 16: yet another problem',
- \ 'Error in "Xtestfile" at line 17:',
- \ 'x should be a dot',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17',
- \ ' ^',
- \ 'Error in "Xtestfile" at line 18:',
- \ 'x should be a dot',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18',
- \ '.............^',
- \ 'Error in "Xtestfile" at line 19:',
- \ 'x should be a dot',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19',
- \ '--------------^',
- \ 'Error in "Xtestfile" at line 20:',
- \ 'x should be a dot',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20',
- \ ' ^',
- \ '',
- \ 'Does anyone know what is the problem and how to correction it?',
- \ '"Xtestfile", line 21 col 9: What is the title of the quickfix window?',
- \ '"Xtestfile", line 22 col 9: What is the title of the quickfix window?'
- \ ]
+ let l =<< trim [DATA]
+ "Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
+ "Xtestfile", line 6 col 19; this is an error
+ gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c
+ Xtestfile:9: parse error before `asd'
+ make: *** [vim] Error 1
+ in file "Xtestfile" linenr 10: there is an error
+
+ 2 returned
+ "Xtestfile", line 11 col 1; this is an error
+ "Xtestfile", line 12 col 2; this is another error
+ "Xtestfile", line 14:10; this is an error in column 10
+ =Xtestfile=, line 15:10; this is another error, but in vcol 10 this time
+ "Xtestfile", linenr 16: yet another problem
+ Error in "Xtestfile" at line 17:
+ x should be a dot
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
+ ^
+ Error in "Xtestfile" at line 18:
+ x should be a dot
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
+ .............^
+ Error in "Xtestfile" at line 19:
+ x should be a dot
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
+ --------------^
+ Error in "Xtestfile" at line 20:
+ x should be a dot
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
+ ^
+
+ Does anyone know what is the problem and how to correction it?
+ "Xtestfile", line 21 col 9: What is the title of the quickfix window?
+ "Xtestfile", line 22 col 9: What is the title of the quickfix window?
+ [DATA]
call writefile(l, 'Xerrorfile1')
call writefile(l[:-2], 'Xerrorfile2')
- let m = [
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21',
- \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22'
- \ ]
+ let m =<< [DATA]
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22
+[DATA]
call writefile(m, 'Xtestfile')
let save_efm = &efm
@@ -895,20 +955,21 @@ func s:dir_stack_tests(cchar)
let save_efm=&efm
set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
- let lines = ["Entering dir 'dir1/a'",
- \ 'habits2.txt:1:Nine Healthy Habits',
- \ "Entering dir 'b'",
- \ 'habits3.txt:2:0 Hours of television',
- \ 'habits2.txt:7:5 Small meals',
- \ "Entering dir 'dir1/c'",
- \ 'habits4.txt:3:1 Hour of exercise',
- \ "Leaving dir 'dir1/c'",
- \ "Leaving dir 'dir1/a'",
- \ 'habits1.txt:4:2 Liters of water',
- \ "Entering dir 'dir2'",
- \ 'habits5.txt:5:3 Cups of hot green tea',
- \ "Leaving dir 'dir2'"
- \]
+ let lines =<< trim [DATA]
+ Entering dir 'dir1/a'
+ habits2.txt:1:Nine Healthy Habits
+ Entering dir 'b'
+ habits3.txt:2:0 Hours of television
+ habits2.txt:7:5 Small meals
+ Entering dir 'dir1/c'
+ habits4.txt:3:1 Hour of exercise
+ Leaving dir 'dir1/c'
+ Leaving dir 'dir1/a'
+ habits1.txt:4:2 Liters of water
+ Entering dir 'dir2'
+ habits5.txt:5:3 Cups of hot green tea
+ Leaving dir 'dir2
+ [DATA]
Xexpr ""
for l in lines
@@ -942,18 +1003,20 @@ func Test_efm_dirstack()
call mkdir('dir1/c')
call mkdir('dir2')
- let lines = ["Nine Healthy Habits",
- \ "0 Hours of television",
- \ "1 Hour of exercise",
- \ "2 Liters of water",
- \ "3 Cups of hot green tea",
- \ "4 Short mental breaks",
- \ "5 Small meals",
- \ "6 AM wake up time",
- \ "7 Minutes of laughter",
- \ "8 Hours of sleep (at least)",
- \ "9 PM end of the day and off to bed"
- \ ]
+ let lines =<< trim [DATA]
+ Nine Healthy Habits,
+ 0 Hours of television,
+ 1 Hour of exercise,
+ 2 Liters of water,
+ 3 Cups of hot green tea,
+ 4 Short mental breaks,
+ 5 Small meals,
+ 6 AM wake up time,
+ 7 Minutes of laughter,
+ 8 Hours of sleep (at least),
+ 9 PM end of the day and off to bed
+ [DATA]
+
call writefile(lines, 'habits1.txt')
call writefile(lines, 'dir1/a/habits2.txt')
call writefile(lines, 'dir1/a/b/habits3.txt')
@@ -1042,28 +1105,29 @@ func Test_efm2()
set efm=%f:%s
cexpr 'Xtestfile:Line search text'
let l = getqflist()
- call assert_equal(l[0].pattern, '^\VLine search text\$')
- call assert_equal(l[0].lnum, 0)
+ call assert_equal('^\VLine search text\$', l[0].pattern)
+ call assert_equal(0, l[0].lnum)
let l = split(execute('clist', ''), "\n")
call assert_equal([' 1 Xtestfile:^\VLine search text\$: '], l)
" Test for %P, %Q and %t format specifiers
- let lines=["[Xtestfile1]",
- \ "(1,17) error: ';' missing",
- \ "(21,2) warning: variable 'z' not defined",
- \ "(67,3) error: end of file found before string ended",
- \ "--",
- \ "",
- \ "[Xtestfile2]",
- \ "--",
- \ "",
- \ "[Xtestfile3]",
- \ "NEW compiler v1.1",
- \ "(2,2) warning: variable 'x' not defined",
- \ "(67,3) warning: 's' already defined",
- \ "--"
- \]
+ let lines =<< trim [DATA]
+ [Xtestfile1]
+ (1,17) error: ';' missing
+ (21,2) warning: variable 'z' not defined
+ (67,3) error: end of file found before string ended
+ --
+
+ [Xtestfile2]
+ --
+
+ [Xtestfile3]
+ NEW compiler v1.1
+ (2,2) warning: variable 'x' not defined
+ (67,3) warning: 's' already defined
+ --
+ [DATA]
set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r
" To exercise the push/pop file functionality in quickfix, the test files
" need to be created.
@@ -1085,11 +1149,13 @@ func Test_efm2()
call delete('Xtestfile3')
" Tests for %E, %C and %Z format specifiers
- let lines = ["Error 275",
- \ "line 42",
- \ "column 3",
- \ "' ' expected after '--'"
- \]
+ let lines =<< trim [DATA]
+ Error 275
+ line 42
+ column 3
+ ' ' expected after '--'
+ [DATA]
+
set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m
cgetexpr lines
let l = getqflist()
@@ -1100,9 +1166,11 @@ func Test_efm2()
call assert_equal("\n' ' expected after '--'", l[0].text)
" Test for %>
- let lines = ["Error in line 147 of foo.c:",
- \"unknown variable 'i'"
- \]
+ let lines =<< trim [DATA]
+ Error in line 147 of foo.c:
+ unknown variable 'i'
+ [DATA]
+
set efm=unknown\ variable\ %m,%E%>Error\ in\ line\ %l\ of\ %f:,%Z%m
cgetexpr lines
let l = getqflist()
@@ -1111,21 +1179,21 @@ func Test_efm2()
call assert_equal("\nunknown variable 'i'", l[0].text)
" Test for %A, %C and other formats
- let lines = [
- \"==============================================================",
- \"FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)",
- \"--------------------------------------------------------------",
- \"Traceback (most recent call last):",
- \' File "unittests/dbfacadeTest.py", line 89, in testFoo',
- \" self.assertEquals(34, dtid)",
- \' File "/usr/lib/python2.2/unittest.py", line 286, in',
- \" failUnlessEqual",
- \" raise self.failureException, \\",
- \"AssertionError: 34 != 33",
- \"",
- \"--------------------------------------------------------------",
- \"Ran 27 tests in 0.063s"
- \]
+ let lines =<< trim [DATA]
+ ==============================================================
+ FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)
+ --------------------------------------------------------------
+ Traceback (most recent call last):
+ File "unittests/dbfacadeTest.py", line 89, in testFoo
+ self.assertEquals(34, dtid)
+ File "/usr/lib/python2.2/unittest.py", line 286, in
+ failUnlessEqual
+ raise self.failureException, \\
+ AssertionError: 34 != 33
+
+ --------------------------------------------------------------
+ Ran 27 tests in 0.063s
+ [DATA]
set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
cgetexpr lines
let l = getqflist()
@@ -1279,6 +1347,28 @@ func SetXlistTests(cchar, bnum)
let l = g:Xgetlist()
call g:Xsetlist(l)
call assert_equal(0, g:Xgetlist()[0].valid)
+ " Adding a non-valid entry should not mark the list as having valid entries
+ call g:Xsetlist([{'bufnr':a:bnum, 'lnum':5, 'valid':0}], 'a')
+ Xwindow
+ call assert_equal(1, winnr('$'))
+
+ " :cnext/:cprev should still work even with invalid entries in the list
+ let l = [{'bufnr' : a:bnum, 'lnum' : 1, 'text' : '1', 'valid' : 0},
+ \ {'bufnr' : a:bnum, 'lnum' : 2, 'text' : '2', 'valid' : 0}]
+ call g:Xsetlist(l)
+ Xnext
+ call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)
+ Xprev
+ call assert_equal(1, g:Xgetlist({'idx' : 0}).idx)
+ " :cnext/:cprev should still work after appending invalid entries to an
+ " empty list
+ call g:Xsetlist([])
+ call g:Xsetlist(l, 'a')
+ Xnext
+ call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)
+ Xprev
+ call assert_equal(1, g:Xgetlist({'idx' : 0}).idx)
+
call g:Xsetlist([{'text':'Text1', 'valid':1}])
Xwindow
call assert_equal(2, winnr('$'))
@@ -1447,6 +1537,13 @@ func Test_setqflist_invalid_nr()
call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST})
endfunc
+func Test_setqflist_user_sets_buftype()
+ call setqflist([{'text': 'foo'}, {'text': 'bar'}])
+ set buftype=quickfix
+ call setqflist([], 'a')
+ enew
+endfunc
+
func Test_quickfix_set_list_with_act()
call XquickfixSetListWithAct('c')
call XquickfixSetListWithAct('l')
@@ -1579,6 +1676,14 @@ func Test_switchbuf()
call assert_equal(3, tabpagenr('$'))
tabfirst | enew | tabonly | only
+ set switchbuf=uselast
+ split
+ let last_winid = win_getid()
+ copen
+ exe "normal 1G\<CR>"
+ call assert_equal(last_winid, win_getid())
+ enew | only
+
set switchbuf=
edit Xqftestfile1
let file1_winid = win_getid()
@@ -1955,6 +2060,18 @@ func Xproperty_tests(cchar)
call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10, 'text' : 'L10'}]})
call assert_equal('TestTitle', g:Xgetlist({'title' : 1}).title)
+ " Test for getting id of window associated with a location list window
+ if a:cchar == 'l'
+ only
+ call assert_equal(0, g:Xgetlist({'all' : 1}).filewinid)
+ let wid = win_getid()
+ Xopen
+ call assert_equal(wid, g:Xgetlist({'filewinid' : 1}).filewinid)
+ wincmd w
+ call assert_equal(0, g:Xgetlist({'filewinid' : 1}).filewinid)
+ only
+ endif
+
" The following used to crash Vim with address sanitizer
call g:Xsetlist([], 'f')
call g:Xsetlist([], 'a', {'items' : [{'filename':'F1', 'lnum':10}]})
@@ -2317,6 +2434,12 @@ func XvimgrepTests(cchar)
call assert_equal('Xtestfile2', bufname(''))
call assert_equal('Editor:Emacs EmAcS', l[0].text)
+ " Test for unloading a buffer after vimgrep searched the buffer
+ %bwipe
+ Xvimgrep /Editor/j Xtestfile*
+ call assert_equal(0, getbufinfo('Xtestfile1')[0].loaded)
+ call assert_equal([], getbufinfo('Xtestfile2'))
+
call delete('Xtestfile1')
call delete('Xtestfile2')
endfunc
@@ -2489,7 +2612,7 @@ func Test_file_from_copen()
cclose
augroup! QF_Test
-endfunction
+endfunc
func Test_resize_from_copen()
augroup QF_Test
@@ -2864,185 +2987,101 @@ func Test_qf_id()
call Xqfid_tests('l')
endfunc
-func Test_getqflist_invalid_nr()
- " The following commands used to crash Vim
- cexpr ""
- call getqflist({'nr' : $XXX_DOES_NOT_EXIST_XXX})
-
- " Cleanup
- call setqflist([], 'r')
-endfunc
-
-" Test for shortening/simplifying the file name when opening the
-" quickfix window or when displaying the quickfix list
-func Test_shorten_fname()
- if !has('unix')
- return
- endif
- %bwipe
- " Create a quickfix list with a absolute path filename
- let fname = getcwd() . '/test_quickfix.vim'
- call setqflist([], ' ', {'lines':[fname . ":20:Line20"], 'efm':'%f:%l:%m'})
- call assert_equal(fname, bufname('test_quickfix.vim'))
- " Opening the quickfix window should simplify the file path
- cwindow
- call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
- cclose
- %bwipe
- " Create a quickfix list with a absolute path filename
- call setqflist([], ' ', {'lines':[fname . ":20:Line20"], 'efm':'%f:%l:%m'})
- call assert_equal(fname, bufname('test_quickfix.vim'))
- " Displaying the quickfix list should simplify the file path
- silent! clist
- call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
-endfunc
-
-" Quickfix title tests
-" In the below tests, 'exe "cmd"' is used to invoke the quickfix commands.
-" Otherwise due to indentation, the title is set with spaces at the beginning
-" of the command.
-func Test_qftitle()
- call writefile(["F1:1:Line1"], 'Xerr')
-
- " :cexpr
- exe "cexpr readfile('Xerr')"
- call assert_equal(":cexpr readfile('Xerr')", getqflist({'title' : 1}).title)
-
- " :cgetexpr
- exe "cgetexpr readfile('Xerr')"
- call assert_equal(":cgetexpr readfile('Xerr')",
- \ getqflist({'title' : 1}).title)
-
- " :caddexpr
- call setqflist([], 'f')
- exe "caddexpr readfile('Xerr')"
- call assert_equal(":caddexpr readfile('Xerr')",
- \ getqflist({'title' : 1}).title)
-
- " :cbuffer
- new Xerr
- exe "cbuffer"
- call assert_equal(':cbuffer (Xerr)', getqflist({'title' : 1}).title)
-
- " :cgetbuffer
- edit Xerr
- exe "cgetbuffer"
- call assert_equal(':cgetbuffer (Xerr)', getqflist({'title' : 1}).title)
-
- " :caddbuffer
- call setqflist([], 'f')
- edit Xerr
- exe "caddbuffer"
- call assert_equal(':caddbuffer (Xerr)', getqflist({'title' : 1}).title)
-
- " :cfile
- exe "cfile Xerr"
- call assert_equal(':cfile Xerr', getqflist({'title' : 1}).title)
-
- " :cgetfile
- exe "cgetfile Xerr"
- call assert_equal(':cgetfile Xerr', getqflist({'title' : 1}).title)
-
- " :caddfile
- call setqflist([], 'f')
- exe "caddfile Xerr"
- call assert_equal(':caddfile Xerr', getqflist({'title' : 1}).title)
-
- " :grep
- set grepprg=internal
- exe "grep F1 Xerr"
- call assert_equal(':grep F1 Xerr', getqflist({'title' : 1}).title)
-
- " :grepadd
- call setqflist([], 'f')
- exe "grepadd F1 Xerr"
- call assert_equal(':grepadd F1 Xerr', getqflist({'title' : 1}).title)
- set grepprg&vim
-
- " :vimgrep
- exe "vimgrep F1 Xerr"
- call assert_equal(':vimgrep F1 Xerr', getqflist({'title' : 1}).title)
+func Xqfjump_tests(cchar)
+ call s:setup_commands(a:cchar)
- " :vimgrepadd
- call setqflist([], 'f')
- exe "vimgrepadd F1 Xerr"
- call assert_equal(':vimgrepadd F1 Xerr', getqflist({'title' : 1}).title)
+ call writefile(["Line1\tFoo", "Line2"], 'F1')
+ call writefile(["Line1\tBar", "Line2"], 'F2')
+ call writefile(["Line1\tBaz", "Line2"], 'F3')
- call setqflist(['F1:10:L10'], ' ')
- call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
+ call g:Xsetlist([], 'f')
- call setqflist([], 'f')
- call setqflist(['F1:10:L10'], 'a')
- call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
+ " Tests for
+ " Jumping to a line using a pattern
+ " Jumping to a column greater than the last column in a line
+ " Jumping to a line greater than the last line in the file
+ let l = []
+ for i in range(1, 7)
+ call add(l, {})
+ endfor
+ let l[0].filename='F1'
+ let l[0].pattern='Line1'
+ let l[1].filename='F2'
+ let l[1].pattern='Line1'
+ let l[2].filename='F3'
+ let l[2].pattern='Line1'
+ let l[3].filename='F3'
+ let l[3].lnum=1
+ let l[3].col=9
+ let l[3].vcol=1
+ let l[4].filename='F3'
+ let l[4].lnum=99
+ let l[5].filename='F3'
+ let l[5].lnum=1
+ let l[5].col=99
+ let l[5].vcol=1
+ let l[6].filename='F3'
+ let l[6].pattern='abcxyz'
- call setqflist([], 'f')
- call setqflist(['F1:10:L10'], 'r')
- call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
+ call g:Xsetlist([], ' ', {'items' : l})
+ Xopen | only
+ 2Xnext
+ call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
+ call assert_equal('F3', bufname('%'))
+ Xnext
+ call assert_equal(7, col('.'))
+ Xnext
+ call assert_equal(2, line('.'))
+ Xnext
+ call assert_equal(9, col('.'))
+ 2
+ Xnext
+ call assert_equal(2, line('.'))
- close
- call delete('Xerr')
+ if a:cchar == 'l'
+ " When jumping to a location list entry in the location list window and
+ " no usable windows are available, then a new window should be opened.
+ enew! | new | only
+ call g:Xsetlist([], 'f')
+ setlocal buftype=nofile
+ new
+ call g:Xsetlist([], ' ', {'lines' : ['F1:1:1:Line1', 'F1:2:2:Line2', 'F2:1:1:Line1', 'F2:2:2:Line2', 'F3:1:1:Line1', 'F3:2:2:Line2']})
+ Xopen
+ let winid = win_getid()
+ wincmd p
+ close
+ call win_gotoid(winid)
+ Xnext
+ call assert_equal(3, winnr('$'))
+ call assert_equal(1, winnr())
+ call assert_equal(2, line('.'))
- call setqflist([], ' ', {'title' : 'Errors'})
- copen
- call assert_equal('Errors', w:quickfix_title)
- call setqflist([], 'r', {'items' : [{'filename' : 'a.c', 'lnum' : 10}]})
- call assert_equal('Errors', w:quickfix_title)
- cclose
-endfunc
+ " When jumping to an entry in the location list window and the window
+ " associated with the location list is not present and a window containing
+ " the file is already present, then that window should be used.
+ close
+ belowright new
+ call g:Xsetlist([], 'f')
+ edit F3
+ call win_gotoid(winid)
+ Xlast
+ call assert_equal(3, winnr())
+ call assert_equal(6, g:Xgetlist({'size' : 1}).size)
+ call assert_equal(winid, g:Xgetlist({'winid' : 1}).winid)
+ endif
-" Test for the position of the quickfix and location list window
-func Test_qfwin_pos()
- " Open two windows
+ " Cleanup
+ enew!
new | only
- new
- cexpr ['F1:10:L10']
- copen
- " Quickfix window should be the bottom most window
- call assert_equal(3, winnr())
- close
- " Open at the very top
- wincmd t
- topleft copen
- call assert_equal(1, winnr())
- close
- " open left of the current window
- wincmd t
- below new
- leftabove copen
- call assert_equal(2, winnr())
- close
- " open right of the current window
- rightbelow copen
- call assert_equal(3, winnr())
- close
-endfunc
-" The following test used to crash Vim
-func Test_lhelpgrep_autocmd()
- lhelpgrep quickfix
- autocmd QuickFixCmdPost * call setloclist(0, [], 'f')
- lhelpgrep buffer
- call assert_equal('help', &filetype)
- call assert_equal(0, getloclist(0, {'nr' : '$'}).nr)
- lhelpgrep tabpage
- call assert_equal('help', &filetype)
- call assert_equal(1, getloclist(0, {'nr' : '$'}).nr)
- au! QuickFixCmdPost
- new | only
+ call delete('F1')
+ call delete('F2')
+ call delete('F3')
endfunc
-" Test to make sure that an empty quickfix buffer is not reused for loading
-" a normal buffer.
-func Test_empty_qfbuf()
- enew | only
- call writefile(["Test"], 'Xfile1')
- call setqflist([], 'f')
- copen | only
- let qfbuf = bufnr('')
- edit Xfile1
- call assert_notequal(qfbuf, bufnr(''))
- enew
- call delete('Xfile1')
+func Test_qfjump()
+ call Xqfjump_tests('c')
+ call Xqfjump_tests('l')
endfunc
" Tests for the getqflist() and getloclist() functions when the list is not
@@ -3061,7 +3100,17 @@ func Xgetlist_empty_tests(cchar)
call assert_equal('', g:Xgetlist({'title' : 0}).title)
call assert_equal(0, g:Xgetlist({'winid' : 0}).winid)
call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick)
- call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, 'changedtick': 0}, g:Xgetlist({'all' : 0}))
+ if a:cchar == 'c'
+ call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
+ \ 'items' : [], 'nr' : 0, 'size' : 0,
+ \ 'title' : '', 'winid' : 0, 'changedtick': 0},
+ \ g:Xgetlist({'all' : 0}))
+ else
+ call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
+ \ 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '',
+ \ 'winid' : 0, 'changedtick': 0, 'filewinid' : 0},
+ \ g:Xgetlist({'all' : 0}))
+ endif
" Quickfix window with empty stack
silent! Xopen
@@ -3094,7 +3143,16 @@ func Xgetlist_empty_tests(cchar)
call assert_equal('', g:Xgetlist({'id' : qfid, 'title' : 0}).title)
call assert_equal(0, g:Xgetlist({'id' : qfid, 'winid' : 0}).winid)
call assert_equal(0, g:Xgetlist({'id' : qfid, 'changedtick' : 0}).changedtick)
- call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0}))
+ if a:cchar == 'c'
+ call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
+ \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
+ \ 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0}))
+ else
+ call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
+ \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
+ \ 'changedtick' : 0, 'filewinid' : 0},
+ \ g:Xgetlist({'id' : qfid, 'all' : 0}))
+ endif
" Non-existing quickfix list number
call assert_equal('', g:Xgetlist({'nr' : 5, 'context' : 0}).context)
@@ -3106,7 +3164,16 @@ func Xgetlist_empty_tests(cchar)
call assert_equal('', g:Xgetlist({'nr' : 5, 'title' : 0}).title)
call assert_equal(0, g:Xgetlist({'nr' : 5, 'winid' : 0}).winid)
call assert_equal(0, g:Xgetlist({'nr' : 5, 'changedtick' : 0}).changedtick)
- call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0, 'changedtick' : 0}, g:Xgetlist({'nr' : 5, 'all' : 0}))
+ if a:cchar == 'c'
+ call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
+ \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
+ \ 'changedtick' : 0}, g:Xgetlist({'nr' : 5, 'all' : 0}))
+ else
+ call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
+ \ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
+ \ 'changedtick' : 0, 'filewinid' : 0},
+ \ g:Xgetlist({'nr' : 5, 'all' : 0}))
+ endif
endfunc
func Test_getqflist()
@@ -3114,6 +3181,16 @@ func Test_getqflist()
call Xgetlist_empty_tests('l')
endfunc
+
+func Test_getqflist_invalid_nr()
+ " The following commands used to crash Vim
+ cexpr ""
+ call getqflist({'nr' : $XXX_DOES_NOT_EXIST_XXX})
+
+ " Cleanup
+ call setqflist([], 'r')
+endfunc
+
" Tests for the quickfix/location list changedtick
func Xqftick_tests(cchar)
call s:setup_commands(a:cchar)
@@ -3172,6 +3249,41 @@ func Test_qf_tick()
call Xqftick_tests('l')
endfunc
+" Test helpgrep with lang specifier
+func Xtest_helpgrep_with_lang_specifier(cchar)
+ call s:setup_commands(a:cchar)
+ Xhelpgrep Vim@en
+ call assert_equal('help', &filetype)
+ call assert_notequal(0, g:Xgetlist({'nr' : '$'}).nr)
+ new | only
+endfunc
+
+func Test_helpgrep_with_lang_specifier()
+ call Xtest_helpgrep_with_lang_specifier('c')
+ call Xtest_helpgrep_with_lang_specifier('l')
+endfunc
+
+" The following test used to crash Vim.
+" Open the location list window and close the regular window associated with
+" the location list. When the garbage collection runs now, it incorrectly
+" marks the location list context as not in use and frees the context.
+func Test_ll_window_ctx()
+ call setloclist(0, [], 'f')
+ call setloclist(0, [], 'a', {'context' : []})
+ lopen | only
+ call test_garbagecollect_now()
+ echo getloclist(0, {'context' : 1}).context
+ enew | only
+endfunc
+
+" The following test used to crash vim
+func Test_lfile_crash()
+ sp Xtest
+ au QuickFixCmdPre * bw
+ call assert_fails('lfile', 'E40')
+ au! QuickFixCmdPre
+endfunc
+
" The following test used to crash vim
func Test_lbuffer_crash()
sv Xtest
@@ -3195,7 +3307,28 @@ func Test_lexpr_crash()
augroup QF_Test
au!
augroup END
+
+ enew | only
+ augroup QF_Test
+ au!
+ au BufNew * call setloclist(0, [], 'f')
+ augroup END
+ lexpr 'x:1:x'
+ augroup QF_Test
+ au!
+ augroup END
+
enew | only
+ lexpr ''
+ lopen
+ augroup QF_Test
+ au!
+ au FileType * call setloclist(0, [], 'f')
+ augroup END
+ lexpr ''
+ augroup QF_Test
+ au!
+ augroup END
endfunc
" The following test used to crash Vim
@@ -3212,122 +3345,39 @@ func Test_lvimgrep_crash()
enew | only
endfunc
-func Xqfjump_tests(cchar)
- call s:setup_commands(a:cchar)
-
- call writefile(["Line1\tFoo", "Line2"], 'F1')
- call writefile(["Line1\tBar", "Line2"], 'F2')
- call writefile(["Line1\tBaz", "Line2"], 'F3')
-
- call g:Xsetlist([], 'f')
+func Test_lvimgrep_crash2()
+ au BufNewFile x sfind
+ call assert_fails('lvimgrep x x', 'E480:')
+ call assert_fails('lvimgrep x x x', 'E480:')
- " Tests for
- " Jumping to a line using a pattern
- " Jumping to a column greater than the last column in a line
- " Jumping to a line greater than the last line in the file
- let l = []
- for i in range(1, 7)
- call add(l, {})
- endfor
- let l[0].filename='F1'
- let l[0].pattern='Line1'
- let l[1].filename='F2'
- let l[1].pattern='Line1'
- let l[2].filename='F3'
- let l[2].pattern='Line1'
- let l[3].filename='F3'
- let l[3].lnum=1
- let l[3].col=9
- let l[3].vcol=1
- let l[4].filename='F3'
- let l[4].lnum=99
- let l[5].filename='F3'
- let l[5].lnum=1
- let l[5].col=99
- let l[5].vcol=1
- let l[6].filename='F3'
- let l[6].pattern='abcxyz'
-
- call g:Xsetlist([], ' ', {'items' : l})
- Xopen | only
- 2Xnext
- call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
- call assert_equal('F3', bufname('%'))
- Xnext
- call assert_equal(7, col('.'))
- Xnext
- call assert_equal(2, line('.'))
- Xnext
- call assert_equal(9, col('.'))
- 2
- Xnext
- call assert_equal(2, line('.'))
-
- if a:cchar == 'l'
- " When jumping to a location list entry in the location list window and
- " no usable windows are available, then a new window should be opened.
- enew! | new | only
- call g:Xsetlist([], 'f')
- setlocal buftype=nofile
- new
- call g:Xsetlist([], ' ', {'lines' : ['F1:1:1:Line1', 'F1:2:2:Line2', 'F2:1:1:Line1', 'F2:2:2:Line2', 'F3:1:1:Line1', 'F3:2:2:Line2']})
- Xopen
- let winid = win_getid()
- wincmd p
- close
- call win_gotoid(winid)
- Xnext
- call assert_equal(3, winnr('$'))
- call assert_equal(1, winnr())
- call assert_equal(2, line('.'))
-
- " When jumping to an entry in the location list window and the window
- " associated with the location list is not present and a window containing
- " the file is already present, then that window should be used.
- close
- belowright new
- call g:Xsetlist([], 'f')
- edit F3
- call win_gotoid(winid)
- Xlast
- call assert_equal(3, winnr())
- call assert_equal(6, g:Xgetlist({'size' : 1}).size)
- call assert_equal(winid, g:Xgetlist({'winid' : 1}).winid)
- endif
-
- " Cleanup
- enew!
- new | only
-
- call delete('F1')
- call delete('F2')
- call delete('F3')
-endfunc
-
-func Test_qfjump()
- call Xqfjump_tests('c')
- call Xqfjump_tests('l')
-endfunc
-
-" The following test used to crash Vim.
-" Open the location list window and close the regular window associated with
-" the location list. When the garbage collection runs now, it incorrectly
-" marks the location list context as not in use and frees the context.
-func Test_ll_window_ctx()
- call setloclist(0, [], 'f')
- call setloclist(0, [], 'a', {'context' : []})
- lopen | only
- call test_garbagecollect_now()
- echo getloclist(0, {'context' : 1}).context
- enew | only
+ au! BufNewFile
endfunc
-" The following test used to crash vim
-func Test_lfile_crash()
- sp Xtest
- au QuickFixCmdPre * bw
- call assert_fails('lfile', 'E40')
- au! QuickFixCmdPre
+" Test for the position of the quickfix and location list window
+func Test_qfwin_pos()
+ " Open two windows
+ new | only
+ new
+ cexpr ['F1:10:L10']
+ copen
+ " Quickfix window should be the bottom most window
+ call assert_equal(3, winnr())
+ close
+ " Open at the very top
+ wincmd t
+ topleft copen
+ call assert_equal(1, winnr())
+ close
+ " open left of the current window
+ wincmd t
+ below new
+ leftabove copen
+ call assert_equal(2, winnr())
+ close
+ " open right of the current window
+ rightbelow copen
+ call assert_equal(3, winnr())
+ close
endfunc
" Tests for quickfix/location lists changed by autocommands when
@@ -3371,6 +3421,137 @@ func Test_vimgrep_autocmd()
call setqflist([], 'f')
endfunc
+" The following test used to crash Vim
+func Test_lhelpgrep_autocmd()
+ lhelpgrep quickfix
+ autocmd QuickFixCmdPost * call setloclist(0, [], 'f')
+ lhelpgrep buffer
+ call assert_equal('help', &filetype)
+ call assert_equal(0, getloclist(0, {'nr' : '$'}).nr)
+ lhelpgrep tabpage
+ call assert_equal('help', &filetype)
+ call assert_equal(1, getloclist(0, {'nr' : '$'}).nr)
+ au! QuickFixCmdPost
+ new | only
+endfunc
+
+" Test for shortening/simplifying the file name when opening the
+" quickfix window or when displaying the quickfix list
+func Test_shorten_fname()
+ if !has('unix')
+ return
+ endif
+ %bwipe
+ " Create a quickfix list with a absolute path filename
+ let fname = getcwd() . '/test_quickfix.vim'
+ call setqflist([], ' ', {'lines':[fname . ":20:Line20"], 'efm':'%f:%l:%m'})
+ call assert_equal(fname, bufname('test_quickfix.vim'))
+ " Opening the quickfix window should simplify the file path
+ cwindow
+ call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
+ cclose
+ %bwipe
+ " Create a quickfix list with a absolute path filename
+ call setqflist([], ' ', {'lines':[fname . ":20:Line20"], 'efm':'%f:%l:%m'})
+ call assert_equal(fname, bufname('test_quickfix.vim'))
+ " Displaying the quickfix list should simplify the file path
+ silent! clist
+ call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
+endfunc
+
+" Quickfix title tests
+" In the below tests, 'exe "cmd"' is used to invoke the quickfix commands.
+" Otherwise due to indentation, the title is set with spaces at the beginning
+" of the command.
+func Test_qftitle()
+ call writefile(["F1:1:Line1"], 'Xerr')
+
+ " :cexpr
+ exe "cexpr readfile('Xerr')"
+ call assert_equal(":cexpr readfile('Xerr')", getqflist({'title' : 1}).title)
+
+ " :cgetexpr
+ exe "cgetexpr readfile('Xerr')"
+ call assert_equal(":cgetexpr readfile('Xerr')",
+ \ getqflist({'title' : 1}).title)
+
+ " :caddexpr
+ call setqflist([], 'f')
+ exe "caddexpr readfile('Xerr')"
+ call assert_equal(":caddexpr readfile('Xerr')",
+ \ getqflist({'title' : 1}).title)
+
+ " :cbuffer
+ new Xerr
+ exe "cbuffer"
+ call assert_equal(':cbuffer (Xerr)', getqflist({'title' : 1}).title)
+
+ " :cgetbuffer
+ edit Xerr
+ exe "cgetbuffer"
+ call assert_equal(':cgetbuffer (Xerr)', getqflist({'title' : 1}).title)
+
+ " :caddbuffer
+ call setqflist([], 'f')
+ edit Xerr
+ exe "caddbuffer"
+ call assert_equal(':caddbuffer (Xerr)', getqflist({'title' : 1}).title)
+
+ " :cfile
+ exe "cfile Xerr"
+ call assert_equal(':cfile Xerr', getqflist({'title' : 1}).title)
+
+ " :cgetfile
+ exe "cgetfile Xerr"
+ call assert_equal(':cgetfile Xerr', getqflist({'title' : 1}).title)
+
+ " :caddfile
+ call setqflist([], 'f')
+ exe "caddfile Xerr"
+ call assert_equal(':caddfile Xerr', getqflist({'title' : 1}).title)
+
+ " :grep
+ set grepprg=internal
+ exe "grep F1 Xerr"
+ call assert_equal(':grep F1 Xerr', getqflist({'title' : 1}).title)
+
+ " :grepadd
+ call setqflist([], 'f')
+ exe "grepadd F1 Xerr"
+ call assert_equal(':grepadd F1 Xerr', getqflist({'title' : 1}).title)
+ set grepprg&vim
+
+ " :vimgrep
+ exe "vimgrep F1 Xerr"
+ call assert_equal(':vimgrep F1 Xerr', getqflist({'title' : 1}).title)
+
+ " :vimgrepadd
+ call setqflist([], 'f')
+ exe "vimgrepadd F1 Xerr"
+ call assert_equal(':vimgrepadd F1 Xerr', getqflist({'title' : 1}).title)
+
+ call setqflist(['F1:10:L10'], ' ')
+ call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
+
+ call setqflist([], 'f')
+ call setqflist(['F1:10:L10'], 'a')
+ call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
+
+ call setqflist([], 'f')
+ call setqflist(['F1:10:L10'], 'r')
+ call assert_equal(':setqflist()', getqflist({'title' : 1}).title)
+
+ close
+ call delete('Xerr')
+
+ call setqflist([], ' ', {'title' : 'Errors'})
+ copen
+ call assert_equal('Errors', w:quickfix_title)
+ call setqflist([], 'r', {'items' : [{'filename' : 'a.c', 'lnum' : 10}]})
+ call assert_equal('Errors', w:quickfix_title)
+ cclose
+endfunc
+
func Test_lbuffer_with_bwipe()
new
new
@@ -3383,23 +3564,6 @@ func Test_lbuffer_with_bwipe()
augroup END
endfunc
-" Tests for the ':filter /pat/ clist' command
-func Test_filter_clist()
- cexpr ['Xfile1:10:10:Line 10', 'Xfile2:15:15:Line 15']
- call assert_equal([' 2 Xfile2:15 col 15: Line 15'],
- \ split(execute('filter /Line 15/ clist'), "\n"))
- call assert_equal([' 1 Xfile1:10 col 10: Line 10'],
- \ split(execute('filter /Xfile1/ clist'), "\n"))
- call assert_equal([], split(execute('filter /abc/ clist'), "\n"))
-
- call setqflist([{'module' : 'abc', 'pattern' : 'pat1'},
- \ {'module' : 'pqr', 'pattern' : 'pat2'}], ' ')
- call assert_equal([' 2 pqr:pat2: '],
- \ split(execute('filter /pqr/ clist'), "\n"))
- call assert_equal([' 1 abc:pat1: '],
- \ split(execute('filter /pat1/ clist'), "\n"))
-endfunc
-
" Test for an autocmd freeing the quickfix/location list when cexpr/lexpr is
" running
func Xexpr_acmd_freelist(cchar)
@@ -3549,6 +3713,23 @@ func Test_autocmd_changelist()
call Xautocmd_changelist('l')
endfunc
+" Tests for the ':filter /pat/ clist' command
+func Test_filter_clist()
+ cexpr ['Xfile1:10:10:Line 10', 'Xfile2:15:15:Line 15']
+ call assert_equal([' 2 Xfile2:15 col 15: Line 15'],
+ \ split(execute('filter /Line 15/ clist'), "\n"))
+ call assert_equal([' 1 Xfile1:10 col 10: Line 10'],
+ \ split(execute('filter /Xfile1/ clist'), "\n"))
+ call assert_equal([], split(execute('filter /abc/ clist'), "\n"))
+
+ call setqflist([{'module' : 'abc', 'pattern' : 'pat1'},
+ \ {'module' : 'pqr', 'pattern' : 'pat2'}], ' ')
+ call assert_equal([' 2 pqr:pat2: '],
+ \ split(execute('filter /pqr/ clist'), "\n"))
+ call assert_equal([' 1 abc:pat1: '],
+ \ split(execute('filter /pat1/ clist'), "\n"))
+endfunc
+
" Tests for the "CTRL-W <CR>" command.
func Xview_result_split_tests(cchar)
call s:setup_commands(a:cchar)
@@ -3575,3 +3756,269 @@ func Test_curswant()
call assert_equal(getcurpos()[4], virtcol('.'))
cclose | helpclose
endfunc
+
+" Test for parsing entries using visual screen column
+func Test_viscol()
+ enew
+ call writefile(["Col1\tCol2\tCol3"], 'Xfile1')
+ edit Xfile1
+
+ " Use byte offset for column number
+ set efm&
+ cexpr "Xfile1:1:5:XX\nXfile1:1:9:YY\nXfile1:1:20:ZZ"
+ call assert_equal([5, 8], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([9, 12], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([14, 20], [col('.'), virtcol('.')])
+
+ " Use screen column offset for column number
+ set efm=%f:%l:%v:%m
+ cexpr "Xfile1:1:8:XX\nXfile1:1:12:YY\nXfile1:1:20:ZZ"
+ call assert_equal([5, 8], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([9, 12], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([14, 20], [col('.'), virtcol('.')])
+ cexpr "Xfile1:1:6:XX\nXfile1:1:15:YY\nXfile1:1:24:ZZ"
+ call assert_equal([5, 8], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([10, 16], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([14, 20], [col('.'), virtcol('.')])
+
+ enew
+ call writefile(["Col1\täü\töß\tCol4"], 'Xfile1')
+
+ " Use byte offset for column number
+ set efm&
+ cexpr "Xfile1:1:8:XX\nXfile1:1:11:YY\nXfile1:1:16:ZZ"
+ call assert_equal([8, 10], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([11, 17], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([16, 25], [col('.'), virtcol('.')])
+
+ " Use screen column offset for column number
+ set efm=%f:%l:%v:%m
+ cexpr "Xfile1:1:10:XX\nXfile1:1:17:YY\nXfile1:1:25:ZZ"
+ call assert_equal([8, 10], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([11, 17], [col('.'), virtcol('.')])
+ cnext
+ call assert_equal([16, 25], [col('.'), virtcol('.')])
+
+ enew | only
+ set efm&
+ call delete('Xfile1')
+endfunc
+
+" Test to make sure that an empty quickfix buffer is not reused for loading
+" a normal buffer.
+func Test_empty_qfbuf()
+ enew | only
+ call writefile(["Test"], 'Xfile1')
+ call setqflist([], 'f')
+ copen | only
+ let qfbuf = bufnr('')
+ edit Xfile1
+ call assert_notequal(qfbuf, bufnr(''))
+ enew
+ call delete('Xfile1')
+endfunc
+
+" Test for the :cbelow, :cabove, :lbelow and :labove commands.
+func Xtest_below(cchar)
+ call s:setup_commands(a:cchar)
+
+ " No quickfix/location list
+ call assert_fails('Xbelow', 'E42:')
+ call assert_fails('Xabove', 'E42:')
+
+ " Empty quickfix/location list
+ call g:Xsetlist([])
+ call assert_fails('Xbelow', 'E42:')
+ call assert_fails('Xabove', 'E42:')
+
+ call s:create_test_file('X1')
+ call s:create_test_file('X2')
+ call s:create_test_file('X3')
+ call s:create_test_file('X4')
+
+ " Invalid entries
+ edit X1
+ call g:Xsetlist(["E1", "E2"])
+ call assert_fails('Xbelow', 'E42:')
+ call assert_fails('Xabove', 'E42:')
+ call assert_fails('3Xbelow', 'E42:')
+ call assert_fails('4Xabove', 'E42:')
+
+ " Test the commands with various arguments
+ Xexpr ["X1:5:L5", "X2:5:L5", "X2:10:L10", "X2:15:L15", "X3:3:L3"]
+ edit +7 X2
+ Xabove
+ call assert_equal(['X2', 5], [bufname(''), line('.')])
+ call assert_fails('Xabove', 'E553:')
+ normal 2j
+ Xbelow
+ call assert_equal(['X2', 10], [bufname(''), line('.')])
+ " Last error in this file
+ Xbelow 99
+ call assert_equal(['X2', 15], [bufname(''), line('.')])
+ call assert_fails('Xbelow', 'E553:')
+ " First error in this file
+ Xabove 99
+ call assert_equal(['X2', 5], [bufname(''), line('.')])
+ call assert_fails('Xabove', 'E553:')
+ normal gg
+ Xbelow 2
+ call assert_equal(['X2', 10], [bufname(''), line('.')])
+ normal G
+ Xabove 2
+ call assert_equal(['X2', 10], [bufname(''), line('.')])
+ edit X4
+ call assert_fails('Xabove', 'E42:')
+ call assert_fails('Xbelow', 'E42:')
+ if a:cchar == 'l'
+ " If a buffer has location list entries from some other window but not
+ " from the current window, then the commands should fail.
+ edit X1 | split | call setloclist(0, [], 'f')
+ call assert_fails('Xabove', 'E776:')
+ call assert_fails('Xbelow', 'E776:')
+ close
+ endif
+
+ " Test for lines with multiple quickfix entries
+ Xexpr ["X1:5:L5", "X2:5:1:L5_1", "X2:5:2:L5_2", "X2:5:3:L5_3",
+ \ "X2:10:1:L10_1", "X2:10:2:L10_2", "X2:10:3:L10_3",
+ \ "X2:15:1:L15_1", "X2:15:2:L15_2", "X2:15:3:L15_3", "X3:3:L3"]
+ edit +1 X2
+ Xbelow 2
+ call assert_equal(['X2', 10, 1], [bufname(''), line('.'), col('.')])
+ normal gg
+ Xbelow 99
+ call assert_equal(['X2', 15, 1], [bufname(''), line('.'), col('.')])
+ normal G
+ Xabove 2
+ call assert_equal(['X2', 10, 1], [bufname(''), line('.'), col('.')])
+ normal G
+ Xabove 99
+ call assert_equal(['X2', 5, 1], [bufname(''), line('.'), col('.')])
+ normal 10G
+ Xabove
+ call assert_equal(['X2', 5, 1], [bufname(''), line('.'), col('.')])
+ normal 10G
+ Xbelow
+ call assert_equal(['X2', 15, 1], [bufname(''), line('.'), col('.')])
+
+ " Invalid range
+ if a:cchar == 'c'
+ call assert_fails('-2cbelow', 'E553:')
+ " TODO: should go to first error in the current line?
+ 0cabove
+ else
+ call assert_fails('-2lbelow', 'E553:')
+ " TODO: should go to first error in the current line?
+ 0labove
+ endif
+
+ call delete('X1')
+ call delete('X2')
+ call delete('X3')
+ call delete('X4')
+endfunc
+
+func Test_cbelow()
+ call Xtest_below('c')
+ call Xtest_below('l')
+endfunc
+
+" Test for aborting quickfix commands using QuickFixCmdPre
+func Xtest_qfcmd_abort(cchar)
+ call s:setup_commands(a:cchar)
+
+ call g:Xsetlist([], 'f')
+
+ " cexpr/lexpr
+ let e = ''
+ try
+ Xexpr ["F1:10:Line10", "F2:20:Line20"]
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+
+ " cfile/lfile
+ call writefile(["F1:10:Line10", "F2:20:Line20"], 'Xfile1')
+ let e = ''
+ try
+ Xfile Xfile1
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+ call delete('Xfile1')
+
+ " cgetbuffer/lgetbuffer
+ enew!
+ call append(0, ["F1:10:Line10", "F2:20:Line20"])
+ let e = ''
+ try
+ Xgetbuffer
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+ enew!
+
+ " vimgrep/lvimgrep
+ let e = ''
+ try
+ Xvimgrep /func/ test_quickfix.vim
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+
+ " helpgrep/lhelpgrep
+ let e = ''
+ try
+ Xhelpgrep quickfix
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+
+ " grep/lgrep
+ if has('unix')
+ let e = ''
+ try
+ silent Xgrep func test_quickfix.vim
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+ endif
+endfunc
+
+func Test_qfcmd_abort()
+ augroup QF_Test
+ au!
+ autocmd QuickFixCmdPre * throw "AbortCmd"
+ augroup END
+
+ call Xtest_qfcmd_abort('c')
+ call Xtest_qfcmd_abort('l')
+
+ augroup QF_Test
+ au!
+ augroup END
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim
index b83fbe40e8..77a5153a81 100644
--- a/src/nvim/testdir/test_quotestar.vim
+++ b/src/nvim/testdir/test_quotestar.vim
@@ -54,34 +54,33 @@ func Do_test_quotestar_for_x11()
" Make sure a previous server has exited
try
call remote_send(name, ":qa!\<CR>")
- call WaitFor('serverlist() !~ "' . name . '"')
catch /E241:/
endtry
- call assert_notmatch(name, serverlist())
+ call WaitForAssert({-> assert_notmatch(name, serverlist())})
let cmd .= ' --servername ' . name
let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
- call WaitFor({-> job_status(job) == "run"})
+ call WaitForAssert({-> assert_equal("run", job_status(job))})
" Takes a short while for the server to be active.
- call WaitFor('serverlist() =~ "' . name . '"')
+ call WaitForAssert({-> assert_match(name, serverlist())})
" Wait for the server to be up and answering requests. One second is not
" always sufficient.
- call WaitFor('remote_expr("' . name . '", "v:version", "", 2) != ""')
+ call WaitForAssert({-> assert_notequal('', remote_expr(name, "v:version", "", 2))})
" Clear the *-register of this vim instance and wait for it to be picked up
" by the server.
let @* = 'no'
call remote_foreground(name)
- call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "no"')
+ call WaitForAssert({-> assert_equal("no", remote_expr(name, "@*", "", 1))})
" Set the * register on the server.
call remote_send(name, ":let @* = 'yes'\<CR>")
- call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "yes"')
+ call WaitForAssert({-> assert_equal("yes", remote_expr(name, "@*", "", 1))})
" Check that the *-register of this vim instance is changed as expected.
- call WaitFor('@* == "yes"')
+ call WaitForAssert({-> assert_equal("yes", @*)})
" Handle the large selection over 262040 byte.
let length = 262044
@@ -109,18 +108,18 @@ func Do_test_quotestar_for_x11()
call remote_send(name, ":gui -f\<CR>")
endif
" Wait for the server in the GUI to be up and answering requests.
- call WaitFor('remote_expr("' . name . '", "has(\"gui_running\")", "", 1) =~ "1"')
+ " On some systems and with valgrind this can be very slow.
+ call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))}, 10000)
call remote_send(name, ":let @* = 'maybe'\<CR>")
- call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"')
- call assert_equal('maybe', remote_expr(name, "@*", "", 2))
+ call WaitForAssert({-> assert_equal("maybe", remote_expr(name, "@*", "", 2))})
call assert_equal('maybe', @*)
endif
call remote_send(name, ":qa!\<CR>")
try
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
if job_status(job) != 'dead'
call assert_report('Server did not exit')
diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim
index 09c8d1cda6..fc073cacd2 100644
--- a/src/nvim/testdir/test_recover.vim
+++ b/src/nvim/testdir/test_recover.vim
@@ -14,6 +14,12 @@ func Test_recover_root_dir()
set dir=/notexist/
endif
call assert_fails('split Xtest', 'E303:')
+
+ " No error with empty 'directory' setting.
+ set directory=
+ split XtestOK
+ close!
+
set dir&
endfunc
diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim
index b5e99b0ed3..2ee0ee1c0c 100644
--- a/src/nvim/testdir/test_regexp_latin.vim
+++ b/src/nvim/testdir/test_regexp_latin.vim
@@ -3,7 +3,7 @@ set encoding=latin1
scriptencoding latin1
func s:equivalence_test()
- let str = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z"
+ let str = "AÀÁÂÃÄÅ B C D EÈÉÊË F G H IÌÍÎÏ J K L M NÑ OÒÓÔÕÖØ P Q R S T UÙÚÛÜ V W X YÝ Z aàáâãäå b c d eèéêë f g h iìíîï j k l m nñ oòóôõöø p q r s t uùúûü v w x yýÿ z"
let groups = split(str)
for group1 in groups
for c in split(group1, '\zs')
@@ -98,3 +98,669 @@ func Test_out_of_memory()
" This will be slow...
call assert_fails('call search("\\v((n||<)+);")', 'E363:')
endfunc
+
+" Tests for regexp patterns without multi-byte support.
+func Test_regexp_single_line_pat()
+ " tl is a List of Lists with:
+ " regexp engine
+ " regexp pattern
+ " text to test the pattern on
+ " expected match (optional)
+ " expected submatch 1 (optional)
+ " expected submatch 2 (optional)
+ " etc.
+ " When there is no match use only the first two items.
+ let tl = []
+
+ call add(tl, [2, 'ab', 'aab', 'ab'])
+ call add(tl, [2, 'b', 'abcdef', 'b'])
+ call add(tl, [2, 'bc*', 'abccccdef', 'bcccc'])
+ call add(tl, [2, 'bc\{-}', 'abccccdef', 'b'])
+ call add(tl, [2, 'bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd'])
+ call add(tl, [2, 'bc*', 'abbdef', 'b'])
+ call add(tl, [2, 'c*', 'ccc', 'ccc'])
+ call add(tl, [2, 'bc*', 'abdef', 'b'])
+ call add(tl, [2, 'c*', 'abdef', ''])
+ call add(tl, [2, 'bc\+', 'abccccdef', 'bcccc'])
+ call add(tl, [2, 'bc\+', 'abdef']) " no match
+
+ " operator \|
+ call add(tl, [2, 'a\|ab', 'cabd', 'a']) " alternation is ordered
+
+ call add(tl, [2, 'c\?', 'ccb', 'c'])
+ call add(tl, [2, 'bc\?', 'abd', 'b'])
+ call add(tl, [2, 'bc\?', 'abccd', 'bc'])
+
+ call add(tl, [2, '\va{1}', 'ab', 'a'])
+
+ call add(tl, [2, '\va{2}', 'aa', 'aa'])
+ call add(tl, [2, '\va{2}', 'caad', 'aa'])
+ call add(tl, [2, '\va{2}', 'aba'])
+ call add(tl, [2, '\va{2}', 'ab'])
+ call add(tl, [2, '\va{2}', 'abaa', 'aa'])
+ call add(tl, [2, '\va{2}', 'aaa', 'aa'])
+
+ call add(tl, [2, '\vb{1}', 'abca', 'b'])
+ call add(tl, [2, '\vba{2}', 'abaa', 'baa'])
+ call add(tl, [2, '\vba{3}', 'aabaac'])
+
+ call add(tl, [2, '\v(ab){1}', 'ab', 'ab', 'ab'])
+ call add(tl, [2, '\v(ab){1}', 'dabc', 'ab', 'ab'])
+ call add(tl, [2, '\v(ab){1}', 'acb'])
+
+ call add(tl, [2, '\v(ab){0,2}', 'acb', "", ""])
+ call add(tl, [2, '\v(ab){0,2}', 'ab', 'ab', 'ab'])
+ call add(tl, [2, '\v(ab){1,2}', 'ab', 'ab', 'ab'])
+ call add(tl, [2, '\v(ab){1,2}', 'ababc', 'abab', 'ab'])
+ call add(tl, [2, '\v(ab){2,4}', 'ababcab', 'abab', 'ab'])
+ call add(tl, [2, '\v(ab){2,4}', 'abcababa', 'abab', 'ab'])
+
+ call add(tl, [2, '\v(ab){2}', 'abab', 'abab', 'ab'])
+ call add(tl, [2, '\v(ab){2}', 'cdababe', 'abab', 'ab'])
+ call add(tl, [2, '\v(ab){2}', 'abac'])
+ call add(tl, [2, '\v(ab){2}', 'abacabab', 'abab', 'ab'])
+ call add(tl, [2, '\v((ab){2}){2}', 'abababab', 'abababab', 'abab', 'ab'])
+ call add(tl, [2, '\v((ab){2}){2}', 'abacabababab', 'abababab', 'abab', 'ab'])
+
+ call add(tl, [2, '\v(a{1}){1}', 'a', 'a', 'a'])
+ call add(tl, [2, '\v(a{2}){1}', 'aa', 'aa', 'aa'])
+ call add(tl, [2, '\v(a{2}){1}', 'aaac', 'aa', 'aa'])
+ call add(tl, [2, '\v(a{2}){1}', 'daaac', 'aa', 'aa'])
+ call add(tl, [2, '\v(a{1}){2}', 'daaac', 'aa', 'a'])
+ call add(tl, [2, '\v(a{1}){2}', 'aaa', 'aa', 'a'])
+ call add(tl, [2, '\v(a{2})+', 'adaac', 'aa', 'aa'])
+ call add(tl, [2, '\v(a{2})+', 'aa', 'aa', 'aa'])
+ call add(tl, [2, '\v(a{2}){1}', 'aa', 'aa', 'aa'])
+ call add(tl, [2, '\v(a{1}){2}', 'aa', 'aa', 'a'])
+ call add(tl, [2, '\v(a{1}){1}', 'a', 'a', 'a'])
+ call add(tl, [2, '\v(a{2}){2}', 'aaaa', 'aaaa', 'aa'])
+ call add(tl, [2, '\v(a{2}){2}', 'aaabaaaa', 'aaaa', 'aa'])
+
+ call add(tl, [2, '\v(a+){2}', 'dadaac', 'aa', 'a'])
+ call add(tl, [2, '\v(a{3}){2}', 'aaaaaaa', 'aaaaaa', 'aaa'])
+
+ call add(tl, [2, '\v(a{1,2}){2}', 'daaac', 'aaa', 'a'])
+ call add(tl, [2, '\v(a{1,3}){2}', 'daaaac', 'aaaa', 'a'])
+ call add(tl, [2, '\v(a{1,3}){2}', 'daaaaac', 'aaaaa', 'aa'])
+ call add(tl, [2, '\v(a{1,3}){3}', 'daac'])
+ call add(tl, [2, '\v(a{1,2}){2}', 'dac'])
+ call add(tl, [2, '\v(a+)+', 'daac', 'aa', 'aa'])
+ call add(tl, [2, '\v(a+)+', 'aaa', 'aaa', 'aaa'])
+ call add(tl, [2, '\v(a+){1,2}', 'aaa', 'aaa', 'aaa'])
+ call add(tl, [2, '\v(a+)(a+)', 'aaa', 'aaa', 'aa', 'a'])
+ call add(tl, [2, '\v(a{3})+', 'daaaac', 'aaa', 'aaa'])
+ call add(tl, [2, '\v(a|b|c)+', 'aacb', 'aacb', 'b'])
+ call add(tl, [2, '\v(a|b|c){2}', 'abcb', 'ab', 'b'])
+ call add(tl, [2, '\v(abc){2}', 'abcabd', ])
+ call add(tl, [2, '\v(abc){2}', 'abdabcabc','abcabc', 'abc'])
+
+ call add(tl, [2, 'a*', 'cc', ''])
+ call add(tl, [2, '\v(a*)+', 'cc', ''])
+ call add(tl, [2, '\v((ab)+)+', 'ab', 'ab', 'ab', 'ab'])
+ call add(tl, [2, '\v(((ab)+)+)+', 'ab', 'ab', 'ab', 'ab', 'ab'])
+ call add(tl, [2, '\v(((ab)+)+)+', 'dababc', 'abab', 'abab', 'abab', 'ab'])
+ call add(tl, [2, '\v(a{0,2})+', 'cc', ''])
+ call add(tl, [2, '\v(a*)+', '', ''])
+ call add(tl, [2, '\v((a*)+)+', '', ''])
+ call add(tl, [2, '\v((ab)*)+', '', ''])
+ call add(tl, [2, '\va{1,3}', 'aab', 'aa'])
+ call add(tl, [2, '\va{2,3}', 'abaa', 'aa'])
+
+ call add(tl, [2, '\v((ab)+|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
+ call add(tl, [2, '\v(a{2})|(b{3})', 'bbabbbb', 'bbb', '', 'bbb'])
+ call add(tl, [2, '\va{2}|b{2}', 'abab'])
+ call add(tl, [2, '\v(a)+|(c)+', 'bbacbaacbbb', 'a', 'a'])
+ call add(tl, [2, '\vab{2,3}c', 'aabbccccccccccccc', 'abbc'])
+ call add(tl, [2, '\vab{2,3}c', 'aabbbccccccccccccc', 'abbbc'])
+ call add(tl, [2, '\vab{2,3}cd{2,3}e', 'aabbbcddee', 'abbbcdde'])
+ call add(tl, [2, '\va(bc){2}d', 'aabcbfbc' ])
+ call add(tl, [2, '\va*a{2}', 'a', ])
+ call add(tl, [2, '\va*a{2}', 'aa', 'aa' ])
+ call add(tl, [2, '\va*a{2}', 'aaa', 'aaa' ])
+ call add(tl, [2, '\va*a{2}', 'bbbabcc', ])
+ call add(tl, [2, '\va*b*|a*c*', 'a', 'a'])
+ call add(tl, [2, '\va{1}b{1}|a{1}b{1}', ''])
+
+ " submatches
+ call add(tl, [2, '\v(a)', 'ab', 'a', 'a'])
+ call add(tl, [2, '\v(a)(b)', 'ab', 'ab', 'a', 'b'])
+ call add(tl, [2, '\v(ab)(b)(c)', 'abbc', 'abbc', 'ab', 'b', 'c'])
+ call add(tl, [2, '\v((a)(b))', 'ab', 'ab', 'ab', 'a', 'b'])
+ call add(tl, [2, '\v(a)|(b)', 'ab', 'a', 'a'])
+
+ call add(tl, [2, '\v(a*)+', 'aaaa', 'aaaa', ''])
+ call add(tl, [2, 'x', 'abcdef'])
+
+ "
+ " Simple tests
+ "
+
+ " Search single groups
+ call add(tl, [2, 'ab', 'aab', 'ab'])
+ call add(tl, [2, 'ab', 'baced'])
+ call add(tl, [2, 'ab', ' ab ', 'ab'])
+
+ " Search multi-modifiers
+ call add(tl, [2, 'x*', 'xcd', 'x'])
+ call add(tl, [2, 'x*', 'xxxxxxxxxxxxxxxxsofijiojgf', 'xxxxxxxxxxxxxxxx'])
+ " empty match is good
+ call add(tl, [2, 'x*', 'abcdoij', ''])
+ " no match here
+ call add(tl, [2, 'x\+', 'abcdoin'])
+ call add(tl, [2, 'x\+', 'abcdeoijdfxxiuhfij', 'xx'])
+ call add(tl, [2, 'x\+', 'xxxxx', 'xxxxx'])
+ call add(tl, [2, 'x\+', 'abc x siufhiush xxxxxxxxx', 'x'])
+ call add(tl, [2, 'x\=', 'x sdfoij', 'x'])
+ call add(tl, [2, 'x\=', 'abc sfoij', '']) " empty match is good
+ call add(tl, [2, 'x\=', 'xxxxxxxxx c', 'x'])
+ call add(tl, [2, 'x\?', 'x sdfoij', 'x'])
+ " empty match is good
+ call add(tl, [2, 'x\?', 'abc sfoij', ''])
+ call add(tl, [2, 'x\?', 'xxxxxxxxxx c', 'x'])
+
+ call add(tl, [2, 'a\{0,0}', 'abcdfdoij', ''])
+ " same thing as 'a?'
+ call add(tl, [2, 'a\{0,1}', 'asiubid axxxaaa', 'a'])
+ " same thing as 'a\{0,1}'
+ call add(tl, [2, 'a\{1,0}', 'asiubid axxxaaa', 'a'])
+ call add(tl, [2, 'a\{3,6}', 'aa siofuh'])
+ call add(tl, [2, 'a\{3,6}', 'aaaaa asfoij afaa', 'aaaaa'])
+ call add(tl, [2, 'a\{3,6}', 'aaaaaaaa', 'aaaaaa'])
+ call add(tl, [2, 'a\{0}', 'asoiuj', ''])
+ call add(tl, [2, 'a\{2}', 'aaaa', 'aa'])
+ call add(tl, [2, 'a\{2}', 'iuash fiusahfliusah fiushfilushfi uhsaifuh askfj nasfvius afg aaaa sfiuhuhiushf', 'aa'])
+ call add(tl, [2, 'a\{2}', 'abcdefghijklmnopqrestuvwxyz1234567890'])
+ " same thing as 'a*'
+ call add(tl, [2, 'a\{0,}', 'oij sdigfusnf', ''])
+ call add(tl, [2, 'a\{0,}', 'aaaaa aa', 'aaaaa'])
+ call add(tl, [2, 'a\{2,}', 'sdfiougjdsafg'])
+ call add(tl, [2, 'a\{2,}', 'aaaaasfoij ', 'aaaaa'])
+ call add(tl, [2, 'a\{5,}', 'xxaaaaxxx '])
+ call add(tl, [2, 'a\{5,}', 'xxaaaaaxxx ', 'aaaaa'])
+ call add(tl, [2, 'a\{,0}', 'oidfguih iuhi hiu aaaa', ''])
+ call add(tl, [2, 'a\{,5}', 'abcd', 'a'])
+ call add(tl, [2, 'a\{,5}', 'aaaaaaaaaa', 'aaaaa'])
+ " leading star as normal char when \{} follows
+ call add(tl, [2, '^*\{4,}$', '***'])
+ call add(tl, [2, '^*\{4,}$', '****', '****'])
+ call add(tl, [2, '^*\{4,}$', '*****', '*****'])
+ " same thing as 'a*'
+ call add(tl, [2, 'a\{}', 'bbbcddiuhfcd', ''])
+ call add(tl, [2, 'a\{}', 'aaaaioudfh coisf jda', 'aaaa'])
+
+ call add(tl, [2, 'a\{-0,0}', 'abcdfdoij', ''])
+ " anti-greedy version of 'a?'
+ call add(tl, [2, 'a\{-0,1}', 'asiubid axxxaaa', ''])
+ call add(tl, [2, 'a\{-3,6}', 'aa siofuh'])
+ call add(tl, [2, 'a\{-3,6}', 'aaaaa asfoij afaa', 'aaa'])
+ call add(tl, [2, 'a\{-3,6}', 'aaaaaaaa', 'aaa'])
+ call add(tl, [2, 'a\{-0}', 'asoiuj', ''])
+ call add(tl, [2, 'a\{-2}', 'aaaa', 'aa'])
+ call add(tl, [2, 'a\{-2}', 'abcdefghijklmnopqrestuvwxyz1234567890'])
+ call add(tl, [2, 'a\{-0,}', 'oij sdigfusnf', ''])
+ call add(tl, [2, 'a\{-0,}', 'aaaaa aa', ''])
+ call add(tl, [2, 'a\{-2,}', 'sdfiougjdsafg'])
+ call add(tl, [2, 'a\{-2,}', 'aaaaasfoij ', 'aa'])
+ call add(tl, [2, 'a\{-,0}', 'oidfguih iuhi hiu aaaa', ''])
+ call add(tl, [2, 'a\{-,5}', 'abcd', ''])
+ call add(tl, [2, 'a\{-,5}', 'aaaaaaaaaa', ''])
+ " anti-greedy version of 'a*'
+ call add(tl, [2, 'a\{-}', 'bbbcddiuhfcd', ''])
+ call add(tl, [2, 'a\{-}', 'aaaaioudfh coisf jda', ''])
+
+ " Test groups of characters and submatches
+ call add(tl, [2, '\(abc\)*', 'abcabcabc', 'abcabcabc', 'abc'])
+ call add(tl, [2, '\(ab\)\+', 'abababaaaaa', 'ababab', 'ab'])
+ call add(tl, [2, '\(abaaaaa\)*cd', 'cd', 'cd', ''])
+ call add(tl, [2, '\(test1\)\? \(test2\)\?', 'test1 test3', 'test1 ', 'test1', ''])
+ call add(tl, [2, '\(test1\)\= \(test2\) \(test4443\)\=', ' test2 test4443 yupiiiiiiiiiii', ' test2 test4443', '', 'test2', 'test4443'])
+ call add(tl, [2, '\(\(sub1\) hello \(sub 2\)\)', 'asterix sub1 hello sub 2 obelix', 'sub1 hello sub 2', 'sub1 hello sub 2', 'sub1', 'sub 2'])
+ call add(tl, [2, '\(\(\(yyxxzz\)\)\)', 'abcdddsfiusfyyzzxxyyxxzz', 'yyxxzz', 'yyxxzz', 'yyxxzz', 'yyxxzz'])
+ call add(tl, [2, '\v((ab)+|c+)+', 'abcccaba', 'abcccab', 'ab', 'ab'])
+ call add(tl, [2, '\v((ab)|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
+ call add(tl, [2, '\v(a(c*)+b)+', 'acbababaaa', 'acbabab', 'ab', ''])
+ call add(tl, [2, '\v(a|b*)+', 'aaaa', 'aaaa', ''])
+ call add(tl, [2, '\p*', 'aá ', 'aá '])
+
+ " Test greedy-ness and lazy-ness
+ call add(tl, [2, 'a\{-2,7}','aaaaaaaaaaaaa', 'aa'])
+ call add(tl, [2, 'a\{-2,7}x','aaaaaaaaax', 'aaaaaaax'])
+ call add(tl, [2, 'a\{2,7}','aaaaaaaaaaaaaaaaaaaa', 'aaaaaaa'])
+ call add(tl, [2, 'a\{2,7}x','aaaaaaaaax', 'aaaaaaax'])
+ call add(tl, [2, '\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
+ call add(tl, [2, '\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
+ call add(tl, [2, '\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
+ call add(tl, [2, '\v(a{-1,3})+', 'aa', 'aa', 'a'])
+ call add(tl, [2, '^\s\{-}\zs\( x\|x$\)', ' x', ' x', ' x'])
+ call add(tl, [2, '^\s\{-}\zs\(x\| x$\)', ' x', ' x', ' x'])
+ call add(tl, [2, '^\s\{-}\ze\(x\| x$\)', ' x', '', ' x'])
+ call add(tl, [2, '^\(\s\{-}\)\(x\| x$\)', ' x', ' x', '', ' x'])
+
+ " Test Character classes
+ call add(tl, [2, '\d\+e\d\d','test 10e23 fd','10e23'])
+
+ " Test collections and character range []
+ call add(tl, [2, '\v[a]', 'abcd', 'a'])
+ call add(tl, [2, 'a[bcd]', 'abcd', 'ab'])
+ call add(tl, [2, 'a[b-d]', 'acbd', 'ac'])
+ call add(tl, [2, '[a-d][e-f][x-x]d', 'cexdxx', 'cexd'])
+ call add(tl, [2, '\v[[:alpha:]]+', 'abcdefghijklmnopqrstuvwxyz6','abcdefghijklmnopqrstuvwxyz'])
+ call add(tl, [2, '[[:alpha:]\+]', '6x8','x'])
+ call add(tl, [2, '[^abc]\+','abcabcabc'])
+ call add(tl, [2, '[^abc]','defghiasijvoinasoiunbvb','d'])
+ call add(tl, [2, '[^abc]\+','ddddddda','ddddddd'])
+ call add(tl, [2, '[^a-d]\+','aaaAAAZIHFNCddd','AAAZIHFNC'])
+ call add(tl, [2, '[a-f]*','iiiiiiii',''])
+ call add(tl, [2, '[a-f]*','abcdefgh','abcdef'])
+ call add(tl, [2, '[^a-f]\+','abcdefgh','gh'])
+ call add(tl, [2, '[a-c]\{-3,6}','abcabc','abc'])
+ call add(tl, [2, '[^[:alpha:]]\+','abcccadfoij7787ysf287yrnccdu','7787'])
+ call add(tl, [2, '[-a]', '-', '-'])
+ call add(tl, [2, '[a-]', '-', '-'])
+ call add(tl, [2, '[a-f]*\c','ABCDEFGH','ABCDEF'])
+ call add(tl, [2, '[abc][xyz]\c','-af-AF-BY--','BY'])
+ " filename regexp
+ call add(tl, [2, '[-./[:alnum:]_~]\+', 'log13.file', 'log13.file'])
+ " special chars
+ call add(tl, [2, '[\]\^\-\\]\+', '\^\\\-\---^', '\^\\\-\---^'])
+ " collation elem
+ call add(tl, [2, '[[.a.]]\+', 'aa', 'aa'])
+ " middle of regexp
+ call add(tl, [2, 'abc[0-9]*ddd', 'siuhabc ii'])
+ call add(tl, [2, 'abc[0-9]*ddd', 'adf abc44482ddd oijs', 'abc44482ddd'])
+ call add(tl, [2, '\_[0-9]\+', 'asfi9888u', '9888'])
+ call add(tl, [2, '[0-9\n]\+', 'asfi9888u', '9888'])
+ call add(tl, [2, '\_[0-9]\+', "asfi\n9888u", "\n9888"])
+ call add(tl, [2, '\_f', " \na ", "\n"])
+ call add(tl, [2, '\_f\+', " \na ", "\na"])
+ call add(tl, [2, '[0-9A-Za-z-_.]\+', " @0_a.A-{ ", "0_a.A-"])
+
+ " Test start/end of line, start/end of file
+ call add(tl, [2, '^a.', "a_\nb ", "a_"])
+ call add(tl, [2, '^a.', "b a \na_"])
+ call add(tl, [2, '.a$', " a\n "])
+ call add(tl, [2, '.a$', " a b\n_a", "_a"])
+ call add(tl, [2, '\%^a.', "a a\na", "a "])
+ call add(tl, [2, '\%^a', " a \na "])
+ call add(tl, [2, '.a\%$', " a\n "])
+ call add(tl, [2, '.a\%$', " a\n_a", "_a"])
+
+ " Test recognition of character classes
+ call add(tl, [2, '[0-7]\+', 'x0123456789x', '01234567'])
+ call add(tl, [2, '[^0-7]\+', '0a;X+% 897', 'a;X+% 89'])
+ call add(tl, [2, '[0-9]\+', 'x0123456789x', '0123456789'])
+ call add(tl, [2, '[^0-9]\+', '0a;X+% 9', 'a;X+% '])
+ call add(tl, [2, '[0-9a-fA-F]\+', 'x0189abcdefg', '0189abcdef'])
+ call add(tl, [2, '[^0-9A-Fa-f]\+', '0189g;X+% ab', 'g;X+% '])
+ call add(tl, [2, '[a-z_A-Z0-9]\+', ';+aso_SfOij ', 'aso_SfOij'])
+ call add(tl, [2, '[^a-z_A-Z0-9]\+', 'aSo_;+% sfOij', ';+% '])
+ call add(tl, [2, '[a-z_A-Z]\+', '0abyz_ABYZ;', 'abyz_ABYZ'])
+ call add(tl, [2, '[^a-z_A-Z]\+', 'abAB_09;+% yzYZ', '09;+% '])
+ call add(tl, [2, '[a-z]\+', '0abcxyz1', 'abcxyz'])
+ call add(tl, [2, '[a-z]\+', 'AabxyzZ', 'abxyz'])
+ call add(tl, [2, '[^a-z]\+', 'a;X09+% x', ';X09+% '])
+ call add(tl, [2, '[^a-z]\+', 'abX0;%yz', 'X0;%'])
+ call add(tl, [2, '[a-zA-Z]\+', '0abABxzXZ9', 'abABxzXZ'])
+ call add(tl, [2, '[^a-zA-Z]\+', 'ab09_;+ XZ', '09_;+ '])
+ call add(tl, [2, '[A-Z]\+', 'aABXYZz', 'ABXYZ'])
+ call add(tl, [2, '[^A-Z]\+', 'ABx0;%YZ', 'x0;%'])
+ call add(tl, [2, '[a-z]\+\c', '0abxyzABXYZ;', 'abxyzABXYZ'])
+ call add(tl, [2, '[A-Z]\+\c', '0abABxzXZ9', 'abABxzXZ'])
+ call add(tl, [2, '\c[^a-z]\+', 'ab09_;+ XZ', '09_;+ '])
+ call add(tl, [2, '\c[^A-Z]\+', 'ab09_;+ XZ', '09_;+ '])
+ call add(tl, [2, '\C[^A-Z]\+', 'ABCOIJDEOIFNSD jsfoij sa', ' jsfoij sa'])
+
+ " Tests for \z features
+ " match ends at \ze
+ call add(tl, [2, 'xx \ze test', 'xx '])
+ call add(tl, [2, 'abc\zeend', 'oij abcend', 'abc'])
+ call add(tl, [2, 'aa\zebb\|aaxx', ' aabb ', 'aa'])
+ call add(tl, [2, 'aa\zebb\|aaxx', ' aaxx ', 'aaxx'])
+ call add(tl, [2, 'aabb\|aa\zebb', ' aabb ', 'aabb'])
+ call add(tl, [2, 'aa\zebb\|aaebb', ' aabb ', 'aa'])
+ " match starts at \zs
+ call add(tl, [2, 'abc\zsdd', 'ddabcddxyzt', 'dd'])
+ call add(tl, [2, 'aa \zsax', ' ax'])
+ call add(tl, [2, 'abc \zsmatch\ze abc', 'abc abc abc match abc abc', 'match'])
+ call add(tl, [2, '\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last'])
+ call add(tl, [2, '\>\zs.', 'aword. ', '.'])
+ call add(tl, [2, '\s\+\ze\[/\|\s\zs\s\+', 'is [a t', ' '])
+
+ " Tests for \@= and \& features
+ call add(tl, [2, 'abc\@=', 'abc', 'ab'])
+ call add(tl, [2, 'abc\@=cd', 'abcd', 'abcd'])
+ call add(tl, [2, 'abc\@=', 'ababc', 'ab'])
+ " will never match, no matter the input text
+ call add(tl, [2, 'abcd\@=e', 'abcd'])
+ " will never match
+ call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
+ call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
+ call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
+ call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
+ call add(tl, [2, '\<\S\+\())\)\@=', '$((i=i+1))', 'i=i+1', '))'])
+ call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
+ call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
+ call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
+ call add(tl, [2, 'foo\(bar\)\@!', 'foobar'])
+ call add(tl, [2, 'foo\(bar\)\@!', 'foo bar', 'foo'])
+ call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if then else'])
+ call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if else ', 'if else ', ' '])
+ call add(tl, [2, '\(foo\)\@!bar', 'foobar', 'bar'])
+ call add(tl, [2, '\(foo\)\@!...bar', 'foobar'])
+ call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' bar foo '])
+ call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo bar '])
+ call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo xxx ', 'foo'])
+ call add(tl, [2, '[ ]\@!\p\%([ ]\@!\p\)*:', 'implicit mappings:', 'mappings:'])
+ call add(tl, [2, '[ ]\@!\p\([ ]\@!\p\)*:', 'implicit mappings:', 'mappings:', 's'])
+ call add(tl, [2, 'm\k\+_\@=\%(_\@!\k\)\@<=\k\+e', 'mx__xe', 'mx__xe'])
+ call add(tl, [2, '\%(\U\@<=S\k*\|S\l\)R', 'SuR', 'SuR'])
+
+ " Combining different tests and features
+ call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
+ call add(tl, [2, '', 'abcd', ''])
+ call add(tl, [2, '\v(())', 'any possible text', ''])
+ call add(tl, [2, '\v%(ab(xyz)c)', ' abxyzc ', 'abxyzc', 'xyz'])
+ call add(tl, [2, '\v(test|)empty', 'tesempty', 'empty', ''])
+ call add(tl, [2, '\v(a|aa)(a|aa)', 'aaa', 'aa', 'a', 'a'])
+
+ " \%u and friends
+ call add(tl, [2, '\%d32', 'yes no', ' '])
+ call add(tl, [2, '\%o40', 'yes no', ' '])
+ call add(tl, [2, '\%x20', 'yes no', ' '])
+ call add(tl, [2, '\%u0020', 'yes no', ' '])
+ call add(tl, [2, '\%U00000020', 'yes no', ' '])
+ call add(tl, [2, '\%d0', "yes\x0ano", "\x0a"])
+
+ "" \%[abc]
+ call add(tl, [2, 'foo\%[bar]', 'fobar'])
+ call add(tl, [2, 'foo\%[bar]', 'foobar', 'foobar'])
+ call add(tl, [2, 'foo\%[bar]', 'fooxx', 'foo'])
+ call add(tl, [2, 'foo\%[bar]', 'foobxx', 'foob'])
+ call add(tl, [2, 'foo\%[bar]', 'foobaxx', 'fooba'])
+ call add(tl, [2, 'foo\%[bar]', 'foobarxx', 'foobar'])
+ call add(tl, [2, 'foo\%[bar]x', 'foobxx', 'foobx'])
+ call add(tl, [2, 'foo\%[bar]x', 'foobarxx', 'foobarx'])
+ call add(tl, [2, '\%[bar]x', 'barxx', 'barx'])
+ call add(tl, [2, '\%[bar]x', 'bxx', 'bx'])
+ call add(tl, [2, '\%[bar]x', 'xxx', 'x'])
+ call add(tl, [2, 'b\%[[ao]r]', 'bar bor', 'bar'])
+ call add(tl, [2, 'b\%[[]]r]', 'b]r bor', 'b]r'])
+ call add(tl, [2, '@\%[\w\-]*', '<http://john.net/pandoc/>[@pandoc]', '@pandoc'])
+
+ " Alternatives, must use first longest match
+ call add(tl, [2, 'goo\|go', 'google', 'goo'])
+ call add(tl, [2, '\<goo\|\<go', 'google', 'goo'])
+ call add(tl, [2, '\<goo\|go', 'google', 'goo'])
+
+ " Back references
+ call add(tl, [2, '\(\i\+\) \1', ' abc abc', 'abc abc', 'abc'])
+ call add(tl, [2, '\(\i\+\) \1', 'xgoo goox', 'goo goo', 'goo'])
+ call add(tl, [2, '\(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9', 'xabcddefghiabcddefghix', 'abcddefghiabcddefghi', 'a', 'b', 'c', 'dd', 'e', 'f', 'g', 'h', 'i'])
+ call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', ''])
+ call add(tl, [2, '^.\(.\).\_..\1.', "aaa\naaa\nb", "aaa\naaa", 'a'])
+ call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<!$', 'foo.bat/foo.com', 'foo.bat/foo.com', 'bat'])
+ call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<!$', 'foo.bat/foo.bat'])
+ call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<=$', 'foo.bat/foo.bat', 'foo.bat/foo.bat', 'bat', 'bat'])
+ call add(tl, [2, '\\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}', '2013-06-27${0}', '${0}', '0'])
+ call add(tl, [2, '^\(a*\)\1$', 'aaaaaaaa', 'aaaaaaaa', 'aaaa'])
+ call add(tl, [2, '^\(a\{-2,}\)\1\+$', 'aaaaaaaaa', 'aaaaaaaaa', 'aaa'])
+
+ " Look-behind with limit
+ call add(tl, [2, '<\@<=span.', 'xxspanxx<spanyyy', 'spany'])
+ call add(tl, [2, '<\@1<=span.', 'xxspanxx<spanyyy', 'spany'])
+ call add(tl, [2, '<\@2<=span.', 'xxspanxx<spanyyy', 'spany'])
+ call add(tl, [2, '\(<<\)\@<=span.', 'xxspanxxxx<spanxx<<spanyyy', 'spany', '<<'])
+ call add(tl, [2, '\(<<\)\@1<=span.', 'xxspanxxxx<spanxx<<spanyyy'])
+ call add(tl, [2, '\(<<\)\@2<=span.', 'xxspanxxxx<spanxx<<spanyyy', 'spany', '<<'])
+ call add(tl, [2, '\(foo\)\@<!bar.', 'xx foobar1 xbar2 xx', 'bar2'])
+
+ " look-behind match in front of a zero-width item
+ call add(tl, [2, '\v\C%(<Last Changed:\s+)@<=.*$', '" test header'])
+ call add(tl, [2, '\v\C%(<Last Changed:\s+)@<=.*$', '" Last Changed: 1970', '1970'])
+ call add(tl, [2, '\(foo\)\@<=\>', 'foobar'])
+ call add(tl, [2, '\(foo\)\@<=\>', 'barfoo', '', 'foo'])
+ call add(tl, [2, '\(foo\)\@<=.*', 'foobar', 'bar', 'foo'])
+
+ " complicated look-behind match
+ call add(tl, [2, '\(r\@<=\|\w\@<!\)\/', 'x = /word/;', '/'])
+ call add(tl, [2, '^[a-z]\+\ze \&\(asdf\)\@<!', 'foo bar', 'foo'])
+
+ "" \@>
+ call add(tl, [2, '\(a*\)\@>a', 'aaaa'])
+ call add(tl, [2, '\(a*\)\@>b', 'aaab', 'aaab', 'aaa'])
+ call add(tl, [2, '^\(.\{-}b\)\@>.', ' abcbd', ' abc', ' ab'])
+ call add(tl, [2, '\(.\{-}\)\(\)\@>$', 'abc', 'abc', 'abc', ''])
+ " TODO: BT engine does not restore submatch after failure
+ call add(tl, [1, '\(a*\)\@>a\|a\+', 'aaaa', 'aaaa'])
+
+ " "\_" prepended negated collection matches EOL
+ call add(tl, [2, '\_[^8-9]\+', "asfi\n9888", "asfi\n"])
+ call add(tl, [2, '\_[^a]\+', "asfi\n9888", "sfi\n9888"])
+
+ " Requiring lots of states.
+ call add(tl, [2, '[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}', " 12345678-1234-1234-1234-123456789012 ", "12345678-1234-1234-1234-123456789012", "1234-"])
+
+ " Skip adding state twice
+ call add(tl, [2, '^\%(\%(^\s*#\s*if\>\|#\s*if\)\)\(\%>1c.*$\)\@=', "#if FOO", "#if", ' FOO'])
+
+ " Test \%V atom
+ call add(tl, [2, '\%>70vGesamt', 'Jean-Michel Charlier & Victor Hubinon\Gesamtausgabe [Salleck] Buck Danny {Jean-Michel Charlier & Victor Hubinon}\Gesamtausgabe', 'Gesamt'])
+
+ " Run the tests
+ for t in tl
+ let re = t[0]
+ let pat = t[1]
+ let text = t[2]
+ let matchidx = 3
+ for engine in [0, 1, 2]
+ if engine == 2 && re == 0 || engine == 1 && re == 1
+ continue
+ endif
+ let &regexpengine = engine
+ try
+ let l = matchlist(text, pat)
+ catch
+ call assert_report('Error ' . engine . ': pat: \"' . pat
+ \ . '\", text: \"' . text . '\", caused an exception: \"'
+ \ . v:exception . '\"')
+ endtry
+ " check the match itself
+ if len(l) == 0 && len(t) > matchidx
+ call assert_report('Error ' . engine . ': pat: \"' . pat
+ \ . '\", text: \"' . text . '\", did not match, expected: \"'
+ \ . t[matchidx] . '\"')
+ elseif len(l) > 0 && len(t) == matchidx
+ call assert_report('Error ' . engine . ': pat: \"' . pat
+ \ . '\", text: \"' . text . '\", match: \"' . l[0]
+ \ . '\", expected no match')
+ elseif len(t) > matchidx && l[0] != t[matchidx]
+ call assert_report('Error ' . engine . ': pat: \"' . pat
+ \ . '\", text: \"' . text . '\", match: \"' . l[0]
+ \ . '\", expected: \"' . t[matchidx] . '\"')
+ else
+ " Test passed
+ endif
+
+ " check all the nine submatches
+ if len(l) > 0
+ for i in range(1, 9)
+ if len(t) <= matchidx + i
+ let e = ''
+ else
+ let e = t[matchidx + i]
+ endif
+ if l[i] != e
+ call assert_report('Error ' . engine . ': pat: \"' . pat
+ \ . '\", text: \"' . text . '\", submatch ' . i . ': \"'
+ \ . l[i] . '\", expected: \"' . e . '\"')
+ endif
+ endfor
+ unlet i
+ endif
+ endfor
+ endfor
+
+ unlet t tl e l
+endfunc
+
+" Tests for multi-line regexp patterns without multi-byte support.
+func Test_regexp_multiline_pat()
+ let tl = []
+
+ " back references
+ call add(tl, [2, '^.\(.\).\_..\1.', ['aaa', 'aaa', 'b'], ['XX', 'b']])
+ call add(tl, [2, '\v.*\/(.*)\n.*\/\1$', ['./Dir1/Dir2/zyxwvuts.txt', './Dir1/Dir2/abcdefgh.bat', '', './Dir1/Dir2/file1.txt', './OtherDir1/OtherDir2/file1.txt'], ['./Dir1/Dir2/zyxwvuts.txt', './Dir1/Dir2/abcdefgh.bat', '', 'XX']])
+
+ " line breaks
+ call add(tl, [2, '\S.*\nx', ['abc', 'def', 'ghi', 'xjk', 'lmn'], ['abc', 'def', 'XXjk', 'lmn']])
+
+ " Check that \_[0-9] matching EOL does not break a following \>
+ call add(tl, [2, '\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>', ['', 'localnet/192.168.0.1', ''], ['', 'localnet/XX', '']])
+
+ " Check a pattern with a line break and ^ and $
+ call add(tl, [2, 'a\n^b$\n^c', ['a', 'b', 'c'], ['XX']])
+
+ call add(tl, [2, '\(^.\+\n\)\1', [' dog', ' dog', 'asdf'], ['XXasdf']])
+
+ " Run the multi-line tests
+ for t in tl
+ let re = t[0]
+ let pat = t[1]
+ let before = t[2]
+ let after = t[3]
+ for engine in [0, 1, 2]
+ if engine == 2 && re == 0 || engine == 1 && re ==1
+ continue
+ endif
+ let &regexpengine = engine
+ new
+ call setline(1, before)
+ exe '%s/' . pat . '/XX/'
+ let result = getline(1, '$')
+ q!
+ if result != after
+ call assert_report('Error: pat: \"' . pat . '\", text: \"'
+ \ . string(before) . '\", expected: \"' . string(after)
+ \ . '\", got: \"' . string(result) . '\"')
+ else
+ " Test passed
+ endif
+ endfor
+ endfor
+ unlet t tl
+endfunc
+
+" Check that using a pattern on two lines doesn't get messed up by using
+" matchstr() with \ze in between.
+func Test_matchstr_with_ze()
+ new
+ call append(0, ['Substitute here:', '<T="">Ta 5</Title>',
+ \ '<T="">Ac 7</Title>'])
+ call cursor(1, 1)
+ set re=0
+
+ .+1,.+2s/""/\='"' . matchstr(getline("."), '\d\+\ze<') . '"'
+ call assert_equal(['Substitute here:', '<T="5">Ta 5</Title>',
+ \ '<T="7">Ac 7</Title>', ''], getline(1, '$'))
+
+ bwipe!
+endfunc
+
+" Check a pattern with a look beind crossing a line boundary
+func Test_lookbehind_across_line()
+ new
+ call append(0, ['Behind:', 'asdfasd<yyy', 'xxstart1', 'asdfasd<yy',
+ \ 'xxxstart2', 'asdfasd<yy', 'xxstart3'])
+ call cursor(1, 1)
+ call search('\(<\_[xy]\+\)\@3<=start')
+ call assert_equal([0, 7, 3, 0], getpos('.'))
+ bwipe!
+endfunc
+
+" Check matching Visual area
+func Test_matching_visual_area()
+ new
+ call append(0, ['Visual:', 'thexe the thexethe', 'andaxand andaxand',
+ \ 'oooxofor foroxooo', 'oooxofor foroxooo'])
+ call cursor(1, 1)
+ exe "normal jfxvfx:s/\\%Ve/E/g\<CR>"
+ exe "normal jV:s/\\%Va/A/g\<CR>"
+ exe "normal jfx\<C-V>fxj:s/\\%Vo/O/g\<CR>"
+ call assert_equal(['Visual:', 'thexE thE thExethe', 'AndAxAnd AndAxAnd',
+ \ 'oooxOfOr fOrOxooo', 'oooxOfOr fOrOxooo', ''], getline(1, '$'))
+ bwipe!
+endfunc
+
+" Check matching marks
+func Test_matching_marks()
+ new
+ call append(0, ['', '', '', 'Marks:', 'asdfSasdfsadfEasdf', 'asdfSas',
+ \ 'dfsadfEasdf', '', '', '', '', ''])
+ call cursor(4, 1)
+ exe "normal jfSmsfEme:.-4,.+6s/.\\%>'s.*\\%<'e../here/\<CR>"
+ exe "normal jfSmsj0fEme:.-4,.+6s/.\\%>'s\\_.*\\%<'e../again/\<CR>"
+ call assert_equal(['', '', '', 'Marks:', 'asdfhereasdf', 'asdfagainasdf',
+ \ '', '', '', '', '', ''], getline(1, '$'))
+ bwipe!
+endfunc
+
+" Check patterns matching cursor position.
+func s:curpos_test()
+ new
+ call setline(1, ['ffooooo', 'boboooo', 'zoooooo', 'koooooo', 'moooooo',
+ \ "\t\t\tfoo", 'abababababababfoo', 'bababababababafoo', '********_',
+ \ ' xxxxxxxxxxxx xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx'])
+ call setpos('.', [0, 1, 0, 0])
+ s/\%>3c.//g
+ call setpos('.', [0, 2, 4, 0])
+ s/\%#.*$//g
+ call setpos('.', [0, 3, 0, 0])
+ s/\%<3c./_/g
+ %s/\%4l\%>5c./_/g
+ %s/\%6l\%>25v./_/g
+ %s/\%>6l\%3c./!/g
+ %s/\%>7l\%12c./?/g
+ %s/\%>7l\%<9l\%>5v\%<8v./#/g
+ $s/\%(|\u.*\)\@<=[^|\t]\+$//ge
+ call assert_equal(['ffo', 'bob', '__ooooo', 'koooo__', 'moooooo',
+ \ ' f__', 'ab!babababababfoo',
+ \ 'ba!ab##abab?bafoo', '**!*****_',
+ \ ' ! xxx?xxxxxxxx xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx'],
+ \ getline(1, '$'))
+ bwipe!
+endfunc
+
+func Test_matching_curpos()
+ set re=0
+ call s:curpos_test()
+ set re=1
+ call s:curpos_test()
+ set re=2
+ call s:curpos_test()
+ set re&
+endfunc
+
+" Test for matching the start and end of a buffer
+func Test_start_end_of_buffer_match()
+ new
+ call setline(1, repeat(['vim edit'], 20))
+ /\%^
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ exe "normal 50%/\\%^..\<CR>"
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ exe "normal 50%/\\%$\<CR>"
+ call assert_equal([0, 20, 8, 0], getpos('.'))
+ exe "normal 6gg/..\\%$\<CR>"
+ call assert_equal([0, 20, 7, 0], getpos('.'))
+ bwipe!
+endfunc
+
+" Check for detecting error
+func Test_regexp_error()
+ set regexpengine=2
+ call assert_fails("call matchlist('x x', ' \\ze*')", 'E888:')
+ call assert_fails("call matchlist('x x', ' \\zs*')", 'E888:')
+ set re&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim
index e06c7d6368..4466ad436a 100644
--- a/src/nvim/testdir/test_regexp_utf8.vim
+++ b/src/nvim/testdir/test_regexp_utf8.vim
@@ -32,6 +32,9 @@ func Test_equivalence_re2()
endfunc
func s:classes_test()
+ if has('win32')
+ set iskeyword=@,48-57,_,192-255
+ endif
set isprint=@,161-255
call assert_equal('Motörhead', matchstr('Motörhead', '[[:print:]]\+'))
@@ -51,6 +54,12 @@ func s:classes_test()
let tabchar = ''
let upperchars = ''
let xdigitchars = ''
+ let identchars = ''
+ let identchars1 = ''
+ let kwordchars = ''
+ let kwordchars1 = ''
+ let fnamechars = ''
+ let fnamechars1 = ''
let i = 1
while i <= 255
let c = nr2char(i)
@@ -102,6 +111,24 @@ func s:classes_test()
if c =~ '[[:xdigit:]]'
let xdigitchars .= c
endif
+ if c =~ '[[:ident:]]'
+ let identchars .= c
+ endif
+ if c =~ '\i'
+ let identchars1 .= c
+ endif
+ if c =~ '[[:keyword:]]'
+ let kwordchars .= c
+ endif
+ if c =~ '\k'
+ let kwordchars1 .= c
+ endif
+ if c =~ '[[:fname:]]'
+ let fnamechars .= c
+ endif
+ if c =~ '\f'
+ let fnamechars1 .= c
+ endif
let i += 1
endwhile
@@ -121,6 +148,37 @@ func s:classes_test()
call assert_equal("\t\n\x0b\f\r ", spacechars)
call assert_equal("\t", tabchar)
call assert_equal('0123456789ABCDEFabcdef', xdigitchars)
+
+ if has('win32')
+ let identchars_ok = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
+ let kwordchars_ok = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzµÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ elseif has('ebcdic')
+ let identchars_ok = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz€ŒŽœž¬®µº¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ let kwordchars_ok = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz€ŒŽœž¬®µº¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ else
+ let identchars_ok = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzµÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ let kwordchars_ok = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzµÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ endif
+
+ if has('win32')
+ let fnamechars_ok = '!#$%+,-./0123456789:=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]_abcdefghijklmnopqrstuvwxyz{}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ elseif has('amiga')
+ let fnamechars_ok = '$+,-./0123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ elseif has('vms')
+ let fnamechars_ok = '#$%+,-./0123456789:;<>ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ elseif has('ebcdic')
+ let fnamechars_ok = '#$%+,-./=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ else
+ let fnamechars_ok = '#$%+,-./0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
+ endif
+
+ call assert_equal(identchars_ok, identchars)
+ call assert_equal(kwordchars_ok, kwordchars)
+ call assert_equal(fnamechars_ok, fnamechars)
+
+ call assert_equal(identchars1, identchars)
+ call assert_equal(kwordchars1, kwordchars)
+ call assert_equal(fnamechars1, fnamechars)
endfunc
func Test_classes_re1()
@@ -192,3 +250,287 @@ func Test_optmatch_toolong()
set re=0
endfunc
+" Test for regexp patterns with multi-byte support, using utf-8.
+func Test_multibyte_chars()
+ " tl is a List of Lists with:
+ " 2: test auto/old/new 0: test auto/old 1: test auto/new
+ " regexp pattern
+ " text to test the pattern on
+ " expected match (optional)
+ " expected submatch 1 (optional)
+ " expected submatch 2 (optional)
+ " etc.
+ " When there is no match use only the first two items.
+ let tl = []
+
+ " Multi-byte character tests. These will fail unless vim is compiled
+ " with Multibyte (FEAT_MBYTE) or BIG/HUGE features.
+ call add(tl, [2, '[[:alpha:][=a=]]\+', '879 aiaãâaiuvna ', 'aiaãâaiuvna'])
+ call add(tl, [2, '[[=a=]]\+', 'ddaãâbcd', 'aãâ']) " equivalence classes
+ call add(tl, [2, '[^ม ]\+', 'มม oijasoifjos ifjoisj f osij j มมมมม abcd', 'oijasoifjos'])
+ call add(tl, [2, ' [^ ]\+', 'start มabcdม ', ' มabcdม'])
+ call add(tl, [2, '[ม[:alpha:][=a=]]\+', '879 aiaãมâมaiuvna ', 'aiaãมâมaiuvna'])
+
+ " this is not a normal "i" but 0xec
+ call add(tl, [2, '\p\+', 'ìa', 'ìa'])
+ call add(tl, [2, '\p*', 'aあ', 'aあ'])
+
+ " Test recognition of some character classes
+ call add(tl, [2, '\i\+', '&*¨xx ', 'xx'])
+ call add(tl, [2, '\f\+', '&*Ÿfname ', 'fname'])
+
+ " Test composing character matching
+ call add(tl, [2, '.ม', 'xม่x yมy', 'yม'])
+ call add(tl, [2, '.ม่', 'xม่x yมy', 'xม่'])
+ call add(tl, [2, "\u05b9", " x\u05b9 ", "x\u05b9"])
+ call add(tl, [2, ".\u05b9", " x\u05b9 ", "x\u05b9"])
+ call add(tl, [2, "\u05b9\u05bb", " x\u05b9\u05bb ", "x\u05b9\u05bb"])
+ call add(tl, [2, ".\u05b9\u05bb", " x\u05b9\u05bb ", "x\u05b9\u05bb"])
+ call add(tl, [2, "\u05bb\u05b9", " x\u05b9\u05bb ", "x\u05b9\u05bb"])
+ call add(tl, [2, ".\u05bb\u05b9", " x\u05b9\u05bb ", "x\u05b9\u05bb"])
+ call add(tl, [2, "\u05b9", " y\u05bb x\u05b9 ", "x\u05b9"])
+ call add(tl, [2, ".\u05b9", " y\u05bb x\u05b9 ", "x\u05b9"])
+ call add(tl, [2, "\u05b9", " y\u05bb\u05b9 x\u05b9 ", "y\u05bb\u05b9"])
+ call add(tl, [2, ".\u05b9", " y\u05bb\u05b9 x\u05b9 ", "y\u05bb\u05b9"])
+ call add(tl, [1, "\u05b9\u05bb", " y\u05b9 x\u05b9\u05bb ", "x\u05b9\u05bb"])
+ call add(tl, [2, ".\u05b9\u05bb", " y\u05bb x\u05b9\u05bb ", "x\u05b9\u05bb"])
+ call add(tl, [2, "a", "ca\u0300t"])
+ call add(tl, [2, "ca", "ca\u0300t"])
+ call add(tl, [2, "a\u0300", "ca\u0300t", "a\u0300"])
+ call add(tl, [2, 'a\%C', "ca\u0300t", "a\u0300"])
+ call add(tl, [2, 'ca\%C', "ca\u0300t", "ca\u0300"])
+ call add(tl, [2, 'ca\%Ct', "ca\u0300t", "ca\u0300t"])
+
+ " Test \Z
+ call add(tl, [2, 'ú\Z', 'x'])
+ call add(tl, [2, 'יהוה\Z', 'יהוה', 'יהוה'])
+ call add(tl, [2, 'יְהוָה\Z', 'יהוה', 'יהוה'])
+ call add(tl, [2, 'יהוה\Z', 'יְהוָה', 'יְהוָה'])
+ call add(tl, [2, 'יְהוָה\Z', 'יְהוָה', 'יְהוָה'])
+ call add(tl, [2, 'יְ\Z', 'וְיַ', 'יַ'])
+ call add(tl, [2, "ק\u200d\u05b9x\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
+ call add(tl, [2, "ק\u200d\u05b9x\\Z", "xק\u200dxy", "ק\u200dx"])
+ call add(tl, [2, "ק\u200dx\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
+ call add(tl, [2, "ק\u200dx\\Z", "xק\u200dxy", "ק\u200dx"])
+ call add(tl, [2, "\u05b9\\Z", "xyz"])
+ call add(tl, [2, "\\Z\u05b9", "xyz"])
+ call add(tl, [2, "\u05b9\\Z", "xy\u05b9z", "y\u05b9"])
+ call add(tl, [2, "\\Z\u05b9", "xy\u05b9z", "y\u05b9"])
+ call add(tl, [1, "\u05b9\\+\\Z", "xy\u05b9z\u05b9 ", "y\u05b9z\u05b9"])
+ call add(tl, [1, "\\Z\u05b9\\+", "xy\u05b9z\u05b9 ", "y\u05b9z\u05b9"])
+
+ " Combining different tests and features
+ call add(tl, [2, '[^[=a=]]\+', 'ddaãâbcd', 'dd'])
+
+ " Run the tests
+ for t in tl
+ let re = t[0]
+ let pat = t[1]
+ let text = t[2]
+ let matchidx = 3
+ for engine in [0, 1, 2]
+ if engine == 2 && re == 0 || engine == 1 && re == 1
+ continue
+ endif
+ let &regexpengine = engine
+ try
+ let l = matchlist(text, pat)
+ catch
+ call assert_report('Error ' . engine . ': pat: \"' . pat .
+ \ '\", text: \"' . text .
+ \ '\", caused an exception: \"' . v:exception . '\"')
+ endtry
+ " check the match itself
+ if len(l) == 0 && len(t) > matchidx
+ call assert_report('Error ' . engine . ': pat: \"' . pat .
+ \ '\", text: \"' . text .
+ \ '\", did not match, expected: \"' . t[matchidx] . '\"')
+ elseif len(l) > 0 && len(t) == matchidx
+ call assert_report('Error ' . engine . ': pat: \"' . pat .
+ \ '\", text: \"' . text . '\", match: \"' . l[0] .
+ \ '\", expected no match')
+ elseif len(t) > matchidx && l[0] != t[matchidx]
+ call assert_report('Error ' . engine . ': pat: \"' . pat .
+ \ '\", text: \"' . text . '\", match: \"' . l[0] .
+ \ '\", expected: \"' . t[matchidx] . '\"')
+ else
+ " Test passed
+ endif
+ if len(l) > 0
+ " check all the nine submatches
+ for i in range(1, 9)
+ if len(t) <= matchidx + i
+ let e = ''
+ else
+ let e = t[matchidx + i]
+ endif
+ if l[i] != e
+ call assert_report('Error ' . engine . ': pat: \"' . pat .
+ \ '\", text: \"' . text . '\", submatch ' . i .
+ \ ': \"' . l[i] . '\", expected: \"' . e . '\"')
+ endif
+ endfor
+ unlet i
+ endif
+ endfor
+ endfor
+ set regexpengine&
+endfunc
+
+" check that 'ambiwidth' does not change the meaning of \p
+func Test_ambiwidth()
+ set regexpengine=1 ambiwidth=single
+ call assert_equal(0, match("\u00EC", '\p'))
+ set regexpengine=1 ambiwidth=double
+ call assert_equal(0, match("\u00EC", '\p'))
+ set regexpengine=2 ambiwidth=single
+ call assert_equal(0, match("\u00EC", '\p'))
+ set regexpengine=2 ambiwidth=double
+ call assert_equal(0, match("\u00EC", '\p'))
+ set regexpengine& ambiwidth&
+endfunc
+
+func Run_regexp_ignore_case()
+ call assert_equal('iIİ', substitute('iIİ', '\([iIİ]\)', '\1', 'g'))
+
+ call assert_equal('iIx', substitute('iIİ', '\c\([İ]\)', 'x', 'g'))
+ call assert_equal('xxİ', substitute('iIİ', '\(i\c\)', 'x', 'g'))
+ call assert_equal('iIx', substitute('iIİ', '\(İ\c\)', 'x', 'g'))
+ call assert_equal('iIx', substitute('iIİ', '\c\(\%u0130\)', 'x', 'g'))
+ call assert_equal('iIx', substitute('iIİ', '\c\([\u0130]\)', 'x', 'g'))
+ call assert_equal('iIx', substitute('iIİ', '\c\([\u012f-\u0131]\)', 'x', 'g'))
+endfunc
+
+func Test_regexp_ignore_case()
+ set regexpengine=1
+ call Run_regexp_ignore_case()
+ set regexpengine=2
+ call Run_regexp_ignore_case()
+ set regexpengine&
+endfunc
+
+" Tests for regexp with multi-byte encoding and various magic settings
+func Run_regexp_multibyte_magic()
+ let text =<< trim END
+ 1 a aa abb abbccc
+ 2 d dd dee deefff
+ 3 g gg ghh ghhiii
+ 4 j jj jkk jkklll
+ 5 m mm mnn mnnooo
+ 6 x ^aa$ x
+ 7 (a)(b) abbaa
+ 8 axx [ab]xx
+ 9 หม่x อมx
+ a อมx หม่x
+ b ちカヨは
+ c x ¬€x
+ d 天使x
+ e y
+ f z
+ g a啷bb
+ j 0123❤x
+ k combinations
+ l äö üᾱ̆́
+ END
+
+ new
+ call setline(1, text)
+ exe 'normal /a*b\{2}c\+/e' .. "\<CR>x"
+ call assert_equal('1 a aa abb abbcc', getline('.'))
+ exe 'normal /\Md\*e\{2}f\+/e' .. "\<CR>x"
+ call assert_equal('2 d dd dee deeff', getline('.'))
+ set nomagic
+ exe 'normal /g\*h\{2}i\+/e' .. "\<CR>x"
+ call assert_equal('3 g gg ghh ghhii', getline('.'))
+ exe 'normal /\mj*k\{2}l\+/e' .. "\<CR>x"
+ call assert_equal('4 j jj jkk jkkll', getline('.'))
+ exe 'normal /\vm*n{2}o+/e' .. "\<CR>x"
+ call assert_equal('5 m mm mnn mnnoo', getline('.'))
+ exe 'normal /\V^aa$/' .. "\<CR>x"
+ call assert_equal('6 x aa$ x', getline('.'))
+ set magic
+ exe 'normal /\v(a)(b)\2\1\1/e' .. "\<CR>x"
+ call assert_equal('7 (a)(b) abba', getline('.'))
+ exe 'normal /\V[ab]\(\[xy]\)\1' .. "\<CR>x"
+ call assert_equal('8 axx ab]xx', getline('.'))
+
+ " search for multi-byte without composing char
+ exe 'normal /ม' .. "\<CR>x"
+ call assert_equal('9 หม่x อx', getline('.'))
+
+ " search for multi-byte with composing char
+ exe 'normal /ม่' .. "\<CR>x"
+ call assert_equal('a อมx หx', getline('.'))
+
+ " find word by change of word class
+ exe 'normal /ち\<カヨ\>は' .. "\<CR>x"
+ call assert_equal('b カヨは', getline('.'))
+
+ " Test \%u, [\u] and friends
+ " c
+ exe 'normal /\%u20ac' .. "\<CR>x"
+ call assert_equal('c x ¬x', getline('.'))
+ " d
+ exe 'normal /[\u4f7f\u5929]\+' .. "\<CR>x"
+ call assert_equal('d 使x', getline('.'))
+ " e
+ exe 'normal /\%U12345678' .. "\<CR>x"
+ call assert_equal('e y', getline('.'))
+ " f
+ exe 'normal /[\U1234abcd\u1234\uabcd]' .. "\<CR>x"
+ call assert_equal('f z', getline('.'))
+ " g
+ exe 'normal /\%d21879b' .. "\<CR>x"
+ call assert_equal('g abb', getline('.'))
+
+ " j Test backwards search from a multi-byte char
+ exe "normal /x\<CR>x?.\<CR>x"
+ call assert_equal('j 012❤', getline('.'))
+ " k
+ let @w=':%s#comb[i]nations#œ̄ṣ́m̥̄ᾱ̆́#g'
+ @w
+ call assert_equal('k œ̄ṣ́m̥̄ᾱ̆́', getline(18))
+
+ close!
+endfunc
+
+func Test_regexp_multibyte_magic()
+ set regexpengine=1
+ call Run_regexp_multibyte_magic()
+ set regexpengine=2
+ call Run_regexp_multibyte_magic()
+ set regexpengine&
+endfunc
+
+" Test for 7.3.192
+" command ":s/ \?/ /g" splits multi-byte characters into bytes
+func Test_split_multibyte_to_bytes()
+ new
+ call setline(1, 'l äö üᾱ̆́')
+ s/ \?/ /g
+ call assert_equal(' l ä ö ü ᾱ̆́', getline(1))
+ close!
+endfunc
+
+" Test for matchstr() with multibyte characters
+func Test_matchstr_multibyte()
+ new
+ call assert_equal('ב', matchstr("אבגד", ".", 0, 2))
+ call assert_equal('בג', matchstr("אבגד", "..", 0, 2))
+ call assert_equal('א', matchstr("אבגד", ".", 0, 0))
+ call assert_equal('ג', matchstr("אבגד", ".", 4, -1))
+ close!
+endfunc
+
+" Test for 7.4.636
+" A search with end offset gets stuck at end of file.
+func Test_search_with_end_offset()
+ new
+ call setline(1, ['', 'dog(a', 'cat('])
+ exe "normal /(/e+" .. "\<CR>"
+ normal "ayn
+ call assert_equal("a\ncat(", @a)
+ close!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim
index 298268a994..d20f8d1eef 100644
--- a/src/nvim/testdir/test_registers.vim
+++ b/src/nvim/testdir/test_registers.vim
@@ -1,3 +1,16 @@
+"
+" Tests for register operations
+"
+
+" This test must be executed first to check for empty and unset registers.
+func Test_aaa_empty_reg_test()
+ call assert_fails('normal @@', 'E748:')
+ call assert_fails('normal @%', 'E354:')
+ call assert_fails('normal @#', 'E354:')
+ call assert_fails('normal @!', 'E354:')
+ call assert_fails('normal @:', 'E30:')
+ call assert_fails('normal @.', 'E29:')
+endfunc
func Test_yank_shows_register()
enew
@@ -82,3 +95,94 @@ func Test_recording_esc_sequence()
let &t_F2 = save_F2
endif
endfunc
+
+" Test for executing the last used register (@)
+func Test_last_used_exec_reg()
+ " Test for the @: command
+ let a = ''
+ call feedkeys(":let a ..= 'Vim'\<CR>", 'xt')
+ normal @:
+ call assert_equal('VimVim', a)
+
+ " Test for the @= command
+ let x = ''
+ let a = ":let x ..= 'Vim'\<CR>"
+ exe "normal @=a\<CR>"
+ normal @@
+ call assert_equal('VimVim', x)
+
+ " Test for the @. command
+ let a = ''
+ call feedkeys("i:let a ..= 'Edit'\<CR>", 'xt')
+ normal @.
+ normal @@
+ call assert_equal('EditEdit', a)
+
+ enew!
+endfunc
+
+func Test_get_register()
+ enew
+ edit Xfile1
+ edit Xfile2
+ call assert_equal('Xfile2', getreg('%'))
+ call assert_equal('Xfile1', getreg('#'))
+
+ call feedkeys("iTwo\<Esc>", 'xt')
+ call assert_equal('Two', getreg('.'))
+ call assert_equal('', getreg('_'))
+ call assert_beeps('normal ":yy')
+ call assert_beeps('normal "%yy')
+ call assert_beeps('normal ".yy')
+
+ call assert_equal('', getreg("\<C-F>"))
+ call assert_equal('', getreg("\<C-W>"))
+ call assert_equal('', getreg("\<C-L>"))
+
+ call assert_equal('', getregtype('!'))
+
+ enew!
+endfunc
+
+func Test_set_register()
+ call assert_fails("call setreg('#', 200)", 'E86:')
+
+ edit Xfile_alt_1
+ let b1 = bufnr('')
+ edit Xfile_alt_2
+ let b2 = bufnr('')
+ edit Xfile_alt_3
+ let b3 = bufnr('')
+ call setreg('#', 'alt_1')
+ call assert_equal('Xfile_alt_1', getreg('#'))
+ call setreg('#', b2)
+ call assert_equal('Xfile_alt_2', getreg('#'))
+
+ let ab = 'regwrite'
+ call setreg('=', '')
+ call setreg('=', 'a', 'a')
+ call setreg('=', 'b', 'a')
+ call assert_equal('regwrite', getreg('='))
+
+ enew!
+endfunc
+
+func Test_ve_blockpaste()
+ new
+ set ve=all
+ 0put =['QWERTZ','ASDFGH']
+ call cursor(1,1)
+ exe ":norm! \<C-V>3ljdP"
+ call assert_equal(1, col('.'))
+ call assert_equal(getline(1, 2), ['QWERTZ', 'ASDFGH'])
+ call cursor(1,1)
+ exe ":norm! \<C-V>3ljd"
+ call cursor(1,1)
+ norm! $3lP
+ call assert_equal(5, col('.'))
+ call assert_equal(getline(1, 2), ['TZ QWER', 'GH ASDF'])
+ set ve&vim
+ bwipe!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_restricted.vim b/src/nvim/testdir/test_restricted.vim
new file mode 100644
index 0000000000..a29f7c33d3
--- /dev/null
+++ b/src/nvim/testdir/test_restricted.vim
@@ -0,0 +1,103 @@
+" Test for "rvim" or "vim -Z"
+
+source shared.vim
+
+"if has('win32') && has('gui')
+" " Win32 GUI shows a dialog instead of displaying the error in the last line.
+" finish
+"endif
+
+func Test_restricted()
+ call Run_restricted_test('!ls', 'E145:')
+endfunc
+
+func Run_restricted_test(ex_cmd, error)
+ let cmd = GetVimCommand('Xrestricted')
+ if cmd == ''
+ return
+ endif
+
+ " Use a VimEnter autocommand to avoid that the error message is displayed in
+ " a dialog with an OK button.
+ call writefile([
+ \ "func Init()",
+ \ " silent! " . a:ex_cmd,
+ \ " call writefile([v:errmsg], 'Xrestrout')",
+ \ " qa!",
+ \ "endfunc",
+ \ "au VimEnter * call Init()",
+ \ ], 'Xrestricted')
+ call system(cmd . ' -Z')
+ call assert_match(a:error, join(readfile('Xrestrout')))
+
+ call delete('Xrestricted')
+ call delete('Xrestrout')
+endfunc
+
+func Test_restricted_lua()
+ if !has('lua')
+ throw 'Skipped: Lua is not supported'
+ endif
+ call Run_restricted_test('lua print("Hello, Vim!")', 'E981:')
+ call Run_restricted_test('luado return "hello"', 'E981:')
+ call Run_restricted_test('luafile somefile', 'E981:')
+ call Run_restricted_test('call luaeval("expression")', 'E145:')
+endfunc
+
+func Test_restricted_mzscheme()
+ if !has('mzscheme')
+ throw 'Skipped: MzScheme is not supported'
+ endif
+ call Run_restricted_test('mzscheme statement', 'E981:')
+ call Run_restricted_test('mzfile somefile', 'E981:')
+ call Run_restricted_test('call mzeval("expression")', 'E145:')
+endfunc
+
+func Test_restricted_perl()
+ if !has('perl')
+ throw 'Skipped: Perl is not supported'
+ endif
+ " TODO: how to make Safe mode fail?
+ " call Run_restricted_test('perl system("ls")', 'E981:')
+ " call Run_restricted_test('perldo system("hello")', 'E981:')
+ " call Run_restricted_test('perlfile somefile', 'E981:')
+ " call Run_restricted_test('call perleval("system(\"ls\")")', 'E145:')
+endfunc
+
+func Test_restricted_python()
+ if !has('python')
+ throw 'Skipped: Python is not supported'
+ endif
+ call Run_restricted_test('python print "hello"', 'E981:')
+ call Run_restricted_test('pydo return "hello"', 'E981:')
+ call Run_restricted_test('pyfile somefile', 'E981:')
+ call Run_restricted_test('call pyeval("expression")', 'E145:')
+endfunc
+
+func Test_restricted_python3()
+ if !has('python3')
+ throw 'Skipped: Python3 is not supported'
+ endif
+ call Run_restricted_test('py3 print "hello"', 'E981:')
+ call Run_restricted_test('py3do return "hello"', 'E981:')
+ call Run_restricted_test('py3file somefile', 'E981:')
+ call Run_restricted_test('call py3eval("expression")', 'E145:')
+endfunc
+
+func Test_restricted_ruby()
+ if !has('ruby')
+ throw 'Skipped: Ruby is not supported'
+ endif
+ call Run_restricted_test('ruby print "Hello"', 'E981:')
+ call Run_restricted_test('rubydo print "Hello"', 'E981:')
+ call Run_restricted_test('rubyfile somefile', 'E981:')
+endfunc
+
+func Test_restricted_tcl()
+ if !has('tcl')
+ throw 'Skipped: Tcl is not supported'
+ endif
+ call Run_restricted_test('tcl puts "Hello"', 'E981:')
+ call Run_restricted_test('tcldo puts "Hello"', 'E981:')
+ call Run_restricted_test('tclfile somefile', 'E981:')
+endfunc
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 5d4c2a015f..8036dea29f 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -1,6 +1,7 @@
" Test for the search command
source shared.vim
+source screendump.vim
func Test_search_cmdline()
" See test/functional/legacy/search_spec.lua
@@ -57,7 +58,7 @@ func Test_search_cmdline()
call feedkeys("/the".repeat("\<C-G>", 6)."\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
:1
- " eigth match
+ " eighth match
call feedkeys("/the".repeat("\<C-G>", 7)."\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
:1
@@ -99,7 +100,7 @@ func Test_search_cmdline()
call feedkeys("/the".repeat("\<C-G>", 6)."\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
:1
- " eigth match
+ " eighth match
call feedkeys("/the".repeat("\<C-G>", 7)."\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
:1
@@ -549,6 +550,36 @@ func Test_incsearch_with_change()
call delete('Xis_change_script')
endfunc
+func Test_incsearch_scrolling()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ call assert_equal(0, &scrolloff)
+ call writefile([
+ \ 'let dots = repeat(".", 120)',
+ \ 'set incsearch cmdheight=2 scrolloff=0',
+ \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
+ \ 'normal gg',
+ \ 'redraw',
+ \ ], 'Xscript')
+ let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
+ " Need to send one key at a time to force a redraw
+ call term_sendkeys(buf, '/')
+ sleep 100m
+ call term_sendkeys(buf, 't')
+ sleep 100m
+ call term_sendkeys(buf, 'a')
+ sleep 100m
+ call term_sendkeys(buf, 'r')
+ sleep 100m
+ call term_sendkeys(buf, 'g')
+ call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ call delete('Xscript')
+endfunc
+
func Test_search_undefined_behaviour()
if !has("terminal")
return
@@ -667,3 +698,9 @@ func Test_search_display_pattern()
set norl
endif
endfunc
+
+func Test_search_special()
+ " this was causing illegal memory access and an endless loop
+ set t_PE=
+ exe "norm /\x80PS"
+endfunc
diff --git a/src/nvim/testdir/test_signs.vim b/src/nvim/testdir/test_signs.vim
index ef4b227215..8b1927e4f0 100644
--- a/src/nvim/testdir/test_signs.vim
+++ b/src/nvim/testdir/test_signs.vim
@@ -4,6 +4,8 @@ if !has('signs')
finish
endif
+source screendump.vim
+
func Test_sign()
new
call setline(1, ['a', 'b', 'c', 'd'])
@@ -210,13 +212,16 @@ func Test_sign_completion()
call assert_equal('"sign define Sign linehl=SpellBad SpellCap ' .
\ 'SpellLocal SpellRare', @:)
- call writefile(['foo'], 'XsignOne')
- call writefile(['bar'], 'XsignTwo')
+ call feedkeys(":sign define Sign texthl=Spell\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign define Sign texthl=SpellBad SpellCap ' .
+ \ 'SpellLocal SpellRare', @:)
+
+ call writefile(repeat(["Sun is shining"], 30), "XsignOne")
+ call writefile(repeat(["Sky is blue"], 30), "XsignTwo")
call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:)
- call delete('XsignOne')
- call delete('XsignTwo')
+ " Test for completion of arguments to ':sign undefine'
call feedkeys(":sign undefine \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign undefine Sign1 Sign2', @:)
@@ -227,17 +232,70 @@ func Test_sign_completion()
call feedkeys(":sign place 1 name=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign place 1 name=Sign1 Sign2', @:)
+ edit XsignOne
+ sign place 1 name=Sign1 line=5
+ sign place 1 name=Sign1 group=g1 line=10
+ edit XsignTwo
+ sign place 1 name=Sign2 group=g2 line=15
+
+ " Test for completion of group= and file= arguments to ':sign place'
+ call feedkeys(":sign place 1 name=Sign1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place 1 name=Sign1 file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign place 1 name=Sign1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place 1 name=Sign1 group=g1 g2', @:)
+
+ " Test for completion of arguments to 'sign place' without sign identifier
+ call feedkeys(":sign place \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place buffer= file= group=', @:)
+ call feedkeys(":sign place file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign place group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place group=g1 g2', @:)
+ call feedkeys(":sign place group=g1 file=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place group=g1 file=XsignOne XsignTwo', @:)
+
+ " Test for completion of arguments to ':sign unplace'
call feedkeys(":sign unplace 1 \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign unplace 1 buffer= file= group=', @:)
-
+ call feedkeys(":sign unplace 1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign unplace 1 file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign unplace 1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign unplace 1 group=g1 g2', @:)
+ call feedkeys(":sign unplace 1 group=g2 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign unplace 1 group=g2 file=XsignOne XsignTwo', @:)
+
+ " Test for completion of arguments to ':sign list'
call feedkeys(":sign list \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign list Sign1 Sign2', @:)
+ " Test for completion of arguments to ':sign jump'
call feedkeys(":sign jump 1 \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign jump 1 buffer= file= group=', @:)
+ call feedkeys(":sign jump 1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign jump 1 file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign jump 1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign jump 1 group=g1 g2', @:)
+
+ " Error cases
+ call feedkeys(":sign here\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign here', @:)
+ call feedkeys(":sign define Sign here=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign define Sign here=\<C-A>", @:)
+ call feedkeys(":sign place 1 here=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign place 1 here=\<C-A>", @:)
+ call feedkeys(":sign jump 1 here=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign jump 1 here=\<C-A>", @:)
+ call feedkeys(":sign here there\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign here there\<C-A>", @:)
+ call feedkeys(":sign here there=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign here there=\<C-A>", @:)
+ sign unplace * group=*
sign undefine Sign1
sign undefine Sign2
+ enew
+ call delete('XsignOne')
+ call delete('XsignTwo')
endfunc
func Test_sign_invalid_commands()
@@ -1127,6 +1185,319 @@ func Test_sign_priority()
\ 'priority' : 10}],
\ s[0].signs)
+ call sign_unplace('*')
+
+ " Three signs on different lines with changing priorities
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 11, 'priority' : 50})
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 12, 'priority' : 60})
+ call sign_place(3, '', 'sign3', 'Xsign',
+ \ {'lnum' : 13, 'priority' : 70})
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 12, 'priority' : 40})
+ call sign_place(3, '', 'sign3', 'Xsign',
+ \ {'lnum' : 13, 'priority' : 30})
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 11, 'priority' : 50})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 11, 'group' : '',
+ \ 'priority' : 50},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 12, 'group' : '',
+ \ 'priority' : 40},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 13, 'group' : '',
+ \ 'priority' : 30}],
+ \ s[0].signs)
+
+ call sign_unplace('*')
+
+ " Two signs on the same line with changing priorities
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 30})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+ " Change the priority of the last sign to highest
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 40})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 40},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30}],
+ \ s[0].signs)
+ " Change the priority of the first sign to lowest
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 25})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 25}],
+ \ s[0].signs)
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 45})
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 55})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 55},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 45}],
+ \ s[0].signs)
+
+ call sign_unplace('*')
+
+ " Three signs on the same line with changing priorities
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 40})
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 30})
+ call sign_place(3, '', 'sign3', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 40},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+
+ " Change the priority of the middle sign to the highest
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 50})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 50},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 40},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+
+ " Change the priority of the middle sign to the lowest
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 15})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 50},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 15}],
+ \ s[0].signs)
+
+ " Change the priority of the last sign to the highest
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 55})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 55},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 50},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+
+ " Change the priority of the first sign to the lowest
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 15})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 50},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 15}],
+ \ s[0].signs)
+
+ call sign_unplace('*')
+
+ " Three signs on the same line with changing priorities along with other
+ " signs
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 2, 'priority' : 10})
+ call sign_place(2, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 30})
+ call sign_place(3, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ call sign_place(4, '', 'sign3', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 25})
+ call sign_place(5, '', 'sign2', 'Xsign',
+ \ {'lnum' : 6, 'priority' : 80})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
+ \ 'priority' : 10},
+ \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 25},
+ \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
+ \ 'priority' : 80}],
+ \ s[0].signs)
+
+ " Change the priority of the first sign to lowest
+ call sign_place(2, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 15})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
+ \ 'priority' : 10},
+ \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 25},
+ \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 15},
+ \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
+ \ 'priority' : 80}],
+ \ s[0].signs)
+
+ " Change the priority of the last sign to highest
+ call sign_place(2, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 30})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
+ \ 'priority' : 10},
+ \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 25},
+ \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
+ \ 'priority' : 80}],
+ \ s[0].signs)
+
+ " Change the priority of the middle sign to lowest
+ call sign_place(4, '', 'sign3', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 15})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
+ \ 'priority' : 10},
+ \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 15},
+ \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
+ \ 'priority' : 80}],
+ \ s[0].signs)
+
+ " Change the priority of the middle sign to highest
+ call sign_place(3, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 35})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
+ \ 'priority' : 10},
+ \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 35},
+ \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 30},
+ \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 15},
+ \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
+ \ 'priority' : 80}],
+ \ s[0].signs)
+
+ call sign_unplace('*')
+
+ " Multiple signs with the same priority on the same line
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ call sign_place(2, '', 'sign2', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ call sign_place(3, '', 'sign3', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+ " Place the last sign again with the same priority
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+ " Place the first sign again with the same priority
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+ " Place the middle sign again with the same priority
+ call sign_place(3, '', 'sign3', 'Xsign',
+ \ {'lnum' : 4, 'priority' : 20})
+ let s = sign_getplaced('Xsign', {'group' : '*'})
+ call assert_equal([
+ \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20},
+ \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
+ \ 'priority' : 20}],
+ \ s[0].signs)
+
+ call sign_unplace('*')
+
+ " Place multiple signs with same id on a line with different priority
+ call sign_place(1, '', 'sign1', 'Xsign',
+ \ {'lnum' : 5, 'priority' : 20})
+ call sign_place(1, '', 'sign2', 'Xsign',
+ \ {'lnum' : 5, 'priority' : 10})
+ let s = sign_getplaced('Xsign', {'lnum' : 5})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign2', 'lnum' : 5, 'group' : '',
+ \ 'priority' : 10}],
+ \ s[0].signs)
+ call sign_place(1, '', 'sign2', 'Xsign',
+ \ {'lnum' : 5, 'priority' : 5})
+ let s = sign_getplaced('Xsign', {'lnum' : 5})
+ call assert_equal([
+ \ {'id' : 1, 'name' : 'sign2', 'lnum' : 5, 'group' : '',
+ \ 'priority' : 5}],
+ \ s[0].signs)
+
" Error case
call assert_fails("call sign_place(1, 'g1', 'sign1', 'Xsign',
\ [])", 'E715:')
@@ -1339,3 +1710,35 @@ func Test_sign_jump_func()
sign undefine sign1
enew! | only!
endfunc
+
+" Test for correct cursor position after the sign column appears or disappears.
+func Test_sign_cursor_position()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot make screendumps'
+ endif
+
+ let lines =<< trim END
+ call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
+ call cursor(2,1)
+ sign define s1 texthl=Search text==>
+ redraw
+ sign place 10 line=2 name=s1
+ END
+ call writefile(lines, 'XtestSigncolumn')
+ let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
+ call VerifyScreenDump(buf, 'Test_sign_cursor_1', {})
+
+ " Change the sign text
+ call term_sendkeys(buf, ":sign define s1 text=-)\<CR>")
+ call VerifyScreenDump(buf, 'Test_sign_cursor_2', {})
+
+ " update cursor position calculation
+ call term_sendkeys(buf, "lh")
+ call term_sendkeys(buf, ":sign unplace 10\<CR>")
+ call VerifyScreenDump(buf, 'Test_sign_cursor_3', {})
+
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestSigncolumn')
+endfunc
diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim
index e49b5542fa..414c7278eb 100644
--- a/src/nvim/testdir/test_spell.vim
+++ b/src/nvim/testdir/test_spell.vim
@@ -1,10 +1,13 @@
" Test spell checking
" Note: this file uses latin1 encoding, but is used with utf-8 encoding.
+source check.vim
if !has('spell')
finish
endif
+source screendump.vim
+
func TearDown()
set nospell
call delete('Xtest.aff')
@@ -130,20 +133,21 @@ endfunc
func Test_spellinfo()
throw 'skipped: Nvim does not support enc=latin1'
new
+ let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
set enc=latin1 spell spelllang=en
- call assert_match("^\nfile: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo'))
+ call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
set enc=cp1250 spell spelllang=en
- call assert_match("^\nfile: .*/runtime/spell/en.ascii.spl\n$", execute('spellinfo'))
+ call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
set enc=utf-8 spell spelllang=en
- call assert_match("^\nfile: .*/runtime/spell/en.utf-8.spl\n$", execute('spellinfo'))
+ call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
set enc=latin1 spell spelllang=en_us,en_nz
call assert_match("^\n" .
- \ "file: .*/runtime/spell/en.latin1.spl\n" .
- \ "file: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo'))
+ \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
+ \ "file: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
set spell spelllang=
call assert_fails('spellinfo', 'E756:')
@@ -151,6 +155,12 @@ func Test_spellinfo()
set nospell spelllang=en
call assert_fails('spellinfo', 'E756:')
+ call assert_fails('set spelllang=foo/bar', 'E474:')
+ call assert_fails('set spelllang=foo\ bar', 'E474:')
+ call assert_fails("set spelllang=foo\\\nbar", 'E474:')
+ call assert_fails("set spelllang=foo\\\rbar", 'E474:')
+ call assert_fails("set spelllang=foo+bar", 'E474:')
+
set enc& spell& spelllang&
bwipe
endfunc
@@ -283,9 +293,9 @@ func Test_zz_affix()
\ ])
call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
- call RunGoodBad("meea1 meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
+ call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
\ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
- \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "prebar", "prebarmeat", "tail"],
+ \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
\ [
\ ["bad", ["bar", "lead", "tail"]],
\ ["mee", ["meea1", "meea\xE9", "bar"]],
@@ -320,6 +330,19 @@ func Test_zz_Numbers()
\ ])
endfunc
+" Affix flags
+func Test_zz_affix_flags()
+ call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
+ call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
+ \ "bad: drinks drinkstable drinkablestable",
+ \ ["drink", "drinkable", "drinkables", "table"],
+ \ [['bad', []],
+ \ ['drinks', ['drink']],
+ \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
+ \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
+ \ ])
+endfunc
+
function FirstSpellWord()
call feedkeys("/^start:\n", 'tx')
normal ]smm
@@ -373,6 +396,11 @@ func Test_zz_sal_and_addition()
call assert_equal("elekwint", SecondSpellWord())
endfunc
+func Test_spellfile_value()
+ set spellfile=Xdir/Xtest.latin1.add
+ set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
+endfunc
+
func Test_region_error()
messages clear
call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
@@ -452,6 +480,44 @@ func RunGoodBad(good, bad, expected_words, expected_bad_words)
bwipe!
endfunc
+func Test_spell_screendump()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, [
+ \ "This is some text without any spell errors. Everything",
+ \ "should just be black, nothing wrong here.",
+ \ "",
+ \ "This line has a sepll error. and missing caps.",
+ \ "And and this is the the duplication.",
+ \ "with missing caps here.",
+ \ ])
+ set spell spelllang=en_nz
+ END
+ call writefile(lines, 'XtestSpell')
+ let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
+ call VerifyScreenDump(buf, 'Test_spell_1', {})
+
+ let lines =<< trim END
+ call setline(1, [
+ \ "This is some text without any spell errors. Everything",
+ \ "should just be black, nothing wrong here.",
+ \ "",
+ \ "This line has a sepll error. and missing caps.",
+ \ "And and this is the the duplication.",
+ \ "with missing caps here.",
+ \ ])
+ set spell spelllang=en_nz
+ END
+ call writefile(lines, 'XtestSpell')
+ let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
+ call VerifyScreenDump(buf, 'Test_spell_1', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestSpell')
+endfunc
+
let g:test_data_aff1 = [
\"SET ISO8859-1",
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
@@ -713,6 +779,9 @@ let g:test_data_aff7 = [
\"SFX 61003 Y 1",
\"SFX 61003 0 meat .",
\"",
+ \"SFX 0 Y 1",
+ \"SFX 0 0 zero .",
+ \"",
\"SFX 391 Y 1",
\"SFX 391 0 a1 .",
\"",
@@ -724,7 +793,7 @@ let g:test_data_aff7 = [
\ ]
let g:test_data_dic7 = [
\"1234",
- \"mee/391,111,9999",
+ \"mee/0,391,111,9999",
\"bar/17,61003,123",
\"lead/2",
\"tail/123",
@@ -748,6 +817,21 @@ let g:test_data_dic9 = [
\"foo",
\"bar",
\ ]
+let g:test_data_aff10 = [
+ \"COMPOUNDRULE se",
+ \"COMPOUNDPERMITFLAG p",
+ \"",
+ \"SFX A Y 1",
+ \"SFX A 0 able/Mp .",
+ \"",
+ \"SFX M Y 1",
+ \"SFX M 0 s .",
+ \ ]
+let g:test_data_dic10 = [
+ \"1234",
+ \"drink/As",
+ \"table/e",
+ \ ]
let g:test_data_aff_sal = [
\"SET ISO8859-1",
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim
index 1e70f28a00..9abaca5957 100644
--- a/src/nvim/testdir/test_startup.vim
+++ b/src/nvim/testdir/test_startup.vim
@@ -20,25 +20,27 @@ func Test_after_comes_later()
if !has('packages')
return
endif
- let before = [
- \ 'set nocp viminfo+=nviminfo',
- \ 'set guioptions+=M',
- \ 'let $HOME = "/does/not/exist"',
- \ 'set loadplugins',
- \ 'set rtp=Xhere,Xafter,Xanother',
- \ 'set packpath=Xhere,Xafter',
- \ 'set nomore',
- \ 'let g:sequence = ""',
- \ ]
- let after = [
- \ 'redir! > Xtestout',
- \ 'scriptnames',
- \ 'redir END',
- \ 'redir! > Xsequence',
- \ 'echo g:sequence',
- \ 'redir END',
- \ 'quit',
- \ ]
+ let before =<< trim [CODE]
+ set nocp viminfo+=nviminfo
+ set guioptions+=M
+ let $HOME = "/does/not/exist"
+ set loadplugins
+ set rtp=Xhere,Xafter,Xanother
+ set packpath=Xhere,Xafter
+ set nomore
+ let g:sequence = ""
+ [CODE]
+
+ let after =<< trim [CODE]
+ redir! > Xtestout
+ scriptnames
+ redir END
+ redir! > Xsequence
+ echo g:sequence
+ redir END
+ quit
+ [CODE]
+
call mkdir('Xhere/plugin', 'p')
call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim')
call mkdir('Xanother/plugin', 'p')
@@ -77,15 +79,16 @@ func Test_pack_in_rtp_when_plugins_run()
if !has('packages')
return
endif
- let before = [
- \ 'set nocp viminfo+=nviminfo',
- \ 'set guioptions+=M',
- \ 'let $HOME = "/does/not/exist"',
- \ 'set loadplugins',
- \ 'set rtp=Xhere',
- \ 'set packpath=Xhere',
- \ 'set nomore',
- \ ]
+ let before =<< trim [CODE]
+ set nocp viminfo+=nviminfo
+ set guioptions+=M
+ let $HOME = "/does/not/exist"
+ set loadplugins
+ set rtp=Xhere
+ set packpath=Xhere
+ set nomore
+ [CODE]
+
let after = [
\ 'quit',
\ ]
@@ -133,11 +136,12 @@ endfunc
func Test_compatible_args()
throw "skipped: Nvim is always 'nocompatible'"
- let after = [
- \ 'call writefile([string(&compatible)], "Xtestout")',
- \ 'set viminfo+=nviminfo',
- \ 'quit',
- \ ]
+ let after =<< trim [CODE]
+ call writefile([string(&compatible)], "Xtestout")
+ set viminfo+=nviminfo
+ quit
+ [CODE]
+
if RunVim([], after, '-C')
let lines = readfile('Xtestout')
call assert_equal('1', lines[0])
@@ -154,14 +158,15 @@ endfunc
" Test the -o[N] and -O[N] arguments to open N windows split
" horizontally or vertically.
func Test_o_arg()
- let after = [
- \ 'call writefile([winnr("$"),
- \ winheight(1), winheight(2), &lines,
- \ winwidth(1), winwidth(2), &columns,
- \ bufname(winbufnr(1)), bufname(winbufnr(2))],
- \ "Xtestout")',
- \ 'qall',
- \ ]
+ let after =<< trim [CODE]
+ call writefile([winnr("$"),
+ \ winheight(1), winheight(2), &lines,
+ \ winwidth(1), winwidth(2), &columns,
+ \ bufname(winbufnr(1)), bufname(winbufnr(2))],
+ \ "Xtestout")
+ qall
+ [CODE]
+
if RunVim([], after, '-o2')
" Open 2 windows split horizontally. Expect:
" - 2 windows
@@ -230,17 +235,18 @@ endfunc
" Test the -p[N] argument to open N tabpages.
func Test_p_arg()
- let after = [
- \ 'call writefile(split(execute("tabs"), "\n"), "Xtestout")',
- \ 'qall',
- \ ]
+ let after =<< trim [CODE]
+ call writefile(split(execute("tabs"), "\n"), "Xtestout")
+ qall
+ [CODE]
+
if RunVim([], after, '-p2')
let lines = readfile('Xtestout')
call assert_equal(4, len(lines))
call assert_equal('Tab page 1', lines[0])
call assert_equal('> [No Name]', lines[1])
call assert_equal('Tab page 2', lines[2])
- call assert_equal(' [No Name]', lines[3])
+ call assert_equal('# [No Name]', lines[3])
endif
if RunVim([], after, '-p foo bar')
@@ -249,7 +255,7 @@ func Test_p_arg()
call assert_equal('Tab page 1', lines[0])
call assert_equal('> foo', lines[1])
call assert_equal('Tab page 2', lines[2])
- call assert_equal(' bar', lines[3])
+ call assert_equal('# bar', lines[3])
endif
call delete('Xtestout')
@@ -265,7 +271,7 @@ func Test_V_arg()
call assert_equal(" verbose=0\n", out)
let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq')
- " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out)
+ " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline \\d\\+: sourcing \"[^\"]*runtime[\\/]filetype\.vim\".*\n", out)
call assert_match(" verbose=2\n", out)
let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq')
@@ -290,10 +296,11 @@ endfunc
" -M resets 'modifiable' and 'write'
" -R sets 'readonly'
func Test_m_M_R()
- let after = [
- \ 'call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout")',
- \ 'qall',
- \ ]
+ let after =<< trim [CODE]
+ call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout")
+ qall
+ [CODE]
+
if RunVim([], after, '')
let lines = readfile('Xtestout')
call assert_equal(['1', '1', '0', '200'], lines)
@@ -316,10 +323,11 @@ endfunc
" Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes).
func Test_A_F_H_arg()
- let after = [
- \ 'call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout")',
- \ 'qall',
- \ ]
+ let after =<< trim [CODE]
+ call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout")
+ qall
+ [CODE]
+
" Use silent Ex mode to avoid the hit-Enter prompt for the warning that
" 'encoding' is not utf-8.
if has('arabic') && &encoding == 'utf-8' && RunVim([], after, '-e -s -A')
@@ -423,10 +431,11 @@ func Test_invalid_args()
endfunc
func Test_file_args()
- let after = [
- \ 'call writefile(argv(), "Xtestout")',
- \ 'qall',
- \ ]
+ let after =<< trim [CODE]
+ call writefile(argv(), "Xtestout")
+ qall
+ [CODE]
+
if RunVim([], after, '')
let lines = readfile('Xtestout')
call assert_equal(0, len(lines))
@@ -487,10 +496,11 @@ func Test_startuptime()
endfunc
func Test_read_stdin()
- let after = [
- \ 'write Xtestout',
- \ 'quit!',
- \ ]
+ let after =<< trim [CODE]
+ write Xtestout
+ quit!
+ [CODE]
+
if RunVimPiped([], after, '-', 'echo something | ')
let lines = readfile('Xtestout')
" MS-Windows adds a space after the word
@@ -540,20 +550,22 @@ endfunc
func Test_zzz_startinsert()
" Test :startinsert
call writefile(['123456'], 'Xtestout')
- let after = [
- \ ':startinsert',
- \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
- \ ]
+ let after =<< trim [CODE]
+ :startinsert
+ call feedkeys("foobar\<c-o>:wq\<cr>","t")
+ [CODE]
+
if RunVim([], after, 'Xtestout')
let lines = readfile('Xtestout')
call assert_equal(['foobar123456'], lines)
endif
" Test :startinsert!
call writefile(['123456'], 'Xtestout')
- let after = [
- \ ':startinsert!',
- \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
- \ ]
+ let after =<< trim [CODE]
+ :startinsert!
+ call feedkeys("foobar\<c-o>:wq\<cr>","t")
+ [CODE]
+
if RunVim([], after, 'Xtestout')
let lines = readfile('Xtestout')
call assert_equal(['123456foobar'], lines)
@@ -572,3 +584,12 @@ func Test_start_with_tabs()
" clean up
call StopVimInTerminal(buf)
endfunc
+
+func Test_v_argv()
+ let out = system(GetVimCommand() . ' -es -V1 -X arg1 --cmd "echo v:argv" --cmd q')
+ let list = split(out, "', '")
+ call assert_match('vim', list[0])
+ let idx = index(list, 'arg1')
+ call assert_true(idx > 2)
+ call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:])
+endfunc
diff --git a/src/nvim/testdir/test_startup_utf8.vim b/src/nvim/testdir/test_startup_utf8.vim
index b24b0eb5cf..1b3d2184a0 100644
--- a/src/nvim/testdir/test_startup_utf8.vim
+++ b/src/nvim/testdir/test_startup_utf8.vim
@@ -1,7 +1,7 @@
" Tests for startup using utf-8.
source shared.vim
-" source screendump.vim
+source screendump.vim
func Test_read_stdin_utf8()
let linesin = ['テスト', '€ÀÈÌÒÙ']
diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim
index b86340a23a..8c81ec3431 100644
--- a/src/nvim/testdir/test_statusline.vim
+++ b/src/nvim/testdir/test_statusline.vim
@@ -7,6 +7,7 @@
" %X
source view_util.vim
+source term_util.vim
func s:get_statusline()
return ScreenLines(&lines - 1, &columns)[0]
@@ -29,7 +30,9 @@ endfunc
" Function used to display syntax group.
func SyntaxItem()
- return synIDattr(synID(line("."),col("."),1),"name")
+ call assert_equal(s:expected_curbuf, g:actual_curbuf)
+ call assert_equal(s:expected_curwin, g:actual_curwin)
+ return synIDattr(synID(line("."), col("."),1), "name")
endfunc
func Test_caught_error_in_statusline()
@@ -218,6 +221,8 @@ func Test_statusline()
"%{: Evaluate expression between '%{' and '}' and substitute result.
syntax on
+ let s:expected_curbuf = string(bufnr(''))
+ let s:expected_curwin = string(win_getid())
set statusline=%{SyntaxItem()}
call assert_match('^vimNumber\s*$', s:get_statusline())
s/^/"/
@@ -332,6 +337,23 @@ func Test_statusline()
set statusline=%!2*3+1
call assert_match('7\s*$', s:get_statusline())
+ func GetNested()
+ call assert_equal(string(win_getid()), g:actual_curwin)
+ call assert_equal(string(bufnr('')), g:actual_curbuf)
+ return 'nested'
+ endfunc
+ func GetStatusLine()
+ call assert_equal(win_getid(), g:statusline_winid)
+ return 'the %{GetNested()} line'
+ endfunc
+ set statusline=%!GetStatusLine()
+ call assert_match('the nested line', s:get_statusline())
+ call assert_false(exists('g:actual_curwin'))
+ call assert_false(exists('g:actual_curbuf'))
+ call assert_false(exists('g:statusline_winid'))
+ delfunc GetNested
+ delfunc GetStatusLine
+
" Check statusline in current and non-current window
" with the 'fillchars' option.
set fillchars=stl:^,stlnc:=,vert:\|,fold:-,diff:-
@@ -347,3 +369,46 @@ func Test_statusline()
set laststatus&
set splitbelow&
endfunc
+
+func Test_statusline_visual()
+ func CallWordcount()
+ call wordcount()
+ endfunc
+ new x1
+ setl statusline=count=%{CallWordcount()}
+ " buffer must not be empty
+ call setline(1, 'hello')
+
+ " window with more lines than x1
+ new x2
+ call setline(1, range(10))
+ $
+ " Visual mode in line below liast line in x1 should not give ml_get error
+ call feedkeys("\<C-V>", "xt")
+ redraw
+
+ delfunc CallWordcount
+ bwipe! x1
+ bwipe! x2
+endfunc
+
+func Test_statusline_removed_group()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot make screendumps'
+ endif
+
+ let lines =<< trim END
+ scriptencoding utf-8
+ set laststatus=2
+ let &statusline = '%#StatColorHi2#%(✓%#StatColorHi2#%) Q≡'
+ END
+ call writefile(lines, 'XTest_statusline')
+
+ let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 10, 'cols': 50})
+ call term_wait(buf, 100)
+ call VerifyScreenDump(buf, 'Test_statusline_1', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XTest_statusline')
+endfunc
diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim
index b29b678129..ff07d8eceb 100644
--- a/src/nvim/testdir/test_substitute.vim
+++ b/src/nvim/testdir/test_substitute.vim
@@ -149,6 +149,7 @@ func Run_SubCmd_Tests(tests)
for t in a:tests
let start = line('.') + 1
let end = start + len(t[2]) - 1
+ " TODO: why is there a one second delay the first time we get here?
exe "normal o" . t[0]
call cursor(start, 1)
exe t[1]
@@ -240,7 +241,7 @@ func Test_sub_cmd_3()
call Run_SubCmd_Tests(tests)
endfunc
-" Test for submatch() on :substitue.
+" Test for submatch() on :substitute.
func Test_sub_cmd_4()
set magic&
set cpo&
@@ -612,6 +613,25 @@ func Test_sub_replace_10()
call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g'))
endfunc
+func SubReplacer(text, submatches)
+ return a:text .. a:submatches[0] .. a:text
+endfunc
+func SubReplacer20(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, submatches)
+ return a:t3 .. a:submatches[0] .. a:t11
+endfunc
+
+func Test_substitute_partial()
+ call assert_equal('1foo2foo3', substitute('123', '2', function('SubReplacer', ['foo']), 'g'))
+
+ " 19 arguments plus one is just OK
+ let Replacer = function('SubReplacer20', repeat(['foo'], 19))
+ call assert_equal('1foo2foo3', substitute('123', '2', Replacer, 'g'))
+
+ " 20 arguments plus one is too many
+ let Replacer = function('SubReplacer20', repeat(['foo'], 20))
+ call assert_fails("call substitute('123', '2', Replacer, 'g')", 'E118')
+endfunc
+
func Test_sub_cmd_9()
new
let input = ['1 aaa', '2 aaa', '3 aaa']
@@ -717,3 +737,12 @@ one two
close!
endfunc
+
+func Test_sub_beyond_end()
+ new
+ call setline(1, '#')
+ let @/ = '^#\n\zs'
+ s///e
+ call assert_equal('#', getline(1))
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_suspend.vim b/src/nvim/testdir/test_suspend.vim
index ef5a96bd72..4b3bd5eadf 100644
--- a/src/nvim/testdir/test_suspend.vim
+++ b/src/nvim/testdir/test_suspend.vim
@@ -1,6 +1,7 @@
" Test :suspend
source shared.vim
+source term_util.vim
func CheckSuspended(buf, fileExists)
call WaitForAssert({-> assert_match('[$#] $', term_getline(a:buf, '.'))})
@@ -55,7 +56,7 @@ func Test_suspend()
call term_wait(buf)
" Wait until Vim actually exited and shell shows a prompt
call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
- call Stop_shell_in_terminal(buf)
+ call StopShellInTerminal(buf)
exe buf . 'bwipe!'
call delete('Xfoo')
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim
index 11eb324488..e072e9ed7f 100644
--- a/src/nvim/testdir/test_swap.vim
+++ b/src/nvim/testdir/test_swap.vim
@@ -221,3 +221,87 @@ func Test_swapfile_delete()
augroup END
augroup! test_swapfile_delete
endfunc
+
+func Test_swap_recover()
+ autocmd! SwapExists
+ augroup test_swap_recover
+ autocmd!
+ autocmd SwapExists * let v:swapchoice = 'r'
+ augroup END
+
+
+ call mkdir('Xswap')
+ let $Xswap = 'foo' " Check for issue #4369.
+ set dir=Xswap//
+ " Create a valid swapfile by editing a file.
+ split Xswap/text
+ call setline(1, ['one', 'two', 'three'])
+ write " file is written, not modified
+ " read the swapfile as a Blob
+ let swapfile_name = swapname('%')
+ let swapfile_bytes = readfile(swapfile_name, 'B')
+
+ " Close the file and recreate the swap file.
+ quit
+ call writefile(swapfile_bytes, swapfile_name)
+ " Edit the file again. This triggers recovery.
+ try
+ split Xswap/text
+ catch
+ " E308 should be caught, not E305.
+ call assert_exception('E308:') " Original file may have been changed
+ endtry
+ " The file should be recovered.
+ call assert_equal(['one', 'two', 'three'], getline(1, 3))
+ quit!
+
+ call delete('Xswap/text')
+ call delete(swapfile_name)
+ call delete('Xswap', 'd')
+ unlet $Xswap
+ set dir&
+ augroup test_swap_recover
+ autocmd!
+ augroup END
+ augroup! test_swap_recover
+endfunc
+
+func Test_swap_recover_ext()
+ autocmd! SwapExists
+ augroup test_swap_recover_ext
+ autocmd!
+ autocmd SwapExists * let v:swapchoice = 'r'
+ augroup END
+
+
+ " Create a valid swapfile by editing a file with a special extension.
+ split Xtest.scr
+ call setline(1, ['one', 'two', 'three'])
+ write " file is written, not modified
+ write " write again to make sure the swapfile is created
+ " read the swapfile as a Blob
+ let swapfile_name = swapname('%')
+ let swapfile_bytes = readfile(swapfile_name, 'B')
+
+ " Close and delete the file and recreate the swap file.
+ quit
+ call delete('Xtest.scr')
+ call writefile(swapfile_bytes, swapfile_name)
+ " Edit the file again. This triggers recovery.
+ try
+ split Xtest.scr
+ catch
+ " E308 should be caught, not E306.
+ call assert_exception('E308:') " Original file may have been changed
+ endtry
+ " The file should be recovered.
+ call assert_equal(['one', 'two', 'three'], getline(1, 3))
+ quit!
+
+ call delete('Xtest.scr')
+ call delete(swapfile_name)
+ augroup test_swap_recover_ext
+ autocmd!
+ augroup END
+ augroup! test_swap_recover_ext
+endfunc
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 598a00476c..85ee42420e 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -1,6 +1,7 @@
" Test for syntax and syntax iskeyword option
source view_util.vim
+source screendump.vim
func GetSyntaxItem(pat)
let c = ''
@@ -152,7 +153,7 @@ endfunc
func Test_syntax_completion()
call feedkeys(":syn \<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_equal('"syn case clear cluster conceal enable include iskeyword keyword list manual match off on region reset spell sync', @:)
+ call assert_equal('"syn case clear cluster conceal enable foldlevel include iskeyword keyword list manual match off on region reset spell sync', @:)
call feedkeys(":syn case \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn case ignore match', @:)
@@ -501,9 +502,7 @@ func Test_syntax_c()
endif
call writefile([
\ '/* comment line at the top */',
- \ ' int',
- \ 'main(int argc, char **argv)// another comment',
- \ '{',
+ \ 'int main(int argc, char **argv) { // another comment',
\ '#if 0',
\ ' int not_used;',
\ '#else',
@@ -518,6 +517,7 @@ func Test_syntax_c()
\ ' for (int i = 0; i < count; ++i) {',
\ ' break;',
\ ' }',
+ \ " Note: asdf",
\ '}',
\ ], 'Xtest.c')
@@ -526,7 +526,8 @@ func Test_syntax_c()
let $COLORFGBG = '15;0'
let buf = RunVimInTerminal('Xtest.c', {})
- call VerifyScreenDump(buf, 'Test_syntax_c_01')
+ call term_sendkeys(buf, ":syn keyword Search Note\r")
+ call VerifyScreenDump(buf, 'Test_syntax_c_01', {})
call StopVimInTerminal(buf)
let $COLORFGBG = ''
@@ -578,3 +579,86 @@ func Test_syntax_hangs()
set redrawtime&
bwipe!
endfunc
+
+func Test_syntax_foldlevel()
+ new
+ call setline(1, [
+ \ 'void f(int a)',
+ \ '{',
+ \ ' if (a == 1) {',
+ \ ' a = 0;',
+ \ ' } else if (a == 2) {',
+ \ ' a = 1;',
+ \ ' } else {',
+ \ ' a = 2;',
+ \ ' }',
+ \ ' if (a > 0) {',
+ \ ' if (a == 1) {',
+ \ ' a = 0;',
+ \ ' } /* missing newline */ } /* end of outer if */ else {',
+ \ ' a = 1;',
+ \ ' }',
+ \ ' if (a == 1)',
+ \ ' {',
+ \ ' a = 0;',
+ \ ' }',
+ \ ' else if (a == 2)',
+ \ ' {',
+ \ ' a = 1;',
+ \ ' }',
+ \ ' else',
+ \ ' {',
+ \ ' a = 2;',
+ \ ' }',
+ \ '}',
+ \ ])
+ setfiletype c
+ syntax on
+ set foldmethod=syntax
+
+ call assert_fails('syn foldlevel start start', 'E390')
+ call assert_fails('syn foldlevel not_an_option', 'E390')
+
+ set foldlevel=1
+
+ syn foldlevel start
+ redir @c
+ syn foldlevel
+ redir END
+ call assert_equal("\nsyntax foldlevel start", @c)
+ syn sync fromstart
+ let a = map(range(3,9), 'foldclosed(v:val)')
+ call assert_equal([3,3,3,3,3,3,3], a) " attached cascade folds together
+ let a = map(range(10,15), 'foldclosed(v:val)')
+ call assert_equal([10,10,10,10,10,10], a) " over-attached 'else' hidden
+ let a = map(range(16,27), 'foldclosed(v:val)')
+ let unattached_results = [-1,17,17,17,-1,21,21,21,-1,25,25,25]
+ call assert_equal(unattached_results, a) " unattached cascade folds separately
+
+ syn foldlevel minimum
+ redir @c
+ syn foldlevel
+ redir END
+ call assert_equal("\nsyntax foldlevel minimum", @c)
+ syn sync fromstart
+ let a = map(range(3,9), 'foldclosed(v:val)')
+ call assert_equal([3,3,5,5,7,7,7], a) " attached cascade folds separately
+ let a = map(range(10,15), 'foldclosed(v:val)')
+ call assert_equal([10,10,10,13,13,13], a) " over-attached 'else' visible
+ let a = map(range(16,27), 'foldclosed(v:val)')
+ call assert_equal(unattached_results, a) " unattached cascade folds separately
+
+ set foldlevel=2
+
+ syn foldlevel start
+ syn sync fromstart
+ let a = map(range(11,14), 'foldclosed(v:val)')
+ call assert_equal([11,11,11,-1], a) " over-attached 'else' hidden
+
+ syn foldlevel minimum
+ syn sync fromstart
+ let a = map(range(11,14), 'foldclosed(v:val)')
+ call assert_equal([11,11,-1,-1], a) " over-attached 'else' visible
+
+ quit!
+endfunc
diff --git a/src/nvim/testdir/test_tabline.vim b/src/nvim/testdir/test_tabline.vim
index f24552088b..117d962d08 100644
--- a/src/nvim/testdir/test_tabline.vim
+++ b/src/nvim/testdir/test_tabline.vim
@@ -64,3 +64,28 @@ func Test_redrawtabline()
let &showtabline = showtabline_save
au! Bufadd
endfunc
+
+function EmptyTabname()
+ return ""
+endfunction
+
+function MakeTabLine() abort
+ let titles = map(range(1, tabpagenr('$')), '"%( %" . v:val . "T%{EmptyTabname()}%T %)"')
+ let sep = 'あ'
+ let tabpages = join(titles, sep)
+ return tabpages .. sep .. '%=%999X X'
+endfunction
+
+func Test_tabline_empty_group()
+ " this was reading invalid memory
+ set tabline=%!MakeTabLine()
+ tabnew
+ redraw!
+
+ tabclose
+ set tabline=
+endfunc
+
+
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim
index c35ddc4473..55dff3d476 100644
--- a/src/nvim/testdir/test_tabpage.vim
+++ b/src/nvim/testdir/test_tabpage.vim
@@ -1,6 +1,6 @@
" Tests for tabpage
-" source screendump.vim
+source screendump.vim
function Test_tabpage()
bw!
@@ -548,7 +548,7 @@ func Test_tabs()
norm ixxx
let a=split(execute(':tabs'), "\n")
call assert_equal(['Tab page 1',
- \ ' [No Name]',
+ \ '# [No Name]',
\ 'Tab page 2',
\ '> + tab1'], a)
diff --git a/src/nvim/testdir/test_tagfunc.vim b/src/nvim/testdir/test_tagfunc.vim
new file mode 100644
index 0000000000..242aa3a235
--- /dev/null
+++ b/src/nvim/testdir/test_tagfunc.vim
@@ -0,0 +1,84 @@
+" Test 'tagfunc'
+
+func TagFunc(pat, flag, info)
+ let g:tagfunc_args = [a:pat, a:flag, a:info]
+ let tags = []
+ for num in range(1,10)
+ let tags += [{
+ \ 'cmd': '2', 'name': 'nothing'.num, 'kind': 'm',
+ \ 'filename': 'Xfile1', 'user_data': 'somedata'.num,
+ \}]
+ endfor
+ return tags
+endfunc
+
+func Test_tagfunc()
+ set tagfunc=TagFunc
+ new Xfile1
+ call setline(1, ['empty', 'one()', 'empty'])
+ write
+
+ call assert_equal({'cmd': '2', 'static': 0,
+ \ 'name': 'nothing2', 'user_data': 'somedata2',
+ \ 'kind': 'm', 'filename': 'Xfile1'}, taglist('.')[1])
+
+ call settagstack(win_getid(), {'items': []})
+
+ tag arbitrary
+ call assert_equal('arbitrary', g:tagfunc_args[0])
+ call assert_equal('', g:tagfunc_args[1])
+ call assert_equal('somedata1', gettagstack().items[0].user_data)
+ 5tag arbitrary
+ call assert_equal('arbitrary', g:tagfunc_args[0])
+ call assert_equal('', g:tagfunc_args[1])
+ call assert_equal('somedata5', gettagstack().items[1].user_data)
+ pop
+ tag
+ call assert_equal('arbitrary', g:tagfunc_args[0])
+ call assert_equal('', g:tagfunc_args[1])
+ call assert_equal('somedata5', gettagstack().items[1].user_data)
+
+ let g:tagfunc_args=[]
+ execute "normal! \<c-]>"
+ call assert_equal('one', g:tagfunc_args[0])
+ call assert_equal('c', g:tagfunc_args[1])
+
+ set cpt=t
+ let g:tagfunc_args=[]
+ execute "normal! i\<c-n>\<c-y>"
+ call assert_equal('ci', g:tagfunc_args[1])
+ call assert_equal('nothing1', getline('.')[0:7])
+
+ func BadTagFunc1(...)
+ return 0
+ endfunc
+ func BadTagFunc2(...)
+ return [1]
+ endfunc
+ func BadTagFunc3(...)
+ return [{'name': 'foo'}]
+ endfunc
+
+ for &tagfunc in ['BadTagFunc1', 'BadTagFunc2', 'BadTagFunc3']
+ try
+ tag nothing
+ call assert_false(1, 'tag command should have failed')
+ catch
+ call assert_exception('E987:')
+ endtry
+ exe 'delf' &tagfunc
+ endfor
+
+ func NullTagFunc(...)
+ return v:null
+ endfunc
+ set tags= tfu=NullTagFunc
+ call assert_fails('tag nothing', 'E426')
+ delf NullTagFunc
+
+ bwipe!
+ set tags& tfu& cpt&
+ call delete('Xfile1')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim
index ce527a5e1d..6abe5b7c89 100644
--- a/src/nvim/testdir/test_tagjump.vim
+++ b/src/nvim/testdir/test_tagjump.vim
@@ -255,8 +255,52 @@ func Test_tagjump_etags()
ta foo
call assert_equal('void foo() {}', getline('.'))
+ " Test for including another tags file
+ call writefile([
+ \ "\x0c",
+ \ "Xmain.c,64",
+ \ "void foo() {}\x7ffoo\x011,0",
+ \ "\x0c",
+ \ "Xnonexisting,include",
+ \ "\x0c",
+ \ "Xtags2,include"
+ \ ], 'Xtags')
+ call writefile([
+ \ "\x0c",
+ \ "Xmain.c,64",
+ \ "int main(int argc, char **argv)\x7fmain\x012,14",
+ \ ], 'Xtags2')
+ tag main
+ call assert_equal(2, line('.'))
+
+ " corrupted tag line
+ call writefile([
+ \ "\x0c",
+ \ "Xmain.c,8",
+ \ "int main"
+ \ ], 'Xtags', 'b')
+ call assert_fails('tag foo', 'E426:')
+
+ " invalid line number
+ call writefile([
+ \ "\x0c",
+ \ "Xmain.c,64",
+ \ "void foo() {}\x7ffoo\x0abc,0",
+ \ ], 'Xtags')
+ call assert_fails('tag foo', 'E426:')
+
+ " invalid tag name
+ call writefile([
+ \ "\x0c",
+ \ "Xmain.c,64",
+ \ ";;;;\x7f1,0",
+ \ ], 'Xtags')
+ call assert_fails('tag foo', 'E426:')
+
call delete('Xtags')
+ call delete('Xtags2')
call delete('Xmain.c')
+ set tags&
bwipe!
endfunc
@@ -340,6 +384,28 @@ func Test_getsettagstack()
\ {'items' : [{'tagname' : 'abc', 'from' : [1, 10, 1, 0]}]}, 'a')
call assert_equal('abc', gettagstack().items[19].tagname)
+ " truncate the tag stack
+ call settagstack(1,
+ \ {'curidx' : 9,
+ \ 'items' : [{'tagname' : 'abc', 'from' : [1, 10, 1, 0]}]}, 't')
+ let t = gettagstack()
+ call assert_equal(9, t.length)
+ call assert_equal(10, t.curidx)
+
+ " truncate the tag stack without pushing any new items
+ call settagstack(1, {'curidx' : 5}, 't')
+ let t = gettagstack()
+ call assert_equal(4, t.length)
+ call assert_equal(5, t.curidx)
+
+ " truncate an empty tag stack and push new items
+ call settagstack(1, {'items' : []})
+ call settagstack(1,
+ \ {'items' : [{'tagname' : 'abc', 'from' : [1, 10, 1, 0]}]}, 't')
+ let t = gettagstack()
+ call assert_equal(1, t.length)
+ call assert_equal(2, t.curidx)
+
" Tag with multiple matches
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "two\tXfile1\t1",
@@ -449,7 +515,8 @@ func Test_tag_line_toolong()
call assert_report(v:exception)
catch /.*/
endtry
- call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1])
+ call assert_equal('Searching tags file Xtags', split(execute('messages'), '\n')[-1])
+
call writefile([
\ '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML'
\ ], 'Xtags')
@@ -460,10 +527,77 @@ func Test_tag_line_toolong()
call assert_report(v:exception)
catch /.*/
endtry
- call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1])
+ call assert_equal('Searching tags file Xtags', split(execute('messages'), '\n')[-1])
+
+ " binary search works in file with long line
+ call writefile([
+ \ 'asdfasfd nowhere 16',
+ \ 'foobar Xsomewhere 3; " 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567',
+ \ 'zasdfasfd nowhere 16',
+ \ ], 'Xtags')
+ call writefile([
+ \ 'one',
+ \ 'two',
+ \ 'trhee',
+ \ 'four',
+ \ ], 'Xsomewhere')
+ tag foobar
+ call assert_equal('Xsomewhere', expand('%'))
+ call assert_equal(3, getcurpos()[1])
+
call delete('Xtags')
+ call delete('Xsomewhere')
set tags&
let &verbose = old_vbs
endfunc
+func Test_tagline()
+ call writefile([
+ \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo',
+ \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:3 language:Python class:Bar',
+ \], 'Xtags')
+ call writefile([
+ \ ' def provision(self, **kwargs):',
+ \ ' pass',
+ \ ' def provision(self, **kwargs):',
+ \ ' pass',
+ \], 'Xtest.py')
+
+ set tags=Xtags
+
+ 1tag provision
+ call assert_equal(line('.'), 1)
+ 2tag provision
+ call assert_equal(line('.'), 3)
+
+ call delete('Xtags')
+ call delete('Xtest.py')
+ set tags&
+endfunc
+
+" Test for the 'taglength' option
+func Test_tag_length()
+ set tags=Xtags
+ call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
+ \ "tame\tXfile1\t1;",
+ \ "tape\tXfile2\t1;"], 'Xtags')
+ call writefile(['tame'], 'Xfile1')
+ call writefile(['tape'], 'Xfile2')
+
+ " Jumping to the tag 'tape', should instead jump to 'tame'
+ new
+ set taglength=2
+ tag tape
+ call assert_equal('Xfile1', @%)
+ " Tag search should jump to the right tag
+ enew
+ tag /^tape$
+ call assert_equal('Xfile2', @%)
+
+ call delete('Xtags')
+ call delete('Xfile1')
+ call delete('Xfile2')
+ set tags& taglength&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim
index cb54ace695..d4ff42fd68 100644
--- a/src/nvim/testdir/test_taglist.vim
+++ b/src/nvim/testdir/test_taglist.vim
@@ -7,6 +7,7 @@ func Test_taglist()
\ "BFoo\tXbar\t1",
\ "BBar\tXbar\t2",
\ "Kindly\tXbar\t3;\"\tv\tfile:",
+ \ "Lambda\tXbar\t3;\"\tλ\tfile:",
\ "Command\tXbar\tcall cursor(3, 4)|;\"\td",
\ ], 'Xtags')
set tags=Xtags
@@ -17,12 +18,16 @@ func Test_taglist()
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
- let kind = taglist("Kindly")
- call assert_equal(1, len(kind))
- call assert_equal('v', kind[0]['kind'])
- call assert_equal('3', kind[0]['cmd'])
- call assert_equal(1, kind[0]['static'])
- call assert_equal('Xbar', kind[0]['filename'])
+ let kindly = taglist("Kindly")
+ call assert_equal(1, len(kindly))
+ call assert_equal('v', kindly[0]['kind'])
+ call assert_equal('3', kindly[0]['cmd'])
+ call assert_equal(1, kindly[0]['static'])
+ call assert_equal('Xbar', kindly[0]['filename'])
+
+ let lambda = taglist("Lambda")
+ call assert_equal(1, len(lambda))
+ call assert_equal('λ', lambda[0]['kind'])
let cmd = taglist("Command")
call assert_equal(1, len(cmd))
diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim
index 13fb50b985..75673adf0a 100644
--- a/src/nvim/testdir/test_textformat.vim
+++ b/src/nvim/testdir/test_textformat.vim
@@ -489,3 +489,426 @@ func Test_format_list_auto()
bwipe!
set fo& ai& bs&
endfunc
+
+" Test for formatting multi-byte text with 'fo=t'
+func Test_tw_2_fo_t()
+ new
+ let t =<< trim END
+ {
+ XYZ
+ abc XYZ
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set tw=2 fo=t
+ let t =<< trim END
+ XYZ
+ abc XYZ
+ END
+ exe "normal gqgqjgqgq"
+ exe "normal o\n" . join(t, "\n")
+
+ let expected =<< trim END
+ {
+ XYZ
+ abc
+ XYZ
+
+ XYZ
+ abc
+ XYZ
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo&
+ bwipe!
+endfunc
+
+" Test for formatting multi-byte text with 'fo=tm' and 'tw=1'
+func Test_tw_1_fo_tm()
+ new
+ let t =<< trim END
+ {
+ X
+ Xa
+ X a
+ XY
+ X Y
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set tw=1 fo=tm
+ let t =<< trim END
+ X
+ Xa
+ X a
+ XY
+ X Y
+ END
+ exe "normal gqgqjgqgqjgqgqjgqgqjgqgq"
+ exe "normal o\n" . join(t, "\n")
+
+ let expected =<< trim END
+ {
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo&
+ bwipe!
+endfunc
+
+" Test for formatting multi-byte text with 'fo=tm' and 'tw=2'
+func Test_tw_2_fo_tm()
+ new
+ let t =<< trim END
+ {
+ X
+ Xa
+ X a
+ XY
+ X Y
+ aX
+ abX
+ abcX
+ abX c
+ abXY
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set tw=2 fo=tm
+ let t =<< trim END
+ X
+ Xa
+ X a
+ XY
+ X Y
+ aX
+ abX
+ abcX
+ abX c
+ abXY
+ END
+ exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
+ exe "normal o\n" . join(t, "\n")
+
+ let expected =<< trim END
+ {
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ a
+ X
+ ab
+ X
+ abc
+ X
+ ab
+ X
+ c
+ ab
+ X
+ Y
+
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ a
+ X
+ ab
+ X
+ abc
+ X
+ ab
+ X
+ c
+ ab
+ X
+ Y
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo&
+ bwipe!
+endfunc
+
+" Test for formatting multi-byte text with 'fo=tm', 'tw=2' and 'autoindent'.
+func Test_tw_2_fo_tm_ai()
+ new
+ let t =<< trim END
+ {
+ X
+ Xa
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set ai tw=2 fo=tm
+ let t =<< trim END
+ X
+ Xa
+ END
+ exe "normal gqgqjgqgq"
+ exe "normal o\n" . join(t, "\n")
+
+ let expected =<< trim END
+ {
+ X
+ X
+ a
+
+ X
+ X
+ a
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo& ai&
+ bwipe!
+endfunc
+
+" Test for formatting multi-byte text with 'fo=tm', 'tw=2' and 'noai'.
+func Test_tw_2_fo_tm_noai()
+ new
+ let t =<< trim END
+ {
+ X
+ Xa
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set noai tw=2 fo=tm
+ exe "normal gqgqjgqgqo\n X\n Xa"
+
+ let expected =<< trim END
+ {
+ X
+ X
+ a
+
+ X
+ X
+ a
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo& ai&
+ bwipe!
+endfunc
+
+func Test_tw_2_fo_cqm_com()
+ new
+ let t =<< trim END
+ {
+ X
+ Xa
+ XaY
+ XY
+ XYZ
+ X Y
+ X YZ
+ XX
+ XXa
+ XXY
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set tw=2 fo=cqm comments=n:X
+ exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
+ let t =<< trim END
+ X
+ Xa
+ XaY
+ XY
+ XYZ
+ X Y
+ X YZ
+ XX
+ XXa
+ XXY
+ END
+ exe "normal o\n" . join(t, "\n")
+
+ let expected =<< trim END
+ {
+ X
+ Xa
+ Xa
+ XY
+ XY
+ XY
+ XZ
+ X Y
+ X Y
+ X Z
+ XX
+ XXa
+ XXY
+
+ X
+ Xa
+ Xa
+ XY
+ XY
+ XY
+ XZ
+ X Y
+ X Y
+ X Z
+ XX
+ XXa
+ XXY
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo& comments&
+ bwipe!
+endfunc
+
+func Test_tw_2_fo_tm_replace()
+ new
+ let t =<< trim END
+ {
+
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set tw=2 fo=tm
+ exe "normal RXa"
+
+ let expected =<< trim END
+ {
+ X
+ a
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set tw& fo&
+ bwipe!
+endfunc
+
+" Test for 'matchpairs' with multibyte chars
+func Test_mps()
+ new
+ let t =<< trim END
+ {
+ ‘ two three ’ four
+ }
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ exe "set mps+=\u2018:\u2019"
+ normal d%
+
+ let expected =<< trim END
+ {
+ four
+ }
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ set mps&
+ bwipe!
+endfunc
+
+" Test for ra on multi-byte characters
+func Test_ra_multibyte()
+ new
+ let t =<< trim END
+ ra test
+ abba
+ aab
+ END
+ call setline(1, t)
+ call cursor(1, 1)
+
+ normal jVjra
+
+ let expected =<< trim END
+ ra test
+ aaaa
+ aaa
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ bwipe!
+endfunc
+
+" Test for 'whichwrap' with multi-byte character
+func Test_whichwrap_multi_byte()
+ new
+ let t =<< trim END
+ á
+ x
+ END
+ call setline(1, t)
+ call cursor(2, 1)
+
+ set whichwrap+=h
+ normal dh
+ set whichwrap&
+
+ let expected =<< trim END
+ áx
+ END
+ call assert_equal(expected, getline(1, '$'))
+
+ bwipe!
+endfunc
+
+func Test_substitute()
+ call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g'))
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_textobjects.vim b/src/nvim/testdir/test_textobjects.vim
index 9194e0014d..7863317eb0 100644
--- a/src/nvim/testdir/test_textobjects.vim
+++ b/src/nvim/testdir/test_textobjects.vim
@@ -46,8 +46,18 @@ func Test_quote_selection_selection_exclusive()
new
call setline(1, "a 'bcde' f")
set selection=exclusive
+
exe "norm! fdvhi'y"
call assert_equal('bcde', @")
+
+ let @"='dummy'
+ exe "norm! $gevi'y"
+ call assert_equal('bcde', @")
+
+ let @"='dummy'
+ exe "norm! 0fbhvi'y"
+ call assert_equal('bcde', @")
+
set selection&vim
bw!
endfunc
@@ -280,5 +290,16 @@ func! Test_sentence_with_cursor_on_delimiter()
normal! 17|yas
call assert_equal("A '([sentence.])' ", @")
+ " don't get stuck on a quote at the start of a sentence
+ %delete _
+ call setline(1, ['A sentence.', '"A sentence"?', 'A sentence!'])
+ normal gg))
+ call assert_equal(3, getcurpos()[1])
+
+ %delete _
+ call setline(1, ['A sentence.', "'A sentence'?", 'A sentence!'])
+ normal gg))
+ call assert_equal(3, getcurpos()[1])
+
%delete _
endfunc
diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim
index 24c735865c..cffd80ff4f 100644
--- a/src/nvim/testdir/test_timers.vim
+++ b/src/nvim/testdir/test_timers.vim
@@ -5,6 +5,7 @@ if !has('timers')
endif
source shared.vim
+source term_util.vim
source load.vim
func MyHandler(timer)
@@ -141,7 +142,7 @@ endfunc
func Test_delete_myself()
let g:called = 0
let t = timer_start(10, 'StopMyself', {'repeat': -1})
- call WaitFor('g:called == 2')
+ call WaitForAssert({-> assert_equal(2, g:called)})
call assert_equal(2, g:called)
call assert_equal([], timer_info(t))
endfunc
@@ -208,7 +209,7 @@ func Test_timer_errors()
let g:call_count = 0
let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
" Timer will be stopped after failing 3 out of 3 times.
- call WaitFor('g:call_count == 3')
+ call WaitForAssert({-> assert_equal(3, g:call_count)})
sleep 50m
call assert_equal(3, g:call_count)
endfunc
@@ -226,7 +227,7 @@ func Test_timer_catch_error()
let g:call_count = 0
let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4})
" Timer will not be stopped.
- call WaitFor('g:call_count == 4')
+ call WaitForAssert({-> assert_equal(4, g:call_count)})
sleep 50m
call assert_equal(4, g:call_count)
endfunc
@@ -252,4 +253,94 @@ func Test_peek_and_get_char()
call timer_stop(intr)
endfunc
+func Test_getchar_zero()
+ if has('win32') && !has('gui_running')
+ " Console: no low-level input
+ return
+ endif
+
+ " Measure the elapsed time to avoid a hang when it fails.
+ let start = reltime()
+ let id = timer_start(20, {-> feedkeys('x', 'L')})
+ let c = 0
+ while c == 0 && reltimefloat(reltime(start)) < 0.2
+ let c = getchar(0)
+ sleep 10m
+ endwhile
+ call assert_equal('x', nr2char(c))
+ call timer_stop(id)
+endfunc
+
+func Test_ex_mode()
+ " Function with an empty line.
+ func Foo(...)
+
+ endfunc
+ let timer = timer_start(40, function('g:Foo'), {'repeat':-1})
+ " This used to throw error E749.
+ exe "normal Qsleep 100m\rvi\r"
+ call timer_stop(timer)
+endfunc
+
+func Test_restore_count()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ " Check that v:count is saved and restored, not changed by a timer.
+ call writefile([
+ \ 'nnoremap <expr><silent> L v:count ? v:count . "l" : "l"',
+ \ 'func Doit(id)',
+ \ ' normal 3j',
+ \ 'endfunc',
+ \ 'call timer_start(100, "Doit")',
+ \ ], 'Xtrcscript')
+ call writefile([
+ \ '1-1234',
+ \ '2-1234',
+ \ '3-1234',
+ \ ], 'Xtrctext')
+ let buf = RunVimInTerminal('-S Xtrcscript Xtrctext', {})
+
+ " Wait for the timer to move the cursor to the third line.
+ call WaitForAssert({-> assert_equal(3, term_getcursor(buf)[0])})
+ call assert_equal(1, term_getcursor(buf)[1])
+ " Now check that v:count has not been set to 3
+ call term_sendkeys(buf, 'L')
+ call WaitForAssert({-> assert_equal(2, term_getcursor(buf)[1])})
+
+ call StopVimInTerminal(buf)
+ call delete('Xtrcscript')
+ call delete('Xtrctext')
+endfunc
+
+" Test that the garbage collector isn't triggered if a timer callback invokes
+" vgetc().
+func Test_nocatch_garbage_collect()
+ " skipped: Nvim does not support test_garbagecollect_soon(), test_override()
+ return
+ " 'uptimetime. must be bigger than the timer timeout
+ set ut=200
+ call test_garbagecollect_soon()
+ call test_override('no_wait_return', 0)
+ func CauseAnError(id)
+ " This will show an error and wait for Enter.
+ let a = {'foo', 'bar'}
+ endfunc
+ func FeedChar(id)
+ call feedkeys('x', 't')
+ endfunc
+ call timer_start(300, 'FeedChar')
+ call timer_start(100, 'CauseAnError')
+ let x = getchar()
+
+ set ut&
+ call test_override('no_wait_return', 1)
+ delfunc CauseAnError
+ delfunc FeedChar
+endfunc
+
+func Test_timer_invalid_callback()
+ call assert_fails('call timer_start(0, "0")', 'E921')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim
index 86674889ef..adcdcb1cd9 100644
--- a/src/nvim/testdir/test_undo.vim
+++ b/src/nvim/testdir/test_undo.vim
@@ -238,7 +238,37 @@ func Test_undojoin()
call assert_equal(['aaaa', 'bbbb', 'cccc'], getline(2, '$'))
call feedkeys("u", 'xt')
call assert_equal(['aaaa'], getline(2, '$'))
- close!
+ bwipe!
+endfunc
+
+func Test_undojoin_redo()
+ new
+ call setline(1, ['first line', 'second line'])
+ call feedkeys("ixx\<Esc>", 'xt')
+ call feedkeys(":undojoin | redo\<CR>", 'xt')
+ call assert_equal('xxfirst line', getline(1))
+ call assert_equal('second line', getline(2))
+ bwipe!
+endfunc
+
+" undojoin not allowed after undo
+func Test_undojoin_after_undo()
+ new
+ call feedkeys("ixx\<Esc>u", 'xt')
+ call assert_fails(':undojoin', 'E790:')
+ bwipe!
+endfunc
+
+" undojoin is a noop when no change yet, or when 'undolevels' is negative
+func Test_undojoin_noop()
+ new
+ call feedkeys(":undojoin\<CR>", 'xt')
+ call assert_equal([''], getline(1, '$'))
+ setlocal undolevels=-1
+ call feedkeys("ixx\<Esc>u", 'xt')
+ call feedkeys(":undojoin\<CR>", 'xt')
+ call assert_equal(['xx'], getline(1, '$'))
+ bwipe!
endfunc
func Test_undo_write()
@@ -327,6 +357,22 @@ func Test_undofile_earlier()
call delete('Xundofile')
endfunc
+func Test_wundo_errors()
+ new
+ call setline(1, 'hello')
+ call assert_fails('wundo! Xdoesnotexist/Xundofile', 'E828:')
+ bwipe!
+endfunc
+
+func Test_rundo_errors()
+ call assert_fails('rundo XfileDoesNotExist', 'E822:')
+
+ call writefile(['abc'], 'Xundofile')
+ call assert_fails('rundo Xundofile', 'E823:')
+
+ call delete('Xundofile')
+endfunc
+
" Test for undo working properly when executing commands from a register.
" Also test this in an empty buffer.
func Test_cmd_in_reg_undo()
@@ -343,6 +389,24 @@ func Test_cmd_in_reg_undo()
let @a = ''
endfunc
+" undo or redo are noop if there is nothing to undo or redo
+func Test_undo_redo_noop()
+ new
+ call assert_fails('undo 2', 'E830:')
+
+ message clear
+ undo
+ let messages = split(execute('message'), "\n")
+ call assert_equal('Already at oldest change', messages[-1])
+
+ message clear
+ redo
+ let messages = split(execute('message'), "\n")
+ call assert_equal('Already at newest change', messages[-1])
+
+ bwipe!
+endfunc
+
func Test_redo_empty_line()
new
exe "norm\x16r\x160"
@@ -443,3 +507,190 @@ func Test_undo_0()
bwipe!
endfunc
+
+" Tests for the undo file
+" Explicitly break changes up in undo-able pieces by setting 'undolevels'.
+func Test_undofile_2()
+ set undolevels=100 undofile
+ edit Xtestfile
+ call append(0, 'this is one line')
+ call cursor(1, 1)
+
+ " first a simple one-line change.
+ set undolevels=100
+ s/one/ONE/
+ set undolevels=100
+ write
+ bwipe!
+ edit Xtestfile
+ undo
+ call assert_equal('this is one line', getline(1))
+
+ " change in original file fails check
+ set noundofile
+ edit! Xtestfile
+ s/line/Line/
+ write
+ set undofile
+ bwipe!
+ edit Xtestfile
+ undo
+ call assert_equal('this is ONE Line', getline(1))
+
+ " add 10 lines, delete 6 lines, undo 3
+ set undofile
+ call setbufline(0, 1, ['one', 'two', 'three', 'four', 'five', 'six',
+ \ 'seven', 'eight', 'nine', 'ten'])
+ set undolevels=100
+ normal 3Gdd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ write
+ bwipe!
+ edit Xtestfile
+ normal uuu
+ call assert_equal(['one', 'two', 'six', 'seven', 'eight', 'nine', 'ten'],
+ \ getline(1, '$'))
+
+ " Test that reading the undofiles when setting undofile works
+ set noundofile undolevels=0
+ exe "normal i\n"
+ undo
+ edit! Xtestfile
+ set undofile undolevels=100
+ normal uuuuuu
+ call assert_equal(['one', 'two', 'three', 'four', 'five', 'six', 'seven',
+ \ 'eight', 'nine', 'ten'], getline(1, '$'))
+
+ bwipe!
+ call delete('Xtestfile')
+ let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
+ call delete(ufile)
+ set undofile& undolevels&
+endfunc
+
+" Test 'undofile' using a file encrypted with 'zip' crypt method
+func Test_undofile_cryptmethod_zip()
+ throw 'skipped: Nvim does not support cryptmethod'
+ edit Xtestfile
+ set undofile cryptmethod=zip
+ call append(0, ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
+ call cursor(5, 1)
+
+ set undolevels=100
+ normal kkkdd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ " encrypt the file using key 'foobar'
+ call feedkeys("foobar\nfoobar\n")
+ X
+ write!
+ bwipe!
+
+ call feedkeys("foobar\n")
+ edit Xtestfile
+ set key=
+ normal uu
+ call assert_equal(['monday', 'wednesday', 'thursday', 'friday', ''],
+ \ getline(1, '$'))
+
+ bwipe!
+ call delete('Xtestfile')
+ let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
+ call delete(ufile)
+ set undofile& undolevels& cryptmethod&
+endfunc
+
+" Test 'undofile' using a file encrypted with 'blowfish' crypt method
+func Test_undofile_cryptmethod_blowfish()
+ throw 'skipped: Nvim does not support cryptmethod'
+ edit Xtestfile
+ set undofile cryptmethod=blowfish
+ call append(0, ['jan', 'feb', 'mar', 'apr', 'jun'])
+ call cursor(5, 1)
+
+ set undolevels=100
+ exe 'normal kk0ifoo '
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ exe 'normal ibar '
+ set undolevels=100
+ " encrypt the file using key 'foobar'
+ call feedkeys("foobar\nfoobar\n")
+ X
+ write!
+ bwipe!
+
+ call feedkeys("foobar\n")
+ edit Xtestfile
+ set key=
+ call search('bar')
+ call assert_equal('bar apr', getline('.'))
+ undo
+ call assert_equal('apr', getline('.'))
+ undo
+ call assert_equal('foo mar', getline('.'))
+ undo
+ call assert_equal('mar', getline('.'))
+
+ bwipe!
+ call delete('Xtestfile')
+ let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
+ call delete(ufile)
+ set undofile& undolevels& cryptmethod&
+endfunc
+
+" Test 'undofile' using a file encrypted with 'blowfish2' crypt method
+func Test_undofile_cryptmethod_blowfish2()
+ throw 'skipped: Nvim does not support cryptmethod'
+ edit Xtestfile
+ set undofile cryptmethod=blowfish2
+ call append(0, ['jan', 'feb', 'mar', 'apr', 'jun'])
+ call cursor(5, 1)
+
+ set undolevels=100
+ exe 'normal kk0ifoo '
+ set undolevels=100
+ normal dd
+ set undolevels=100
+ exe 'normal ibar '
+ set undolevels=100
+ " encrypt the file using key 'foo2bar'
+ call feedkeys("foo2bar\nfoo2bar\n")
+ X
+ write!
+ bwipe!
+
+ call feedkeys("foo2bar\n")
+ edit Xtestfile
+ set key=
+ call search('bar')
+ call assert_equal('bar apr', getline('.'))
+ normal u
+ call assert_equal('apr', getline('.'))
+ normal u
+ call assert_equal('foo mar', getline('.'))
+ normal u
+ call assert_equal('mar', getline('.'))
+
+ bwipe!
+ call delete('Xtestfile')
+ let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
+ call delete(ufile)
+ set undofile& undolevels& cryptmethod&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_user_func.vim b/src/nvim/testdir/test_user_func.vim
index e7a3701386..67701ee3ca 100644
--- a/src/nvim/testdir/test_user_func.vim
+++ b/src/nvim/testdir/test_user_func.vim
@@ -94,3 +94,7 @@ func Test_user_func()
unlet g:retval g:counter
enew!
endfunc
+
+func Test_failed_call_in_try()
+ try | call UnknownFunc() | catch | endtry
+endfunc
diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim
index b1f33f56dd..1b4ce4c4af 100644
--- a/src/nvim/testdir/test_utf8.vim
+++ b/src/nvim/testdir/test_utf8.vim
@@ -60,3 +60,46 @@ func Test_getvcol()
call assert_equal(2, virtcol("'["))
call assert_equal(2, virtcol("']"))
endfunc
+
+func Test_list2str_str2list_utf8()
+ " One Unicode codepoint
+ let s = "\u3042\u3044"
+ let l = [0x3042, 0x3044]
+ call assert_equal(l, str2list(s, 1))
+ call assert_equal(s, list2str(l, 1))
+ if &enc ==# 'utf-8'
+ call assert_equal(str2list(s), str2list(s, 1))
+ call assert_equal(list2str(l), list2str(l, 1))
+ endif
+
+ " With composing characters
+ let s = "\u304b\u3099\u3044"
+ let l = [0x304b, 0x3099, 0x3044]
+ call assert_equal(l, str2list(s, 1))
+ call assert_equal(s, list2str(l, 1))
+ if &enc ==# 'utf-8'
+ call assert_equal(str2list(s), str2list(s, 1))
+ call assert_equal(list2str(l), list2str(l, 1))
+ endif
+
+ " Null list is the same as an empty list
+ call assert_equal('', list2str([]))
+ " call assert_equal('', list2str(test_null_list()))
+endfunc
+
+func Test_list2str_str2list_latin1()
+ " When 'encoding' is not multi-byte can still get utf-8 string.
+ " But we need to create the utf-8 string while 'encoding' is utf-8.
+ let s = "\u3042\u3044"
+ let l = [0x3042, 0x3044]
+
+ let save_encoding = &encoding
+ " set encoding=latin1
+
+ let lres = str2list(s, 1)
+ let sres = list2str(l, 1)
+
+ let &encoding = save_encoding
+ call assert_equal(l, lres)
+ call assert_equal(s, sres)
+endfunc
diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim
index f39e53d6dd..d2f13ff072 100644
--- a/src/nvim/testdir/test_vimscript.vim
+++ b/src/nvim/testdir/test_vimscript.vim
@@ -1284,7 +1284,7 @@ func s:DoNothing()
endfunc
func Test_script_local_func()
- set nocp viminfo+=nviminfo
+ set nocp nomore viminfo+=nviminfo
new
nnoremap <buffer> _x :call <SID>DoNothing()<bar>call <SID>DoLast()<bar>delfunc <SID>DoNothing<bar>delfunc <SID>DoLast<cr>
@@ -1409,6 +1409,76 @@ func Test_compound_assignment_operators()
let @/ = ''
endfunc
+func Test_function_defined_line()
+ if has('gui_running')
+ " Can't catch the output of gvim.
+ return
+ endif
+
+ let lines =<< trim [CODE]
+ " F1
+ func F1()
+ " F2
+ func F2()
+ "
+ "
+ "
+ return
+ endfunc
+ " F3
+ execute "func F3()\n\n\n\nreturn\nendfunc"
+ " F4
+ execute "func F4()\n
+ \\n
+ \\n
+ \\n
+ \return\n
+ \endfunc"
+ endfunc
+ " F5
+ execute "func F5()\n\n\n\nreturn\nendfunc"
+ " F6
+ execute "func F6()\n
+ \\n
+ \\n
+ \\n
+ \return\n
+ \endfunc"
+ call F1()
+ verbose func F1
+ verbose func F2
+ verbose func F3
+ verbose func F4
+ verbose func F5
+ verbose func F6
+ qall!
+ [CODE]
+
+ call writefile(lines, 'Xtest.vim')
+ let res = system(v:progpath .. ' --clean -es -X -S Xtest.vim')
+ call assert_equal(0, v:shell_error)
+
+ let m = matchstr(res, 'function F1()[^[:print:]]*[[:print:]]*')
+ call assert_match(' line 2$', m)
+
+ let m = matchstr(res, 'function F2()[^[:print:]]*[[:print:]]*')
+ call assert_match(' line 4$', m)
+
+ let m = matchstr(res, 'function F3()[^[:print:]]*[[:print:]]*')
+ call assert_match(' line 11$', m)
+
+ let m = matchstr(res, 'function F4()[^[:print:]]*[[:print:]]*')
+ call assert_match(' line 13$', m)
+
+ let m = matchstr(res, 'function F5()[^[:print:]]*[[:print:]]*')
+ call assert_match(' line 21$', m)
+
+ let m = matchstr(res, 'function F6()[^[:print:]]*[[:print:]]*')
+ call assert_match(' line 23$', m)
+
+ call delete('Xtest.vim')
+endfunc
+
"-------------------------------------------------------------------------------
" Modelines {{{1
" vim: ts=8 sw=4 tw=80 fdm=marker
diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim
index 67adede8d7..8f992f7501 100644
--- a/src/nvim/testdir/test_virtualedit.vim
+++ b/src/nvim/testdir/test_virtualedit.vim
@@ -73,3 +73,147 @@ func Test_edit_CTRL_G()
bwipe!
set virtualedit=
endfunc
+
+func Test_edit_change()
+ new
+ set virtualedit=all
+ call setline(1, "\t⒌")
+ normal Cx
+ call assert_equal('x', getline(1))
+ bwipe!
+endfunc
+
+" Insert "keyword keyw", ESC, C CTRL-N, shows "keyword ykeyword".
+" Repeating CTRL-N fixes it. (Mary Ellen Foster)
+func Test_ve_completion()
+ new
+ set completeopt&vim
+ set virtualedit=all
+ exe "normal ikeyword keyw\<Esc>C\<C-N>"
+ call assert_equal('keyword keyword', getline(1))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Using "C" then then <CR> moves the last remaining character to the next
+" line. (Mary Ellen Foster)
+func Test_ve_del_to_eol()
+ new
+ set virtualedit=all
+ call append(0, 'all your base are belong to us')
+ call search('are', 'w')
+ exe "normal C\<CR>are belong to vim"
+ call assert_equal(['all your base ', 'are belong to vim'], getline(1, 2))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" When past the end of a line that ends in a single character "b" skips
+" that word.
+func Test_ve_b_past_eol()
+ new
+ set virtualedit=all
+ call append(0, '1 2 3 4 5 6')
+ normal gg^$15lbC7
+ call assert_equal('1 2 3 4 5 7', getline(1))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Make sure 'i', 'C', 'a', 'A' and 'D' works
+func Test_ve_ins_del()
+ new
+ set virtualedit=all
+ call append(0, ["'i'", "'C'", "'a'", "'A'", "'D'"])
+ call cursor(1, 1)
+ normal $4lix
+ call assert_equal("'i' x", getline(1))
+ call cursor(2, 1)
+ normal $4lCx
+ call assert_equal("'C' x", getline(2))
+ call cursor(3, 1)
+ normal $4lax
+ call assert_equal("'a' x", getline(3))
+ call cursor(4, 1)
+ normal $4lAx
+ call assert_equal("'A'x", getline(4))
+ call cursor(5, 1)
+ normal $4lDix
+ call assert_equal("'D' x", getline(5))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Test for yank bug reported by Mark Waggoner.
+func Test_yank_block()
+ new
+ set virtualedit=block
+ call append(0, repeat(['this is a test'], 3))
+ exe "normal gg^2w\<C-V>3jy"
+ call assert_equal("a\na\na\n ", @")
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Test "r" beyond the end of the line
+func Test_replace_after_eol()
+ new
+ set virtualedit=all
+ call append(0, '"r"')
+ normal gg$5lrxa
+ call assert_equal('"r" x', getline(1))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Test "r" on a tab
+" Note that for this test, 'ts' must be 8 (the default).
+func Test_replace_on_tab()
+ new
+ set virtualedit=all
+ call append(0, "'r'\t")
+ normal gg^5lrxAy
+ call assert_equal("'r' x y", getline(1))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Test to make sure 'x' can delete control characters
+func Test_ve_del_ctrl_chars()
+ new
+ set virtualedit=all
+ call append(0, "a\<C-V>b\<CR>sd")
+ set display=uhex
+ normal gg^xxxxxxi[text]
+ set display=
+ call assert_equal('[text]', getline(1))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Test for ^Y/^E due to bad w_virtcol value, reported by
+" Roy <royl@netropolis.net>.
+func Test_ins_copy_char()
+ new
+ set virtualedit=all
+ call append(0, 'abcv8efi.him2kl')
+ exe "normal gg^O\<Esc>3li\<C-E>\<Esc>4li\<C-E>\<Esc>4li\<C-E> <--"
+ exe "normal j^o\<Esc>4li\<C-Y>\<Esc>4li\<C-Y>\<Esc>4li\<C-Y> <--"
+ call assert_equal(' v i m <--', getline(1))
+ call assert_equal(' 8 . 2 <--', getline(3))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" Test for yanking and pasting using the small delete register
+func Test_yank_paste_small_del_reg()
+ new
+ set virtualedit=all
+ call append(0, "foo, bar")
+ normal ggdewve"-p
+ call assert_equal(', foo', getline(1))
+ bwipe!
+ set virtualedit=
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim
index c87c0a0af4..aaa291f87d 100644
--- a/src/nvim/testdir/test_window_cmd.vim
+++ b/src/nvim/testdir/test_window_cmd.vim
@@ -69,18 +69,6 @@ function Test_window_cmd_wincmd_gf()
augroup! test_window_cmd_wincmd_gf
endfunc
-func Test_next_split_all()
- " This was causing an illegal memory access.
- n x
- norm axxx
- split
- split
- s/x
- s/x
- all
- bwipe!
-endfunc
-
func Test_window_quit()
e Xa
split Xb
@@ -117,15 +105,71 @@ func Test_window_vertical_split()
bw
endfunc
+" Test the ":wincmd ^" and "<C-W>^" commands.
func Test_window_split_edit_alternate()
- e Xa
- e Xb
+ " Test for failure when the alternate buffer/file no longer exists.
+ edit Xfoo | %bw
+ call assert_fails(':wincmd ^', 'E23')
+
+ " Test for the expected behavior when we have two named buffers.
+ edit Xfoo | edit Xbar
wincmd ^
- call assert_equal('Xa', bufname(winbufnr(1)))
- call assert_equal('Xb', bufname(winbufnr(2)))
+ call assert_equal('Xfoo', bufname(winbufnr(1)))
+ call assert_equal('Xbar', bufname(winbufnr(2)))
+ only
- bw Xa Xb
+ " Test for the expected behavior when the alternate buffer is not named.
+ enew | let l:nr1 = bufnr('%')
+ edit Xfoo | let l:nr2 = bufnr('%')
+ wincmd ^
+ call assert_equal(l:nr1, winbufnr(1))
+ call assert_equal(l:nr2, winbufnr(2))
+ only
+
+ " FIXME: this currently fails on AppVeyor, but passes locally
+ if !has('win32')
+ " Test the Normal mode command.
+ call feedkeys("\<C-W>\<C-^>", 'tx')
+ call assert_equal(l:nr2, winbufnr(1))
+ call assert_equal(l:nr1, winbufnr(2))
+ endif
+
+ %bw!
+endfunc
+
+" Test the ":[count]wincmd ^" and "[count]<C-W>^" commands.
+func Test_window_split_edit_bufnr()
+
+ %bwipeout
+ let l:nr = bufnr('%') + 1
+ call assert_fails(':execute "normal! ' . l:nr . '\<C-W>\<C-^>"', 'E92')
+ call assert_fails(':' . l:nr . 'wincmd ^', 'E16')
+ call assert_fails(':0wincmd ^', 'E16')
+
+ edit Xfoo | edit Xbar | edit Xbaz
+ let l:foo_nr = bufnr('Xfoo')
+ let l:bar_nr = bufnr('Xbar')
+ let l:baz_nr = bufnr('Xbaz')
+
+ " FIXME: this currently fails on AppVeyor, but passes locally
+ if !has('win32')
+ call feedkeys(l:foo_nr . "\<C-W>\<C-^>", 'tx')
+ call assert_equal('Xfoo', bufname(winbufnr(1)))
+ call assert_equal('Xbaz', bufname(winbufnr(2)))
+ only
+
+ call feedkeys(l:bar_nr . "\<C-W>\<C-^>", 'tx')
+ call assert_equal('Xbar', bufname(winbufnr(1)))
+ call assert_equal('Xfoo', bufname(winbufnr(2)))
+ only
+
+ execute l:baz_nr . 'wincmd ^'
+ call assert_equal('Xbaz', bufname(winbufnr(1)))
+ call assert_equal('Xbar', bufname(winbufnr(2)))
+ endif
+
+ %bw!
endfunc
func Test_window_preview()
@@ -446,6 +490,17 @@ func Test_window_newtab()
%bw!
endfunc
+func Test_next_split_all()
+ " This was causing an illegal memory access.
+ n x
+ norm axxx
+ split
+ split
+ s/x
+ s/x
+ all
+ bwipe!
+endfunc
" Tests for adjusting window and contents
func GetScreenStr(row)
@@ -485,6 +540,11 @@ func Test_window_contents()
call test_garbagecollect_now()
endfunc
+func Test_window_colon_command()
+ " This was reading invalid memory.
+ exe "norm! v\<C-W>:\<C-U>echo v:version"
+endfunc
+
func Test_access_freed_mem()
" This was accessing freed memory
au * 0 vs xxx
@@ -700,6 +760,42 @@ func Test_relative_cursor_second_line_after_resize()
let &so = so_save
endfunc
+func Test_split_noscroll()
+ let so_save = &so
+ enew
+ call setline(1, range(1, 8))
+ normal 100%
+ split
+
+ 1wincmd w
+ let winid1 = win_getid()
+ let info1 = getwininfo(winid1)[0]
+
+ 2wincmd w
+ let winid2 = win_getid()
+ let info2 = getwininfo(winid2)[0]
+
+ call assert_equal(1, info1.topline)
+ call assert_equal(1, info2.topline)
+
+ " window that fits all lines by itself, but not when split: closing other
+ " window should restore fraction.
+ only!
+ call setline(1, range(1, &lines - 10))
+ exe &lines / 4
+ let winid1 = win_getid()
+ let info1 = getwininfo(winid1)[0]
+ call assert_equal(1, info1.topline)
+ new
+ redraw
+ close
+ let info1 = getwininfo(winid1)[0]
+ call assert_equal(1, info1.topline)
+
+ bwipe!
+ let &so = so_save
+endfunc
+
" Tests for the winnr() function
func Test_winnr()
only | tabonly
@@ -745,9 +841,4 @@ func Test_winnr()
only | tabonly
endfunc
-func Test_window_colon_command()
- " This was reading invalid memory.
- exe "norm! v\<C-W>:\<C-U>echo v:version"
-endfunc
-
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim
index 6066d61af4..56031662a3 100644
--- a/src/nvim/testdir/test_writefile.vim
+++ b/src/nvim/testdir/test_writefile.vim
@@ -1,4 +1,4 @@
-" Tests for the writefile() function.
+" Tests for the writefile() function and some :write commands.
func Test_writefile()
let f = tempname()
@@ -16,6 +16,11 @@ func Test_writefile()
call delete(f)
endfunc
+func Test_writefile_ignore_regexp_error()
+ write Xt[z-a]est.txt
+ call delete('Xt[z-a]est.txt')
+endfunc
+
func Test_writefile_fails_gently()
call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:')
call assert_false(filereadable("Xfile"))
diff --git a/src/nvim/testdir/view_util.vim b/src/nvim/testdir/view_util.vim
index 29ea073f97..1def201a05 100644
--- a/src/nvim/testdir/view_util.vim
+++ b/src/nvim/testdir/view_util.vim
@@ -1,10 +1,21 @@
" Functions about view shared by several tests
" Only load this script once.
-if exists('*ScreenLines')
+if exists('*Screenline')
finish
endif
+" Get line "lnum" as displayed on the screen.
+" Trailing white space is trimmed.
+func Screenline(lnum)
+ let chars = []
+ for c in range(1, winwidth(0))
+ call add(chars, nr2char(screenchar(a:lnum, c)))
+ endfor
+ let line = join(chars, '')
+ return matchstr(line, '^.\{-}\ze\s*$')
+endfunc
+
" ScreenLines(lnum, width) or
" ScreenLines([start, end], width)
function! ScreenLines(lnum, width) abort
@@ -42,6 +53,7 @@ endfunction
function! NewWindow(height, width) abort
exe a:height . 'new'
exe a:width . 'vsp'
+ set winfixwidth winfixheight
redraw!
endfunction