026_execute_while_if_spec.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. -- Test for :execute, :while and :if
  2. local n = require('test.functional.testnvim')()
  3. local clear = n.clear
  4. local expect = n.expect
  5. local source = n.source
  6. local command = n.command
  7. describe(':execute, :while and :if', function()
  8. setup(clear)
  9. it('is working', function()
  10. source([[
  11. let i = 0
  12. while i < 12
  13. let i = i + 1
  14. execute "normal o" . i . "\033"
  15. if i % 2
  16. normal Ax
  17. if i == 9
  18. break
  19. endif
  20. if i == 5
  21. continue
  22. else
  23. let j = 9
  24. while j > 0
  25. execute "normal" j . "a" . j . "\x1b"
  26. let j = j - 1
  27. endwhile
  28. endif
  29. endif
  30. if i == 9
  31. execute "normal Az\033"
  32. endif
  33. endwhile
  34. unlet i j
  35. ]])
  36. -- Remove empty line
  37. command('1d')
  38. -- Assert buffer contents.
  39. expect([[
  40. 1x999999999888888887777777666666555554444333221
  41. 2
  42. 3x999999999888888887777777666666555554444333221
  43. 4
  44. 5x
  45. 6
  46. 7x999999999888888887777777666666555554444333221
  47. 8
  48. 9x]])
  49. end)
  50. end)