highlight_spec.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local Screen = require('test.functional.ui.screen')
  2. local helpers = require("test.functional.helpers")(after_each)
  3. local eq, command = helpers.eq, helpers.command
  4. local clear = helpers.clear
  5. local eval, exc_exec = helpers.eval, helpers.exc_exec
  6. local exec = helpers.exec
  7. local funcs = helpers.funcs
  8. local meths = helpers.meths
  9. describe(':highlight', function()
  10. local screen
  11. before_each(function()
  12. clear()
  13. screen = Screen.new()
  14. screen:attach()
  15. end)
  16. it('invalid color name', function()
  17. eq('Vim(highlight):E421: Color name or number not recognized: ctermfg=#181818',
  18. exc_exec("highlight normal ctermfg=#181818"))
  19. eq('Vim(highlight):E421: Color name or number not recognized: ctermbg=#181818',
  20. exc_exec("highlight normal ctermbg=#181818"))
  21. end)
  22. it('invalid group name', function()
  23. eq('Vim(highlight):E411: highlight group not found: foo',
  24. exc_exec("highlight foo"))
  25. end)
  26. it('"Normal" foreground with red', function()
  27. eq('', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
  28. command('highlight normal ctermfg=red')
  29. eq('9', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
  30. end)
  31. it('"Normal" background with red', function()
  32. eq('', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
  33. command('highlight normal ctermbg=red')
  34. eq('9', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
  35. end)
  36. it('only the last underline style takes effect #22371', function()
  37. command('highlight NonText gui=underline,undercurl')
  38. eq('', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
  39. eq('1', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
  40. command('highlight NonText gui=undercurl,underline')
  41. eq('', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
  42. eq('1', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
  43. end)
  44. it('clear', function()
  45. meths.set_var('colors_name', 'foo')
  46. eq(1, funcs.exists('g:colors_name'))
  47. command('hi clear')
  48. eq(0, funcs.exists('g:colors_name'))
  49. meths.set_var('colors_name', 'foo')
  50. eq(1, funcs.exists('g:colors_name'))
  51. exec([[
  52. func HiClear()
  53. hi clear
  54. endfunc
  55. ]])
  56. funcs.HiClear()
  57. eq(0, funcs.exists('g:colors_name'))
  58. end)
  59. end)