vim-patch:8.1.2011: more functions can be used as methods

Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.  Make the window
            command test faster.
ce90e36f59

test_* functions in the patch are N/A as they modify internal state.

Include test changes for test_ignore_error and test_feedinput (though they aren't run).
Other changed tests were excluded from previous patches, except test_termcodes.vim, which hasn't
been ported yet.
This commit is contained in:
Sean Dewar
2021-11-01 00:28:00 +00:00
parent 0f4510cb1a
commit 39776d1a65
6 changed files with 21 additions and 10 deletions

View File

@@ -9982,6 +9982,8 @@ tabpagebuflist([{arg}]) *tabpagebuflist()*
endfor endfor
< Note that a buffer may appear in more than one window. < Note that a buffer may appear in more than one window.
Can also be used as a |method|: >
GetTabpage()->tabpagebuflist()
tabpagenr([{arg}]) *tabpagenr()* tabpagenr([{arg}]) *tabpagenr()*
The result is a Number, which is the number of the current The result is a Number, which is the number of the current
@@ -10008,6 +10010,9 @@ tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
tabpagewinnr(4, '$') " number of windows in tab page 4 tabpagewinnr(4, '$') " number of windows in tab page 4
< When {tabarg} is invalid zero is returned. < When {tabarg} is invalid zero is returned.
Can also be used as a |method|: >
GetTabpage()->tabpagewinnr()
<
*tagfiles()* *tagfiles()*
tagfiles() Returns a |List| with the file names used to search for tags tagfiles() Returns a |List| with the file names used to search for tags
for the current buffer. This is the 'tags' option expanded. for the current buffer. This is the 'tags' option expanded.
@@ -10056,6 +10061,9 @@ taglist({expr} [, {filename}]) *taglist()*
located by Vim. Refer to |tags-file-format| for the format of located by Vim. Refer to |tags-file-format| for the format of
the tags file generated by the different ctags tools. the tags file generated by the different ctags tools.
Can also be used as a |method|: >
GetTagpattern()->taglist()
tempname() *tempname()* *temp-file-name* tempname() *tempname()* *temp-file-name*
The result is a String, which is the name of a file that The result is a String, which is the name of a file that
doesn't exist. It can be used for a temporary file. Example: > doesn't exist. It can be used for a temporary file. Example: >

View File

@@ -374,11 +374,11 @@ return {
synstack={args=2}, synstack={args=2},
system={args={1, 2}, base=1}, system={args={1, 2}, base=1},
systemlist={args={1, 3}, base=1}, systemlist={args={1, 3}, base=1},
tabpagebuflist={args={0, 1}}, tabpagebuflist={args={0, 1}, base=1},
tabpagenr={args={0, 1}}, tabpagenr={args={0, 1}},
tabpagewinnr={args={1, 2}}, tabpagewinnr={args={1, 2}, base=1},
tagfiles={}, tagfiles={},
taglist={args={1, 2}}, taglist={args={1, 2}, base=1},
tan={args=1, base=1, func="float_op_wrapper", data="&tan"}, tan={args=1, base=1, func="float_op_wrapper", data="&tan"},
tanh={args=1, base=1, func="float_op_wrapper", data="&tanh"}, tanh={args=1, base=1, func="float_op_wrapper", data="&tanh"},
tempname={}, tempname={},

View File

@@ -87,7 +87,7 @@ func Test_echoerr()
if has('float') if has('float')
call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"')) call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
endif endif
call test_ignore_error('<lambda>') eval '<lambda>'->test_ignore_error()
call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}')) call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
call test_ignore_error('RESET') call test_ignore_error('RESET')
endfunc endfunc

View File

@@ -14,7 +14,7 @@ func Test_taglist()
split Xtext split Xtext
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name})) call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name})) call assert_equal(['FFoo', 'BFoo'], map("Foo"->taglist("Xtext"), {i, v -> v.name}))
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name})) call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name})) call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))

View File

@@ -239,7 +239,7 @@ func FeedAndPeek(timer)
endfunc endfunc
func Interrupt(timer) func Interrupt(timer)
" call test_feedinput("\<C-C>") " eval "\<C-C>"->test_feedinput()
call nvim_input("\<C-C>") call nvim_input("\<C-C>")
endfunc endfunc

View File

@@ -452,7 +452,7 @@ func Test_window_newtab()
wincmd T wincmd T
call assert_equal(2, tabpagenr('$')) call assert_equal(2, tabpagenr('$'))
call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)')) call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)'))
call assert_equal(['Xc' ], map(tabpagebuflist(2), 'bufname(v:val)')) call assert_equal(['Xc' ], map(2->tabpagebuflist(), 'bufname(v:val)'))
%bw! %bw!
endfunc endfunc
@@ -577,8 +577,11 @@ endfunc
function! Fun_RenewFile() function! Fun_RenewFile()
" Need to wait a bit for the timestamp to be older. " Need to wait a bit for the timestamp to be older.
sleep 2 let old_ftime = getftime("tmp.txt")
while getftime("tmp.txt") == old_ftime
sleep 100m
silent execute '!echo "1" > tmp.txt' silent execute '!echo "1" > tmp.txt'
endwhile
sp sp
wincmd p wincmd p
edit! tmp.txt edit! tmp.txt
@@ -814,7 +817,7 @@ func Test_winnr()
tabnew tabnew
call assert_equal(8, tabpagewinnr(1, 'j')) call assert_equal(8, tabpagewinnr(1, 'j'))
call assert_equal(2, tabpagewinnr(1, 'k')) call assert_equal(2, 1->tabpagewinnr('k'))
call assert_equal(4, tabpagewinnr(1, 'h')) call assert_equal(4, tabpagewinnr(1, 'h'))
call assert_equal(6, tabpagewinnr(1, 'l')) call assert_equal(6, tabpagewinnr(1, 'l'))