mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 07:58:35 +00:00
feat(eval/method): partially port v8.1.1925
Adds method call support for all functions in the patch, but it cannot be fully ported due to missing tests for: - getcwd(): requires chdir() and Test_chdir_func() from v8.1.1291. Note that the method call tests for getreg() and getregtype() were removed in v8.2.1547, which has already been ported, but doesn't seem to have been replaced with a new test... This patch also makes getchangelist()'s argument optional (defaults to the current buffer). eval.txt includes a typo for gettabwinvar(), which is fixed in v8.1.1952.
This commit is contained in:
@@ -137,9 +137,9 @@ return {
|
||||
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,30 +148,30 @@ 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}},
|
||||
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}},
|
||||
getwininfo={args={0, 1}},
|
||||
getwinpos={args={0, 1}},
|
||||
@@ -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;
|
||||
}
|
||||
|
@@ -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))
|
||||
|
@@ -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')
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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, ''))
|
||||
|
@@ -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>"
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user