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