aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/051_highlight_spec.lua
blob: f35b70f93f27914b0655bfb1f5d6581a4fac87d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for ":highlight".

local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect

describe(':highlight', function()
  setup(clear)

  it('is working', function()
    -- Basic test if ":highlight" doesn't crash
    execute('highlight')
    execute('hi Search')

    -- Test setting colors.
    -- Test clearing one color and all doesn't generate error or warning
    execute('hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan')
    execute('hi Group2 term= cterm=')
    execute('hi Group3 term=underline cterm=bold')
    execute('redir! @a')
    execute('hi NewGroup')
    execute('hi Group2')
    execute('hi Group3')
    execute('hi clear NewGroup')
    execute('hi NewGroup')
    execute('hi Group2')
    execute('hi Group2 NONE')
    execute('hi Group2')
    execute('hi clear')
    execute('hi Group3')
    execute([[hi Crash term='asdf]])
    execute('redir END')

    -- Filter ctermfg and ctermbg, the numbers depend on the terminal
    execute('0put a')
    execute([[%s/ctermfg=\d*/ctermfg=2/]])
    execute([[%s/ctermbg=\d*/ctermbg=3/]])

    -- Filter out possibly translated error message
    execute('%s/E475: [^:]*:/E475:/')

    -- Fix the fileformat
    execute('set ff&')
    execute('$d')

    -- Assert buffer contents.
    expect([[
      
      
      NewGroup       xxx term=bold cterm=italic ctermfg=2 ctermbg=3
      
      Group2         xxx cleared
      
      Group3         xxx term=underline cterm=bold
      
      
      NewGroup       xxx cleared
      
      Group2         xxx cleared
      
      
      Group2         xxx cleared
      
      
      Group3         xxx cleared
      
      E475: term='asdf]])
  end)
end)