mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.2100: insufficient testing for function range and dict
Problem: Insufficient testing for function range and dict.
Solution: Add a few tests. (Dominique Pellé, closes vim/vim#7428)
67322bf74a
This commit is contained in:
parent
245e6c5b30
commit
bd122494cc
@ -1865,6 +1865,7 @@ func Test_call()
|
|||||||
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
|
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
|
||||||
eval mydict.len->call([], mydict)->assert_equal(4)
|
eval mydict.len->call([], mydict)->assert_equal(4)
|
||||||
call assert_fails("call call('Mylen', [], 0)", 'E715:')
|
call assert_fails("call call('Mylen', [], 0)", 'E715:')
|
||||||
|
call assert_fails('call foo', 'E107:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_char2nr()
|
func Test_char2nr()
|
||||||
|
@ -245,6 +245,11 @@ func Test_closure_counter()
|
|||||||
call assert_equal(2, l:F())
|
call assert_equal(2, l:F())
|
||||||
call assert_equal(3, l:F())
|
call assert_equal(3, l:F())
|
||||||
call assert_equal(4, l:F())
|
call assert_equal(4, l:F())
|
||||||
|
|
||||||
|
call assert_match("^\n function <SNR>\\d\\+_bar() closure"
|
||||||
|
\ .. "\n1 let x += 1"
|
||||||
|
\ .. "\n2 return x"
|
||||||
|
\ .. "\n endfunction$", execute('func s:bar'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_closure_unlet()
|
func Test_closure_unlet()
|
||||||
|
@ -129,8 +129,7 @@ func Test_deadly_signal_TERM()
|
|||||||
call assert_equal(['foo'], getline(1, '$'))
|
call assert_equal(['foo'], getline(1, '$'))
|
||||||
|
|
||||||
let result = readfile('XautoOut')
|
let result = readfile('XautoOut')
|
||||||
call assert_match('VimLeavePre triggered', result[0])
|
call assert_equal(["VimLeavePre triggered", "VimLeave triggered"], result)
|
||||||
call assert_match('VimLeave triggered', result[1])
|
|
||||||
|
|
||||||
%bwipe!
|
%bwipe!
|
||||||
call delete('.Xsig_TERM.swp')
|
call delete('.Xsig_TERM.swp')
|
||||||
|
@ -445,4 +445,36 @@ func Test_func_arg_error()
|
|||||||
delfunc Xfunc
|
delfunc Xfunc
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_func_dict()
|
||||||
|
let mydict = {'a': 'b'}
|
||||||
|
function mydict.somefunc() dict
|
||||||
|
return len(self)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict))
|
||||||
|
call assert_equal(2, mydict.somefunc())
|
||||||
|
call assert_match("^\n function \\d\\\+() dict"
|
||||||
|
\ .. "\n1 return len(self)"
|
||||||
|
\ .. "\n endfunction$", execute('func mydict.somefunc'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_func_range()
|
||||||
|
new
|
||||||
|
call setline(1, range(1, 8))
|
||||||
|
func FuncRange() range
|
||||||
|
echo a:firstline
|
||||||
|
echo a:lastline
|
||||||
|
endfunc
|
||||||
|
3
|
||||||
|
call assert_equal("\n3\n3", execute('call FuncRange()'))
|
||||||
|
call assert_equal("\n4\n6", execute('4,6 call FuncRange()'))
|
||||||
|
call assert_equal("\n function FuncRange() range"
|
||||||
|
\ .. "\n1 echo a:firstline"
|
||||||
|
\ .. "\n2 echo a:lastline"
|
||||||
|
\ .. "\n endfunction",
|
||||||
|
\ execute('function FuncRange'))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user