1" Tests for nested functions 2 3source check.vim 4 5func NestedFunc() 6 func! Func1() 7 let g:text .= 'Func1 ' 8 endfunc 9 call Func1() 10 func! s:func2() 11 let g:text .= 's:func2 ' 12 endfunc 13 call s:func2() 14 func! s:_func3() 15 let g:text .= 's:_func3 ' 16 endfunc 17 call s:_func3() 18 let fn = 'Func4' 19 func! {fn}() 20 let g:text .= 'Func4 ' 21 endfunc 22 call {fn}() 23 let fn = 'func5' 24 func! s:{fn}() 25 let g:text .= 's:func5' 26 endfunc 27 call s:{fn}() 28endfunc 29 30func Test_nested_functions() 31 let g:text = '' 32 call NestedFunc() 33 call assert_equal('Func1 s:func2 s:_func3 Func4 s:func5', g:text) 34endfunction 35 36func Test_nested_argument() 37 func g:X() 38 let g:Y = function('sort') 39 endfunc 40 let g:Y = function('sort') 41 echo g:Y([], g:X()) 42 delfunc g:X 43 unlet g:Y 44endfunc 45 46func Recurse(count) 47 if a:count > 0 48 call Recurse(a:count - 1) 49 endif 50endfunc 51 52func Test_max_nesting() 53 " TODO: why does this fail on Windows? Runs out of stack perhaps? 54 CheckNotMSWindows 55 56 let call_depth_here = 2 57 let ex_depth_here = 5 58 set mfd& 59 60 call Recurse(99 - call_depth_here) 61 call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:') 62 63 set mfd=210 64 call Recurse(209 - ex_depth_here) 65 call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:') 66 67 set mfd& 68endfunc 69 70" vim: shiftwidth=2 sts=2 expandtab 71