nested_function_spec.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- Tests for nested function.
  2. local helpers = require('test.functional.helpers')(after_each)
  3. local clear, insert = helpers.clear, helpers.insert
  4. local command, expect, source = helpers.command, helpers.expect, helpers.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)