051_highlight_spec.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. -- Tests for ":highlight".
  2. local Screen = require('test.functional.ui.screen')
  3. local helpers = require('test.functional.helpers')(after_each)
  4. local clear, feed = helpers.clear, helpers.feed
  5. local expect = helpers.expect
  6. local eq = helpers.eq
  7. local poke_eventloop = helpers.poke_eventloop
  8. local exc_exec = helpers.exc_exec
  9. local feed_command = helpers.feed_command
  10. describe(':highlight', function()
  11. setup(clear)
  12. it('is working', function()
  13. local screen = Screen.new(35, 10)
  14. screen:attach()
  15. -- Basic test if ":highlight" doesn't crash
  16. feed_command('set more')
  17. feed(':highlight<CR>')
  18. -- FIXME(tarruda): We need to be sure the prompt is displayed before
  19. -- continuing, or risk a race condition where some of the following input
  20. -- is discarded resulting in test failure
  21. screen:expect([[
  22. :highlight |
  23. SpecialKey xxx ctermfg=4 |
  24. guifg=Blue |
  25. EndOfBuffer xxx links to NonText|
  26. |
  27. TermCursor xxx cterm=reverse |
  28. gui=reverse |
  29. TermCursorNC xxx cleared |
  30. NonText xxx ctermfg=12 |
  31. -- More --^ |
  32. ]])
  33. feed('q')
  34. poke_eventloop() -- wait until we're back to normal
  35. feed_command('hi Search')
  36. feed_command('hi Normal')
  37. -- Test setting colors.
  38. -- Test clearing one color and all doesn't generate error or warning
  39. feed_command('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan')
  40. feed_command('hi Group2 cterm=NONE')
  41. feed_command('hi Group3 cterm=bold')
  42. feed_command('redir! @a')
  43. feed_command('hi NewGroup')
  44. feed_command('hi Group2')
  45. feed_command('hi Group3')
  46. feed_command('hi clear NewGroup')
  47. feed_command('hi NewGroup')
  48. feed_command('hi Group2')
  49. feed_command('hi Group2 NONE')
  50. feed_command('hi Group2')
  51. feed_command('hi clear')
  52. feed_command('hi Group3')
  53. feed('<cr>')
  54. eq('Vim(highlight):E475: Invalid argument: cterm=\'asdf',
  55. exc_exec([[hi Crash cterm='asdf]]))
  56. feed_command('redir END')
  57. -- Filter ctermfg and ctermbg, the numbers depend on the terminal
  58. feed_command('0put a')
  59. feed_command([[%s/ctermfg=\d*/ctermfg=2/]])
  60. feed_command([[%s/ctermbg=\d*/ctermbg=3/]])
  61. -- Fix the fileformat
  62. feed_command('set ff&')
  63. feed_command('$d')
  64. -- Assert buffer contents.
  65. expect([[
  66. NewGroup xxx cterm=italic
  67. ctermfg=2
  68. ctermbg=3
  69. guifg=#00ff00
  70. guibg=Cyan
  71. Group2 xxx cleared
  72. Group3 xxx cterm=bold
  73. NewGroup xxx cleared
  74. Group2 xxx cleared
  75. Group2 xxx cleared
  76. Group3 xxx cleared]])
  77. end)
  78. end)