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