nested_function_spec.lua 1.0 KB

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