charsearch_spec.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. -- Test for character searches
  2. local helpers = require('test.functional.helpers')(after_each)
  3. local feed, insert = helpers.feed, helpers.insert
  4. local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
  5. describe('charsearch', function()
  6. setup(clear)
  7. it('is working', function()
  8. insert([[
  9. Xabcdefghijkemnopqretuvwxyz
  10. Yabcdefghijkemnopqretuvwxyz
  11. Zabcdefghijkemnokqretkvwxyz]])
  12. -- Check that "fe" and ";" work.
  13. feed_command('/^X')
  14. feed('ylfep;;p,,p')
  15. -- Check that save/restore works.
  16. feed_command('/^Y')
  17. feed('ylfep')
  18. feed_command('let csave = getcharsearch()')
  19. feed('fip')
  20. feed_command('call setcharsearch(csave)')
  21. feed(';p;p')
  22. -- Check that setcharsearch() changes the settings.
  23. feed_command('/^Z')
  24. feed('ylfep')
  25. feed_command("call setcharsearch({'char': 'k'})")
  26. feed(';p')
  27. feed_command("call setcharsearch({'forward': 0})")
  28. feed('$;p')
  29. feed_command("call setcharsearch({'until': 1})")
  30. feed(';;p')
  31. -- Assert buffer contents.
  32. expect([[
  33. XabcdeXfghijkeXmnopqreXtuvwxyz
  34. YabcdeYfghiYjkeYmnopqreYtuvwxyz
  35. ZabcdeZfghijkZZemnokqretkZvwxyz]])
  36. end)
  37. end)