Skip to content

Commit 67322bf

Browse files
committed
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 #7428)
1 parent 918a424 commit 67322bf

5 files changed

Lines changed: 41 additions & 2 deletions

File tree

src/testdir/test_functions.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,7 @@ func Test_call()
20992099
let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
21002100
eval mydict.len->call([], mydict)->assert_equal(4)
21012101
call assert_fails("call call('Mylen', [], 0)", 'E715:')
2102+
call assert_fails('call foo', 'E107:')
21022103
endfunc
21032104

21042105
func Test_char2nr()

src/testdir/test_lambda.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ func Test_closure_counter()
247247
call assert_equal(2, l:F())
248248
call assert_equal(3, l:F())
249249
call assert_equal(4, l:F())
250+
251+
call assert_match("^\n function <SNR>\\d\\+_bar() closure"
252+
\ .. "\n1 let x += 1"
253+
\ .. "\n2 return x"
254+
\ .. "\n endfunction$", execute('func s:bar'))
250255
endfunc
251256

252257
func Test_closure_unlet()

src/testdir/test_signals.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ func Test_deadly_signal_TERM()
153153
call assert_equal(['foo'], getline(1, '$'))
154154

155155
let result = readfile('XautoOut')
156-
call assert_match('VimLeavePre triggered', result[0])
157-
call assert_match('VimLeave triggered', result[1])
156+
call assert_equal(["VimLeavePre triggered", "VimLeave triggered"], result)
158157

159158
%bwipe!
160159
call delete('.Xsig_TERM.swp')

src/testdir/test_user_func.vim

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,36 @@ func Test_func_arg_error()
445445
delfunc Xfunc
446446
endfunc
447447

448+
func Test_func_dict()
449+
let mydict = {'a': 'b'}
450+
function mydict.somefunc() dict
451+
return len(self)
452+
endfunc
453+
454+
call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict))
455+
call assert_equal(2, mydict.somefunc())
456+
call assert_match("^\n function \\d\\\+() dict"
457+
\ .. "\n1 return len(self)"
458+
\ .. "\n endfunction$", execute('func mydict.somefunc'))
459+
endfunc
460+
461+
func Test_func_range()
462+
new
463+
call setline(1, range(1, 8))
464+
func FuncRange() range
465+
echo a:firstline
466+
echo a:lastline
467+
endfunc
468+
3
469+
call assert_equal("\n3\n3", execute('call FuncRange()'))
470+
call assert_equal("\n4\n6", execute('4,6 call FuncRange()'))
471+
call assert_equal("\n function FuncRange() range"
472+
\ .. "\n1 echo a:firstline"
473+
\ .. "\n2 echo a:lastline"
474+
\ .. "\n endfunction",
475+
\ execute('function FuncRange'))
476+
477+
bwipe!
478+
endfunc
479+
448480
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2100,
753755
/**/
754756
2099,
755757
/**/

0 commit comments

Comments
 (0)