023_edit_arguments_spec.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. -- Tests for complicated + argument to :edit command
  2. local helpers = require('test.functional.helpers')(after_each)
  3. local clear, insert = helpers.clear, helpers.insert
  4. local command, expect = helpers.command, helpers.expect
  5. local poke_eventloop = helpers.poke_eventloop
  6. describe(':edit', function()
  7. setup(clear)
  8. it('is working', function()
  9. insert([[
  10. The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar"
  11. foo|bar
  12. foo/bar]])
  13. poke_eventloop()
  14. -- Prepare some test files
  15. command('$-1w! Xfile1')
  16. command('$w! Xfile2')
  17. command('w! Xfile0')
  18. -- Open Xfile using '+' range
  19. command('edit +1 Xfile1')
  20. command('s/|/PIPE/')
  21. command('yank A')
  22. command('w! Xfile1')
  23. -- Open Xfile2 using '|' range
  24. command('edit Xfile2|1')
  25. command("s/\\//SLASH/")
  26. command('yank A')
  27. command('w! Xfile2')
  28. -- Clean first buffer and put @a
  29. command('bf')
  30. command('%d')
  31. command('0put a')
  32. -- Remove empty line
  33. command('$d')
  34. -- The buffer should now contain
  35. expect([[
  36. fooPIPEbar
  37. fooSLASHbar]])
  38. end)
  39. teardown(function()
  40. os.remove('Xfile0')
  41. os.remove('Xfile1')
  42. os.remove('Xfile2')
  43. end)
  44. end)