mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
Merge pull request #15502 from seandewar/vim-8.1.1921
Add method call support for more built-ins: vim-patch:8.1.{1336,1952,1961,1984}
This commit is contained in:
@@ -102,44 +102,44 @@ return {
|
||||
diff_hlID={args=2, base=1},
|
||||
empty={args=1, base=1},
|
||||
environ={},
|
||||
escape={args=2},
|
||||
escape={args=2, base=1},
|
||||
eval={args=1, base=1},
|
||||
eventhandler={},
|
||||
executable={args=1},
|
||||
execute={args={1, 2}},
|
||||
exepath={args=1},
|
||||
exists={args=1},
|
||||
executable={args=1, base=1},
|
||||
execute={args={1, 2}, base=1},
|
||||
exepath={args=1, base=1},
|
||||
exists={args=1, base=1},
|
||||
exp={args=1, base=1, func="float_op_wrapper", data="&exp"},
|
||||
expand={args={1, 3}},
|
||||
expandcmd={args=1},
|
||||
expand={args={1, 3}, base=1},
|
||||
expandcmd={args=1, base=1},
|
||||
extend={args={2, 3}, base=1},
|
||||
feedkeys={args={1, 2}},
|
||||
file_readable={args=1, func='f_filereadable'}, -- obsolete
|
||||
filereadable={args=1},
|
||||
filewritable={args=1},
|
||||
feedkeys={args={1, 2}, base=1},
|
||||
file_readable={args=1, base=1, func='f_filereadable'}, -- obsolete
|
||||
filereadable={args=1, base=1},
|
||||
filewritable={args=1, base=1},
|
||||
filter={args=2, base=1},
|
||||
finddir={args={1, 3}},
|
||||
findfile={args={1, 3}},
|
||||
finddir={args={1, 3}, base=1},
|
||||
findfile={args={1, 3}, base=1},
|
||||
flatten={args={1, 2}},
|
||||
float2nr={args=1, base=1},
|
||||
floor={args=1, base=1, func="float_op_wrapper", data="&floor"},
|
||||
fmod={args=2, base=1},
|
||||
fnameescape={args=1},
|
||||
fnamemodify={args=2},
|
||||
foldclosed={args=1},
|
||||
foldclosedend={args=1},
|
||||
foldlevel={args=1},
|
||||
fnameescape={args=1, base=1},
|
||||
fnamemodify={args=2, base=1},
|
||||
foldclosed={args=1, base=1},
|
||||
foldclosedend={args=1, base=1},
|
||||
foldlevel={args=1, base=1},
|
||||
foldtext={},
|
||||
foldtextresult={args=1},
|
||||
foldtextresult={args=1, base=1},
|
||||
foreground={},
|
||||
funcref={args={1, 3}},
|
||||
['function']={args={1, 3}},
|
||||
funcref={args={1, 3}, base=1},
|
||||
['function']={args={1, 3}, base=1},
|
||||
garbagecollect={args={0, 1}},
|
||||
get={args={2, 3}, base=1},
|
||||
getbufinfo={args={0, 1}},
|
||||
getbufline={args={2, 3}},
|
||||
getbufvar={args={2, 3}},
|
||||
getchangelist={args={1, 1}},
|
||||
getbufline={args={2, 3}, base=1},
|
||||
getbufvar={args={2, 3}, base=1},
|
||||
getchangelist={args={0, 1}, base=1},
|
||||
getchar={args={0, 1}},
|
||||
getcharmod={},
|
||||
getcharsearch={},
|
||||
@@ -148,67 +148,67 @@ return {
|
||||
getcmdpos={},
|
||||
getcmdtype={},
|
||||
getcmdwintype={},
|
||||
getcompletion={args={2, 3}},
|
||||
getcompletion={args={2, 3}, base=1},
|
||||
getcurpos={},
|
||||
getcwd={args={0,2}},
|
||||
getenv={args={1}},
|
||||
getcwd={args={0, 2}, base=1},
|
||||
getenv={args={1}, base=1},
|
||||
getfontname={args={0, 1}},
|
||||
getfperm={args=1},
|
||||
getfsize={args=1},
|
||||
getftime={args=1},
|
||||
getftype={args=1},
|
||||
getjumplist={args={0, 2}},
|
||||
getline={args={1, 2}},
|
||||
getfperm={args=1, base=1},
|
||||
getfsize={args=1, base=1},
|
||||
getftime={args=1, base=1},
|
||||
getftype={args=1, base=1},
|
||||
getjumplist={args={0, 2}, base=1},
|
||||
getline={args={1, 2}, base=1},
|
||||
getloclist={args={1, 2}},
|
||||
getmarklist={args={0, 1}},
|
||||
getmatches={args={0, 1}},
|
||||
getmousepos={},
|
||||
getpid={},
|
||||
getpos={args=1},
|
||||
getpos={args=1, base=1},
|
||||
getqflist={args={0, 1}},
|
||||
getreg={args={0, 3}},
|
||||
getreg={args={0, 3}, base=1},
|
||||
getreginfo={args={0, 1}, base=1},
|
||||
getregtype={args={0, 1}},
|
||||
gettabinfo={args={0, 1}},
|
||||
gettabvar={args={2, 3}},
|
||||
gettabwinvar={args={3, 4}},
|
||||
gettagstack={args={0, 1}},
|
||||
getwininfo={args={0, 1}},
|
||||
getwinpos={args={0, 1}},
|
||||
getregtype={args={0, 1}, base=1},
|
||||
gettabinfo={args={0, 1}, base=1},
|
||||
gettabvar={args={2, 3}, base=1},
|
||||
gettabwinvar={args={3, 4}, base=1},
|
||||
gettagstack={args={0, 1}, base=1},
|
||||
getwininfo={args={0, 1}, base=1},
|
||||
getwinpos={args={0, 1}, base=1},
|
||||
getwinposx={},
|
||||
getwinposy={},
|
||||
getwinvar={args={2, 3}},
|
||||
glob={args={1, 4}},
|
||||
glob2regpat={args=1},
|
||||
globpath={args={2, 5}},
|
||||
getwinvar={args={2, 3}, base=1},
|
||||
glob={args={1, 4}, base=1},
|
||||
glob2regpat={args=1, base=1},
|
||||
globpath={args={2, 5}, base=2},
|
||||
has={args=1},
|
||||
has_key={args=2, base=1},
|
||||
haslocaldir={args={0,2}},
|
||||
hasmapto={args={1, 3}},
|
||||
highlightID={args=1, func='f_hlID'}, -- obsolete
|
||||
highlight_exists={args=1, func='f_hlexists'}, -- obsolete
|
||||
histadd={args=2},
|
||||
histdel={args={1, 2}},
|
||||
histget={args={1, 2}},
|
||||
histnr={args=1},
|
||||
hlID={args=1},
|
||||
hlexists={args=1},
|
||||
haslocaldir={args={0, 2}, base=1},
|
||||
hasmapto={args={1, 3}, base=1},
|
||||
highlightID={args=1, base=1, func='f_hlID'}, -- obsolete
|
||||
highlight_exists={args=1, base=1, func='f_hlexists'}, -- obsolete
|
||||
histadd={args=2, base=2},
|
||||
histdel={args={1, 2}, base=1},
|
||||
histget={args={1, 2}, base=1},
|
||||
histnr={args=1, base=1},
|
||||
hlID={args=1, base=1},
|
||||
hlexists={args=1, base=1},
|
||||
hostname={},
|
||||
iconv={args=3},
|
||||
indent={args=1},
|
||||
iconv={args=3, base=1},
|
||||
indent={args=1, base=1},
|
||||
index={args={2, 4}, base=1},
|
||||
input={args={1, 3}},
|
||||
inputdialog={args={1, 3}},
|
||||
inputlist={args=1},
|
||||
input={args={1, 3}, base=1},
|
||||
inputdialog={args={1, 3}, base=1},
|
||||
inputlist={args=1, base=1},
|
||||
inputrestore={},
|
||||
inputsave={},
|
||||
inputsecret={args={1, 2}},
|
||||
inputsecret={args={1, 2}, base=1},
|
||||
insert={args={2, 3}, base=1},
|
||||
interrupt={args=0},
|
||||
invert={args=1, base=1},
|
||||
isdirectory={args=1},
|
||||
isdirectory={args=1, base=1},
|
||||
isinf={args=1, base=1},
|
||||
islocked={args=1},
|
||||
islocked={args=1, base=1},
|
||||
isnan={args=1, base=1},
|
||||
id={args=1},
|
||||
items={args=1, base=1},
|
||||
@@ -220,76 +220,76 @@ return {
|
||||
jobstop={args=1},
|
||||
jobwait={args={1, 2}},
|
||||
join={args={1, 2}, base=1},
|
||||
json_decode={args=1},
|
||||
json_encode={args=1},
|
||||
json_decode={args=1, base=1},
|
||||
json_encode={args=1, base=1},
|
||||
keys={args=1, base=1},
|
||||
last_buffer_nr={}, -- obsolete
|
||||
len={args=1, base=1},
|
||||
libcall={args=3},
|
||||
libcallnr={args=3},
|
||||
line={args={1, 2}},
|
||||
line2byte={args=1},
|
||||
lispindent={args=1},
|
||||
list2str={args={1, 2}},
|
||||
libcall={args=3, base=3},
|
||||
libcallnr={args=3, base=3},
|
||||
line={args={1, 2}, base=1},
|
||||
line2byte={args=1, base=1},
|
||||
lispindent={args=1, base=1},
|
||||
list2str={args={1, 2}, base=1},
|
||||
localtime={},
|
||||
log={args=1, base=1, func="float_op_wrapper", data="&log"},
|
||||
log10={args=1, base=1, func="float_op_wrapper", data="&log10"},
|
||||
luaeval={args={1, 2}},
|
||||
luaeval={args={1, 2}, base=1},
|
||||
map={args=2, base=1},
|
||||
maparg={args={1, 4}},
|
||||
mapcheck={args={1, 3}},
|
||||
match={args={2, 4}},
|
||||
matchadd={args={2, 5}},
|
||||
matchaddpos={args={2, 5}},
|
||||
matcharg={args=1},
|
||||
matchdelete={args={1, 2}},
|
||||
matchend={args={2, 4}},
|
||||
matchlist={args={2, 4}},
|
||||
matchstr={args={2, 4}},
|
||||
matchstrpos={args={2,4}},
|
||||
maparg={args={1, 4}, base=1},
|
||||
mapcheck={args={1, 3}, base=1},
|
||||
match={args={2, 4}, base=1},
|
||||
matchadd={args={2, 5}, base=1},
|
||||
matchaddpos={args={2, 5}, base=1},
|
||||
matcharg={args=1, base=1},
|
||||
matchdelete={args={1, 2}, base=1},
|
||||
matchend={args={2, 4}, base=1},
|
||||
matchlist={args={2, 4}, base=1},
|
||||
matchstr={args={2, 4}, base=1},
|
||||
matchstrpos={args={2,4}, base=1},
|
||||
max={args=1, base=1},
|
||||
menu_get={args={1, 2}},
|
||||
min={args=1, base=1},
|
||||
mkdir={args={1, 3}},
|
||||
mode={args={0, 1}},
|
||||
mkdir={args={1, 3}, base=1},
|
||||
mode={args={0, 1}, base=1},
|
||||
msgpackdump={args={1, 2}},
|
||||
msgpackparse={args=1},
|
||||
nextnonblank={args=1},
|
||||
nr2char={args={1, 2}},
|
||||
nextnonblank={args=1, base=1},
|
||||
nr2char={args={1, 2}, base=1},
|
||||
['or']={args=2, base=1},
|
||||
pathshorten={args=1},
|
||||
pathshorten={args=1, base=1},
|
||||
pow={args=2, base=1},
|
||||
prevnonblank={args=1},
|
||||
prevnonblank={args=1, base=1},
|
||||
printf={args=varargs(1), base=2},
|
||||
prompt_getprompt={args=1},
|
||||
prompt_setcallback={args={2, 2}},
|
||||
prompt_setinterrupt={args={2, 2}},
|
||||
prompt_setprompt={args={2, 2}},
|
||||
prompt_setcallback={args={2, 2}, base=1},
|
||||
prompt_setinterrupt={args={2, 2}, base=1},
|
||||
prompt_setprompt={args={2, 2}, base=1},
|
||||
pum_getpos={},
|
||||
pumvisible={},
|
||||
py3eval={args=1},
|
||||
pyeval={args=1},
|
||||
pyxeval={args=1},
|
||||
perleval={args=1},
|
||||
range={args={1, 3}},
|
||||
readdir={args={1, 2}},
|
||||
readfile={args={1, 3}},
|
||||
py3eval={args=1, base=1},
|
||||
pyeval={args=1, base=1},
|
||||
pyxeval={args=1, base=1},
|
||||
perleval={args=1, base=1},
|
||||
range={args={1, 3}, base=1},
|
||||
readdir={args={1, 2}, base=1},
|
||||
readfile={args={1, 3}, base=1},
|
||||
reg_executing={},
|
||||
reg_recording={},
|
||||
reltime={args={0, 2}},
|
||||
reltimefloat={args=1},
|
||||
reltimestr={args=1},
|
||||
reltime={args={0, 2}, base=1},
|
||||
reltimefloat={args=1, base=1},
|
||||
reltimestr={args=1, base=1},
|
||||
remove={args={2, 3}, base=1},
|
||||
rename={args=2},
|
||||
rename={args=2, base=1},
|
||||
['repeat']={args=2, base=1},
|
||||
resolve={args=1},
|
||||
resolve={args=1, base=1},
|
||||
reverse={args=1, base=1},
|
||||
round={args=1, base=1, func="float_op_wrapper", data="&round"},
|
||||
rpcnotify={args=varargs(2)},
|
||||
rpcrequest={args=varargs(2)},
|
||||
rpcstart={args={1, 2}},
|
||||
rpcstop={args=1},
|
||||
rubyeval={args=1},
|
||||
rubyeval={args=1, base=1},
|
||||
screenattr={args=2},
|
||||
screenchar={args=2},
|
||||
screenchars={args=2},
|
||||
@@ -311,7 +311,7 @@ return {
|
||||
setcharsearch={args=1},
|
||||
setcmdpos={args=1},
|
||||
setenv={args=2},
|
||||
setfperm={args=2},
|
||||
setfperm={args=2, base=1},
|
||||
setline={args=2},
|
||||
setloclist={args={2, 4}},
|
||||
setmatches={args={1, 2}},
|
||||
|
@@ -3088,10 +3088,16 @@ f_getbufvar_end:
|
||||
static void f_getchangelist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
tv_list_alloc_ret(rettv, 2);
|
||||
vim_ignored = tv_get_number(&argvars[0]); // issue errmsg if type error
|
||||
emsg_off++;
|
||||
const buf_T *const buf = tv_get_buf(&argvars[0], false);
|
||||
emsg_off--;
|
||||
|
||||
const buf_T *buf;
|
||||
if (argvars[0].v_type == VAR_UNKNOWN) {
|
||||
buf = curbuf;
|
||||
} else {
|
||||
vim_ignored = tv_get_number(&argvars[0]); // issue errmsg if type error
|
||||
emsg_off++;
|
||||
buf = tv_get_buf(&argvars[0], false);
|
||||
emsg_off--;
|
||||
}
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ func Test_argadd_empty_curbuf()
|
||||
argadd Xargadd
|
||||
call assert_equal(curbuf, bufnr('%'))
|
||||
call assert_equal('', bufname('%'))
|
||||
call assert_equal(1, line('$'))
|
||||
call assert_equal(1, '$'->line())
|
||||
rew
|
||||
call assert_notequal(curbuf, '%'->bufnr())
|
||||
call assert_equal('Xargadd', '%'->bufname())
|
||||
|
@@ -418,8 +418,8 @@ endfunc
|
||||
func Test_breakindent11()
|
||||
" test strdisplaywidth()
|
||||
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
|
||||
let text=getline(2)
|
||||
let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
|
||||
let text = getline(2)
|
||||
let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
|
||||
call assert_equal(width, strdisplaywidth(text))
|
||||
call s:close_windows('set sbr=')
|
||||
endfunc
|
||||
@@ -431,7 +431,7 @@ func Test_breakindent11_vartabs()
|
||||
" test strdisplaywidth()
|
||||
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
|
||||
let text = getline(2)
|
||||
let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
|
||||
let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
|
||||
call assert_equal(width, strdisplaywidth(text))
|
||||
call s:close_windows('set sbr= vts&')
|
||||
endfunc
|
||||
|
@@ -9,7 +9,7 @@ func Test_setbufline_getbufline()
|
||||
hide
|
||||
call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
|
||||
call assert_equal(['foo'], getbufline(b, 1))
|
||||
call assert_equal(['bar'], getbufline(b, 2))
|
||||
call assert_equal(['bar'], getbufline(b, '$'))
|
||||
call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
|
||||
exe "bd!" b
|
||||
call assert_equal([], getbufline(b, 1, 2))
|
||||
@@ -21,7 +21,7 @@ func Test_setbufline_getbufline()
|
||||
call assert_equal(1, setbufline(b, 5, ['x']))
|
||||
call assert_equal(1, setbufline(1234, 1, ['x']))
|
||||
call assert_equal(0, setbufline(b, 4, ['d', 'e']))
|
||||
call assert_equal(['c'], getbufline(b, 3))
|
||||
call assert_equal(['c'], b->getbufline(3))
|
||||
call assert_equal(['d'], getbufline(b, 4))
|
||||
call assert_equal(['e'], getbufline(b, 5))
|
||||
call assert_equal([], getbufline(b, 6))
|
||||
@@ -82,6 +82,7 @@ func Test_appendbufline()
|
||||
call setline(1, ['a', 'b', 'c'])
|
||||
let b = bufnr('%')
|
||||
wincmd w
|
||||
call assert_equal(1, appendbufline(b, -1, ['x']))
|
||||
call assert_equal(1, appendbufline(b, 4, ['x']))
|
||||
call assert_equal(1, appendbufline(1234, 1, ['x']))
|
||||
call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
|
||||
@@ -104,8 +105,11 @@ func Test_deletebufline()
|
||||
exe "bd!" b
|
||||
call assert_equal(1, b->deletebufline(1))
|
||||
|
||||
call assert_equal(1, deletebufline(-1, 1))
|
||||
|
||||
split Xtest
|
||||
call setline(1, ['a', 'b', 'c'])
|
||||
call cursor(line('$'), 1)
|
||||
let b = bufnr('%')
|
||||
wincmd w
|
||||
call assert_equal(1, deletebufline(b, 4))
|
||||
|
@@ -77,7 +77,7 @@ function Test_getbufwintabinfo()
|
||||
|
||||
call assert_equal('green', winlist[2].variables.signal)
|
||||
call assert_equal(w4_id, winlist[3].winid)
|
||||
let winfo = getwininfo(w5_id)[0]
|
||||
let winfo = w5_id->getwininfo()[0]
|
||||
call assert_equal(2, winfo.tabnr)
|
||||
call assert_equal([], getwininfo(3))
|
||||
|
||||
@@ -88,7 +88,7 @@ function Test_getbufwintabinfo()
|
||||
call assert_equal(2, tablist[1].tabnr)
|
||||
call assert_equal('build', tablist[0].variables.space)
|
||||
call assert_equal(w2_id, tablist[0].windows[0])
|
||||
call assert_equal([], gettabinfo(3))
|
||||
call assert_equal([], 3->gettabinfo())
|
||||
|
||||
tabonly | only
|
||||
|
||||
@@ -106,7 +106,7 @@ function Test_getbufwintabinfo()
|
||||
endfunction
|
||||
|
||||
function Test_get_buf_options()
|
||||
let opts = getbufvar(bufnr('%'), '&')
|
||||
let opts = bufnr()->getbufvar('&')
|
||||
call assert_equal(v:t_dict, type(opts))
|
||||
call assert_equal(8, opts.tabstop)
|
||||
endfunc
|
||||
|
@@ -8,8 +8,8 @@ func Test_getchangelist()
|
||||
|
||||
bwipe!
|
||||
enew
|
||||
call assert_equal([], getchangelist(10))
|
||||
call assert_equal([[], 0], getchangelist('%'))
|
||||
call assert_equal([], 10->getchangelist())
|
||||
call assert_equal([[], 0], getchangelist())
|
||||
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')
|
||||
|
@@ -34,7 +34,7 @@ func Test_client_server()
|
||||
" When using valgrind it takes much longer.
|
||||
call WaitForAssert({-> assert_match(name, serverlist())})
|
||||
|
||||
call remote_foreground(name)
|
||||
eval name->remote_foreground()
|
||||
|
||||
call remote_send(name, ":let testvar = 'yes'\<CR>")
|
||||
call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"')
|
||||
@@ -53,7 +53,7 @@ func Test_client_server()
|
||||
endif
|
||||
" Wait for the server to be up and answering requests.
|
||||
sleep 100m
|
||||
call WaitForAssert({-> assert_true(remote_expr(name, "v:version", "", 1) != "")})
|
||||
call WaitForAssert({-> assert_true(name->remote_expr("v:version", "", 1) != "")})
|
||||
|
||||
call remote_send(name, ":let testvar = 'maybe'\<CR>")
|
||||
call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})
|
||||
@@ -72,7 +72,7 @@ func Test_client_server()
|
||||
|
||||
" Expression evaluated locally.
|
||||
if v:servername == ''
|
||||
call remote_startserver('MYSELF')
|
||||
eval 'MYSELF'->remote_startserver()
|
||||
" May get MYSELF1 when running the test again.
|
||||
call assert_match('MYSELF', v:servername)
|
||||
endif
|
||||
@@ -80,11 +80,11 @@ func Test_client_server()
|
||||
call assert_equal('myself', remote_expr(v:servername, 'testvar'))
|
||||
|
||||
call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid')
|
||||
call assert_equal('got it', remote_read(g:myserverid, 2))
|
||||
call assert_equal('got it', g:myserverid->remote_read(2))
|
||||
|
||||
call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid')
|
||||
let peek_result = 'nothing'
|
||||
let r = remote_peek(g:myserverid, 'peek_result')
|
||||
let r = g:myserverid->remote_peek('peek_result')
|
||||
" unpredictable whether the result is already available.
|
||||
if r > 0
|
||||
call assert_equal('another', peek_result)
|
||||
@@ -98,7 +98,7 @@ func Test_client_server()
|
||||
call assert_equal('another', g:peek_result)
|
||||
call assert_equal('another', remote_read(g:myserverid, 2))
|
||||
|
||||
call remote_send(name, ":qa!\<CR>")
|
||||
eval name->remote_send(":qa!\<CR>")
|
||||
try
|
||||
call WaitForAssert({-> assert_equal("dead", job_status(job))})
|
||||
finally
|
||||
|
@@ -260,7 +260,7 @@ func Test_getcompletion()
|
||||
endif
|
||||
let groupcount = len(getcompletion('', 'event'))
|
||||
call assert_true(groupcount > 0)
|
||||
let matchcount = len(getcompletion('File', 'event'))
|
||||
let matchcount = len('File'->getcompletion('event'))
|
||||
call assert_true(matchcount > 0)
|
||||
call assert_true(groupcount > matchcount)
|
||||
|
||||
|
@@ -25,6 +25,12 @@ func Test_move_cursor()
|
||||
call cursor(9, 1)
|
||||
call assert_equal([4, 1, 0, 1], getcurpos()[1:])
|
||||
|
||||
call setline(1, ["\<TAB>"])
|
||||
call cursor(1, 1, 1)
|
||||
call assert_equal([1, 1, 1], getcurpos()[1:3])
|
||||
|
||||
call assert_equal(-1, cursor(-1, -1))
|
||||
|
||||
quit!
|
||||
endfunc
|
||||
|
||||
|
@@ -201,11 +201,11 @@ func Test_edit_07()
|
||||
endfu
|
||||
au InsertCharPre <buffer> :call DoIt()
|
||||
call feedkeys("A\<f5>\<c-p>u\<cr>\<c-l>\<cr>", 'tx')
|
||||
call assert_equal(["Jan\<c-l>",''], getline(1,'$'))
|
||||
call assert_equal(["Jan\<c-l>",''], 1->getline('$'))
|
||||
%d
|
||||
call setline(1, 'J')
|
||||
call feedkeys("A\<f5>\<c-p>u\<down>\<c-l>\<cr>", 'tx')
|
||||
call assert_equal(["January"], getline(1,'$'))
|
||||
call assert_equal(["January"], 1->getline('$'))
|
||||
|
||||
delfu ListMonths
|
||||
delfu DoIt
|
||||
@@ -348,7 +348,7 @@ func Test_edit_12()
|
||||
call cursor(2, 4)
|
||||
call feedkeys("R^\<c-d>", 'tnix')
|
||||
call assert_equal(["\tabc", "def"], getline(1, '$'))
|
||||
call assert_equal([0, 2, 2, 0], getpos('.'))
|
||||
call assert_equal([0, 2, 2, 0], '.'->getpos())
|
||||
%d
|
||||
call setline(1, ["\tabc", "\t\tdef"])
|
||||
call cursor(2, 2)
|
||||
|
@@ -15,7 +15,7 @@ endfunc
|
||||
|
||||
func Test_getenv()
|
||||
unlet! $TESTENV
|
||||
call assert_equal(v:null, getenv('TESTENV'))
|
||||
call assert_equal(v:null, 'TESTENV'->getenv())
|
||||
let $TESTENV = 'foo'
|
||||
call assert_equal('foo', getenv('TESTENV'))
|
||||
endfunc
|
||||
|
@@ -16,7 +16,7 @@ function Test_glob()
|
||||
" Execute these commands in the sandbox, so that using the shell fails.
|
||||
" Setting 'shell' to an invalid name causes a memory leak.
|
||||
sandbox call assert_equal("", glob('Xxx\{'))
|
||||
sandbox call assert_equal("", glob('Xxx\$'))
|
||||
sandbox call assert_equal("", 'Xxx\$'->glob())
|
||||
w! Xxx\{
|
||||
" } to fix highlighting
|
||||
w! Xxx\$
|
||||
@@ -28,7 +28,7 @@ endfunction
|
||||
|
||||
function Test_globpath()
|
||||
sandbox call assert_equal(expand("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim"),
|
||||
\ globpath('sautest/autoload', 'glob*.vim'))
|
||||
\ globpath('sautest/autoload', 'glob*.vim'))
|
||||
sandbox call assert_equal([expand('sautest/autoload/globone.vim'), expand('sautest/autoload/globtwo.vim')],
|
||||
\ globpath('sautest/autoload', 'glob*.vim', 0, 1))
|
||||
\ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
|
||||
endfunction
|
||||
|
@@ -37,6 +37,15 @@ func Test_expand_sflnum()
|
||||
delcommand Flnum
|
||||
endfunc
|
||||
|
||||
func Test_expand()
|
||||
new
|
||||
call assert_equal("", expand('%:S'))
|
||||
call assert_equal('3', '<slnum>'->expand())
|
||||
call assert_equal(['4'], expand('<slnum>', v:false, v:true))
|
||||
" Don't add any line above this, otherwise <slnum> will change.
|
||||
quit
|
||||
endfunc
|
||||
|
||||
func Test_expand_sfile()
|
||||
call assert_match('test_expand_func\.vim$', s:sfile)
|
||||
call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>'))
|
||||
|
@@ -147,7 +147,7 @@ function Test_printf_spec_s()
|
||||
call assert_equal(string(value), printf('%s', value))
|
||||
|
||||
" funcref
|
||||
call assert_equal('printf', printf('%s', function('printf')))
|
||||
call assert_equal('printf', printf('%s', 'printf'->function()))
|
||||
|
||||
" partial
|
||||
call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
|
||||
@@ -477,7 +477,7 @@ func Test_funcref()
|
||||
endfunc
|
||||
call assert_equal(2, OneByName())
|
||||
call assert_equal(1, OneByRef())
|
||||
let OneByRef = funcref('One')
|
||||
let OneByRef = 'One'->funcref()
|
||||
call assert_equal(2, OneByRef())
|
||||
call assert_fails('echo funcref("{")', 'E475:')
|
||||
let OneByRef = funcref("One", repeat(["foo"], 20))
|
||||
|
@@ -50,7 +50,7 @@ func Test_findfile()
|
||||
set path=.
|
||||
call assert_equal('Xdir2/foo', findfile('foo'))
|
||||
call assert_equal('', findfile('bar'))
|
||||
call assert_equal('Xdir2/foobar', findfile('foobar'))
|
||||
call assert_equal('Xdir2/foobar', 'foobar'->findfile())
|
||||
|
||||
" Empty {path} 2nd argument is the same as no 2nd argument.
|
||||
call assert_equal('Xdir2/foo', findfile('foo', ''))
|
||||
@@ -138,7 +138,7 @@ func Test_finddir()
|
||||
cd Xdir1
|
||||
|
||||
call assert_equal('Xdir2', finddir('Xdir2'))
|
||||
call assert_equal('', finddir('Xdir3'))
|
||||
call assert_equal('', 'Xdir3'->finddir())
|
||||
|
||||
" Files should not be found (findfile() finds them).
|
||||
call assert_equal('', finddir('foo'))
|
||||
|
@@ -15,6 +15,7 @@ func Test_abs()
|
||||
call assert_equal("str2float('inf')", string(abs(1.0/0.0)))
|
||||
call assert_equal("str2float('inf')", string(abs(-1.0/0.0)))
|
||||
call assert_equal("str2float('nan')", string(abs(0.0/0.0)))
|
||||
call assert_equal('12', string(abs('12abc')))
|
||||
call assert_equal('12', string(abs('-12abc')))
|
||||
call assert_fails("call abs([])", 'E745:')
|
||||
call assert_fails("call abs({})", 'E728:')
|
||||
|
@@ -13,7 +13,7 @@ func Test_fnameescape()
|
||||
let fname = 'Xemark!'
|
||||
let status = v:false
|
||||
try
|
||||
exe "w! " . fnameescape(fname)
|
||||
exe "w! " . fname->fnameescape()
|
||||
let status = v:true
|
||||
endtry
|
||||
call assert_true(status, "ExclamationMark")
|
||||
|
@@ -13,7 +13,7 @@ func Test_fnamemodify()
|
||||
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
|
||||
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
|
||||
call assert_equal('~/testdir/a', fnamemodify('../testdir/a', ':~'))
|
||||
call assert_equal('a', fnamemodify('../testdir/a', ':t'))
|
||||
call assert_equal('a', '../testdir/a'->fnamemodify(':t'))
|
||||
call assert_equal('', fnamemodify('.', ':p:t'))
|
||||
call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
|
||||
call assert_equal('out', fnamemodify('test.out', ':p:e'))
|
||||
|
@@ -88,7 +88,7 @@ func Test_indent_fold2()
|
||||
setl fen fdm=marker
|
||||
2
|
||||
norm! >>
|
||||
let a=map(range(1,5), 'foldclosed(v:val)')
|
||||
let a=map(range(1,5), 'v:val->foldclosed()')
|
||||
call assert_equal([-1,-1,-1,4,4], a)
|
||||
bw!
|
||||
endfunc
|
||||
@@ -132,7 +132,7 @@ func Test_indent_fold_with_read()
|
||||
call assert_equal(0, foldlevel(3))
|
||||
call assert_equal(0, foldlevel(4))
|
||||
call assert_equal(1, foldlevel(5))
|
||||
call assert_equal(7, foldclosedend(5))
|
||||
call assert_equal(7, 5->foldclosedend())
|
||||
|
||||
bwipe!
|
||||
set foldmethod&
|
||||
@@ -207,7 +207,7 @@ func Test_update_folds_expr_read()
|
||||
%foldclose
|
||||
call assert_equal(2, foldclosedend(1))
|
||||
call assert_equal(0, foldlevel(3))
|
||||
call assert_equal(0, foldlevel(4))
|
||||
call assert_equal(0, 4->foldlevel())
|
||||
call assert_equal(6, foldclosedend(5))
|
||||
call assert_equal(10, foldclosedend(7))
|
||||
call assert_equal(14, foldclosedend(11))
|
||||
@@ -663,7 +663,7 @@ func Test_fold_move()
|
||||
call assert_equal(10, foldclosed(10))
|
||||
call assert_equal(11, foldclosedend(10))
|
||||
call assert_equal('+-- 2 lines: Line2', foldtextresult(2))
|
||||
call assert_equal('+-- 2 lines: Line8', foldtextresult(10))
|
||||
call assert_equal('+-- 2 lines: Line8', 10->foldtextresult())
|
||||
|
||||
set fdm& sw& fdl&
|
||||
enew!
|
||||
|
@@ -56,6 +56,7 @@ func Test_empty()
|
||||
endif
|
||||
|
||||
call assert_equal(0, empty(function('Test_empty')))
|
||||
call assert_equal(0, empty(function('Test_empty', [0])))
|
||||
endfunc
|
||||
|
||||
func Test_len()
|
||||
@@ -294,7 +295,7 @@ func Test_resolve_unix()
|
||||
call delete('Xlink')
|
||||
|
||||
silent !ln -s -f Xlink2/ Xlink1
|
||||
call assert_equal('Xlink2', resolve('Xlink1'))
|
||||
call assert_equal('Xlink2', 'Xlink1'->resolve())
|
||||
call assert_equal('Xlink2/', resolve('Xlink1/'))
|
||||
call delete('Xlink1')
|
||||
|
||||
@@ -359,10 +360,10 @@ endfunc
|
||||
func Test_pathshorten()
|
||||
call assert_equal('', pathshorten(''))
|
||||
call assert_equal('foo', pathshorten('foo'))
|
||||
call assert_equal('/foo', pathshorten('/foo'))
|
||||
call assert_equal('/foo', '/foo'->pathshorten())
|
||||
call assert_equal('f/', pathshorten('foo/'))
|
||||
call assert_equal('f/bar', pathshorten('foo/bar'))
|
||||
call assert_equal('f/b/foobar', pathshorten('foo/bar/foobar'))
|
||||
call assert_equal('f/b/foobar', 'foo/bar/foobar'->pathshorten())
|
||||
call assert_equal('/f/b/foobar', pathshorten('/foo/bar/foobar'))
|
||||
call assert_equal('.f/bar', pathshorten('.foo/bar'))
|
||||
call assert_equal('~f/bar', pathshorten('~foo/bar'))
|
||||
@@ -657,8 +658,8 @@ func Test_mode()
|
||||
exe "normal gRabc\<C-X>\<C-L>\<F2>\<Esc>u"
|
||||
call assert_equal('R-Rvc', g:current_modes)
|
||||
|
||||
call assert_equal('n', mode(0))
|
||||
call assert_equal('n', mode(1))
|
||||
call assert_equal('n', 0->mode())
|
||||
call assert_equal('n', 1->mode())
|
||||
|
||||
" i_CTRL-O
|
||||
exe "normal i\<C-O>:call Save_mode()\<Cr>\<Esc>"
|
||||
@@ -822,7 +823,7 @@ endfunc
|
||||
|
||||
func Test_match_func()
|
||||
call assert_equal(4, match('testing', 'ing'))
|
||||
call assert_equal(4, match('testing', 'ing', 2))
|
||||
call assert_equal(4, 'testing'->match('ing', 2))
|
||||
call assert_equal(-1, match('testing', 'ing', 5))
|
||||
call assert_equal(-1, match('testing', 'ing', 8))
|
||||
call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing'))
|
||||
@@ -831,7 +832,7 @@ endfunc
|
||||
|
||||
func Test_matchend()
|
||||
call assert_equal(7, matchend('testing', 'ing'))
|
||||
call assert_equal(7, matchend('testing', 'ing', 2))
|
||||
call assert_equal(7, 'testing'->matchend('ing', 2))
|
||||
call assert_equal(-1, matchend('testing', 'ing', 5))
|
||||
call assert_equal(-1, matchend('testing', 'ing', 8))
|
||||
call assert_equal(match(['vim', 'testing', 'execute'], 'ing'), matchend(['vim', 'testing', 'execute'], 'ing'))
|
||||
@@ -840,13 +841,13 @@ endfunc
|
||||
|
||||
func Test_matchlist()
|
||||
call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)'))
|
||||
call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
|
||||
call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], 'acd'->matchlist('\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
|
||||
call assert_equal([], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 4))
|
||||
endfunc
|
||||
|
||||
func Test_matchstr()
|
||||
call assert_equal('ing', matchstr('testing', 'ing'))
|
||||
call assert_equal('ing', matchstr('testing', 'ing', 2))
|
||||
call assert_equal('ing', 'testing'->matchstr('ing', 2))
|
||||
call assert_equal('', matchstr('testing', 'ing', 5))
|
||||
call assert_equal('', matchstr('testing', 'ing', 8))
|
||||
call assert_equal('testing', matchstr(['vim', 'testing', 'execute'], 'ing'))
|
||||
@@ -855,7 +856,7 @@ endfunc
|
||||
|
||||
func Test_matchstrpos()
|
||||
call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
|
||||
call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
|
||||
call assert_equal(['ing', 4, 7], 'testing'->matchstrpos('ing', 2))
|
||||
call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
|
||||
call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8))
|
||||
call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing'))
|
||||
@@ -876,21 +877,21 @@ Test
|
||||
call assert_equal(0, nextnonblank(-1))
|
||||
call assert_equal(0, nextnonblank(0))
|
||||
call assert_equal(1, nextnonblank(1))
|
||||
call assert_equal(4, nextnonblank(2))
|
||||
call assert_equal(4, 2->nextnonblank())
|
||||
call assert_equal(4, nextnonblank(3))
|
||||
call assert_equal(4, nextnonblank(4))
|
||||
call assert_equal(6, nextnonblank(5))
|
||||
call assert_equal(6, nextnonblank(6))
|
||||
call assert_equal(7, nextnonblank(7))
|
||||
call assert_equal(0, nextnonblank(8))
|
||||
call assert_equal(0, 8->nextnonblank())
|
||||
|
||||
call assert_equal(0, prevnonblank(-1))
|
||||
call assert_equal(0, prevnonblank(0))
|
||||
call assert_equal(1, prevnonblank(1))
|
||||
call assert_equal(1, 1->prevnonblank())
|
||||
call assert_equal(1, prevnonblank(2))
|
||||
call assert_equal(1, prevnonblank(3))
|
||||
call assert_equal(4, prevnonblank(4))
|
||||
call assert_equal(4, prevnonblank(5))
|
||||
call assert_equal(4, 5->prevnonblank())
|
||||
call assert_equal(6, prevnonblank(6))
|
||||
call assert_equal(7, prevnonblank(7))
|
||||
call assert_equal(0, prevnonblank(8))
|
||||
@@ -912,7 +913,7 @@ func Test_byte2line_line2byte()
|
||||
call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
|
||||
\ map(range(-1, 8), 'v:val->byte2line()'))
|
||||
call assert_equal([-1, -1, 1, 3, 6, 8, -1],
|
||||
\ map(range(-1, 5), 'line2byte(v:val)'))
|
||||
\ map(range(-1, 5), 'v:val->line2byte()'))
|
||||
|
||||
set fileformat=dos
|
||||
call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1],
|
||||
@@ -1007,6 +1008,7 @@ func Test_count()
|
||||
call assert_equal(1, count(l, 'a', 0, 1))
|
||||
call assert_equal(2, count(l, 'a', 1, 1))
|
||||
call assert_fails('call count(l, "a", 0, 10)', 'E684:')
|
||||
call assert_fails('call count(l, "a", [])', 'E745:')
|
||||
|
||||
let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'}
|
||||
call assert_equal(2, count(d, 'a'))
|
||||
@@ -1034,6 +1036,8 @@ func Test_count()
|
||||
call assert_equal(2, count("foo", "O", 1))
|
||||
call assert_equal(2, count("fooooo", "oo"))
|
||||
call assert_equal(0, count("foo", ""))
|
||||
|
||||
call assert_fails('call count(0, 0)', 'E712:')
|
||||
endfunc
|
||||
|
||||
func Test_changenr()
|
||||
@@ -1061,7 +1065,7 @@ func Test_filewritable()
|
||||
call assert_equal(0, filewritable('Xfilewritable'))
|
||||
|
||||
call assert_notequal(0, setfperm('Xfilewritable', 'rw-r-----'))
|
||||
call assert_equal(1, filewritable('Xfilewritable'))
|
||||
call assert_equal(1, 'Xfilewritable'->filewritable())
|
||||
|
||||
call assert_equal(0, filewritable('doesnotexist'))
|
||||
|
||||
@@ -1072,12 +1076,12 @@ endfunc
|
||||
func Test_Executable()
|
||||
if has('win32')
|
||||
call assert_equal(1, executable('notepad'))
|
||||
call assert_equal(1, executable('notepad.exe'))
|
||||
call assert_equal(1, 'notepad.exe'->executable())
|
||||
call assert_equal(0, executable('notepad.exe.exe'))
|
||||
call assert_equal(0, executable('shell32.dll'))
|
||||
call assert_equal(0, executable('win.ini'))
|
||||
elseif has('unix')
|
||||
call assert_equal(1, executable('cat'))
|
||||
call assert_equal(1, 'cat'->executable())
|
||||
call assert_equal(0, executable('nodogshere'))
|
||||
|
||||
" get "cat" path and remove the leading /
|
||||
@@ -1086,8 +1090,7 @@ func Test_Executable()
|
||||
" check that the relative path works in /
|
||||
lcd /
|
||||
call assert_equal(1, executable(catcmd))
|
||||
" let result = catcmd->exepath()
|
||||
let result = exepath(catcmd)
|
||||
let result = catcmd->exepath()
|
||||
" when using chroot looking for sbin/cat can return bin/cat, that is OK
|
||||
if catcmd =~ '\<sbin\>' && result =~ '\<bin\>'
|
||||
call assert_equal('/' .. substitute(catcmd, '\<sbin\>', 'bin', ''), result)
|
||||
@@ -1132,7 +1135,7 @@ endfunc
|
||||
|
||||
func Test_hlexists()
|
||||
call assert_equal(0, hlexists('does_not_exist'))
|
||||
" call assert_equal(0, hlexists('Number'))
|
||||
" call assert_equal(0, 'Number'->hlexists())
|
||||
call assert_equal(0, highlight_exists('does_not_exist'))
|
||||
" call assert_equal(0, highlight_exists('Number'))
|
||||
syntax on
|
||||
@@ -1165,7 +1168,7 @@ endfunc
|
||||
func Test_inputlist()
|
||||
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx')
|
||||
call assert_equal(1, c)
|
||||
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>2\<cr>", 'tx')
|
||||
call feedkeys(":let c = ['Select color:', '1. red', '2. green', '3. blue']->inputlist()\<cr>2\<cr>", 'tx')
|
||||
call assert_equal(2, c)
|
||||
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
|
||||
call assert_equal(3, c)
|
||||
@@ -1297,7 +1300,7 @@ func Test_trim()
|
||||
call assert_fails('call trim(" vim ", " ", -1)', 'E475:')
|
||||
call assert_fails('call trim(" vim ", " ", 3)', 'E475:')
|
||||
|
||||
let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '')
|
||||
let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '')
|
||||
call assert_equal("x", trim(chars . "x" . chars))
|
||||
endfunc
|
||||
|
||||
@@ -1311,7 +1314,7 @@ func Test_func_range_with_edit()
|
||||
" is invalid in that buffer.
|
||||
call writefile(['just one line'], 'Xfuncrange2')
|
||||
new
|
||||
call setline(1, range(10))
|
||||
call setline(1, 10->range())
|
||||
write Xfuncrange1
|
||||
call assert_fails('5,8call EditAnotherFile()', 'E16:')
|
||||
|
||||
@@ -1324,7 +1327,7 @@ func Test_func_exists_on_reload()
|
||||
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
|
||||
call assert_equal(0, exists('*ExistingFunction'))
|
||||
source Xfuncexists
|
||||
call assert_equal(1, exists('*ExistingFunction'))
|
||||
call assert_equal(1, '*ExistingFunction'->exists())
|
||||
" Redefining a function when reloading a script is OK.
|
||||
source Xfuncexists
|
||||
call assert_equal(1, exists('*ExistingFunction'))
|
||||
@@ -1355,7 +1358,7 @@ func Test_func_sandbox()
|
||||
sandbox let F = {-> 'hello'}
|
||||
call assert_equal('hello', F())
|
||||
|
||||
sandbox let F = {-> execute("normal ix\<Esc>")}
|
||||
sandbox let F = {-> "normal ix\<Esc>"->execute()}
|
||||
call assert_fails('call F()', 'E48:')
|
||||
unlet F
|
||||
|
||||
@@ -1418,7 +1421,7 @@ func Test_reg_executing_and_recording()
|
||||
let g:regs = []
|
||||
func TestFunc() abort
|
||||
let g:regs += [reg_executing()]
|
||||
let g:typed = input('?')
|
||||
let g:typed = '?'->input()
|
||||
let g:regs += [reg_executing()]
|
||||
endfunc
|
||||
call feedkeys("@qy\<CR>", 'xt')
|
||||
@@ -1434,6 +1437,25 @@ func Test_reg_executing_and_recording()
|
||||
unlet s:reg_stat
|
||||
endfunc
|
||||
|
||||
func Test_inputsecret()
|
||||
map W :call TestFunc()<CR>
|
||||
let @q = "W"
|
||||
let g:typed1 = ''
|
||||
let g:typed2 = ''
|
||||
let g:regs = []
|
||||
func TestFunc() abort
|
||||
let g:typed1 = '?'->inputsecret()
|
||||
let g:typed2 = inputsecret('password: ')
|
||||
endfunc
|
||||
call feedkeys("@qsomething\<CR>else\<CR>", 'xt')
|
||||
call assert_equal("something", g:typed1)
|
||||
call assert_equal("else", g:typed2)
|
||||
delfunc TestFunc
|
||||
unmap W
|
||||
unlet g:typed1
|
||||
unlet g:typed2
|
||||
endfunc
|
||||
|
||||
func Test_getchar()
|
||||
call feedkeys('a', '')
|
||||
call assert_equal(char2nr('a'), getchar())
|
||||
@@ -1491,17 +1513,17 @@ func Test_libcall_libcallnr()
|
||||
endif
|
||||
|
||||
if has('win32')
|
||||
call assert_equal($USERPROFILE, libcall(libc, 'getenv', 'USERPROFILE'))
|
||||
call assert_equal($USERPROFILE, 'USERPROFILE'->libcall(libc, 'getenv'))
|
||||
else
|
||||
call assert_equal($HOME, libcall(libc, 'getenv', 'HOME'))
|
||||
call assert_equal($HOME, 'HOME'->libcall(libc, 'getenv'))
|
||||
endif
|
||||
|
||||
" If function returns NULL, libcall() should return an empty string.
|
||||
call assert_equal('', libcall(libc, 'getenv', 'X_ENV_DOES_NOT_EXIT'))
|
||||
|
||||
" Test libcallnr() with string and integer argument.
|
||||
call assert_equal(4, libcallnr(libc, 'strlen', 'abcd'))
|
||||
call assert_equal(char2nr('A'), libcallnr(libc, 'toupper', char2nr('a')))
|
||||
call assert_equal(4, 'abcd'->libcallnr(libc, 'strlen'))
|
||||
call assert_equal(char2nr('A'), char2nr('a')->libcallnr(libc, 'toupper'))
|
||||
|
||||
call assert_fails("call libcall(libc, 'Xdoesnotexist_', '')", 'E364:')
|
||||
call assert_fails("call libcallnr(libc, 'Xdoesnotexist_', '')", 'E364:')
|
||||
@@ -1564,7 +1586,7 @@ func Test_readdir()
|
||||
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
|
||||
|
||||
" Only results containing "f"
|
||||
let files = readdir('Xdir', { x -> stridx(x, 'f') !=- 1 })
|
||||
let files = 'Xdir'->readdir({ x -> stridx(x, 'f') !=- 1 })
|
||||
call assert_equal(['foo.txt'], sort(files))
|
||||
|
||||
" Only .txt files
|
||||
@@ -1597,6 +1619,14 @@ func Test_call()
|
||||
call assert_fails("call call('Mylen', [], 0)", 'E715:')
|
||||
endfunc
|
||||
|
||||
func Test_char2nr()
|
||||
call assert_equal(12354, char2nr('あ', 1))
|
||||
endfunc
|
||||
|
||||
func Test_eventhandler()
|
||||
call assert_equal(0, eventhandler())
|
||||
endfunc
|
||||
|
||||
" Test for the eval() function
|
||||
func Test_eval()
|
||||
call assert_fails("call eval('5 a')", 'E488:')
|
||||
|
@@ -17,7 +17,7 @@ func GetCwdInfo(win, tab)
|
||||
let lflag = haslocaldir(a:win)
|
||||
else
|
||||
let dirname = fnamemodify(getcwd(a:win, a:tab), mod)
|
||||
let lflag = haslocaldir(a:win, a:tab)
|
||||
let lflag = a:win->haslocaldir(a:tab)
|
||||
endif
|
||||
return bufname . ' ' . dirname . ' ' . lflag
|
||||
endfunc
|
||||
@@ -35,7 +35,7 @@ function SetUp()
|
||||
" we start from a clean state.
|
||||
call delete("Xtopdir", "rf")
|
||||
new
|
||||
call mkdir('Xtopdir')
|
||||
eval 'Xtopdir'->mkdir()
|
||||
cd Xtopdir
|
||||
let g:topdir = getcwd()
|
||||
call mkdir('Xdir1')
|
||||
|
@@ -12,8 +12,8 @@ func Test_var()
|
||||
let def_str = "Chance"
|
||||
call assert_equal('Dance', getwinvar(1, 'var_str'))
|
||||
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
|
||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
|
||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
|
||||
call assert_equal({'var_str': 'Dance'}, 1->getwinvar(''))
|
||||
call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str))
|
||||
unlet w:var_str
|
||||
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
|
||||
call assert_equal({}, getwinvar(1, ''))
|
||||
@@ -31,7 +31,7 @@ func Test_var()
|
||||
let t:other = 777
|
||||
let def_list = [4, 5, 6, 7]
|
||||
tabrewind
|
||||
call assert_equal([1, 2, 3], gettabvar(3, 'var_list'))
|
||||
call assert_equal([1, 2, 3], 3->gettabvar('var_list'))
|
||||
call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
|
||||
call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
|
||||
call assert_equal({'var_list': [1, 2, 3], 'other': 777},
|
||||
@@ -61,7 +61,7 @@ func Test_var()
|
||||
let def_dict = {'dict2': 'newval'}
|
||||
wincmd b
|
||||
tabrewind
|
||||
call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict'))
|
||||
call assert_equal({'dict': 'tabwin'}, 2->gettabwinvar(3, 'var_dict'))
|
||||
call assert_equal({'dict': 'tabwin'},
|
||||
\ gettabwinvar(2, 3, 'var_dict', def_dict))
|
||||
call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))
|
||||
|
@@ -10,7 +10,7 @@ endfunc
|
||||
|
||||
func Test_glob2regpat_valid()
|
||||
call assert_equal('^foo\.', glob2regpat('foo.*'))
|
||||
call assert_equal('^foo.$', glob2regpat('foo?'))
|
||||
call assert_equal('^foo.$', 'foo?'->glob2regpat())
|
||||
call assert_equal('\.vim$', glob2regpat('*.vim'))
|
||||
call assert_equal('^[abc]$', glob2regpat('[abc]'))
|
||||
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
|
||||
|
@@ -13,7 +13,7 @@ function History_Tests(hist)
|
||||
call assert_equal(-1, histnr(a:hist))
|
||||
call assert_equal('', histget(a:hist))
|
||||
|
||||
call assert_true(histadd(a:hist, 'ls'))
|
||||
call assert_true('ls'->histadd(a:hist))
|
||||
call assert_true(histadd(a:hist, 'buffers'))
|
||||
call assert_equal('buffers', histget(a:hist))
|
||||
call assert_equal('ls', histget(a:hist, -2))
|
||||
@@ -22,14 +22,14 @@ function History_Tests(hist)
|
||||
call assert_equal('', histget(a:hist, -5))
|
||||
call assert_equal(2, histnr(a:hist))
|
||||
call assert_true(histdel(a:hist, 2))
|
||||
call assert_false(histdel(a:hist, 7))
|
||||
call assert_false(a:hist->histdel(7))
|
||||
call assert_equal(1, histnr(a:hist))
|
||||
call assert_equal('ls', histget(a:hist, -1))
|
||||
|
||||
call assert_true(histadd(a:hist, 'buffers'))
|
||||
call assert_true(histadd(a:hist, 'ls'))
|
||||
call assert_equal('ls', histget(a:hist, -1))
|
||||
call assert_equal(4, histnr(a:hist))
|
||||
call assert_equal('ls', a:hist->histget(-1))
|
||||
call assert_equal(4, a:hist->histnr())
|
||||
|
||||
let a=execute('history ' . a:hist)
|
||||
call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a)
|
||||
|
@@ -39,7 +39,7 @@ func Test_getjumplist()
|
||||
" Traverse the jump list and verify the results
|
||||
5
|
||||
exe "normal \<C-O>"
|
||||
call assert_equal(2, getjumplist(1)[1])
|
||||
call assert_equal(2, 1->getjumplist()[1])
|
||||
exe "normal 2\<C-O>"
|
||||
call assert_equal(0, getjumplist(1, 1)[1])
|
||||
exe "normal 3\<C-I>"
|
||||
|
@@ -43,6 +43,9 @@ func Test_lisp_indent()
|
||||
\ ',@body',
|
||||
\ '(princ "</a>")))'
|
||||
\ ])
|
||||
call assert_equal(7, lispindent(2))
|
||||
call assert_equal(5, 6->lispindent())
|
||||
|
||||
set lisp
|
||||
set lispwords&
|
||||
let save_copt = &cpoptions
|
||||
|
@@ -573,7 +573,7 @@ func Test_lockvar_script_autoload()
|
||||
set rtp+=./sautest
|
||||
lockvar g:footest#x
|
||||
unlockvar g:footest#x
|
||||
call assert_equal(-1, islocked('g:footest#x'))
|
||||
call assert_equal(-1, 'g:footest#x'->islocked())
|
||||
call assert_equal(0, exists('g:footest#x'))
|
||||
call assert_equal(1, g:footest#x)
|
||||
let &rtp = old_rtp
|
||||
|
@@ -1,5 +1,6 @@
|
||||
" Tests for maparg().
|
||||
" Also test utf8 map with a 0x80 byte.
|
||||
" Also test mapcheck()
|
||||
|
||||
function s:SID()
|
||||
return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
|
||||
@@ -22,7 +23,7 @@ function Test_maparg()
|
||||
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v',
|
||||
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
|
||||
\ 'rhs': 'isbar', 'buffer': 1},
|
||||
\ maparg('bar', '', 0, 1))
|
||||
\ 'bar'->maparg('', 0, 1))
|
||||
let lnum = expand('<sflnum>')
|
||||
map <buffer> <nowait> foo bar
|
||||
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ',
|
||||
@@ -51,6 +52,45 @@ function Test_maparg()
|
||||
unmap abc
|
||||
endfunction
|
||||
|
||||
func Test_mapcheck()
|
||||
call assert_equal('', mapcheck('a'))
|
||||
call assert_equal('', mapcheck('abc'))
|
||||
call assert_equal('', mapcheck('ax'))
|
||||
call assert_equal('', mapcheck('b'))
|
||||
|
||||
map a something
|
||||
call assert_equal('something', mapcheck('a'))
|
||||
call assert_equal('something', mapcheck('a', 'n'))
|
||||
call assert_equal('', mapcheck('a', 'c'))
|
||||
call assert_equal('', mapcheck('a', 'i'))
|
||||
call assert_equal('something', 'abc'->mapcheck())
|
||||
call assert_equal('something', 'ax'->mapcheck())
|
||||
call assert_equal('', mapcheck('b'))
|
||||
unmap a
|
||||
|
||||
map ab foobar
|
||||
call assert_equal('foobar', mapcheck('a'))
|
||||
call assert_equal('foobar', mapcheck('abc'))
|
||||
call assert_equal('', mapcheck('ax'))
|
||||
call assert_equal('', mapcheck('b'))
|
||||
unmap ab
|
||||
|
||||
map abc barfoo
|
||||
call assert_equal('barfoo', mapcheck('a'))
|
||||
call assert_equal('barfoo', mapcheck('a', 'n', 0))
|
||||
call assert_equal('', mapcheck('a', 'n', 1))
|
||||
call assert_equal('barfoo', mapcheck('abc'))
|
||||
call assert_equal('', mapcheck('ax'))
|
||||
call assert_equal('', mapcheck('b'))
|
||||
unmap abc
|
||||
|
||||
abbr ab abbrev
|
||||
call assert_equal('abbrev', mapcheck('a', 'i', 1))
|
||||
call assert_equal('', mapcheck('a', 'n', 1))
|
||||
call assert_equal('', mapcheck('a', 'i', 0))
|
||||
unabbr ab
|
||||
endfunc
|
||||
|
||||
function Test_range_map()
|
||||
new
|
||||
" Outside of the range, minimum
|
||||
|
@@ -14,7 +14,7 @@ function Test_match()
|
||||
2match MyGroup2 /FIXME/
|
||||
3match MyGroup3 /XXX/
|
||||
call assert_equal(['MyGroup1', 'TODO'], matcharg(1))
|
||||
call assert_equal(['MyGroup2', 'FIXME'], matcharg(2))
|
||||
call assert_equal(['MyGroup2', 'FIXME'], 2->matcharg())
|
||||
call assert_equal(['MyGroup3', 'XXX'], matcharg(3))
|
||||
|
||||
" --- Check that "matcharg()" returns an empty list if the argument is not 1,
|
||||
@@ -43,7 +43,7 @@ function Test_match()
|
||||
" --- Check that "matchdelete()" deletes the matches defined in the previous
|
||||
" --- test correctly.
|
||||
call matchdelete(m1)
|
||||
call matchdelete(m2)
|
||||
eval m2->matchdelete()
|
||||
call matchdelete(m3)
|
||||
call assert_equal([], getmatches())
|
||||
|
||||
@@ -55,7 +55,7 @@ function Test_match()
|
||||
" --- Check that "clearmatches()" clears all matches defined by ":match" and
|
||||
" --- "matchadd()".
|
||||
let m1 = matchadd("MyGroup1", "TODO")
|
||||
let m2 = matchadd("MyGroup2", "FIXME", 42)
|
||||
let m2 = "MyGroup2"->matchadd("FIXME", 42)
|
||||
let m3 = matchadd("MyGroup3", "XXX", 60, 17)
|
||||
match MyGroup1 /COFFEE/
|
||||
2match MyGroup2 /HUMPPA/
|
||||
@@ -117,7 +117,7 @@ function Test_match()
|
||||
call clearmatches()
|
||||
|
||||
call setline(1, 'abcdΣabcdef')
|
||||
call matchaddpos("MyGroup1", [[1, 4, 2], [1, 9, 2]])
|
||||
eval "MyGroup1"->matchaddpos([[1, 4, 2], [1, 9, 2]])
|
||||
1
|
||||
redraw!
|
||||
let v1 = screenattr(1, 1)
|
||||
|
@@ -32,7 +32,7 @@ endfunc
|
||||
|
||||
funct Test_VIM_Blob()
|
||||
call assert_equal('0z', perleval('VIM::Blob("")'))
|
||||
call assert_equal('0z31326162', perleval('VIM::Blob("12ab")'))
|
||||
call assert_equal('0z31326162', 'VIM::Blob("12ab")'->perleval())
|
||||
call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")'))
|
||||
call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")'))
|
||||
endfunc
|
||||
|
@@ -110,11 +110,8 @@ func Test_prompt_garbage_collect()
|
||||
|
||||
new
|
||||
set buftype=prompt
|
||||
" Nvim doesn't support method call syntax yet.
|
||||
" eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}]))
|
||||
" eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}]))
|
||||
eval prompt_setcallback(bufnr(''), function('MyPromptCallback', [{}]))
|
||||
eval prompt_setinterrupt(bufnr(''), function('MyPromptInterrupt', [{}]))
|
||||
eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}]))
|
||||
eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}]))
|
||||
call test_garbagecollect_now()
|
||||
" Must not crash
|
||||
call feedkeys("\<CR>\<C-C>", 'xt')
|
||||
|
@@ -59,7 +59,7 @@ func Test_vim_function()
|
||||
|
||||
try
|
||||
py f = vim.Function('\x80\xfdR' + vim.eval('s:foo()'))
|
||||
call assert_equal(name, pyeval('f.name'))
|
||||
call assert_equal(name, 'f.name'->pyeval())
|
||||
catch
|
||||
call assert_false(v:exception)
|
||||
endtry
|
||||
|
@@ -59,7 +59,7 @@ func Test_vim_function()
|
||||
|
||||
try
|
||||
py3 f = vim.Function(b'\x80\xfdR' + vim.eval('s:foo()').encode())
|
||||
call assert_equal(name, py3eval('f.name'))
|
||||
call assert_equal(name, 'f.name'->py3eval())
|
||||
catch
|
||||
call assert_false(v:exception)
|
||||
endtry
|
||||
|
@@ -35,7 +35,7 @@ endfunc
|
||||
|
||||
func Test_pyxeval()
|
||||
pyx import sys
|
||||
call assert_match(s:py2pattern, split(pyxeval('sys.version'))[0])
|
||||
call assert_match(s:py2pattern, split('sys.version'->pyxeval())[0])
|
||||
endfunc
|
||||
|
||||
|
||||
|
@@ -8,11 +8,11 @@ func Test_reltime()
|
||||
let now = reltime()
|
||||
sleep 10m
|
||||
let later = reltime()
|
||||
let elapsed = reltime(now)
|
||||
let elapsed = now->reltime()
|
||||
call assert_true(reltimestr(elapsed) =~ '0\.0')
|
||||
call assert_true(reltimestr(elapsed) != '0.0')
|
||||
call assert_true(elapsed->reltimestr() != '0.0')
|
||||
call assert_true(reltimefloat(elapsed) < 0.1)
|
||||
call assert_true(reltimefloat(elapsed) > 0.0)
|
||||
call assert_true(elapsed->reltimefloat() > 0.0)
|
||||
|
||||
let same = reltime(now, now)
|
||||
call assert_equal('0.000', split(reltimestr(same))[0][:4])
|
||||
|
@@ -25,7 +25,7 @@ func Test_rename_file_ignore_case()
|
||||
set fileignorecase
|
||||
call writefile(['foo'], 'Xrename')
|
||||
|
||||
call assert_equal(0, rename('Xrename', 'XRENAME'))
|
||||
call assert_equal(0, 'Xrename'->rename('XRENAME'))
|
||||
|
||||
call assert_equal(['foo'], readfile('XRENAME'))
|
||||
|
||||
|
@@ -1338,7 +1338,7 @@ func Test_search_display_pattern()
|
||||
|
||||
call cursor(1, 1)
|
||||
let @/ = 'foo'
|
||||
let pat = escape(@/, '()*?'. '\s\+')
|
||||
let pat = @/->escape('()*?'. '\s\+')
|
||||
let g:a = execute(':unsilent :norm! n')
|
||||
call assert_match(pat, g:a)
|
||||
|
||||
|
@@ -10,7 +10,7 @@ func CheckFileTime(doSleep)
|
||||
let fl = ['Hello World!']
|
||||
for fname in fnames
|
||||
call writefile(fl, fname)
|
||||
call add(times, getftime(fname))
|
||||
call add(times, fname->getftime())
|
||||
if a:doSleep
|
||||
sleep 1
|
||||
endif
|
||||
@@ -19,8 +19,8 @@ func CheckFileTime(doSleep)
|
||||
let time_correct = (times[0] <= times[1] && times[1] <= times[2])
|
||||
if a:doSleep || time_correct
|
||||
call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
|
||||
call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0]))
|
||||
call assert_equal('file', getftype(fnames[0]))
|
||||
call assert_equal(strlen(fl[0] . "\n"), fnames[0]->getfsize())
|
||||
call assert_equal('file', fnames[0]->getftype())
|
||||
call assert_equal('rw-', getfperm(fnames[0])[0:2])
|
||||
let result = 1
|
||||
endif
|
||||
|
@@ -8,7 +8,7 @@ func Test_missing_attr()
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
|
||||
hi Mine cterm=standout gui=undercurl
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
|
||||
call assert_equal('1', synIDattr("Mine"->hlID(), "undercurl", 'gui'))
|
||||
hi Mine gui=strikethrough
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "strikethrough", 'gui'))
|
||||
hi Mine cterm=NONE gui=NONE
|
||||
|
@@ -316,7 +316,7 @@ func Test_getsettagstack()
|
||||
enew | only
|
||||
call settagstack(1, {'items' : []})
|
||||
call assert_equal(0, gettagstack(1).length)
|
||||
call assert_equal([], gettagstack(1).items)
|
||||
call assert_equal([], 1->gettagstack().items)
|
||||
" Error cases
|
||||
call assert_equal({}, gettagstack(100))
|
||||
call assert_equal(-1, settagstack(100, {'items' : []}))
|
||||
|
@@ -104,7 +104,7 @@ func Test_true_false_arg()
|
||||
call Try_arg_true_false('maparg("asdf", "i", %v%)', "", "asdff")
|
||||
call Try_arg_true_false('FilterMapArg(maparg("asdf", "i", 1, %v%))', "asdff", {'rhs': 'asdff'})
|
||||
|
||||
call Try_arg_true_false('hasmapto("asdf", "i", %v%)', 0, 1)
|
||||
call Try_arg_true_false('"asdf"->hasmapto("i", %v%)', 0, 1)
|
||||
|
||||
new colored
|
||||
call setline(1, '<here>')
|
||||
|
@@ -111,7 +111,7 @@ func Test_list2str_str2list_utf8()
|
||||
let s = "\u304b\u3099\u3044"
|
||||
let l = [0x304b, 0x3099, 0x3044]
|
||||
call assert_equal(l, str2list(s, 1))
|
||||
call assert_equal(s, list2str(l, 1))
|
||||
call assert_equal(s, l->list2str(1))
|
||||
if &enc ==# 'utf-8'
|
||||
call assert_equal(str2list(s), str2list(s, 1))
|
||||
call assert_equal(list2str(l), list2str(l, 1))
|
||||
|
@@ -635,7 +635,7 @@ function! MSG(enr, emsg)
|
||||
if v:errmsg == ""
|
||||
Xout "Message missing."
|
||||
else
|
||||
let v:errmsg = escape(v:errmsg, '"')
|
||||
let v:errmsg = v:errmsg->escape('"')
|
||||
Xout "Unexpected message:" v:errmsg
|
||||
endif
|
||||
endif
|
||||
|
Reference in New Issue
Block a user