robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for nested function. 2 3local n =require ( 'test.functional.testnvim' )() 4local t =require ( 'test.testutil' ) 5 6local describe , it , setup =t . describe , t . it , t . setup 7local clear , insert =n . clear , n . insert 8local command , expect , source =n . command , n . expect , n . source 9 10describe ( 'test_nested_function' , function () 11setup ( clear ) 12 13it ( 'is working' , function () 14insert ( [[ 15result:]] ) 16 17source ( [[ 18:fu! NestedFunc() 19: fu! Func1() 20: $put ='Func1' 21: endfunction 22: call Func1() 23: fu! s:func2() 24: $put ='s:func2' 25: endfunction 26: call s:func2() 27: fu! s:_func3() 28: $put ='s:_func3' 29: endfunction 30: call s:_func3() 31: let fn = 'Func4' 32: fu! {fn}() 33: $put ='Func4' 34: endfunction 35: call {fn}() 36: let fn = 'func5' 37: fu! s:{fn}() 38: $put ='s:func5' 39: endfunction 40: call s:{fn}() 41:endfunction]] ) 42command ( 'call NestedFunc()' ) 43 44-- Assert buffer contents. 45expect ( [[ 46result: 47Func1 48s:func2 49s:_func3 50Func4 51s:func5]] ) 52end ) 53end )