046_multi_line_regexps_spec.lua 1022 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. -- vim: set foldmethod=marker foldmarker=[[,]] :
  2. -- Tests for multi-line regexps with ":s"
  3. local helpers = require('test.functional.helpers')(after_each)
  4. local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
  5. local expect = helpers.expect
  6. describe('multi-line regexp', function()
  7. setup(clear)
  8. it('is working', function()
  9. insert([[
  10. 1 aa
  11. bb
  12. cc
  13. 2 dd
  14. ee
  15. 3 ef
  16. gh
  17. 4 ij
  18. 5 a8
  19. 8b c9
  20. 9d
  21. 6 e7
  22. 77f
  23. xxxxx]])
  24. -- Test if replacing a line break works with a back reference
  25. feed([[:/^1/,/^2/s/\n\(.\)/ \1/<cr>]])
  26. -- Test if inserting a line break works with a back reference
  27. feed([[:/^3/,/^4/s/\(.\)$/\r\1/<cr>]])
  28. -- Test if replacing a line break with another line break works
  29. feed([[:/^5/,/^6/s/\(\_d\{3}\)/x\1x/<cr>]])
  30. expect([[
  31. 1 aa bb cc 2 dd ee
  32. 3 e
  33. f
  34. g
  35. h
  36. 4 i
  37. j
  38. 5 ax8
  39. 8xb cx9
  40. 9xd
  41. 6 ex7
  42. 7x7f
  43. xxxxx]])
  44. end)
  45. end)