063_match_and_matchadd_spec.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- Tests for adjusting window and contents
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local clear, command = n.clear, n.command
  5. local insert = n.insert
  6. describe('063: Test for ":match", "matchadd()" and related functions', function()
  7. setup(clear)
  8. it('is working', function()
  9. local screen = Screen.new(40, 5)
  10. command('highlight MyGroup1 term=bold ctermbg=red guibg=red')
  11. command('highlight MyGroup2 term=italic ctermbg=green guibg=green')
  12. command('highlight MyGroup3 term=underline ctermbg=blue guibg=blue')
  13. -- Check that "matchaddpos()" positions matches correctly
  14. insert('abcdefghijklmnopq')
  15. command("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)")
  16. screen:expect([[
  17. abcd{30:e}fg{30:hij}klmnop^q |
  18. {1:~ }|*3
  19. |
  20. ]])
  21. command('call clearmatches()')
  22. command("call setline(1, 'abcdΣabcdef')")
  23. command("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])")
  24. screen:expect([[
  25. abc{30:dΣ}ab{30:cd}e^f |
  26. {1:~ }|*3
  27. |
  28. ]])
  29. end)
  30. end)