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