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

Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.
3f4f3d8e7e

test_prompt_buffer.vim already had all the changes, except
Test_prompt_garbage_collect().
This commit is contained in:
Sean Dewar
2021-09-01 12:28:16 +01:00
parent d23d37b212
commit c5583df3c0
8 changed files with 56 additions and 27 deletions

View File

@@ -254,23 +254,23 @@ return {
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},
py3eval={args=1, base=1},
pyeval={args=1, base=1},
pyxeval={args=1, base=1},
perleval={args=1, base=1},
range={args={1, 3}},
readdir={args={1, 2}},
readfile={args={1, 3}},

View File

@@ -360,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'))
@@ -869,21 +869,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))
@@ -1292,7 +1292,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

View File

@@ -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

View File

@@ -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')

View File

@@ -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

View File

@@ -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

View File

@@ -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