aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:15:05 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:27:38 +0000
commitc5d770d311841ea5230426cc4c868e8db27300a8 (patch)
treedd21f70127b4b8b5f109baefc8ecc5016f507c91 /test/old/testdir
parent9be89f131f87608f224f0ee06d199fcd09d32176 (diff)
parent081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff)
downloadrneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/old/testdir')
-rw-r--r--test/old/testdir/Makefile15
-rw-r--r--test/old/testdir/gen_opt_test.vim507
-rw-r--r--test/old/testdir/runtest.vim26
-rw-r--r--test/old/testdir/script_util.vim2
-rw-r--r--test/old/testdir/shared.vim14
-rw-r--r--test/old/testdir/test_autocmd.vim11
-rw-r--r--test/old/testdir/test_cmdline.vim113
-rw-r--r--test/old/testdir/test_compiler.vim7
-rw-r--r--test/old/testdir/test_curswant.vim52
-rw-r--r--test/old/testdir/test_diffmode.vim27
-rw-r--r--test/old/testdir/test_edit.vim2
-rw-r--r--test/old/testdir/test_expr.vim10
-rw-r--r--test/old/testdir/test_filetype.vim67
-rw-r--r--test/old/testdir/test_findfile.vim525
-rw-r--r--test/old/testdir/test_functions.vim22
-rw-r--r--test/old/testdir/test_getvar.vim11
-rw-r--r--test/old/testdir/test_ins_complete.vim93
-rw-r--r--test/old/testdir/test_map_functions.vim19
-rw-r--r--test/old/testdir/test_mapping.vim77
-rw-r--r--test/old/testdir/test_modeline.vim1
-rw-r--r--test/old/testdir/test_normal.vim10
-rw-r--r--test/old/testdir/test_options.vim575
-rw-r--r--test/old/testdir/test_options_all.vim13
-rw-r--r--test/old/testdir/test_popup.vim30
-rw-r--r--test/old/testdir/test_quickfix.vim104
-rw-r--r--test/old/testdir/test_spellfile.vim2
-rw-r--r--test/old/testdir/test_swap.vim2
-rw-r--r--test/old/testdir/test_tagfunc.vim4
-rw-r--r--test/old/testdir/test_undo.vim3
-rw-r--r--test/old/testdir/test_window_cmd.vim2
-rw-r--r--test/old/testdir/test_windows_home.vim2
31 files changed, 2217 insertions, 131 deletions
diff --git a/test/old/testdir/Makefile b/test/old/testdir/Makefile
index 20272a24c7..d73571f463 100644
--- a/test/old/testdir/Makefile
+++ b/test/old/testdir/Makefile
@@ -55,6 +55,8 @@ else
endif
endif
+default: nongui
+
nongui: nolog $(FIXFF) newtests report
.gdbinit:
@@ -112,6 +114,7 @@ CLEAN_FILES := *.out \
*.rej \
*.orig \
*.tlog \
+ opt_test.vim \
test_result.log \
$(CLEANUP_FILES) \
$(RM_ON_RUN) \
@@ -151,6 +154,18 @@ newtests: newtestssilent
newtestssilent: $(NEW_TESTS_RES)
+GEN_OPT_DEPS = gen_opt_test.vim ../../../src/nvim/options.lua ../../../runtime/doc/options.txt
+
+opt_test.vim: $(GEN_OPT_DEPS)
+ $(NVIM_PRG) -e -s -u NONE $(NO_INITS) -S $(GEN_OPT_DEPS)
+ @if test -f test.log; then \
+ cat test.log; \
+ exit 1; \
+ fi
+
+# Explicit dependencies.
+test_options_all.res: opt_test.vim
+
%.res: %.vim .gdbinit
@echo "[OLDTEST] Running" $*
@rm -rf $*.failed test.ok $(RM_ON_RUN)
diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim
new file mode 100644
index 0000000000..be5a7e6ee4
--- /dev/null
+++ b/test/old/testdir/gen_opt_test.vim
@@ -0,0 +1,507 @@
+" Script to generate test/old/testdir/opt_test.vim from src/nvim/options.lua
+" and runtime/doc/options.txt
+
+set cpo&vim
+
+" Only do this when build with the +eval feature.
+if 1
+
+try
+
+set nomore
+
+const K_KENTER = -16715
+
+" Get global-local options.
+" "key" is full-name of the option.
+" "value" is the local value to switch back to the global value.
+b options.txt
+call cursor(1, 1)
+let global_locals = {}
+while search("^'[^']*'.*\\n.*|global-local", 'W')
+ let fullname = getline('.')->matchstr("^'\\zs[^']*")
+ let global_locals[fullname] = ''
+endwhile
+call extend(global_locals, #{
+ \ scrolloff: -1,
+ \ sidescrolloff: -1,
+ \ undolevels: -123456,
+ \})
+
+" Get local-noglobal options.
+" "key" is full-name of the option.
+" "value" is no used.
+b options.txt
+call cursor(1, 1)
+let local_noglobals = {}
+while search("^'[^']*'.*\\n.*|local-noglobal", 'W')
+ let fullname = getline('.')->matchstr("^'\\zs[^']*")
+ let local_noglobals[fullname] = v:true
+endwhile
+
+" Options to skip `setglobal` tests.
+" "key" is full-name of the option.
+" "value" is the reason.
+let skip_setglobal_reasons = #{
+ \ iminsert: 'The global value is always overwritten by the local value',
+ \ imsearch: 'The global value is always overwritten by the local value',
+ \}
+
+" Script header.
+" The test values contains multibyte characters.
+let script = [
+ \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
+ \ '" Used by test_options_all.vim.',
+ \ '',
+ \ 'scriptencoding utf-8',
+ \ ]
+
+let options = luaeval('loadfile("../../../src/nvim/options.lua")().options')
+
+" font name that works everywhere (hopefully)
+let fontname = has('win32') ? 'fixedsys' : 'fixed'
+
+" Two lists with values: values that work and values that fail.
+" When not listed, "othernum" or "otherstring" is used.
+" When both lists are empty, skip tests for the option.
+" For boolean options, if non-empty a fixed test will be run, otherwise skipped.
+let test_values = {
+ "\ Nvim-only options
+ \ 'channel': [[], []],
+ \ 'inccommand': [['', 'nosplit', 'split'], ['xxx']],
+ \ 'mousescroll': [['ver:1', 'hor:2', 'ver:1,hor:2', 'hor:1,ver:2'],
+ \ ['xxx', 'ver:1,xxx', 'hor:2,xxx']],
+ \ 'redrawdebug': [[''], ['xxx']],
+ \ 'shada': [['', '''50', '"30'], ['xxx']],
+ \ 'termpastefilter': [['BS', 'HT', 'FF', 'ESC', 'DEL', 'C0', 'C1', 'C0,C1'],
+ \ ['xxx', 'C0,C1,xxx']],
+ \ 'winhighlight': [['', 'a:b', 'a:', 'a:b,c:d'],
+ \ ['a', ':', ':b', 'a:b:c', 'a:/', '/:b', ',', 'a:b,,', 'a:b,c']],
+ \
+ "\ Options for which Nvim has different allowed values
+ \ 'backspace': [[2, '', 'indent', 'eol', 'start', 'nostop',
+ \ 'eol,start', 'indent,eol,nostop'],
+ \ [-1, 4, 'xxx']],
+ \ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
+ \ 'prompt'],
+ \ ['xxx', 'help,nofile']],
+ \ 'clipboard': [['', 'unnamed'], ['xxx', '\ze*', 'exclude:\\%(']],
+ \ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
+ \ 'noinsert', 'noselect', 'fuzzy', 'menu,longest'],
+ \ ['xxx', 'menu,,,longest,']],
+ \ 'encoding': [['utf8'], []],
+ \ 'foldcolumn': [[0, 1, 4, 'auto', 'auto:1', 'auto:9'], [-1, 13, 999]],
+ \ 'foldlevel': [[0, 100], [-1, '']],
+ \ 'highlight': [[&highlight], []],
+ \ 'iminsert': [[0, 1], [-1, 2, 3, 999]],
+ \ 'imsearch': [[-1, 0, 1], [-2, 2, 3, 999]],
+ \ 'signcolumn': [['auto', 'no', 'yes', 'number', 'yes:1', 'auto:1-9'],
+ \ ['', 'xxx', 'no,yes', 'auto:0-9', 'auto:9-1', 'auto:1-@']],
+ \ 'writedelay': [[0, 100], [-1, '']],
+ \
+ "\ boolean options
+ \ 'termguicolors': [
+ \ has('vtp') && !has('vcon') && !has('gui_running') ? [] : [1],
+ \ []],
+ \
+ "\ number options
+ \ 'cmdheight': [[0, 1, 2, 10], [-1]],
+ \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
+ \ 'columns': [[12, 80, 10000], [-1, 0, 10]],
+ \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
+ "\ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
+ \ 'helpheight': [[0, 10, 100], [-1]],
+ \ 'history': [[0, 1, 100, 10000], [-1, 10001]],
+ "\ 'iminsert': [[0, 1, 2], [-1, 3, 999]],
+ "\ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]],
+ "\ 'imstyle': [[0, 1], [-1, 2, 999]],
+ \ 'lines': [[2, 24, 1000], [-1, 0, 1]],
+ \ 'linespace': [[-1, 0, 2, 4, 999], ['']],
+ \ 'msghistory': [[0, 1, 100, 10000], [-1, 10001]],
+ \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
+ \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
+ \ 'report': [[0, 1, 2, 9999], [-1]],
+ \ 'scroll': [[0, 1, 2, 20], [-1, 999]],
+ \ 'scrolljump': [[-100, -1, 0, 1, 2, 20], [-101, 999]],
+ \ 'scrolloff': [[0, 1, 8, 999], [-1]],
+ \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
+ \ 'sidescroll': [[0, 1, 8, 999], [-1]],
+ \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
+ \ 'tabstop': [[1, 4, 8, 12, 9999], [-1, 0, 10000]],
+ \ 'textwidth': [[0, 1, 8, 99], [-1]],
+ \ 'timeoutlen': [[0, 8, 99999], [-1]],
+ \ 'titlelen': [[0, 1, 8, 9999], [-1]],
+ \ 'updatecount': [[0, 1, 8, 9999], [-1]],
+ \ 'updatetime': [[0, 1, 8, 9999], [-1]],
+ \ 'verbose': [[-1, 0, 1, 8, 9999], ['']],
+ \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'],
+ \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
+ \ '<NL>', '<CR>', K_KENTER]],
+ \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'],
+ \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
+ \ '<NL>', '<CR>', K_KENTER]],
+ \ 'winheight': [[1, 10, 999], [-1, 0]],
+ \ 'winminheight': [[0, 1], [-1]],
+ \ 'winminwidth': [[0, 1, 10], [-1]],
+ \ 'winwidth': [[1, 10, 999], [-1, 0]],
+ \
+ "\ string options
+ \ 'ambiwidth': [['', 'single', 'double'], ['xxx']],
+ \ 'background': [['', 'light', 'dark'], ['xxx']],
+ "\ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop',
+ "\ " 'eol,start', 'indent,eol,nostop'],
+ "\ " [-1, 4, 'xxx']],
+ \ 'backupcopy': [['yes', 'no', 'auto'], ['', 'xxx', 'yes,no']],
+ \ 'backupext': [['xxx'], [&patchmode, '*']],
+ \ 'belloff': [['', 'all', 'backspace', 'cursor', 'complete', 'copy',
+ \ 'ctrlg', 'error', 'esc', 'ex', 'hangul', 'insertmode', 'lang',
+ \ 'mess', 'showmatch', 'operator', 'register', 'shell', 'spell',
+ \ 'term', 'wildmode', 'copy,error,shell'],
+ \ ['xxx']],
+ \ 'breakindentopt': [['', 'min:3', 'shift:4', 'shift:-2', 'sbr', 'list:5',
+ \ 'list:-1', 'column:10', 'column:-5', 'min:1,sbr,shift:2'],
+ \ ['xxx', 'min', 'min:x', 'min:-1', 'shift:x', 'sbr:1', 'list:x',
+ \ 'column:x']],
+ \ 'browsedir': [['', 'last', 'buffer', 'current', './Xdir\ with\ space'],
+ \ ['xxx']],
+ \ 'bufhidden': [['', 'hide', 'unload', 'delete', 'wipe'],
+ \ ['xxx', 'hide,wipe']],
+ "\ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
+ "\ " 'terminal', 'prompt', 'popup'],
+ "\ " ['xxx', 'help,nofile']],
+ \ 'casemap': [['', 'internal', 'keepascii', 'internal,keepascii'],
+ \ ['xxx']],
+ \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'],
+ \ ['xxx', 'f', '<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
+ "\ 'clipboard': [['', 'unnamed', 'unnamedplus', 'autoselect',
+ "\ " 'autoselectplus', 'autoselectml', 'html', 'exclude:vimdisplay',
+ "\ " 'autoselect,unnamed', 'unnamed,exclude:.*'],
+ "\ " ['xxx', 'exclude:\\ze*', 'exclude:\\%(']],
+ \ 'colorcolumn': [['', '8', '+2', '1,+1,+3'], ['xxx', '-a', '1,', '1;']],
+ \ 'comments': [['', 'b:#', 'b:#,:%'], ['xxx', '-']],
+ \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
+ \ 'complete': [['', '.', 'w', 'b', 'u', 'U', 'i', 'd', ']', 't',
+ \ 'k', 'kspell', 'k/tmp/dir\\\ with\\\ space/*',
+ \ 's', 's/tmp/dir\\\ with\\\ space/*',
+ \ 'w,b,k/tmp/dir\\\ with\\\ space/*,s'],
+ \ ['xxx']],
+ \ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']],
+ "\ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
+ "\ " 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'menu,longest'],
+ "\ " ['xxx', 'menu,,,longest,']],
+ \ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'],
+ \ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr',
+ \ 'abbr1234,kind,menu']],
+ "\ 'completepopup': [['', 'height:13', 'width:20', 'highlight:That',
+ "\ " 'align:item', 'align:menu', 'border:on', 'border:off',
+ "\ " 'width:10,height:234,highlight:Mine'],
+ "\ " ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
+ "\ " 'border:maybe', 'border:1', 'border:']],
+ \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
+ "\ 'cryptmethod': [['', 'zip'], ['xxx']],
+ "\ 'cscopequickfix': [['', 's-', 'g-', 'd-', 'c-', 't-', 'e-', 'f-', 'i-',
+ "\ " 'a-', 's-,c+,e0'],
+ "\ " ['xxx', 's,g,d']],
+ \ 'cursorlineopt': [['both', 'line', 'number', 'screenline',
+ \ 'line,number'],
+ \ ['', 'xxx', 'line,screenline']],
+ \ 'debug': [['', 'msg', 'throw', 'beep'], ['xxx']],
+ \ 'diffopt': [['', 'filler', 'context:0', 'context:999', 'iblank',
+ \ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical',
+ \ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12',
+ \ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers',
+ \ 'algorithm:minimal', 'algorithm:patience',
+ \ 'algorithm:histogram', 'icase,iwhite'],
+ \ ['xxx', 'foldcolumn:xxx', 'algorithm:xxx', 'algorithm:']],
+ \ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'],
+ \ ['xxx']],
+ \ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
+ "\ 'encoding': [['latin1'], ['xxx', '']],
+ \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
+ \ ['xxx']],
+ \ 'fileencoding': [['', 'latin1', 'xxx'], []],
+ \ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
+ \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
+ \ 'fillchars': [['', 'stl:x', 'stlnc:x', 'vert:x', 'fold:x', 'foldopen:x',
+ \ 'foldclose:x', 'foldsep:x', 'diff:x', 'eob:x', 'lastline:x',
+ \ 'stl:\ ,vert:\|,fold:\\,diff:x'],
+ \ ['xxx', 'vert:']],
+ \ 'foldclose': [['', 'all'], ['xxx']],
+ \ 'foldmethod': [['manual', 'indent', 'expr', 'marker', 'syntax', 'diff'],
+ \ ['', 'xxx', 'expr,diff']],
+ \ 'foldopen': [['', 'all', 'block', 'hor', 'insert', 'jump', 'mark',
+ \ 'percent', 'quickfix', 'search', 'tag', 'undo', 'hor,jump'],
+ \ ['xxx']],
+ \ 'foldmarker': [['((,))'], ['', 'xxx', '{{{,']],
+ \ 'formatoptions': [['', 't', 'c', 'r', 'o', '/', 'q', 'w', 'a', 'n', '2',
+ \ 'v', 'b', 'l', 'm', 'M', 'B', '1', ']', 'j', 'p', 'vt', 'v,t'],
+ \ ['xxx']],
+ \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
+ \ 'guifont': [['', fontname], []],
+ \ 'guifontwide': [['', fontname], []],
+ "\ 'guifontset': [['', fontname], []],
+ \ 'guioptions': [['', '!', 'a', 'P', 'A', 'c', 'd', 'e', 'f', 'i', 'm',
+ \ 'M', 'g', 't', 'T', 'r', 'R', 'l', 'L', 'b', 'h', 'v', 'p', 'F',
+ \ 'k', '!abvR'],
+ \ ['xxx', 'a,b']],
+ \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
+ "\ 'highlight': [['', 'e:Error'], ['xxx']],
+ "\ 'imactivatekey': [['', 'S-space'], ['xxx']],
+ \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
+ \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
+ \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
+ \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
+ \ 'jumpoptions': [['', 'stack'], ['xxx']],
+ \ 'keymap': [['', 'accents'], ['/']],
+ \ 'keymodel': [['', 'startsel', 'stopsel', 'startsel,stopsel'], ['xxx']],
+ "\ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
+ "\ " ['xxx', ':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
+ \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
+ \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx', 'expr:x', 'expr:']],
+ \ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x',
+ \ 'multispace:xxxy', 'lead:x', 'leadmultispace:xxxy', 'trail:x',
+ \ 'extends:x', 'precedes:x', 'conceal:x', 'nbsp:x', 'eol:\\x24',
+ \ 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
+ \ ['xxx', 'eol:']],
+ \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
+ \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
+ \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
+ \ ['xxx', 'n,v,i']],
+ \ 'mousemodel': [['', 'extend', 'popup', 'popup_setpos'], ['xxx']],
+ \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
+ \ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank',
+ \ 'alpha,hex,bin'],
+ \ ['xxx']],
+ \ 'patchmode': [['', 'xxx', '.x'], [&backupext, '*']],
+ "\ 'previewpopup': [['', 'height:13', 'width:20', 'highlight:That',
+ "\ " 'align:item', 'align:menu', 'border:on', 'border:off',
+ "\ " 'width:10,height:234,highlight:Mine'],
+ "\ " ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
+ "\ " 'border:maybe', 'border:1', 'border:']],
+ "\ 'printmbfont': [['', 'r:some', 'b:some', 'i:some', 'o:some', 'c:yes',
+ "\ " 'c:no', 'a:yes', 'a:no', 'b:Bold,c:yes'],
+ "\ " ['xxx', 'xxx,c:yes', 'xxx:', 'xxx:,c:yes']],
+ "\ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'],
+ "\ " ['xxx', 'header:-1']],
+ \ 'scrollopt': [['', 'ver', 'hor', 'jump', 'ver,hor'], ['xxx']],
+ "\ 'renderoptions': [[''], ['xxx']],
+ \ 'rightleftcmd': [['search'], ['xxx']],
+ \ 'rulerformat': [['', 'xxx'], ['%-', '%(', '%15(%%']],
+ \ 'selection': [['old', 'inclusive', 'exclusive'], ['', 'xxx']],
+ \ 'selectmode': [['', 'mouse', 'key', 'cmd', 'key,cmd'], ['xxx']],
+ \ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir',
+ \ 'help,options,slash'],
+ \ ['xxx', 'curdir,sesdir']],
+ \ 'showcmdloc': [['', 'last', 'statusline', 'tabline'], ['xxx']],
+ "\ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']],
+ \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
+ \ '/tmp/dir\ with\ space/en.utf-8.add',
+ \ '/tmp/dir\\,with\\,comma/en.utf-8.add'],
+ \ ['xxx', '/tmp/file', '/tmp/dir*with:invalid?char/file.en.add',
+ \ ',file.en.add', 'xxx,yyy.en.add', 'xxx.en.add,yyy,zzz.ja.add']],
+ \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
+ \ 'spelloptions': [['', 'camel'], ['xxx']],
+ \ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100',
+ \ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'],
+ \ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']],
+ \ 'splitkeep': [['', 'cursor', 'screen', 'topline'], ['xxx']],
+ \ 'statusline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
+ "\ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
+ \ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab',
+ \ 'uselast', 'split,newtab'],
+ \ ['xxx']],
+ \ 'tabclose': [['', 'left', 'uselast', 'left,uselast'], ['xxx']],
+ \ 'tabline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
+ \ 'tagcase': [['followic', 'followscs', 'ignore', 'match', 'smart'],
+ \ ['', 'xxx', 'smart,match']],
+ \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
+ "\ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<',
+ "\ " '^'],
+ "\ " ['<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
+ "\ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'],
+ "\ " ['xxx', '80', '8ax9', '24x80b']],
+ "\ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
+ "\ 'titlestring': [['', 'xxx', '%('], []],
+ "\ 'toolbar': [['', 'icons', 'text', 'horiz', 'tooltips', 'icons,text'],
+ "\ " ['xxx']],
+ "\ 'toolbariconsize': [['', 'tiny', 'small', 'medium', 'large', 'huge',
+ "\ " 'giant'],
+ "\ " ['xxx']],
+ "\ 'ttymouse': [['', 'xterm'], ['xxx']],
+ \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
+ \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
+ \ 'verbosefile': [['', './Xfile'], []],
+ \ 'viewoptions': [['', 'cursor', 'folds', 'options', 'localoptions',
+ \ 'slash', 'unix', 'curdir', 'unix,slash'], ['xxx']],
+ \ 'viminfo': [['', '''50', '"30', "'100,<50,s10,h"], ['xxx', 'h']],
+ \ 'virtualedit': [['', 'block', 'insert', 'all', 'onemore', 'none',
+ \ 'NONE', 'all,block'],
+ \ ['xxx']],
+ \ 'whichwrap': [['', 'b', 's', 'h', 'l', '<', '>', '~', '[', ']', 'b,s',
+ \ 'bs'],
+ \ ['xxx']],
+ \ 'wildmode': [['', 'full', 'longest', 'list', 'lastused', 'list:full',
+ \ 'full,longest', 'full,full,full,full'],
+ \ ['xxx', 'a4', 'full,full,full,full,full']],
+ \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
+ \ 'winaltkeys': [['no', 'yes', 'menu'], ['', 'xxx']],
+ \
+ "\ skipped options
+ "\ 'luadll': [[], []],
+ "\ 'perldll': [[], []],
+ "\ 'pythondll': [[], []],
+ "\ 'pythonthreedll': [[], []],
+ \ 'pyxversion': [[], []],
+ "\ 'rubydll': [[], []],
+ "\ 'tcldll': [[], []],
+ \ 'term': [[], []],
+ \ 'ttytype': [[], []],
+ \
+ "\ default behaviours
+ \ 'othernum': [[-1, 0, 100], ['']],
+ \ 'otherstring': [['', 'xxx'], []],
+ \}
+
+" Two lists with values: values that pre- and post-processing in test.
+" Clear out t_WS: we don't want to resize the actual terminal.
+let test_prepost = {
+ \ 'browsedir': [["call mkdir('Xdir with space', 'D')"], []],
+ \ 'columns': [[
+ \ 'set t_WS=',
+ \ 'let save_columns = &columns'
+ \ ], [
+ \ 'let &columns = save_columns',
+ \ 'set t_WS&'
+ \ ]],
+ \ 'lines': [[
+ \ 'set t_WS=',
+ \ 'let save_lines = &lines'
+ \ ], [
+ \ 'let &lines = save_lines',
+ \ 'set t_WS&'
+ \ ]],
+ \ 'verbosefile': [[], ['call delete("Xfile")']],
+ \}
+
+const invalid_options = test_values->keys()
+ \->filter({-> v:val !~# '^other' && !exists($"&{v:val}")})
+if !empty(invalid_options)
+ throw $"Invalid option name in test_values: '{invalid_options->join("', '")}'"
+endif
+
+for option in options
+ let fullname = option.full_name
+ let shortname = get(option, 'abbreviation', fullname)
+
+ if !exists('+' .. fullname)
+ continue
+ endif
+
+ let [valid_values, invalid_values] = test_values[
+ \ has_key(test_values, fullname) ? fullname
+ \ : option.type == 'number' ? 'othernum'
+ \ : 'otherstring']
+
+ if empty(valid_values) && empty(invalid_values)
+ continue
+ endif
+
+ call add(script, $"func Test_opt_set_{fullname}()")
+ call add(script, $"if exists('+{fullname}') && execute('set!') =~# '\\n..{fullname}\\([=\\n]\\|$\\)'")
+ call add(script, $"let l:saved = [&g:{fullname}, &l:{fullname}]")
+ call add(script, 'endif')
+
+ let [pre_processing, post_processing] = get(test_prepost, fullname, [[], []])
+ let script += pre_processing
+
+ if option.type == 'boolean'
+ for opt in [fullname, shortname]
+ for cmd in ['set', 'setlocal', 'setglobal']
+ call add(script, $'{cmd} {opt}')
+ call add(script, $'{cmd} no{opt}')
+ call add(script, $'{cmd} inv{opt}')
+ call add(script, $'{cmd} {opt}!')
+ endfor
+ endfor
+ else " P_NUM || P_STRING
+ " Normal tests
+ for opt in [fullname, shortname]
+ for cmd in ['set', 'setlocal', 'setglobal']
+ for val in valid_values
+ if local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
+ " Skip `:setglobal {option}={val}` for local-noglobal option.
+ " It has no effect.
+ let pre = '" Skip local-noglobal: '
+ else
+ let pre = ''
+ endif
+ call add(script, $'{pre}{cmd} {opt}={val}')
+ endfor
+ endfor
+ " Testing to clear the local value and switch back to the global value.
+ if global_locals->has_key(fullname)
+ let switchback_val = global_locals[fullname]
+ call add(script, $'setlocal {opt}={switchback_val}')
+ call add(script, $'call assert_equal(&g:{fullname}, &{fullname})')
+ endif
+ endfor
+
+ " Failure tests
+ " Setting an option can only fail when it's implemented.
+ call add(script, $"if exists('+{fullname}')")
+ for opt in [fullname, shortname]
+ for cmd in ['set', 'setlocal', 'setglobal']
+ for val in invalid_values
+ if val is# global_locals->get(fullname, {}) && cmd ==# 'setlocal'
+ " Skip setlocal switchback-value to global-local option. It will
+ " not result in failure.
+ let pre = '" Skip global-local: '
+ elseif local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
+ " Skip setglobal to local-noglobal option. It will not result in
+ " failure.
+ let pre = '" Skip local-noglobal: '
+ elseif skip_setglobal_reasons->has_key(fullname) && cmd ==# 'setglobal'
+ " Skip setglobal to reasoned option. It will not result in failure.
+ let reason = skip_setglobal_reasons[fullname]
+ let pre = $'" Skip {reason}: '
+ else
+ let pre = ''
+ endif
+ let cmdline = $'{cmd} {opt}={val}'
+ call add(script, $"{pre}silent! call assert_fails({string(cmdline)})")
+ endfor
+ endfor
+ endfor
+ call add(script, "endif")
+ endif
+
+ " Cannot change 'termencoding' in GTK
+ if fullname != 'termencoding' || !has('gui_gtk')
+ call add(script, $'set {fullname}&')
+ call add(script, $'set {shortname}&')
+ call add(script, $"if exists('l:saved')")
+ call add(script, $"let [&g:{fullname}, &l:{fullname}] = l:saved")
+ call add(script, 'endif')
+ endif
+
+ let script += post_processing
+ call add(script, 'endfunc')
+endfor
+
+call writefile(script, 'opt_test.vim')
+
+" Write error messages if error occurs.
+catch
+ " Append errors to test.log
+ let error = $'Error: {v:exception} in {v:throwpoint}'
+ echo error
+ split test.log
+ call append('$', error)
+ write
+endtry
+
+endif
+
+qa!
+
+" vim:sw=2:ts=8:noet:nosta:
diff --git a/test/old/testdir/runtest.vim b/test/old/testdir/runtest.vim
index e05a78e9ca..058635c332 100644
--- a/test/old/testdir/runtest.vim
+++ b/test/old/testdir/runtest.vim
@@ -174,10 +174,6 @@ func GetAllocId(name)
return lnum - top - 1
endfunc
-if has('reltime')
- let g:func_start = reltime()
-endif
-
" Get the list of swap files in the current directory.
func s:GetSwapFileList()
let save_dir = &directory
@@ -567,6 +563,16 @@ for g:testfunc in sort(s:tests)
" A test can set g:test_is_flaky to retry running the test.
let g:test_is_flaky = 0
+ " A test can set g:max_run_nr to change the max retry count.
+ let g:max_run_nr = 5
+ if has('mac')
+ let g:max_run_nr = 10
+ endif
+
+ " By default, give up if the same error occurs. A test can set
+ " g:giveup_same_error to 0 to not give up on the same error and keep trying.
+ let g:giveup_same_error = 1
+
let starttime = strftime("%H:%M:%S")
call RunTheTest(g:testfunc)
@@ -582,10 +588,15 @@ for g:testfunc in sort(s:tests)
call extend(s:messages, v:errors)
let endtime = strftime("%H:%M:%S")
- call add(total_errors, $'Run {g:run_nr}, {starttime} - {endtime}:')
+ if has('reltime')
+ let suffix = $' in{reltimestr(reltime(g:func_start))} seconds'
+ else
+ let suffix = ''
+ endif
+ call add(total_errors, $'Run {g:run_nr}, {starttime} - {endtime}{suffix}:')
call extend(total_errors, v:errors)
- if g:run_nr >= 5 || prev_error == v:errors[0]
+ if g:run_nr >= g:max_run_nr || g:giveup_same_error && prev_error == v:errors[0]
call add(total_errors, 'Flaky test failed too often, giving up')
let v:errors = total_errors
break
@@ -596,7 +607,8 @@ for g:testfunc in sort(s:tests)
" Flakiness is often caused by the system being very busy. Sleep a
" couple of seconds to have a higher chance of succeeding the second
" time.
- sleep 2
+ let delay = g:run_nr * 2
+ exe 'sleep' delay
let prev_error = v:errors[0]
let v:errors = []
diff --git a/test/old/testdir/script_util.vim b/test/old/testdir/script_util.vim
index 28d6a621d6..a300b670c7 100644
--- a/test/old/testdir/script_util.vim
+++ b/test/old/testdir/script_util.vim
@@ -1,4 +1,4 @@
-" Functions shared by the tests for Vim Script
+" Functions shared by the tests for Vim script
" Commands to track the execution path of a script
com! XpathINIT let g:Xpath = ''
diff --git a/test/old/testdir/shared.vim b/test/old/testdir/shared.vim
index e7a5f471e7..bb1a6c8f5b 100644
--- a/test/old/testdir/shared.vim
+++ b/test/old/testdir/shared.vim
@@ -35,12 +35,20 @@ func PythonProg()
if has('unix')
" We also need the job feature or the pkill command to make sure the server
" can be stopped.
- if !(executable('python') && (has('job') || executable('pkill')))
+ if !(has('job') || executable('pkill'))
return ''
endif
- let s:python = 'python'
+ if executable('python3')
+ let s:python = 'python3'
+ elseif executable('python')
+ let s:python = 'python'
+ else
+ return ''
+ end
elseif has('win32')
" Use Python Launcher for Windows (py.exe) if available.
+ " NOTE: if you get a "Python was not found" error, disable the Python
+ " shortcuts in "Windows menu / Settings / Manage App Execution Aliases".
if executable('py.exe')
let s:python = 'py.exe'
elseif executable('python.exe')
@@ -64,7 +72,7 @@ func RunCommand(cmd)
let job = job_start(a:cmd, {"stoponexit": "hup"})
call job_setoptions(job, {"stoponexit": "kill"})
elseif has('win32')
- exe 'silent !start cmd /c start "test_channel" ' . a:cmd
+ exe 'silent !start cmd /D /c start "test_channel" ' . a:cmd
else
exe 'silent !' . a:cmd . '&'
endif
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 9d06ebb2be..64599c869a 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -88,9 +88,9 @@ if has('timers')
" CursorHoldI event.
let g:triggered = 0
au CursorHoldI * let g:triggered += 1
- set updatetime=500
- call job_start(has('win32') ? 'cmd /c echo:' : 'echo',
- \ {'exit_cb': {-> timer_start(1000, 'ExitInsertMode')}})
+ set updatetime=100
+ call job_start(has('win32') ? 'cmd /D /c echo:' : 'echo',
+ \ {'exit_cb': {-> timer_start(200, 'ExitInsertMode')}})
call feedkeys('a', 'x!')
call assert_equal(1, g:triggered)
unlet g:triggered
@@ -2003,7 +2003,10 @@ func Test_Cmdline()
au! CmdlineLeave
let save_shellslash = &shellslash
- set noshellslash
+ " Nvim doesn't allow setting value of a hidden option to non-default value
+ if exists('+shellslash')
+ set noshellslash
+ endif
au! CmdlineEnter / let g:entered = expand('<afile>')
au! CmdlineLeave / let g:left = expand('<afile>')
let g:entered = 0
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
index 9f25a42c38..290af4a4ca 100644
--- a/test/old/testdir/test_cmdline.vim
+++ b/test/old/testdir/test_cmdline.vim
@@ -271,6 +271,12 @@ func Test_changing_cmdheight()
let lines =<< trim END
set cmdheight=1 laststatus=2
+ func EchoOne()
+ set laststatus=2 cmdheight=1
+ echo 'foo'
+ echo 'bar'
+ set cmdheight=2
+ endfunc
func EchoTwo()
set laststatus=2
set cmdheight=5
@@ -306,6 +312,10 @@ func Test_changing_cmdheight()
call term_sendkeys(buf, ":call EchoTwo()\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_6', {})
+ " increasing 'cmdheight' doesn't clear the messages that need hit-enter
+ call term_sendkeys(buf, ":call EchoOne()\<CR>")
+ call VerifyScreenDump(buf, 'Test_changing_cmdheight_7', {})
+
" clean up
call StopVimInTerminal(buf)
endfunc
@@ -727,8 +737,8 @@ func Test_fullcommand()
\ ':5s': 'substitute',
\ "'<,'>s": 'substitute',
\ ":'<,'>s": 'substitute',
- \ 'CheckUni': 'CheckUnix',
- \ 'CheckUnix': 'CheckUnix',
+ \ 'CheckLin': 'CheckLinux',
+ \ 'CheckLinux': 'CheckLinux',
\ }
for [in, want] in items(tests)
@@ -1012,8 +1022,7 @@ func Test_cmdline_complete_user_names()
call feedkeys(':e ~' . first_letter . "\<c-a>\<c-B>\"\<cr>", 'tx')
call assert_match('^"e \~.*\<' . whoami . '\>', @:)
endif
- endif
- if has('win32')
+ elseif has('win32')
" Just in case: check that the system has an Administrator account.
let names = system('net user')
if names =~ 'Administrator'
@@ -1022,14 +1031,27 @@ func Test_cmdline_complete_user_names()
call feedkeys(':e ~A' . "\<c-a>\<c-B>\"\<cr>", 'tx')
call assert_match('^"e \~.*Administrator', @:)
endif
+ else
+ throw 'Skipped: does not work on this platform'
endif
endfunc
+func Test_cmdline_complete_shellcmdline()
+ CheckExecutable whoami
+ command -nargs=1 -complete=shellcmdline MyCmd
+
+ call feedkeys(":MyCmd whoam\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('^".*\<whoami\>', @:)
+ let l = getcompletion('whoam', 'shellcmdline')
+ call assert_match('\<whoami\>', join(l, ' '))
+
+ delcommand MyCmd
+endfunc
+
func Test_cmdline_complete_bang()
- if executable('whoami')
- call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('^".*\<whoami\>', @:)
- endif
+ CheckExecutable whoami
+ call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('^".*\<whoami\>', @:)
endfunc
func Test_cmdline_complete_languages()
@@ -2307,6 +2329,7 @@ endfunc
" Test for 'imcmdline' and 'imsearch'
" This test doesn't actually test the input method functionality.
func Test_cmdline_inputmethod()
+ throw 'Skipped: Nvim does not allow setting the value of a hidden option'
new
call setline(1, ['', 'abc', ''])
set imcmdline
@@ -3800,6 +3823,60 @@ func Test_cmdline_complete_substitute_short()
endfor
endfunc
+" Test for shellcmdline command argument completion
+func Test_cmdline_complete_shellcmdline_argument()
+ command -nargs=+ -complete=shellcmdline MyCmd
+
+ set wildoptions=fuzzy
+
+ call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim test_cmdline.vim', @:)
+ call assert_equal(['test_cmdline.vim'],
+ \ getcompletion('vim test_cmdline.', 'shellcmdline'))
+
+ call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim nonexistentfile', @:)
+ call assert_equal([],
+ \ getcompletion('vim nonexistentfile', 'shellcmdline'))
+
+ let compl1 = getcompletion('', 'file')[0]
+ let compl2 = getcompletion('', 'file')[1]
+ call feedkeys(":MyCmd vim \<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim ' .. compl1, @:)
+
+ call feedkeys(":MyCmd vim \<Tab> \<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl1, @:)
+
+ let compl = getcompletion('', 'file')[1]
+ call feedkeys(":MyCmd vim \<Tab> \<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl2, @:)
+
+ set wildoptions&
+ call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim test_cmdline.vim', @:)
+ call assert_equal(['test_cmdline.vim'],
+ \ getcompletion('vim test_cmdline.', 'shellcmdline'))
+
+ call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim nonexistentfile', @:)
+ call assert_equal([],
+ \ getcompletion('vim nonexistentfile', 'shellcmdline'))
+
+ let compl1 = getcompletion('', 'file')[0]
+ let compl2 = getcompletion('', 'file')[1]
+ call feedkeys(":MyCmd vim \<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim ' .. compl1, @:)
+
+ call feedkeys(":MyCmd vim \<Tab> \<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl1, @:)
+
+ let compl = getcompletion('', 'file')[1]
+ call feedkeys(":MyCmd vim \<Tab> \<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl2, @:)
+
+ delcommand MyCmd
+endfunc
+
" Test for :! shell command argument completion
func Test_cmdline_complete_bang_cmd_argument()
set wildoptions=fuzzy
@@ -3811,30 +3888,32 @@ func Test_cmdline_complete_bang_cmd_argument()
endfunc
func Call_cmd_funcs()
- return [getcmdpos(), getcmdscreenpos(), getcmdcompltype()]
+ return [getcmdpos(), getcmdscreenpos(), getcmdcompltype(), getcmdcomplpat()]
endfunc
func Test_screenpos_and_completion()
call assert_equal(0, getcmdpos())
call assert_equal(0, getcmdscreenpos())
call assert_equal('', getcmdcompltype())
+ call assert_equal('', getcmdcomplpat())
cnoremap <expr> <F2> string(Call_cmd_funcs())
call feedkeys(":let a\<F2>\<C-B>\"\<CR>", "xt")
- call assert_equal("\"let a[6, 7, 'var']", @:)
+ call assert_equal("\"let a[6, 7, 'var', 'a']", @:)
call feedkeys(":quit \<F2>\<C-B>\"\<CR>", "xt")
- call assert_equal("\"quit [6, 7, '']", @:)
+ call assert_equal("\"quit [6, 7, '', '']", @:)
call feedkeys(":nosuchcommand \<F2>\<C-B>\"\<CR>", "xt")
- call assert_equal("\"nosuchcommand [15, 16, '']", @:)
+ call assert_equal("\"nosuchcommand [15, 16, '', '']", @:)
- " Check that getcmdcompltype() doesn't interfere with cmdline completion.
+ " Check that getcmdcompltype() and getcmdcomplpat() don't interfere with
+ " cmdline completion.
let g:results = []
cnoremap <F2> <Cmd>let g:results += [[getcmdline()] + Call_cmd_funcs()]<CR>
call feedkeys(":sign un\<Tab>\<F2>\<Tab>\<F2>\<Tab>\<F2>\<C-C>", "xt")
call assert_equal([
- \ ['sign undefine', 14, 15, 'sign'],
- \ ['sign unplace', 13, 14, 'sign'],
- \ ['sign un', 8, 9, 'sign']], g:results)
+ \ ['sign undefine', 14, 15, 'sign', 'undefine'],
+ \ ['sign unplace', 13, 14, 'sign', 'unplace'],
+ \ ['sign un', 8, 9, 'sign', 'un']], g:results)
unlet g:results
cunmap <F2>
@@ -4070,7 +4149,7 @@ func Test_term_option()
let &cpo = _cpo
endfunc
-func Test_cd_bslsh_completion_windows()
+func Test_cd_bslash_completion_windows()
CheckMSWindows
let save_shellslash = &shellslash
set noshellslash
diff --git a/test/old/testdir/test_compiler.vim b/test/old/testdir/test_compiler.vim
index 69420b4b7f..07b57b76d9 100644
--- a/test/old/testdir/test_compiler.vim
+++ b/test/old/testdir/test_compiler.vim
@@ -10,9 +10,12 @@ func Test_compiler()
let save_LC_ALL = $LC_ALL
let $LC_ALL= "C"
- " %:S does not work properly with 'shellslash' set
let save_shellslash = &shellslash
- set noshellslash
+ " Nvim doesn't allow setting value of a hidden option to non-default value
+ if exists('+shellslash')
+ " %:S does not work properly with 'shellslash' set
+ set noshellslash
+ endif
e Xfoo.pl
compiler perl
diff --git a/test/old/testdir/test_curswant.vim b/test/old/testdir/test_curswant.vim
index e54cd4b280..c67cca5f7d 100644
--- a/test/old/testdir/test_curswant.vim
+++ b/test/old/testdir/test_curswant.vim
@@ -1,4 +1,7 @@
-" Tests for curswant not changing when setting an option
+" Tests for not changing curswant
+
+source check.vim
+source term_util.vim
func Test_curswant()
new
@@ -19,5 +22,50 @@ func Test_curswant()
let &ttimeoutlen=&ttimeoutlen
call assert_equal(7, winsaveview().curswant)
- enew!
+ bw!
+endfunc
+
+func Test_normal_gm()
+ CheckRunVimInTerminal
+ let lines =<< trim END
+ call setline(1, repeat([" abcd\tefgh\tij"], 10))
+ call cursor(1, 1)
+ END
+ call writefile(lines, 'XtestCurswant', 'D')
+ let buf = RunVimInTerminal('-S XtestCurswant', #{rows: 10})
+ if has("folding")
+ call term_sendkeys(buf, "jVjzf")
+ " gm
+ call term_sendkeys(buf, "gmk")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
+ " g0
+ call term_sendkeys(buf, "jg0k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
+ " g^
+ call term_sendkeys(buf, "jg^k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
+ endif
+ call term_sendkeys(buf, ":call cursor(10, 1)\<cr>")
+ " gm
+ call term_sendkeys(buf, "gmk")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call term_wait(buf)
+ call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
+ " g0
+ call term_sendkeys(buf, "g0k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
+ " g^
+ call term_sendkeys(buf, "g^k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
+ " clean up
+ call StopVimInTerminal(buf)
+ wincmd p
+ wincmd c
endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim
index a448ed9b7f..880286d329 100644
--- a/test/old/testdir/test_diffmode.vim
+++ b/test/old/testdir/test_diffmode.vim
@@ -2007,4 +2007,31 @@ func Test_diff_overlapped_diff_blocks_will_be_merged()
call StopVimInTerminal(buf)
endfunc
+" switching windows in diff mode caused an unnecessary scroll
+func Test_diff_topline_noscroll()
+ CheckScreendump
+
+ let content =<< trim END
+ call setline(1, range(1,60))
+ vnew
+ call setline(1, range(1,10) + range(50,60))
+ windo diffthis
+ norm! G
+ exe "norm! 30\<C-y>"
+ END
+ call writefile(content, 'Xcontent', 'D')
+ let buf = RunVimInTerminal('-S Xcontent', {'rows': 20})
+ call VerifyScreenDump(buf, 'Test_diff_topline_1', {})
+ call term_sendkeys(buf, ":echo line('w0', 1001)\<cr>")
+ call term_wait(buf)
+ call VerifyScreenDump(buf, 'Test_diff_topline_2', {})
+ call term_sendkeys(buf, "\<C-W>p")
+ call term_wait(buf)
+ call VerifyScreenDump(buf, 'Test_diff_topline_3', {})
+ call term_sendkeys(buf, "\<C-W>p")
+ call term_wait(buf)
+ call VerifyScreenDump(buf, 'Test_diff_topline_4', {})
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim
index 037282bf1a..9114cf8b11 100644
--- a/test/old/testdir/test_edit.vim
+++ b/test/old/testdir/test_edit.vim
@@ -2035,7 +2035,7 @@ func Test_edit_browse()
au!
augroup END
- " When the USE_FNAME_CASE is defined this used to cause a crash.
+ " When the CASE_INSENSITIVE_FILENAME is defined this used to cause a crash.
browse enew
bwipe!
diff --git a/test/old/testdir/test_expr.vim b/test/old/testdir/test_expr.vim
index 8871e7e7d7..56a4c3bffa 100644
--- a/test/old/testdir/test_expr.vim
+++ b/test/old/testdir/test_expr.vim
@@ -799,10 +799,10 @@ func Test_expr_completion()
call assert_equal('"echo 1 || g:tvar1 g:tvar2', @:)
" completion for options
- call feedkeys(":echo &compat\<C-A>\<C-B>\"\<CR>", 'xt')
- call assert_equal('"echo &compatible', @:)
- call feedkeys(":echo 1 && &compat\<C-A>\<C-B>\"\<CR>", 'xt')
- call assert_equal('"echo 1 && &compatible', @:)
+ "call feedkeys(":echo &compat\<C-A>\<C-B>\"\<CR>", 'xt')
+ "call assert_equal('"echo &compatible', @:)
+ "call feedkeys(":echo 1 && &compat\<C-A>\<C-B>\"\<CR>", 'xt')
+ "call assert_equal('"echo 1 && &compatible', @:)
call feedkeys(":echo &g:equala\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"echo &g:equalalways', @:)
@@ -883,7 +883,7 @@ func Test_string_interp()
#" String conversion.
call assert_equal('hello from ' .. v:version, $"hello from {v:version}")
call assert_equal('hello from ' .. v:version, $'hello from {v:version}')
- #" Paper over a small difference between VimScript behaviour.
+ #" Paper over a small difference between Vim script behaviour.
call assert_equal(string(v:true), $"{v:true}")
call assert_equal('(1+1=2)', $"(1+1={1 + 1})")
#" Hex-escaped opening brace: char2nr('{') == 0x7b
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index d99656be47..19b7d41552 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -97,8 +97,17 @@ func s:GetFilenameChecks() abort
\ 'ampl': ['file.run'],
\ 'ant': ['build.xml'],
\ 'antlr4': ['parser.g4'],
- \ 'apache': ['.htaccess', '/etc/httpd/file.conf', '/etc/apache2/sites-2/file.com', '/etc/apache2/some.config', '/etc/apache2/conf.file/conf', '/etc/apache2/mods-some/file', '/etc/apache2/sites-some/file', '/etc/httpd/conf.d/file.config', '/etc/apache2/conf.file/file', '/etc/apache2/file.conf', '/etc/apache2/file.conf-file', '/etc/apache2/mods-file/file', '/etc/apache2/sites-file/file', '/etc/apache2/sites-file/file.com', '/etc/httpd/conf.d/file.conf', '/etc/httpd/conf.d/file.conf-file', 'access.conf', 'access.conf-file', 'any/etc/apache2/conf.file/file', 'any/etc/apache2/file.conf', 'any/etc/apache2/file.conf-file', 'any/etc/apache2/mods-file/file', 'any/etc/apache2/sites-file/file', 'any/etc/apache2/sites-file/file.com', 'any/etc/httpd/conf.d/file.conf', 'any/etc/httpd/conf.d/file.conf-file', 'any/etc/httpd/file.conf', 'apache.conf', 'apache.conf-file', 'apache2.conf', 'apache2.conf-file', 'httpd.conf', 'httpd.conf-file', 'srm.conf', 'srm.conf-file', '/etc/httpd/mods-some/file', '/etc/httpd/sites-some/file', '/etc/httpd/conf.file/conf'],
- \ 'apachestyle': ['/etc/proftpd/file.config,/etc/proftpd/conf.file/file', '/etc/proftpd/conf.file/file', '/etc/proftpd/file.conf', '/etc/proftpd/file.conf-file', 'any/etc/proftpd/conf.file/file', 'any/etc/proftpd/file.conf', 'any/etc/proftpd/file.conf-file', 'proftpd.conf', 'proftpd.conf-file'],
+ \ 'apache': ['.htaccess', '/etc/httpd/file.conf', '/etc/apache2/sites-2/file.com', '/etc/apache2/some.config', '/etc/apache2/conf.file/conf',
+ \ '/etc/apache2/mods-some/file', '/etc/apache2/sites-some/file', '/etc/httpd/conf.d/file.config', '/etc/apache2/conf.file/file', '/etc/apache2/file.conf',
+ \ '/etc/apache2/file.conf-file', '/etc/apache2/mods-file/file', '/etc/apache2/sites-file/file', '/etc/apache2/sites-file/file.com',
+ \ '/etc/httpd/conf.d/file.conf', '/etc/httpd/conf.d/file.conf-file', 'access.conf', 'access.conf-file', 'any/etc/apache2/conf.file/file',
+ \ 'any/etc/apache2/file.conf', 'any/etc/apache2/file.conf-file', 'any/etc/apache2/mods-file/file', 'any/etc/apache2/sites-file/file',
+ \ 'any/etc/apache2/sites-file/file.com', 'any/etc/httpd/conf.d/file.conf', 'any/etc/httpd/conf.d/file.conf-file', 'any/etc/httpd/file.conf',
+ \ 'apache.conf', 'apache.conf-file', 'apache2.conf', 'apache2.conf-file', 'httpd.conf', 'httpd.conf-file', 'httpd-some.conf',
+ \ 'httpd-some.conf-file', 'srm.conf', 'srm.conf-file', 'proxy-html.conf', 'proxy-html.conf-file', '/etc/httpd/mods-some/file',
+ \ '/etc/httpd/sites-some/file', '/etc/httpd/conf.file/conf'],
+ \ 'apachestyle': ['/etc/proftpd/file.config,/etc/proftpd/conf.file/file', '/etc/proftpd/conf.file/file', '/etc/proftpd/file.conf', '/etc/proftpd/file.conf-file',
+ \ 'any/etc/proftpd/conf.file/file', 'any/etc/proftpd/file.conf', 'any/etc/proftpd/file.conf-file', 'proftpd.conf', 'proftpd.conf-file'],
\ 'applescript': ['file.scpt'],
\ 'aptconf': ['apt.conf', '/.aptitude/config', 'any/.aptitude/config'],
\ 'arch': ['.arch-inventory', '=tagging-method'],
@@ -125,7 +134,7 @@ func s:GetFilenameChecks() abort
\ 'bib': ['file.bib'],
\ 'bicep': ['file.bicep', 'file.bicepparam'],
\ 'bindzone': ['named.root', '/bind/db.file', '/named/db.file', 'any/bind/db.file', 'any/named/db.file', 'foobar.zone'],
- \ 'bitbake': ['file.bb', 'file.bbappend', 'file.bbclass', 'build/conf/local.conf', 'meta/conf/layer.conf', 'build/conf/bbappend.conf', 'meta-layer/conf/distro/foo.conf'],
+ \ 'bitbake': ['file.bb', 'file.bbappend', 'file.bbclass', 'build/conf/local.conf', 'meta/conf/layer.conf', 'build/conf/bbappend.conf', 'meta-layer/conf/distro/foo.conf', 'project-spec/configs/zynqmp-generic-xczu7ev.conf'],
\ 'blade': ['file.blade.php'],
\ 'blank': ['file.bl'],
\ 'blueprint': ['file.blp'],
@@ -218,7 +227,7 @@ func s:GetFilenameChecks() abort
\ 'dockerfile': ['Containerfile', 'Dockerfile', 'dockerfile', 'file.Dockerfile', 'file.dockerfile', 'Dockerfile.debian', 'Containerfile.something'],
\ 'dosbatch': ['file.bat'],
\ 'dosini': ['/etc/yum.conf', '/etc/nfs.conf', '/etc/nfsmount.conf', 'file.ini',
- \ 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file',
+ \ 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', 'php-fpm.conf', 'php-fpm.conf.default', 'www.conf', 'www.conf.default',
\ '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap',
\ 'file.vbp', 'ja2.ini', 'JA2.INI', 'mimeapps.list', 'pip.conf', 'setup.cfg', 'pudb.cfg',
\ '.coveragerc', '.pypirc', '.gitlint', '.oelint.cfg', 'pylintrc', '.pylintrc',
@@ -230,7 +239,7 @@ func s:GetFilenameChecks() abort
\ 'dracula': ['file.drac', 'file.drc', 'file.lvs', 'file.lpe', 'drac.file'],
\ 'dtd': ['file.dtd'],
\ 'dtrace': ['/usr/lib/dtrace/io.d'],
- \ 'dts': ['file.dts', 'file.dtsi', 'file.dtso', 'file.its', 'file.keymap'],
+ \ 'dts': ['file.dts', 'file.dtsi', 'file.dtso', 'file.its', 'file.keymap', 'file.overlay'],
\ 'dune': ['jbuild', 'dune', 'dune-project', 'dune-workspace', 'dune-file'],
\ 'dylan': ['file.dylan'],
\ 'dylanintr': ['file.intr'],
@@ -349,12 +358,14 @@ func s:GetFilenameChecks() abort
\ 'ibasic': ['file.iba', 'file.ibi'],
\ 'icemenu': ['/.icewm/menu', 'any/.icewm/menu'],
\ 'icon': ['file.icn'],
+ \ 'idris2': ['file.idr'],
\ 'indent': ['.indent.pro', 'indentrc'],
\ 'inform': ['file.inf', 'file.INF'],
\ 'initng': ['/etc/initng/any/file.i', 'file.ii', 'any/etc/initng/any/file.i'],
\ 'inittab': ['inittab'],
\ 'inko': ['file.inko'],
\ 'ipfilter': ['ipf.conf', 'ipf6.conf', 'ipf.rules'],
+ \ 'ipkg': ['file.ipkg'],
\ 'iss': ['file.iss'],
\ 'ist': ['file.ist', 'file.mst'],
\ 'j': ['file.ijs'],
@@ -397,10 +408,13 @@ func s:GetFilenameChecks() abort
\ 'lean': ['file.lean'],
\ 'ledger': ['file.ldg', 'file.ledger', 'file.journal'],
\ 'less': ['file.less'],
+ \ 'leo': ['file.leo'],
\ 'lex': ['file.lex', 'file.l', 'file.lxx', 'file.l++'],
+ \ 'lf': ['lfrc'],
\ 'lftp': ['lftp.conf', '.lftprc', 'anylftp/rc', 'lftp/rc', 'some-lftp/rc'],
\ 'lhaskell': ['file.lhs'],
\ 'libao': ['/etc/libao.conf', '/.libao', 'any/.libao', 'any/etc/libao.conf'],
+ \ 'lidris2': ['file.lidr'],
\ 'lifelines': ['file.ll'],
\ 'lilo': ['lilo.conf', 'lilo.conf-file'],
\ 'lilypond': ['file.ly', 'file.ily'],
@@ -477,6 +491,7 @@ func s:GetFilenameChecks() abort
\ 'mgp': ['file.mgp'],
\ 'mib': ['file.mib', 'file.my'],
\ 'mix': ['file.mix', 'file.mixal'],
+ \ 'mlir': ['file.mlir'],
\ 'mma': ['file.nb', 'file.wl'],
\ 'mmp': ['file.mmp'],
\ 'modconf': ['/etc/modules.conf', '/etc/modules', '/etc/conf.modules', '/etc/modprobe.file', 'any/etc/conf.modules', 'any/etc/modprobe.file', 'any/etc/modules', 'any/etc/modules.conf'],
@@ -489,6 +504,7 @@ func s:GetFilenameChecks() abort
\ 'mplayerconf': ['mplayer.conf', '/.mplayer/config', 'any/.mplayer/config'],
\ 'mrxvtrc': ['mrxvtrc', '.mrxvtrc'],
\ 'msidl': ['file.odl', 'file.mof'],
+ \ 'mss': ['file.mss'],
\ 'msql': ['file.msql'],
\ 'mojo': ['file.mojo', 'file.🔥'],
\ 'msmtp': ['.msmtprc'],
@@ -513,6 +529,7 @@ func s:GetFilenameChecks() abort
\ 'nanorc': ['/etc/nanorc', 'file.nanorc', 'any/etc/nanorc'],
\ 'natural': ['file.NSA', 'file.NSC', 'file.NSG', 'file.NSL', 'file.NSM', 'file.NSN', 'file.NSP', 'file.NSS'],
\ 'ncf': ['file.ncf'],
+ \ 'neomuttlog': ['/home/user/.neomuttdebug1'],
\ 'neomuttrc': ['Neomuttrc', '.neomuttrc', '.neomuttrc-file', '/.neomutt/neomuttrc', '/.neomutt/neomuttrc-file', 'Neomuttrc', 'Neomuttrc-file', 'any/.neomutt/neomuttrc', 'any/.neomutt/neomuttrc-file', 'neomuttrc', 'neomuttrc-file'],
\ 'netrc': ['.netrc'],
\ 'nginx': ['file.nginx', 'nginxfile.conf', 'filenginx.conf', 'any/etc/nginx/file', 'any/usr/local/nginx/conf/file', 'any/nginx/file.conf'],
@@ -659,7 +676,7 @@ func s:GetFilenameChecks() abort
\ '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh',
\ '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile',
\ 'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf', 'file.mdd', 'file.cygport', '.env', '.envrc', 'devscripts.conf',
- \ '.devscripts'],
+ \ '.devscripts', 'file.lo', 'file.la', 'file.lai'],
\ 'sieve': ['file.siv', 'file.sieve'],
\ 'sil': ['file.sil'],
\ 'simula': ['file.sim'],
@@ -714,6 +731,7 @@ func s:GetFilenameChecks() abort
\ 'svelte': ['file.svelte'],
\ 'svg': ['file.svg'],
\ 'svn': ['svn-commitfile.tmp', 'svn-commit-file.tmp', 'svn-commit.tmp'],
+ \ 'sway': ['file.sw'],
\ 'swayconfig': ['/home/user/.sway/config', '/home/user/.config/sway/config', '/etc/sway/config', '/etc/xdg/sway/config'],
\ 'swift': ['file.swift', 'file.swiftinterface'],
\ 'swiftgyb': ['file.swift.gyb'],
@@ -853,7 +871,10 @@ func s:GetFilenameChecks() abort
\ 'xinetd': ['/etc/xinetd.conf', '/etc/xinetd.d/file', 'any/etc/xinetd.conf', 'any/etc/xinetd.d/file'],
\ 'xkb': ['/usr/share/X11/xkb/compat/pc', '/usr/share/X11/xkb/geometry/pc', '/usr/share/X11/xkb/keycodes/evdev', '/usr/share/X11/xkb/symbols/pc', '/usr/share/X11/xkb/types/pc'],
\ 'xmath': ['file.msc', 'file.msf'],
- \ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.fsproj', 'file.fsproj.user', 'file.vbproj', 'file.vbproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old', 'any/etc/xdg/menus/file.menu', 'file.atom', 'file.rss', 'file.cdxml', 'file.psc1', 'file.mpd', 'fonts.conf', 'file.xcu', 'file.xlb', 'file.xlc', 'file.xba', 'file.xpr', 'file.xpfm', 'file.spfm', 'file.bxml'],
+ \ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.fsproj', 'file.fsproj.user', 'file.vbproj', 'file.vbproj.user', 'file.ui',
+ \ 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old',
+ \ 'any/etc/xdg/menus/file.menu', 'file.atom', 'file.rss', 'file.cdxml', 'file.psc1', 'file.mpd', 'fonts.conf', 'file.xcu', 'file.xlb', 'file.xlc', 'file.xba', 'file.xpr',
+ \ 'file.xpfm', 'file.spfm', 'file.bxml', 'file.mmi'],
\ 'xmodmap': ['anyXmodmap', 'Xmodmap', 'some-Xmodmap', 'some-xmodmap', 'some-xmodmap-file', 'xmodmap', 'xmodmap-file'],
\ 'xpm': ['file.xpm'],
\ 'xpm2': ['file.xpm2'],
@@ -862,7 +883,8 @@ func s:GetFilenameChecks() abort
\ 'xsd': ['file.xsd'],
\ 'xslt': ['file.xsl', 'file.xslt'],
\ 'yacc': ['file.yy', 'file.yxx', 'file.y++'],
- \ 'yaml': ['file.yaml', 'file.yml', 'file.eyaml', 'any/.bundle/config', '.clangd', '.clang-format', '.clang-tidy', 'file.mplstyle', 'matplotlibrc', 'yarn.lock'],
+ \ 'yaml': ['file.yaml', 'file.yml', 'file.eyaml', 'any/.bundle/config', '.clangd', '.clang-format', '.clang-tidy', 'file.mplstyle', 'matplotlibrc', 'yarn.lock',
+ \ '/home/user/.kube/config'],
\ 'yang': ['file.yang'],
\ 'yuck': ['file.yuck'],
\ 'z8a': ['file.z8a'],
@@ -2419,6 +2441,24 @@ func Test_inc_file()
filetype off
endfunc
+func Test_ll_file()
+ filetype on
+
+ " LLVM IR
+ call writefile(['target triple = "nvptx64-nvidia-cuda"'], 'Xfile.ll', 'D')
+ split Xfile.ll
+ call assert_equal('llvm', &filetype)
+ bwipe!
+
+ " lifelines
+ call writefile(['proc main() {}'], 'Xfile.ll', 'D')
+ split Xfile.ll
+ call assert_equal('lifelines', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_lsl_file()
filetype on
@@ -2697,4 +2737,15 @@ func Test_make_file()
filetype off
endfunc
+func Test_org_file()
+ filetype on
+
+ call writefile(['* org Headline', '*some bold text*', '/some italic text/'], 'Xfile.org', 'D')
+ split Xfile.org
+ call assert_equal('org', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_findfile.vim b/test/old/testdir/test_findfile.vim
index 06d781ed69..539c7a661a 100644
--- a/test/old/testdir/test_findfile.vim
+++ b/test/old/testdir/test_findfile.vim
@@ -1,5 +1,8 @@
" Test findfile() and finddir()
+source check.vim
+source vim9.vim
+
let s:files = [ 'Xfinddir1/foo',
\ 'Xfinddir1/bar',
\ 'Xfinddir1/Xdir2/foo',
@@ -286,4 +289,526 @@ func Test_find_non_existing_path()
let &path = save_path
endfunc
+" Test for 'findfunc'
+func Test_findfunc()
+ CheckUnix
+ call assert_equal('', &findfunc)
+ call writefile(['aFile'], 'Xfindfunc1.c', 'D')
+ call writefile(['bFile'], 'Xfindfunc2.c', 'D')
+ call writefile(['cFile'], 'Xfindfunc3.c', 'D')
+
+ " basic tests
+ func FindFuncBasic(pat, cmdcomplete)
+ let fnames = ['Xfindfunc1.c', 'Xfindfunc2.c', 'Xfindfunc3.c']
+ return fnames->copy()->filter('v:val =~? a:pat')
+ endfunc
+
+ set findfunc=FindFuncBasic
+ find Xfindfunc3
+ call assert_match('Xfindfunc3.c', @%)
+ bw!
+ 2find Xfind
+ call assert_match('Xfindfunc2.c', @%)
+ bw!
+ call assert_fails('4find Xfind', 'E347: No more file "Xfind" found in path')
+ call assert_fails('find foobar', 'E345: Can''t find file "foobar" in path')
+
+ sfind Xfindfunc2.c
+ call assert_match('Xfindfunc2.c', @%)
+ call assert_equal(2, winnr('$'))
+ %bw!
+ call assert_fails('sfind foobar', 'E345: Can''t find file "foobar" in path')
+
+ tabfind Xfindfunc3.c
+ call assert_match('Xfindfunc3.c', @%)
+ call assert_equal(2, tabpagenr())
+ %bw!
+ call assert_fails('tabfind foobar', 'E345: Can''t find file "foobar" in path')
+
+ " Test garbage collection
+ call test_garbagecollect_now()
+ find Xfindfunc2
+ call assert_match('Xfindfunc2.c', @%)
+ bw!
+ delfunc FindFuncBasic
+ call test_garbagecollect_now()
+ call assert_fails('find Xfindfunc2', 'E117: Unknown function: FindFuncBasic')
+
+ " Buffer-local option
+ func GlobalFindFunc(pat, cmdcomplete)
+ return ['global']
+ endfunc
+ func LocalFindFunc(pat, cmdcomplete)
+ return ['local']
+ endfunc
+ set findfunc=GlobalFindFunc
+ new
+ setlocal findfunc=LocalFindFunc
+ find xxxx
+ call assert_equal('local', @%)
+ wincmd w
+ find xxxx
+ call assert_equal('global', @%)
+ aboveleft new
+ call assert_equal("GlobalFindFunc", &findfunc)
+ wincmd k
+ aboveleft new
+ call assert_equal("GlobalFindFunc", &findfunc)
+ %bw!
+ delfunc GlobalFindFunc
+ delfunc LocalFindFunc
+
+ " Assign an expression
+ set findfunc=[]
+ call assert_fails('find xxxx', 'E117: Unknown function: []')
+
+ " Error cases
+
+ " Function that doesn't take any arguments
+ func FindFuncNoArg()
+ endfunc
+ set findfunc=FindFuncNoArg
+ call assert_fails('find Xfindfunc1.c', 'E118: Too many arguments for function: FindFuncNoArg')
+ delfunc FindFuncNoArg
+
+ " Syntax error in the function
+ func FindFuncSyntaxError(pat, cmdcomplete)
+ return l
+ endfunc
+ set findfunc=FindFuncSyntaxError
+ call assert_fails('find Xfindfunc1.c', 'E121: Undefined variable: l')
+ delfunc FindFuncSyntaxError
+
+ " Find function throws an error
+ func FindFuncWithThrow(pat, cmdcomplete)
+ throw 'find error'
+ endfunc
+ set findfunc=FindFuncWithThrow
+ call assert_fails('find Xfindfunc1.c', 'find error')
+ delfunc FindFuncWithThrow
+
+ " Try using a null function
+ "call assert_fails('let &findfunc = test_null_function()', 'E129: Function name required')
+
+ " Try to create a new window from the find function
+ func FindFuncNewWindow(pat, cmdexpand)
+ new
+ return ["foo"]
+ endfunc
+ set findfunc=FindFuncNewWindow
+ call assert_fails('find Xfindfunc1.c', 'E565: Not allowed to change text or change window')
+ delfunc FindFuncNewWindow
+
+ " Try to modify the current buffer from the find function
+ func FindFuncModifyBuf(pat, cmdexpand)
+ call setline(1, ['abc'])
+ return ["foo"]
+ endfunc
+ set findfunc=FindFuncModifyBuf
+ call assert_fails('find Xfindfunc1.c', 'E565: Not allowed to change text or change window')
+ delfunc FindFuncModifyBuf
+
+ " Return the wrong type from the function
+ func FindFuncWrongRet(pat, cmdexpand)
+ return 'foo'
+ endfunc
+ set findfunc=FindFuncWrongRet
+ call assert_fails('find Xfindfunc1.c', "E1514: 'findfunc' did not return a List type")
+ delfunc FindFuncWrongRet
+
+ set findfunc&
+endfunc
+
+" Test for using a script-local function for 'findfunc'
+func Test_findfunc_scriptlocal_func()
+ func! s:FindFuncScript(pat, cmdexpand)
+ let g:FindFuncArg = a:pat
+ return ['xxx']
+ endfunc
+
+ set findfunc=s:FindFuncScript
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ new | only
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ set findfunc=<SID>FindFuncScript
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ new | only
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ let &findfunc = 's:FindFuncScript'
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ new | only
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ let &findfunc = '<SID>FindFuncScript'
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ new | only
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ set findfunc=
+ setglobal findfunc=s:FindFuncScript
+ setlocal findfunc=
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ call assert_equal('', &l:findfunc)
+ new | only
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ new | only
+ set findfunc=
+ setglobal findfunc=
+ setlocal findfunc=s:FindFuncScript
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &l:findfunc)
+ call assert_equal('', &g:findfunc)
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ new | only
+ set findfunc=
+ setlocal findfunc=NoSuchFunc
+ setglobal findfunc=s:FindFuncScript
+ call assert_equal('NoSuchFunc', &findfunc)
+ call assert_equal('NoSuchFunc', &l:findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ new | only
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ call assert_equal('', &l:findfunc)
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ new | only
+ set findfunc=
+ setlocal findfunc=NoSuchFunc
+ set findfunc=s:FindFuncScript
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ call assert_equal('', &l:findfunc)
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ new | only
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
+ call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
+ call assert_equal('', &l:findfunc)
+ let g:FindFuncArg = ''
+ find abc
+ call assert_equal('abc', g:FindFuncArg)
+ bw!
+
+ set findfunc=
+ delfunc s:FindFuncScript
+endfunc
+
+" Test for expanding the argument to the :find command using 'findfunc'
+func Test_findfunc_expand_arg()
+ let s:fnames = ['Xfindfunc1.c', 'Xfindfunc2.c', 'Xfindfunc3.c']
+
+ " 'findfunc' that accepts a regular expression
+ func FindFuncRegexp(pat, cmdcomplete)
+ return s:fnames->copy()->filter('v:val =~? a:pat')
+ endfunc
+
+ " 'findfunc' that accepts a glob
+ func FindFuncGlob(pat_arg, cmdcomplete)
+ let pat = glob2regpat(a:cmdcomplete ? $'*{a:pat_arg}*' : a:pat_arg)
+ return s:fnames->copy()->filter('v:val =~? pat')
+ endfunc
+
+ for regexp in [v:true, v:false]
+ let &findfunc = regexp ? 'FindFuncRegexp' : 'FindFuncGlob'
+
+ call feedkeys(":find \<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindfunc1.c', @:)
+
+ call feedkeys(":find Xfind\<Tab>\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindfunc2.c', @:)
+
+ call assert_equal(s:fnames, getcompletion('find ', 'cmdline'))
+ call assert_equal(s:fnames, getcompletion('find Xfind', 'cmdline'))
+
+ let pat = regexp ? 'X.*1\.c' : 'X*1.c'
+ call feedkeys($":find {pat}\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindfunc1.c', @:)
+ call assert_equal(['Xfindfunc1.c'], getcompletion($'find {pat}', 'cmdline'))
+
+ call feedkeys(":find 3\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindfunc3.c', @:)
+ call assert_equal(['Xfindfunc3.c'], getcompletion($'find 3', 'cmdline'))
+
+ call feedkeys(":find Xfind\<C-A>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find Xfindfunc1.c Xfindfunc2.c Xfindfunc3.c', @:)
+
+ call feedkeys(":find abc\<Tab>\<C-B>\"\<CR>", "xt")
+ call assert_equal('"find abc', @:)
+ call assert_equal([], getcompletion('find abc', 'cmdline'))
+ endfor
+
+ set findfunc&
+ delfunc! FindFuncRegexp
+ delfunc! FindFuncGlob
+ unlet s:fnames
+endfunc
+
+" Test for different ways of setting the 'findfunc' option
+func Test_findfunc_callback()
+ new
+ func FindFunc1(pat, cmdexpand)
+ let g:FindFunc1Args = [a:pat, a:cmdexpand]
+ return ['findfunc1']
+ endfunc
+
+ let lines =<< trim END
+ #" Test for using a function name
+ LET &findfunc = 'g:FindFunc1'
+ LET g:FindFunc1Args = []
+ find abc1
+ call assert_equal(['abc1', v:false], g:FindFunc1Args)
+
+ #" Test for using a function()
+ set findfunc=function('g:FindFunc1')
+ LET g:FindFunc1Args = []
+ find abc2
+ call assert_equal(['abc2', v:false], g:FindFunc1Args)
+
+ #" Using a funcref variable to set 'findfunc'
+ VAR Fn = function('g:FindFunc1')
+ LET &findfunc = Fn
+ LET g:FindFunc1Args = []
+ find abc3
+ call assert_equal(['abc3', v:false], g:FindFunc1Args)
+
+ #" Using a string(funcref_variable) to set 'findfunc'
+ LET Fn = function('g:FindFunc1')
+ LET &findfunc = string(Fn)
+ LET g:FindFunc1Args = []
+ find abc4
+ call assert_equal(['abc4', v:false], g:FindFunc1Args)
+
+ #" Test for using a funcref()
+ set findfunc=funcref('g:FindFunc1')
+ LET g:FindFunc1Args = []
+ find abc5
+ call assert_equal(['abc5', v:false], g:FindFunc1Args)
+
+ #" Using a funcref variable to set 'findfunc'
+ LET Fn = funcref('g:FindFunc1')
+ LET &findfunc = Fn
+ LET g:FindFunc1Args = []
+ find abc6
+ call assert_equal(['abc6', v:false], g:FindFunc1Args)
+
+ #" Using a string(funcref_variable) to set 'findfunc'
+ LET Fn = funcref('g:FindFunc1')
+ LET &findfunc = string(Fn)
+ LET g:FindFunc1Args = []
+ find abc7
+ call assert_equal(['abc7', v:false], g:FindFunc1Args)
+
+ #" Test for using a lambda function using set
+ VAR optval = "LSTART pat, cmdexpand LMIDDLE FindFunc1(pat, cmdexpand) LEND"
+ LET optval = substitute(optval, ' ', '\\ ', 'g')
+ exe "set findfunc=" .. optval
+ LET g:FindFunc1Args = []
+ find abc8
+ call assert_equal(['abc8', v:false], g:FindFunc1Args)
+
+ #" Test for using a lambda function using LET
+ LET &findfunc = LSTART pat, _ LMIDDLE FindFunc1(pat, v:false) LEND
+ LET g:FindFunc1Args = []
+ find abc9
+ call assert_equal(['abc9', v:false], g:FindFunc1Args)
+
+ #" Set 'findfunc' to a string(lambda expression)
+ LET &findfunc = 'LSTART pat, _ LMIDDLE FindFunc1(pat, v:false) LEND'
+ LET g:FindFunc1Args = []
+ find abc10
+ call assert_equal(['abc10', v:false], g:FindFunc1Args)
+
+ #" Set 'findfunc' to a variable with a lambda expression
+ VAR Lambda = LSTART pat, _ LMIDDLE FindFunc1(pat, v:false) LEND
+ LET &findfunc = Lambda
+ LET g:FindFunc1Args = []
+ find abc11
+ call assert_equal(['abc11', v:false], g:FindFunc1Args)
+
+ #" Set 'findfunc' to a string(variable with a lambda expression)
+ LET Lambda = LSTART pat, _ LMIDDLE FindFunc1(pat, v:false) LEND
+ LET &findfunc = string(Lambda)
+ LET g:FindFunc1Args = []
+ find abc12
+ call assert_equal(['abc12', v:false], g:FindFunc1Args)
+
+ #" Try to use 'findfunc' after the function is deleted
+ func g:TmpFindFunc(pat, cmdexpand)
+ let g:TmpFindFunc1Args = [a:pat, a:cmdexpand]
+ endfunc
+ LET &findfunc = function('g:TmpFindFunc')
+ delfunc g:TmpFindFunc
+ call test_garbagecollect_now()
+ LET g:TmpFindFunc1Args = []
+ call assert_fails('find abc13', 'E117:')
+ call assert_equal([], g:TmpFindFunc1Args)
+
+ #" Try to use a function with three arguments for 'findfunc'
+ func g:TmpFindFunc2(x, y, z)
+ let g:TmpFindFunc2Args = [a:x, a:y, a:z]
+ endfunc
+ set findfunc=TmpFindFunc2
+ LET g:TmpFindFunc2Args = []
+ call assert_fails('find abc14', 'E119:')
+ call assert_equal([], g:TmpFindFunc2Args)
+ delfunc TmpFindFunc2
+
+ #" Try to use a function with zero arguments for 'findfunc'
+ func g:TmpFindFunc3()
+ let g:TmpFindFunc3Called = v:true
+ endfunc
+ set findfunc=TmpFindFunc3
+ LET g:TmpFindFunc3Called = v:false
+ call assert_fails('find abc15', 'E118:')
+ call assert_equal(v:false, g:TmpFindFunc3Called)
+ delfunc TmpFindFunc3
+
+ #" Try to use a lambda function with three arguments for 'findfunc'
+ LET &findfunc = LSTART a, b, c LMIDDLE FindFunc1(a, v:false) LEND
+ LET g:FindFunc1Args = []
+ call assert_fails('find abc16', 'E119:')
+ call assert_equal([], g:FindFunc1Args)
+
+ #" Test for clearing the 'findfunc' option
+ set findfunc=''
+ set findfunc&
+ call assert_fails("set findfunc=function('abc')", "E700:")
+ call assert_fails("set findfunc=funcref('abc')", "E700:")
+
+ #" set 'findfunc' to a non-existing function
+ LET &findfunc = function('g:FindFunc1')
+ call assert_fails("set findfunc=function('NonExistingFunc')", 'E700:')
+ call assert_fails("LET &findfunc = function('NonExistingFunc')", 'E700:')
+ LET g:FindFunc1Args = []
+ find abc17
+ call assert_equal(['abc17', v:false], g:FindFunc1Args)
+ END
+ call CheckTransLegacySuccess(lines)
+
+ " Test for using a script-local function name
+ func s:FindFunc2(pat, cmdexpand)
+ let g:FindFunc2Args = [a:pat, a:cmdexpand]
+ return ['findfunc2']
+ endfunc
+ set findfunc=s:FindFunc2
+ let g:FindFunc2Args = []
+ find abc18
+ call assert_equal(['abc18', v:false], g:FindFunc2Args)
+
+ let &findfunc = 's:FindFunc2'
+ let g:FindFunc2Args = []
+ find abc19
+ call assert_equal(['abc19', v:false], g:FindFunc2Args)
+ delfunc s:FindFunc2
+
+ " Using Vim9 lambda expression in legacy context should fail
+ set findfunc=(pat,\ cmdexpand)\ =>\ FindFunc1(pat,\ v:false)
+ let g:FindFunc1Args = []
+ call assert_fails('find abc20', 'E117:')
+ call assert_equal([], g:FindFunc1Args)
+
+ " set 'findfunc' to a partial with dict.
+ func SetFindFunc()
+ let operator = {'execute': function('FindFuncExecute')}
+ let &findfunc = operator.execute
+ endfunc
+ func FindFuncExecute(pat, cmdexpand) dict
+ return ['findfuncexecute']
+ endfunc
+ call SetFindFunc()
+ call test_garbagecollect_now()
+ set findfunc=
+ delfunc SetFindFunc
+ delfunc FindFuncExecute
+
+ func FindFunc2(pat, cmdexpand)
+ let g:FindFunc2Args = [a:pat, a:cmdexpand]
+ return ['findfunc2']
+ endfunc
+
+ " Vim9 tests
+ let lines =<< trim END
+ vim9script
+
+ def g:Vim9findFunc(pat: string, cmdexpand: bool): list<string>
+ g:FindFunc1Args = [pat, cmdexpand]
+ return ['vim9findfunc']
+ enddef
+
+ # Test for using a def function with findfunc
+ set findfunc=function('g:Vim9findFunc')
+ g:FindFunc1Args = []
+ find abc21
+ assert_equal(['abc21', false], g:FindFunc1Args)
+
+ # Test for using a global function name
+ &findfunc = g:FindFunc2
+ g:FindFunc2Args = []
+ find abc22
+ assert_equal(['abc22', false], g:FindFunc2Args)
+ bw!
+
+ # Test for using a script-local function name
+ def LocalFindFunc(pat: string, cmdexpand: bool): list<string>
+ g:LocalFindFuncArgs = [pat, cmdexpand]
+ return ['localfindfunc']
+ enddef
+ &findfunc = LocalFindFunc
+ g:LocalFindFuncArgs = []
+ find abc23
+ assert_equal(['abc23', false], g:LocalFindFuncArgs)
+ bw!
+ END
+ call CheckScriptSuccess(lines)
+
+ " setting 'findfunc' to a script local function outside of a script context
+ " should fail
+ let cleanup =<< trim END
+ call writefile([execute('messages')], 'Xtest.out')
+ qall
+ END
+ call writefile(cleanup, 'Xverify.vim', 'D')
+ call RunVim([], [], "-c \"set findfunc=s:abc\" -S Xverify.vim")
+ call assert_match('E81: Using <SID> not in a', readfile('Xtest.out')[0])
+ call delete('Xtest.out')
+
+ " cleanup
+ set findfunc&
+ delfunc FindFunc1
+ delfunc FindFunc2
+ unlet g:FindFunc1Args g:FindFunc2Args
+ %bw!
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index ffe7f3fb39..327ea98e1c 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -272,17 +272,17 @@ func Test_strftime()
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')
+ " Force different time zones, save the current hour (24-hour clock) for each
+ let $TZ = 'GMT+1' | let one = strftime('%H')
+ let $TZ = 'GMT+2' | let two = 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)
+ call assert_equal(strlen(one), 2)
+ call assert_equal(strlen(two), 2)
" TODO: this fails on MS-Windows
if has('unix')
- call assert_notequal(est, utc)
+ call assert_notequal(one, two)
endif
" If we cached a timezone value, put it back, otherwise clear it
@@ -383,6 +383,12 @@ func Test_simplify()
call assert_equal('/', simplify('/.'))
call assert_equal('/', simplify('/..'))
call assert_equal('/...', simplify('/...'))
+ call assert_equal('//path', simplify('//path'))
+ if has('unix')
+ call assert_equal('/path', simplify('///path'))
+ call assert_equal('/path', simplify('////path'))
+ endif
+
call assert_equal('./dir/file', './dir/file'->simplify())
call assert_equal('./dir/file', simplify('.///dir//file'))
call assert_equal('./dir/file', simplify('./dir/./file'))
@@ -2069,6 +2075,7 @@ endfunc
" Test for the inputdialog() function
func Test_inputdialog()
+ set timeout timeoutlen=10
if has('gui_running')
call assert_fails('let v=inputdialog([], "xx")', 'E730:')
call assert_fails('let v=inputdialog("Q", [])', 'E730:')
@@ -2078,6 +2085,7 @@ func Test_inputdialog()
call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<Esc>", 'xt')
call assert_equal('yy', v)
endif
+ set timeout& timeoutlen&
endfunc
" Test for inputlist()
@@ -3089,7 +3097,7 @@ func Test_range()
call assert_fails('call term_start(range(3, 4))', 'E474:')
let g:terminal_ansi_colors = range(16)
if has('win32')
- let cmd = "cmd /c dir"
+ let cmd = "cmd /D /c dir"
else
let cmd = "ls"
endif
diff --git a/test/old/testdir/test_getvar.vim b/test/old/testdir/test_getvar.vim
index 56f737ab9c..de00281ba3 100644
--- a/test/old/testdir/test_getvar.vim
+++ b/test/old/testdir/test_getvar.vim
@@ -22,6 +22,12 @@ func Test_var()
call assert_equal('Chance', getwinvar(9, '', def_str))
call assert_equal(0, getwinvar(1, '&nu'))
call assert_equal(0, getwinvar(1, '&nu', 1))
+ call assert_match(v:t_dict, type(getwinvar(1, '&')))
+ call assert_match(v:t_dict, type(getwinvar(1, '&', def_str)))
+ call assert_equal('', getwinvar(9, '&'))
+ call assert_equal('Chance', getwinvar(9, '&', def_str))
+ call assert_equal('', getwinvar(1, '&nux'))
+ call assert_equal('Chance', getwinvar(1, '&nux', def_str))
unlet def_str
" test for gettabvar()
@@ -83,7 +89,12 @@ func Test_var()
unlet def_dict
+ call assert_match(v:t_dict, type(gettabwinvar(2, 3, '&')))
+ call assert_match(v:t_dict, type(gettabwinvar(2, 3, '&', 1)))
call assert_equal("", gettabwinvar(9, 2020, ''))
+ call assert_equal(1, gettabwinvar(9, 2020, '', 1))
+ call assert_equal('', gettabwinvar(9, 2020, '&'))
+ call assert_equal(1, gettabwinvar(9, 2020, '&', 1))
call assert_equal('', gettabwinvar(2, 3, '&nux'))
call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
tabonly
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
index 48319f5017..c02aa1db62 100644
--- a/test/old/testdir/test_ins_complete.vim
+++ b/test/old/testdir/test_ins_complete.vim
@@ -950,6 +950,46 @@ func Test_completeopt_buffer_local()
call assert_equal('menu', &completeopt)
call assert_equal('menu', &g:completeopt)
+ new | only
+ call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+ set completeopt&
+ setlocal completeopt=menu,fuzzy,noinsert
+ setglobal completeopt=menu,longest
+ call assert_equal('menu,fuzzy,noinsert', &completeopt)
+ call assert_equal('menu,fuzzy,noinsert', &l:completeopt)
+ call assert_equal('menu,longest', &g:completeopt)
+ call feedkeys("Gccf\<C-X>\<C-N>bz\<C-Y>", 'tnix')
+ call assert_equal('foobaz', getline('.'))
+ setlocal bufhidden=wipe
+ new | only!
+ call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+ call assert_equal('menu,longest', &completeopt)
+ call assert_equal('menu,longest', &g:completeopt)
+ call assert_equal('', &l:completeopt)
+ call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
+ call assert_equal('foo', getline('.'))
+ bwipe!
+
+ new | only
+ call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+ set completeopt&
+ setlocal completeopt=menu,fuzzy,noinsert
+ set completeopt=menu,longest
+ call assert_equal('menu,longest', &completeopt)
+ call assert_equal('menu,longest', &g:completeopt)
+ call assert_equal('', &l:completeopt)
+ call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
+ call assert_equal('foo', getline('.'))
+ setlocal bufhidden=wipe
+ new | only!
+ call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+ call assert_equal('menu,longest', &completeopt)
+ call assert_equal('menu,longest', &g:completeopt)
+ call assert_equal('', &l:completeopt)
+ call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
+ call assert_equal('foo', getline('.'))
+ bwipe!
+
set completeopt&
endfunc
@@ -1713,10 +1753,10 @@ func Test_completefunc_callback()
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
" Using Vim9 lambda expression in legacy context should fail
- " set completefunc=(a,\ b)\ =>\ CompleteFunc1(21,\ a,\ b)
+ set completefunc=(a,\ b)\ =>\ CompleteFunc1(21,\ a,\ b)
new | only
let g:CompleteFunc1Args = []
- " call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
+ call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
call assert_equal([], g:CompleteFunc1Args)
" set 'completefunc' to a partial with dict. This used to cause a crash.
@@ -1970,10 +2010,10 @@ func Test_omnifunc_callback()
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
" Using Vim9 lambda expression in legacy context should fail
- " set omnifunc=(a,\ b)\ =>\ OmniFunc1(21,\ a,\ b)
+ set omnifunc=(a,\ b)\ =>\ OmniFunc1(21,\ a,\ b)
new | only
let g:OmniFunc1Args = []
- " call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:')
+ call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:')
call assert_equal([], g:OmniFunc1Args)
" set 'omnifunc' to a partial with dict. This used to cause a crash.
@@ -2228,6 +2268,7 @@ func Test_thesaurusfunc_callback()
call add(g:TsrFunc3Args, [a:findstart, a:base])
return a:findstart ? 0 : []
endfunc
+
set tsrfu=s:TsrFunc3
new
call setline(1, 'script1')
@@ -2243,6 +2284,46 @@ func Test_thesaurusfunc_callback()
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
call assert_equal([[1, ''], [0, 'script2']], g:TsrFunc3Args)
bw!
+
+ new | only
+ set thesaurusfunc=
+ setlocal thesaurusfunc=NoSuchFunc
+ setglobal thesaurusfunc=s:TsrFunc3
+ call assert_equal('NoSuchFunc', &thesaurusfunc)
+ call assert_equal('NoSuchFunc', &l:thesaurusfunc)
+ call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
+ new | only
+ call assert_equal('s:TsrFunc3', &thesaurusfunc)
+ call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
+ call assert_equal('', &l:thesaurusfunc)
+ call setline(1, 'script1')
+ let g:TsrFunc3Args = []
+ call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
+ call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
+ bw!
+
+ new | only
+ set thesaurusfunc=
+ setlocal thesaurusfunc=NoSuchFunc
+ set thesaurusfunc=s:TsrFunc3
+ call assert_equal('s:TsrFunc3', &thesaurusfunc)
+ call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
+ call assert_equal('', &l:thesaurusfunc)
+ call setline(1, 'script1')
+ let g:TsrFunc3Args = []
+ call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
+ call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
+ setlocal bufhidden=wipe
+ new | only!
+ call assert_equal('s:TsrFunc3', &thesaurusfunc)
+ call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
+ call assert_equal('', &l:thesaurusfunc)
+ call setline(1, 'script1')
+ let g:TsrFunc3Args = []
+ call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
+ call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
+ bw!
+
delfunc s:TsrFunc3
" invalid return value
@@ -2250,10 +2331,10 @@ func Test_thesaurusfunc_callback()
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
" Using Vim9 lambda expression in legacy context should fail
- " set thesaurusfunc=(a,\ b)\ =>\ TsrFunc1(21,\ a,\ b)
+ set thesaurusfunc=(a,\ b)\ =>\ TsrFunc1(21,\ a,\ b)
new | only
let g:TsrFunc1Args = []
- " call assert_fails('call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")', 'E117:')
+ call assert_fails('call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")', 'E117:')
call assert_equal([], g:TsrFunc1Args)
bw!
diff --git a/test/old/testdir/test_map_functions.vim b/test/old/testdir/test_map_functions.vim
index 8f7c8bae76..5118063b36 100644
--- a/test/old/testdir/test_map_functions.vim
+++ b/test/old/testdir/test_map_functions.vim
@@ -527,6 +527,25 @@ func Test_map_restore_negative_sid()
call delete('Xresult')
endfunc
+" Check that restoring a mapping doesn't remove a mapping whose {rhs} matches
+" the restored mapping's {lhs}.
+func Test_map_restore_with_rhs_match_lhs()
+ nnoremap <F2> <F3>
+ nnoremap <F3> <F4>
+ call assert_equal('<F3>', maparg('<F2>', 'n'))
+ call assert_equal('<F4>', maparg('<F3>', 'n'))
+ let d = maparg('<F3>', 'n', v:false, v:true)
+ nunmap <F3>
+ call assert_equal('<F3>', maparg('<F2>', 'n'))
+ call assert_equal('', maparg('<F3>', 'n'))
+ call mapset(d)
+ call assert_equal('<F3>', maparg('<F2>', 'n'))
+ call assert_equal('<F4>', maparg('<F3>', 'n'))
+
+ nunmap <F2>
+ nunmap <F3>
+endfunc
+
func Test_maplist()
new
func s:ClearMappingsAbbreviations()
diff --git a/test/old/testdir/test_mapping.vim b/test/old/testdir/test_mapping.vim
index e4e446c55c..96fa0304dc 100644
--- a/test/old/testdir/test_mapping.vim
+++ b/test/old/testdir/test_mapping.vim
@@ -6,33 +6,62 @@ source screendump.vim
source term_util.vim
func Test_abbreviation()
+ new
" abbreviation with 0x80 should work
inoreab чкпр vim
call feedkeys("Goчкпр \<Esc>", "xt")
call assert_equal('vim ', getline('$'))
iunab чкпр
- set nomodified
+ bwipe!
+endfunc
+
+func Test_abbreviation_with_noremap()
+ nnoremap <F2> :echo "cheese"
+ cabbr cheese xxx
+ call feedkeys(":echo \"cheese\"\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"echo "xxx"', @:)
+ call feedkeys("\<F2>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"echo "cheese"', @:)
+ nnoremap <F2> :echo "cheese<C-]>"
+ call feedkeys("\<F2>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"echo "xxx"', @:)
+ nunmap <F2>
+ cunabbr cheese
+
+ new
+ inoremap <buffer> ( <C-]>()
+ iabbr <buffer> fnu fun
+ call feedkeys("ifnu(", 'tx')
+ call assert_equal('fun()', getline(1))
+ bwipe!
endfunc
func Test_abclear()
- abbrev foo foobar
- iabbrev fooi foobari
- cabbrev fooc foobarc
- call assert_equal("\n\nc fooc foobarc\ni fooi foobari\n! foo foobar", execute('abbrev'))
+ abbrev foo foobar
+ iabbrev fooi foobari
+ cabbrev fooc foobarc
+ call assert_equal("\n\n"
+ \ .. "c fooc foobarc\n"
+ \ .. "i fooi foobari\n"
+ \ .. "! foo foobar", execute('abbrev'))
- iabclear
- call assert_equal("\n\nc fooc foobarc\nc foo foobar", execute('abbrev'))
- abbrev foo foobar
- iabbrev fooi foobari
+ iabclear
+ call assert_equal("\n\n"
+ \ .. "c fooc foobarc\n"
+ \ .. "c foo foobar", execute('abbrev'))
+ abbrev foo foobar
+ iabbrev fooi foobari
- cabclear
- call assert_equal("\n\ni fooi foobari\ni foo foobar", execute('abbrev'))
- abbrev foo foobar
- cabbrev fooc foobarc
+ cabclear
+ call assert_equal("\n\n"
+ \ .. "i fooi foobari\n"
+ \ .. "i foo foobar", execute('abbrev'))
+ abbrev foo foobar
+ cabbrev fooc foobarc
- abclear
- call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
- call assert_fails('%abclear', 'E481:')
+ abclear
+ call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
+ call assert_fails('%abclear', 'E481:')
endfunc
func Test_abclear_buffer()
@@ -42,18 +71,24 @@ func Test_abclear_buffer()
new X2
abbrev <buffer> foo2 foobar2
- call assert_equal("\n\n! foo2 @foobar2\n! foo foobar", execute('abbrev'))
+ call assert_equal("\n\n"
+ \ .. "! foo2 @foobar2\n"
+ \ .. "! foo foobar", execute('abbrev'))
abclear <buffer>
- call assert_equal("\n\n! foo foobar", execute('abbrev'))
+ call assert_equal("\n\n"
+ \ .. "! foo foobar", execute('abbrev'))
b X1
- call assert_equal("\n\n! foo1 @foobar1\n! foo foobar", execute('abbrev'))
+ call assert_equal("\n\n"
+ \ .. "! foo1 @foobar1\n"
+ \ .. "! foo foobar", execute('abbrev'))
abclear <buffer>
- call assert_equal("\n\n! foo foobar", execute('abbrev'))
+ call assert_equal("\n\n"
+ \ .. "! foo foobar", execute('abbrev'))
abclear
- call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
+ call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
%bwipe
endfunc
diff --git a/test/old/testdir/test_modeline.vim b/test/old/testdir/test_modeline.vim
index 487a89e038..2cd9e49a12 100644
--- a/test/old/testdir/test_modeline.vim
+++ b/test/old/testdir/test_modeline.vim
@@ -217,6 +217,7 @@ func Test_modeline_fails_always()
call s:modeline_fails('equalprg', 'equalprg=Something()', 'E520:')
call s:modeline_fails('errorfile', 'errorfile=Something()', 'E520:')
call s:modeline_fails('exrc', 'exrc=Something()', 'E520:')
+ call s:modeline_fails('findfunc', 'findfunc=Something', 'E520:')
call s:modeline_fails('formatprg', 'formatprg=Something()', 'E520:')
call s:modeline_fails('fsync', 'fsync=Something()', 'E520:')
call s:modeline_fails('grepprg', 'grepprg=Something()', 'E520:')
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index 46fddd6c1a..c89e73bada 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -692,9 +692,9 @@ func Test_opfunc_callback()
delfunc s:OpFunc3
" Using Vim9 lambda expression in legacy context should fail
- " set opfunc=(a)\ =>\ OpFunc1(24,\ a)
+ set opfunc=(a)\ =>\ OpFunc1(24,\ a)
let g:OpFunc1Args = []
- " call assert_fails('normal! g@l', 'E117:')
+ call assert_fails('normal! g@l', 'E117:')
call assert_equal([], g:OpFunc1Args)
" set 'operatorfunc' to a partial with dict. This used to cause a crash.
@@ -3958,8 +3958,7 @@ func Test_mouse_shape_after_failed_change()
END
call writefile(lines, 'Xmouseshape.vim', 'D')
call RunVim([], [], "-g -S Xmouseshape.vim")
- sleep 300m
- call assert_equal(['busy', 'arrow'], readfile('Xmouseshapes'))
+ call WaitForAssert({-> assert_equal(['busy', 'arrow'], readfile('Xmouseshapes'))}, 300)
call delete('Xmouseshapes')
endfunc
@@ -3990,8 +3989,7 @@ func Test_mouse_shape_after_cancelling_gr()
END
call writefile(lines, 'Xmouseshape.vim', 'D')
call RunVim([], [], "-g -S Xmouseshape.vim")
- sleep 300m
- call assert_equal(['beam', 'arrow'], readfile('Xmouseshapes'))
+ call WaitForAssert({-> assert_equal(['beam', 'arrow'], readfile('Xmouseshapes'))}, 300)
call delete('Xmouseshapes')
endfunc
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index d0ae33605b..b6bdb1be52 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -1,8 +1,11 @@
" Test for options
+source shared.vim
source check.vim
source view_util.vim
+scriptencoding utf-8
+
func Test_whichwrap()
set whichwrap=b,s
call assert_equal('b,s', &whichwrap)
@@ -740,6 +743,7 @@ func Test_set_option_errors()
call assert_fails('set backupcopy=', 'E474:')
call assert_fails('set regexpengine=3', 'E474:')
call assert_fails('set history=10001', 'E474:')
+ call assert_fails('set msghistory=10001', 'E474:')
call assert_fails('set numberwidth=21', 'E474:')
call assert_fails('set colorcolumn=-a', 'E474:')
call assert_fails('set colorcolumn=a', 'E474:')
@@ -753,6 +757,7 @@ func Test_set_option_errors()
endif
call assert_fails('set helpheight=-1', 'E487:')
call assert_fails('set history=-1', 'E487:')
+ call assert_fails('set msghistory=-1', 'E487:')
call assert_fails('set report=-1', 'E487:')
call assert_fails('set shiftwidth=-1', 'E487:')
call assert_fails('set sidescroll=-1', 'E487:')
@@ -766,8 +771,47 @@ func Test_set_option_errors()
call assert_fails('set updatetime=-1', 'E487:')
call assert_fails('set winheight=-1', 'E487:')
call assert_fails('set tabstop!', 'E488:')
+
+ " Test for setting unknown option errors
call assert_fails('set xxx', 'E518:')
- call assert_fails('set beautify?', 'E518:')
+ call assert_fails('setlocal xxx', 'E518:')
+ call assert_fails('setglobal xxx', 'E518:')
+ call assert_fails('set xxx=', 'E518:')
+ call assert_fails('setlocal xxx=', 'E518:')
+ call assert_fails('setglobal xxx=', 'E518:')
+ call assert_fails('set xxx:', 'E518:')
+ call assert_fails('setlocal xxx:', 'E518:')
+ call assert_fails('setglobal xxx:', 'E518:')
+ call assert_fails('set xxx!', 'E518:')
+ call assert_fails('setlocal xxx!', 'E518:')
+ call assert_fails('setglobal xxx!', 'E518:')
+ call assert_fails('set xxx?', 'E518:')
+ call assert_fails('setlocal xxx?', 'E518:')
+ call assert_fails('setglobal xxx?', 'E518:')
+ call assert_fails('set xxx&', 'E518:')
+ call assert_fails('setlocal xxx&', 'E518:')
+ call assert_fails('setglobal xxx&', 'E518:')
+ call assert_fails('set xxx<', 'E518:')
+ call assert_fails('setlocal xxx<', 'E518:')
+ call assert_fails('setglobal xxx<', 'E518:')
+
+ " Test for missing-options errors.
+ " call assert_fails('set autoprint?', 'E519:')
+ " call assert_fails('set beautify?', 'E519:')
+ " call assert_fails('set flash?', 'E519:')
+ " call assert_fails('set graphic?', 'E519:')
+ " call assert_fails('set hardtabs?', 'E519:')
+ " call assert_fails('set mesg?', 'E519:')
+ " call assert_fails('set novice?', 'E519:')
+ " call assert_fails('set open?', 'E519:')
+ " call assert_fails('set optimize?', 'E519:')
+ " call assert_fails('set redraw?', 'E519:')
+ " call assert_fails('set slowopen?', 'E519:')
+ " call assert_fails('set sourceany?', 'E519:')
+ " call assert_fails('set w300?', 'E519:')
+ " call assert_fails('set w1200?', 'E519:')
+ " call assert_fails('set w9600?', 'E519:')
+
call assert_fails('set undolevels=x', 'E521:')
call assert_fails('set tabstop=', 'E521:')
call assert_fails('set comments=-', 'E524:')
@@ -779,12 +823,16 @@ func Test_set_option_errors()
call assert_fails('set rulerformat=%-', 'E539:')
call assert_fails('set rulerformat=%(', 'E542:')
call assert_fails('set rulerformat=%15(%%', 'E542:')
+
+ " Test for 'statusline' errors
call assert_fails('set statusline=%$', 'E539:')
call assert_fails('set statusline=%{', 'E540:')
call assert_fails('set statusline=%{%', 'E540:')
call assert_fails('set statusline=%{%}', 'E539:')
call assert_fails('set statusline=%(', 'E542:')
call assert_fails('set statusline=%)', 'E542:')
+
+ " Test for 'tabline' errors
call assert_fails('set tabline=%$', 'E539:')
call assert_fails('set tabline=%{', 'E540:')
call assert_fails('set tabline=%{%', 'E540:')
@@ -801,6 +849,7 @@ func Test_set_option_errors()
call assert_fails('set guicursor=r-cr:horx', 'E548:')
call assert_fails('set guicursor=r-cr:hor0', 'E549:')
endif
+
if has('mouseshape')
call assert_fails('se mouseshape=i-r:x', 'E547:')
endif
@@ -814,15 +863,19 @@ func Test_set_option_errors()
call assert_equal('.bak', &backupext)
set backupext& patchmode&
+ " 'winheight' cannot be smaller than 'winminheight'
call assert_fails('set winminheight=10 winheight=9', 'E591:')
set winminheight& winheight&
set winheight=10 winminheight=10
call assert_fails('set winheight=9', 'E591:')
set winminheight& winheight&
+
+ " 'winwidth' cannot be smaller than 'winminwidth'
call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
set winminwidth& winwidth&
call assert_fails('set winwidth=9 winminwidth=10', 'E592:')
set winwidth& winminwidth&
+
call assert_fails("set showbreak=\x01", 'E595:')
" call assert_fails('set t_foo=', 'E846:')
call assert_fails('set tabstop??', 'E488:')
@@ -842,18 +895,23 @@ func Test_set_option_errors()
call assert_fails('set sessionoptions=curdir,sesdir', 'E474:')
call assert_fails('set foldmarker={{{,', 'E474:')
call assert_fails('set sessionoptions=sesdir,curdir', 'E474:')
+
+ " 'ambiwidth' conflict 'listchars'
setlocal listchars=trail:·
call assert_fails('set ambiwidth=double', 'E834:')
setlocal listchars=trail:-
setglobal listchars=trail:·
call assert_fails('set ambiwidth=double', 'E834:')
set listchars&
+
+ " 'ambiwidth' conflict 'fillchars'
setlocal fillchars=stl:·
call assert_fails('set ambiwidth=double', 'E835:')
setlocal fillchars=stl:-
setglobal fillchars=stl:·
call assert_fails('set ambiwidth=double', 'E835:')
set fillchars&
+
call assert_fails('set fileencoding=latin1,utf-8', 'E474:')
set nomodifiable
call assert_fails('set fileencoding=latin1', 'E21:')
@@ -861,6 +919,8 @@ func Test_set_option_errors()
" call assert_fails('set t_#-&', 'E522:')
call assert_fails('let &formatoptions = "?"', 'E539:')
call assert_fails('call setbufvar("", "&formatoptions", "?")', 'E539:')
+
+ " Should raises only one error if passing a wrong variable type.
call assert_fails('call setwinvar(0, "&scrolloff", [])', ['E745:', 'E745:'])
call assert_fails('call setwinvar(0, "&list", [])', ['E745:', 'E745:'])
call assert_fails('call setwinvar(0, "&listchars", [])', ['E730:', 'E730:'])
@@ -947,6 +1007,7 @@ func Test_set_ttytype()
endif
endfunc
+" Test for :set all
func Test_set_all()
set tw=75
set iskeyword=a-z,A-Z
@@ -958,7 +1019,8 @@ func Test_set_all()
set tw& iskeyword& splitbelow&
endfunc
-func Test_set_one_column()
+" Test for :set! all
+func Test_set_all_one_column()
let out_mult = execute('set all')->split("\n")
let out_one = execute('set! all')->split("\n")
call assert_true(len(out_mult) < len(out_one))
@@ -967,15 +1029,6 @@ func Test_set_one_column()
call assert_equal(sort(copy(options)), options)
endfunc
-func Test_set_values()
- " opt_test.vim is generated from ../optiondefs.h using gen_opt_test.vim
- if filereadable('opt_test.vim')
- source opt_test.vim
- else
- throw 'Skipped: opt_test.vim does not exist'
- endif
-endfunc
-
func Test_renderoptions()
throw 'skipped: Nvim does not support renderoptions'
" Only do this for Windows Vista and later, fails on Windows XP and earlier.
@@ -1335,7 +1388,8 @@ func Test_local_scrolloff()
call assert_equal(5, &so)
wincmd w
call assert_equal(3, &so)
- setlocal so<
+ "setlocal so<
+ set so<
call assert_equal(5, &so)
setglob so=8
call assert_equal(8, &so)
@@ -1352,7 +1406,8 @@ func Test_local_scrolloff()
call assert_equal(7, &siso)
wincmd w
call assert_equal(3, &siso)
- setlocal siso<
+ "setlocal siso<
+ set siso<
call assert_equal(7, &siso)
setglob siso=4
call assert_equal(4, &siso)
@@ -1506,40 +1561,83 @@ endfunc
" Test for changing options in a sandbox
func Test_opt_sandbox()
- for opt in ['backupdir', 'cdpath', 'exrc']
+ for opt in ['backupdir', 'cdpath', 'exrc', 'findfunc']
call assert_fails('sandbox set ' .. opt .. '?', 'E48:')
call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:')
endfor
call assert_fails('sandbox let &modelineexpr = 1', 'E48:')
endfunc
-" Test for setting an option with local value to global value
-func Test_opt_local_to_global()
+" Test for setting string global-local option value
+func Test_set_string_global_local_option()
setglobal equalprg=gprg
setlocal equalprg=lprg
call assert_equal('gprg', &g:equalprg)
call assert_equal('lprg', &l:equalprg)
call assert_equal('lprg', &equalprg)
+
+ " :set {option}< removes the local value, so that the global value will be used.
set equalprg<
call assert_equal('', &l:equalprg)
call assert_equal('gprg', &equalprg)
+
+ " :setlocal {option}< set the effective value of {option} to its global value.
setglobal equalprg=gnewprg
setlocal equalprg=lnewprg
setlocal equalprg<
call assert_equal('gnewprg', &l:equalprg)
call assert_equal('gnewprg', &equalprg)
+
set equalprg&
+endfunc
+
+" Test for setting number global-local option value
+func Test_set_number_global_local_option()
+ setglobal scrolloff=10
+ setlocal scrolloff=12
+ call assert_equal(10, &g:scrolloff)
+ call assert_equal(12, &l:scrolloff)
+ call assert_equal(12, &scrolloff)
+
+ " :setlocal {option}< set the effective value of {option} to its global value.
+ "set scrolloff<
+ setlocal scrolloff<
+ call assert_equal(10, &l:scrolloff)
+ call assert_equal(10, &scrolloff)
+
+ " :set {option}< removes the local value, so that the global value will be used.
+ setglobal scrolloff=15
+ setlocal scrolloff=18
+ "setlocal scrolloff<
+ set scrolloff<
+ call assert_equal(-1, &l:scrolloff)
+ call assert_equal(15, &scrolloff)
+
+ set scrolloff&
+endfunc
- " Test for setting the global/local value of a boolean option
+" Test for setting boolean global-local option value
+func Test_set_boolean_global_local_option()
setglobal autoread
setlocal noautoread
- call assert_false(&autoread)
- set autoread<
- call assert_true(&autoread)
+ call assert_equal(1, &g:autoread)
+ call assert_equal(0, &l:autoread)
+ call assert_equal(0, &autoread)
+
+ " :setlocal {option}< set the effective value of {option} to its global value.
+ "set autoread<
+ setlocal autoread<
+ call assert_equal(1, &l:autoread)
+ call assert_equal(1, &autoread)
+
+ " :set {option}< removes the local value, so that the global value will be used.
setglobal noautoread
setlocal autoread
- setlocal autoread<
- call assert_false(&autoread)
+ "setlocal autoread<
+ set autoread<
+ call assert_equal(-1, &l:autoread)
+ call assert_equal(0, &autoread)
+
set autoread&
endfunc
@@ -1565,32 +1663,437 @@ func Test_set_in_sandbox()
set filetype&
endfunc
-" Test for incrementing, decrementing and multiplying a number option value
-func Test_opt_num_op()
+" Test for setting string option value
+func Test_set_string_option()
+ " :set {option}=
+ set makeprg=
+ call assert_equal('', &mp)
+ set makeprg=abc
+ call assert_equal('abc', &mp)
+
+ " :set {option}:
+ set makeprg:
+ call assert_equal('', &mp)
+ set makeprg:abc
+ call assert_equal('abc', &mp)
+
+ " Let string
+ let &makeprg = ''
+ call assert_equal('', &mp)
+ let &makeprg = 'abc'
+ call assert_equal('abc', &mp)
+
+ " Let number converts to string
+ let &makeprg = 42
+ call assert_equal('42', &mp)
+
+ " Appending
+ set makeprg=abc
+ set makeprg+=def
+ call assert_equal('abcdef', &mp)
+ set makeprg+=def
+ call assert_equal('abcdefdef', &mp, ':set+= appends a value even if it already contained')
+ let &makeprg .= 'gh'
+ call assert_equal('abcdefdefgh', &mp)
+ let &makeprg ..= 'ij'
+ call assert_equal('abcdefdefghij', &mp)
+
+ " Removing
+ set makeprg=abcdefghi
+ set makeprg-=def
+ call assert_equal('abcghi', &mp)
+ set makeprg-=def
+ call assert_equal('abcghi', &mp, ':set-= does not remove a value if it is not contained')
+
+ " Prepending
+ set makeprg=abc
+ set makeprg^=def
+ call assert_equal('defabc', &mp)
+ set makeprg^=def
+ call assert_equal('defdefabc', &mp, ':set+= prepends a value even if it already contained')
+
+ set makeprg&
+endfunc
+
+" Test for setting string comma-separated list option value
+func Test_set_string_comma_list_option()
+ " :set {option}=
+ set wildignore=
+ call assert_equal('', &wildignore)
+ set wildignore=*.png
+ call assert_equal('*.png', &wildignore)
+
+ " :set {option}:
+ set wildignore:
+ call assert_equal('', &wildignore)
+ set wildignore:*.png
+ call assert_equal('*.png', &wildignore)
+
+ " Let string
+ let &wildignore = ''
+ call assert_equal('', &wildignore)
+ let &wildignore = '*.png'
+ call assert_equal('*.png', &wildignore)
+
+ " Let number converts to string
+ let &wildignore = 42
+ call assert_equal('42', &wildignore)
+
+ " Appending
+ set wildignore=*.png
+ set wildignore+=*.jpg
+ call assert_equal('*.png,*.jpg', &wildignore, ':set+= prepends a comma to append a value')
+ set wildignore+=*.jpg
+ call assert_equal('*.png,*.jpg', &wildignore, ':set+= does not append a value if it already contained')
+ set wildignore+=jpg
+ call assert_equal('*.png,*.jpg,jpg', &wildignore, ':set+= prepends a comma to append a value if it is not exactly match to item')
+ let &wildignore .= 'foo'
+ call assert_equal('*.png,*.jpg,jpgfoo', &wildignore, ':let-& .= appends a value without a comma')
+ let &wildignore ..= 'bar'
+ call assert_equal('*.png,*.jpg,jpgfoobar', &wildignore, ':let-& ..= appends a value without a comma')
+
+ " Removing
+ set wildignore=*.png,*.jpg,*.obj
+ set wildignore-=*.jpg
+ call assert_equal('*.png,*.obj', &wildignore)
+ set wildignore-=*.jpg
+ call assert_equal('*.png,*.obj', &wildignore, ':set-= does not remove a value if it is not contained')
+ set wildignore-=jpg
+ call assert_equal('*.png,*.obj', &wildignore, ':set-= does not remove a value if it is not exactly match to item')
+
+ " Prepending
+ set wildignore=*.png
+ set wildignore^=*.jpg
+ call assert_equal('*.jpg,*.png', &wildignore)
+ set wildignore^=*.jpg
+ call assert_equal('*.jpg,*.png', &wildignore, ':set+= does not prepend a value if it already contained')
+ set wildignore^=jpg
+ call assert_equal('jpg,*.jpg,*.png', &wildignore, ':set+= prepend a value if it is not exactly match to item')
+
+ set wildignore&
+endfunc
+
+" Test for setting string flags option value
+func Test_set_string_flags_option()
+ " :set {option}=
+ set formatoptions=
+ call assert_equal('', &fo)
+ set formatoptions=abc
+ call assert_equal('abc', &fo)
+
+ " :set {option}:
+ set formatoptions:
+ call assert_equal('', &fo)
+ set formatoptions:abc
+ call assert_equal('abc', &fo)
+
+ " Let string
+ let &formatoptions = ''
+ call assert_equal('', &fo)
+ let &formatoptions = 'abc'
+ call assert_equal('abc', &fo)
+
+ " Let number converts to string
+ let &formatoptions = 12
+ call assert_equal('12', &fo)
+
+ " Appending
+ set formatoptions=abc
+ set formatoptions+=pqr
+ call assert_equal('abcpqr', &fo)
+ set formatoptions+=pqr
+ call assert_equal('abcpqr', &fo, ':set+= does not append a value if it already contained')
+ let &formatoptions .= 'r'
+ call assert_equal('abcpqrr', &fo, ':let-& .= appends a value even if it already contained')
+ let &formatoptions ..= 'r'
+ call assert_equal('abcpqrrr', &fo, ':let-& ..= appends a value even if it already contained')
+
+ " Removing
+ set formatoptions=abcpqr
+ set formatoptions-=cp
+ call assert_equal('abqr', &fo)
+ set formatoptions-=cp
+ call assert_equal('abqr', &fo, ':set-= does not remove a value if it is not contained')
+ set formatoptions-=ar
+ call assert_equal('abqr', &fo, ':set-= does not remove a value if it is not exactly match')
+
+ " Prepending
+ set formatoptions=abc
+ set formatoptions^=pqr
+ call assert_equal('pqrabc', &fo)
+ set formatoptions^=qr
+ call assert_equal('pqrabc', &fo, ':set+= does not prepend a value if it already contained')
+
+ set formatoptions&
+endfunc
+
+" Test for setting number option value
+func Test_set_number_option()
+ " :set {option}=
+ set scrolljump=5
+ call assert_equal(5, &sj)
+ set scrolljump=-3
+ call assert_equal(-3, &sj)
+
+ " :set {option}:
+ set scrolljump:7
+ call assert_equal(7, &sj)
+ set scrolljump:-5
+ call assert_equal(-5, &sj)
+
+ " Set hex
+ set scrolljump=0x10
+ call assert_equal(16, &sj)
+ set scrolljump=-0x10
+ call assert_equal(-16, &sj)
+ set scrolljump=0X12
+ call assert_equal(18, &sj)
+ set scrolljump=-0X12
+ call assert_equal(-18, &sj)
+
+ " Set octal
+ set scrolljump=010
+ call assert_equal(8, &sj)
+ set scrolljump=-010
+ call assert_equal(-8, &sj)
+ set scrolljump=0o12
+ call assert_equal(10, &sj)
+ set scrolljump=-0o12
+ call assert_equal(-10, &sj)
+ set scrolljump=0O15
+ call assert_equal(13, &sj)
+ set scrolljump=-0O15
+ call assert_equal(-13, &sj)
+
+ " Let number
+ let &scrolljump = 4
+ call assert_equal(4, &sj)
+ let &scrolljump = -6
+ call assert_equal(-6, &sj)
+
+ " Let numeric string converts to number
+ let &scrolljump = '7'
+ call assert_equal(7, &sj)
+ let &scrolljump = '-9'
+ call assert_equal(-9, &sj)
+
+ " Incrementing
set shiftwidth=4
set sw+=2
call assert_equal(6, &sw)
+ let &shiftwidth += 2
+ call assert_equal(8, &sw)
+
+ " Decrementing
+ set shiftwidth=6
set sw-=2
call assert_equal(4, &sw)
+ let &shiftwidth -= 2
+ call assert_equal(2, &sw)
+
+ " Multiplying
+ set shiftwidth=4
set sw^=2
call assert_equal(8, &sw)
+ let &shiftwidth *= 2
+ call assert_equal(16, &sw)
+
+ set scrolljump&
set shiftwidth&
endfunc
-" Test for setting option values using v:false and v:true
-func Test_opt_boolean()
+" Test for setting boolean option value
+func Test_set_boolean_option()
set number&
+
+ " :set {option}
set number
call assert_equal(1, &nu)
+
+ " :set no{option}
set nonu
call assert_equal(0, &nu)
+
+ " :set {option}!
+ set number!
+ call assert_equal(1, &nu)
+ set number!
+ call assert_equal(0, &nu)
+
+ " :set inv{option}
+ set invnumber
+ call assert_equal(1, &nu)
+ set invnumber
+ call assert_equal(0, &nu)
+
+ " Let number
+ let &number = 1
+ call assert_equal(1, &nu)
+ let &number = 0
+ call assert_equal(0, &nu)
+
+ " Let numeric string converts to number
+ let &number = '1'
+ call assert_equal(1, &nu)
+ let &number = '0'
+ call assert_equal(0, &nu)
+
+ " Let v:true and v:false
let &nu = v:true
call assert_equal(1, &nu)
let &nu = v:false
call assert_equal(0, &nu)
+
set number&
endfunc
+" Test for setting string option errors
+func Test_set_string_option_errors()
+ " :set no{option}
+ call assert_fails('set nomakeprg', 'E474:')
+ call assert_fails('setlocal nomakeprg', 'E474:')
+ call assert_fails('setglobal nomakeprg', 'E474:')
+
+ " :set inv{option}
+ call assert_fails('set invmakeprg', 'E474:')
+ call assert_fails('setlocal invmakeprg', 'E474:')
+ call assert_fails('setglobal invmakeprg', 'E474:')
+
+ " :set {option}!
+ call assert_fails('set makeprg!', 'E488:')
+ call assert_fails('setlocal makeprg!', 'E488:')
+ call assert_fails('setglobal makeprg!', 'E488:')
+
+ " Invalid trailing chars
+ call assert_fails('set makeprg??', 'E488:')
+ call assert_fails('setlocal makeprg??', 'E488:')
+ call assert_fails('setglobal makeprg??', 'E488:')
+ call assert_fails('set makeprg&&', 'E488:')
+ call assert_fails('setlocal makeprg&&', 'E488:')
+ call assert_fails('setglobal makeprg&&', 'E488:')
+ call assert_fails('set makeprg<<', 'E488:')
+ call assert_fails('setlocal makeprg<<', 'E488:')
+ call assert_fails('setglobal makeprg<<', 'E488:')
+ call assert_fails('set makeprg@', 'E488:')
+ call assert_fails('setlocal makeprg@', 'E488:')
+ call assert_fails('setglobal makeprg@', 'E488:')
+
+ " Invalid type
+ call assert_fails("let &makeprg = ['xxx']", 'E730:')
+endfunc
+
+" Test for setting number option errors
+func Test_set_number_option_errors()
+ " :set no{option}
+ call assert_fails('set notabstop', 'E474:')
+ call assert_fails('setlocal notabstop', 'E474:')
+ call assert_fails('setglobal notabstop', 'E474:')
+
+ " :set inv{option}
+ call assert_fails('set invtabstop', 'E474:')
+ call assert_fails('setlocal invtabstop', 'E474:')
+ call assert_fails('setglobal invtabstop', 'E474:')
+
+ " :set {option}!
+ call assert_fails('set tabstop!', 'E488:')
+ call assert_fails('setlocal tabstop!', 'E488:')
+ call assert_fails('setglobal tabstop!', 'E488:')
+
+ " Invalid trailing chars
+ call assert_fails('set tabstop??', 'E488:')
+ call assert_fails('setlocal tabstop??', 'E488:')
+ call assert_fails('setglobal tabstop??', 'E488:')
+ call assert_fails('set tabstop&&', 'E488:')
+ call assert_fails('setlocal tabstop&&', 'E488:')
+ call assert_fails('setglobal tabstop&&', 'E488:')
+ call assert_fails('set tabstop<<', 'E488:')
+ call assert_fails('setlocal tabstop<<', 'E488:')
+ call assert_fails('setglobal tabstop<<', 'E488:')
+ call assert_fails('set tabstop@', 'E488:')
+ call assert_fails('setlocal tabstop@', 'E488:')
+ call assert_fails('setglobal tabstop@', 'E488:')
+
+ " Not a number
+ call assert_fails('set tabstop=', 'E521:')
+ call assert_fails('setlocal tabstop=', 'E521:')
+ call assert_fails('setglobal tabstop=', 'E521:')
+ call assert_fails('set tabstop=x', 'E521:')
+ call assert_fails('setlocal tabstop=x', 'E521:')
+ call assert_fails('setglobal tabstop=x', 'E521:')
+ call assert_fails('set tabstop=1x', 'E521:')
+ call assert_fails('setlocal tabstop=1x', 'E521:')
+ call assert_fails('setglobal tabstop=1x', 'E521:')
+ call assert_fails('set tabstop=-x', 'E521:')
+ call assert_fails('setlocal tabstop=-x', 'E521:')
+ call assert_fails('setglobal tabstop=-x', 'E521:')
+ call assert_fails('set tabstop=0x', 'E521:')
+ call assert_fails('setlocal tabstop=0x', 'E521:')
+ call assert_fails('setglobal tabstop=0x', 'E521:')
+ call assert_fails('set tabstop=0o', 'E521:')
+ call assert_fails('setlocal tabstop=0o', 'E521:')
+ call assert_fails('setglobal tabstop=0o', 'E521:')
+ call assert_fails("let &tabstop = 'x'", 'E521:')
+ call assert_fails("let &g:tabstop = 'x'", 'E521:')
+ call assert_fails("let &l:tabstop = 'x'", 'E521:')
+
+ " Invalid type
+ call assert_fails("let &tabstop = 'xxx'", 'E521:')
+endfunc
+
+" Test for setting boolean option errors
+func Test_set_boolean_option_errors()
+ " :set {option}=
+ call assert_fails('set number=', 'E474:')
+ call assert_fails('setlocal number=', 'E474:')
+ call assert_fails('setglobal number=', 'E474:')
+ call assert_fails('set number=1', 'E474:')
+ call assert_fails('setlocal number=1', 'E474:')
+ call assert_fails('setglobal number=1', 'E474:')
+
+ " :set {option}:
+ call assert_fails('set number:', 'E474:')
+ call assert_fails('setlocal number:', 'E474:')
+ call assert_fails('setglobal number:', 'E474:')
+ call assert_fails('set number:1', 'E474:')
+ call assert_fails('setlocal number:1', 'E474:')
+ call assert_fails('setglobal number:1', 'E474:')
+
+ " :set {option}+=
+ call assert_fails('set number+=1', 'E474:')
+ call assert_fails('setlocal number+=1', 'E474:')
+ call assert_fails('setglobal number+=1', 'E474:')
+
+ " :set {option}^=
+ call assert_fails('set number^=1', 'E474:')
+ call assert_fails('setlocal number^=1', 'E474:')
+ call assert_fails('setglobal number^=1', 'E474:')
+
+ " :set {option}-=
+ call assert_fails('set number-=1', 'E474:')
+ call assert_fails('setlocal number-=1', 'E474:')
+ call assert_fails('setglobal number-=1', 'E474:')
+
+ " Invalid trailing chars
+ call assert_fails('set number!!', 'E488:')
+ call assert_fails('setlocal number!!', 'E488:')
+ call assert_fails('setglobal number!!', 'E488:')
+ call assert_fails('set number??', 'E488:')
+ call assert_fails('setlocal number??', 'E488:')
+ call assert_fails('setglobal number??', 'E488:')
+ call assert_fails('set number&&', 'E488:')
+ call assert_fails('setlocal number&&', 'E488:')
+ call assert_fails('setglobal number&&', 'E488:')
+ call assert_fails('set number<<', 'E488:')
+ call assert_fails('setlocal number<<', 'E488:')
+ call assert_fails('setglobal number<<', 'E488:')
+ call assert_fails('set number@', 'E488:')
+ call assert_fails('setlocal number@', 'E488:')
+ call assert_fails('setglobal number@', 'E488:')
+
+ " Invalid type
+ call assert_fails("let &number = 'xxx'", 'E521:')
+endfunc
+
" Test for the 'window' option
func Test_window_opt()
" Needs only one open widow
@@ -2289,4 +2792,24 @@ func Test_delcombine()
bwipe!
endfunc
+" Should not raise errors when set missing-options.
+func Test_set_missing_options()
+ throw 'Skipped: N/A'
+ set autoprint
+ set beautify
+ set flash
+ set graphic
+ set hardtabs=8
+ set mesg
+ set novice
+ set open
+ set optimize
+ set redraw
+ set slowopen
+ set sourceany
+ set w300=23
+ set w1200=23
+ set w9600=23
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_options_all.vim b/test/old/testdir/test_options_all.vim
new file mode 100644
index 0000000000..a2330ecb90
--- /dev/null
+++ b/test/old/testdir/test_options_all.vim
@@ -0,0 +1,13 @@
+" Test for options
+
+" opt_test.vim is generated from src/optiondefs.h and runtime/doc/options.txt
+" using gen_opt_test.vim
+if filereadable('opt_test.vim')
+ source opt_test.vim
+else
+ func Test_set_values()
+ throw 'Skipped: opt_test.vim does not exist'
+ endfunc
+endif
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index 472882fb87..601ba6c688 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -1506,20 +1506,31 @@ func Test_pum_highlights_match()
call StopVimInTerminal(buf)
endfunc
-func Test_pum_user_hl_group()
+func Test_pum_user_abbr_hlgroup()
CheckScreendump
let lines =<< trim END
- func CompleteFunc( findstart, base )
+ let s:var = 0
+ func CompleteFunc(findstart, base)
if a:findstart
return 0
endif
+ if s:var == 1
+ return {
+ \ 'words': [
+ \ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' },
+ \ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' },
+ \]}
+ endif
return {
\ 'words': [
- \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'hl_group': 'StrikeFake' },
+ \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
- \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'hl_group': 'StrikeFake' },
+ \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
\]}
endfunc
+ func ChangeVar()
+ let s:var = 1
+ endfunc
set completeopt=menu
set completefunc=CompleteFunc
@@ -1547,19 +1558,26 @@ func Test_pum_user_hl_group()
call VerifyScreenDump(buf, 'Test_pum_highlights_14', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
+ call TermWait(buf)
+ call term_sendkeys(buf, ":call ChangeVar()\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, "S\<C-X>\<C-U>")
+ call VerifyScreenDump(buf, 'Test_pum_highlights_17', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
call StopVimInTerminal(buf)
endfunc
func Test_pum_user_kind_hlgroup()
CheckScreendump
let lines =<< trim END
- func CompleteFunc( findstart, base )
+ func CompleteFunc(findstart, base)
if a:findstart
return 0
endif
return {
\ 'words': [
- \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'hl_group': 'StrikeFake' },
+ \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'abbr_hlgroup': 'StrikeFake' },
\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'function', 'kind_hlgroup': 'KindFunc' },
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'class', 'kind_hlgroup': 'KindClass' },
\]}
diff --git a/test/old/testdir/test_quickfix.vim b/test/old/testdir/test_quickfix.vim
index 753875963b..ca48812e7d 100644
--- a/test/old/testdir/test_quickfix.vim
+++ b/test/old/testdir/test_quickfix.vim
@@ -6340,6 +6340,106 @@ func Test_quickfix_buffer_contents()
call setqflist([], 'f')
endfunc
+func XquickfixUpdateTests(cchar)
+ call s:setup_commands(a:cchar)
+
+ " Setup: populate a couple buffers
+ new
+ call setline(1, range(1, 5))
+ let b1 = bufnr()
+ new
+ call setline(1, range(1, 3))
+ let b2 = bufnr()
+ " Setup: set a quickfix list.
+ let items = [{'bufnr': b1, 'lnum': 1}, {'bufnr': b1, 'lnum': 2}, {'bufnr': b2, 'lnum': 1}, {'bufnr': b2, 'lnum': 2}]
+ call g:Xsetlist(items)
+
+ " Open the quickfix list, select the third entry.
+ Xopen
+ exe "normal jj\<CR>"
+ call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
+
+ " Update the quickfix list. Make sure the third entry is still selected.
+ call g:Xsetlist([], 'u', { 'items': items })
+ call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
+
+ " Update the quickfix list again, but this time with missing line number
+ " information. Confirm that we keep the current buffer selected.
+ call g:Xsetlist([{'bufnr': b1}, {'bufnr': b2}], 'u')
+ call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)
+
+ Xclose
+
+ " Cleanup the buffers we allocated during this test.
+ %bwipe!
+endfunc
+
+" Test for updating a quickfix list using the "u" flag in setqflist()
+func Test_quickfix_update()
+ call XquickfixUpdateTests('c')
+ call XquickfixUpdateTests('l')
+endfunc
+
+func Test_quickfix_update_with_missing_coordinate_info()
+ new
+ call setline(1, range(1, 5))
+ let b1 = bufnr()
+
+ new
+ call setline(1, range(1, 3))
+ let b2 = bufnr()
+
+ new
+ call setline(1, range(1, 2))
+ let b3 = bufnr()
+
+ " Setup: set a quickfix list with no coordinate information at all.
+ call setqflist([{}, {}])
+
+ " Open the quickfix list, select the second entry.
+ copen
+ exe "normal j\<CR>"
+ call assert_equal(2, getqflist({'idx' : 0}).idx)
+
+ " Update the quickfix list. As the previously selected entry has no
+ " coordinate information, we expect the first entry to now be selected.
+ call setqflist([{'bufnr': b1}, {'bufnr': b2}, {'bufnr': b3}], 'u')
+ call assert_equal(1, getqflist({'idx' : 0}).idx)
+
+ " Select the second entry in the quickfix list.
+ copen
+ exe "normal j\<CR>"
+ call assert_equal(2, getqflist({'idx' : 0}).idx)
+
+ " Update the quickfix list again. The currently selected entry does not have
+ " a line number, but we should keep the file selected.
+ call setqflist([{'bufnr': b1}, {'bufnr': b2, 'lnum': 3}, {'bufnr': b3}], 'u')
+ call assert_equal(2, getqflist({'idx' : 0}).idx)
+
+ " Update the quickfix list again. The currently selected entry (bufnr=b2, lnum=3)
+ " is no longer present. We should pick the nearest entry.
+ call setqflist([{'bufnr': b1}, {'bufnr': b2, 'lnum': 1}, {'bufnr': b2, 'lnum': 4}], 'u')
+ call assert_equal(3, getqflist({'idx' : 0}).idx)
+
+ " Set the quickfix list again, with a specific column number. The currently selected entry doesn't have a
+ " column number, but they share a line number.
+ call setqflist([{'bufnr': b1}, {'bufnr': b2, 'lnum': 4, 'col': 5}, {'bufnr': b2, 'lnum': 4, 'col': 6}], 'u')
+ call assert_equal(2, getqflist({'idx' : 0}).idx)
+
+ " Set the quickfix list again. The currently selected column number (6) is
+ " no longer present. We should select the nearest column number.
+ call setqflist([{'bufnr': b1}, {'bufnr': b2, 'lnum': 4, 'col': 2}, {'bufnr': b2, 'lnum': 4, 'col': 4}], 'u')
+ call assert_equal(3, getqflist({'idx' : 0}).idx)
+
+ " Now set the quickfix list, but without columns. We should still pick the
+ " same line.
+ call setqflist([{'bufnr': b2, 'lnum': 3}, {'bufnr': b2, 'lnum': 4}, {'bufnr': b2, 'lnum': 4}], 'u')
+ call assert_equal(2, getqflist({'idx' : 0}).idx)
+
+ " Cleanup the buffers we allocated during this test.
+ %bwipe!
+endfunc
+
" Test for "%b" in "errorformat"
func Test_efm_format_b()
call setqflist([], 'f')
@@ -6459,8 +6559,8 @@ func Test_cbuffer_range()
call XbufferTests_range('l')
endfunc
-" Test for displaying fname pass from setqflist when the name
-" are hard links to prevent seemly duplicate entries.
+" Test for displaying fname passed from setqflist() when the names include
+" hard links to prevent seemingly duplicate entries.
func Xtest_hardlink_fname(cchar)
call s:setup_commands(a:cchar)
%bwipe
diff --git a/test/old/testdir/test_spellfile.vim b/test/old/testdir/test_spellfile.vim
index 48e46641f4..f356b12370 100644
--- a/test/old/testdir/test_spellfile.vim
+++ b/test/old/testdir/test_spellfile.vim
@@ -1155,7 +1155,7 @@ endfunc
" 'spellfile' accepts '@' on top of 'isfname'.
func Test_spellfile_allow_at_character()
call mkdir('Xtest/the foo@bar,dir', 'p')
- let &spellfile = './Xtest/the foo@bar,dir/Xspellfile.add'
+ let &spellfile = './Xtest/the foo@bar\,dir/Xspellfile.add'
let &spellfile = ''
call delete('Xtest', 'rf')
endfunc
diff --git a/test/old/testdir/test_swap.vim b/test/old/testdir/test_swap.vim
index 8a1b3ce133..e174356ed7 100644
--- a/test/old/testdir/test_swap.vim
+++ b/test/old/testdir/test_swap.vim
@@ -420,7 +420,7 @@ func s:get_unused_pid(base)
if has('job')
" Execute 'echo' as a temporary job, and return its pid as an unused pid.
if has('win32')
- let cmd = 'cmd /c echo'
+ let cmd = 'cmd /D /c echo'
else
let cmd = 'echo'
endif
diff --git a/test/old/testdir/test_tagfunc.vim b/test/old/testdir/test_tagfunc.vim
index 812603a430..ec1f93e9be 100644
--- a/test/old/testdir/test_tagfunc.vim
+++ b/test/old/testdir/test_tagfunc.vim
@@ -291,10 +291,10 @@ func Test_tagfunc_callback()
call assert_fails("echo taglist('a')", "E987:")
" Using Vim9 lambda expression in legacy context should fail
- " set tagfunc=(a,\ b,\ c)\ =>\ g:TagFunc1(21,\ a,\ b,\ c)
+ set tagfunc=(a,\ b,\ c)\ =>\ g:TagFunc1(21,\ a,\ b,\ c)
new
let g:TagFunc1Args = []
- " call assert_fails("tag a17", "E117:")
+ call assert_fails("tag a17", "E117:")
call assert_equal([], g:TagFunc1Args)
bw!
diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim
index a207f4f4e0..d876277850 100644
--- a/test/old/testdir/test_undo.vim
+++ b/test/old/testdir/test_undo.vim
@@ -187,7 +187,8 @@ func Test_global_local_undolevels()
" Resetting the local 'undolevels' value to use the global value
setlocal undolevels=5
- setlocal undolevels<
+ "setlocal undolevels<
+ set undolevels<
call assert_equal(-123456, &l:undolevels)
" Drop created windows
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 50da2beb40..8048fa6ff8 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -539,7 +539,7 @@ func Test_equalalways_on_close()
1wincmd w
split
4wincmd w
- resize + 5
+ resize +5
" left column has three windows, equalized heights.
" right column has two windows, top one a bit higher
let height_1 = winheight(1)
diff --git a/test/old/testdir/test_windows_home.vim b/test/old/testdir/test_windows_home.vim
index 3c2db01444..0f86124d3e 100644
--- a/test/old/testdir/test_windows_home.vim
+++ b/test/old/testdir/test_windows_home.vim
@@ -105,7 +105,7 @@ func Test_WindowsHome()
RestoreEnv
let $HOME = save_home
let env = ''
- let job = job_start('cmd /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
+ let job = job_start('cmd /D /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
sleep 1
let env = filter(split(env, "\n"), 'v:val=="HOME"')
let home = len(env) == 0 ? "" : env[0]