0
0
mirror of https://github.com/vim/vim.git synced 2025-10-18 07:54:29 -04:00

patch 8.2.0693: closure using argument not tested

Problem:    Closure using argument not tested.
Solution:   Add a test, make it work.
This commit is contained in:
Bram Moolenaar
2020-05-03 22:30:49 +02:00
parent 4515bcdec8
commit 2fd4cd755c
3 changed files with 82 additions and 38 deletions

View File

@@ -700,5 +700,26 @@ def Test_closure_two_indirect_refs()
unlet g:Read
enddef
def MakeArgRefs(theArg: string)
let local = 'loc_val'
g:UseArg = {s -> theArg .. '/' .. local .. '/' .. s}
enddef
def MakeArgRefsVarargs(theArg: string, ...rest: list<string>)
let local = 'the_loc'
g:UseVararg = {s -> theArg .. '/' .. local .. '/' .. s .. '/' .. join(rest)}
enddef
def Test_closure_using_argument()
MakeArgRefs('arg_val')
assert_equal('arg_val/loc_val/call_val', g:UseArg('call_val'))
MakeArgRefsVarargs('arg_val', 'one', 'two')
assert_equal('arg_val/the_loc/call_val/one two', g:UseVararg('call_val'))
unlet g:UseArg
unlet g:UseVararg
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker