Bram Moolenaar | 75373f3 | 2017-08-07 22:02:30 +0200 | [diff] [blame] | 1 | " Tests for ":highlight". |
| 2 | func Test_highlight() |
| 3 | " basic test if ":highlight" doesn't crash |
| 4 | highlight |
| 5 | hi Search |
| 6 | |
| 7 | " test setting colors. |
| 8 | " test clearing one color and all doesn't generate error or warning |
| 9 | silent! hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan |
| 10 | silent! hi Group2 term= cterm= |
| 11 | hi Group3 term=underline cterm=bold |
| 12 | |
| 13 | let res = split(execute("hi NewGroup"), "\n")[0] |
| 14 | " filter ctermfg and ctermbg, the numbers depend on the terminal |
| 15 | let res = substitute(res, 'ctermfg=\d*', 'ctermfg=2', '') |
| 16 | let res = substitute(res, 'ctermbg=\d*', 'ctermbg=3', '') |
| 17 | call assert_equal("NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3", |
| 18 | \ res) |
| 19 | call assert_equal("Group2 xxx cleared", |
| 20 | \ split(execute("hi Group2"), "\n")[0]) |
| 21 | call assert_equal("Group3 xxx term=underline cterm=bold", |
| 22 | \ split(execute("hi Group3"), "\n")[0]) |
| 23 | |
| 24 | hi clear NewGroup |
| 25 | call assert_equal("NewGroup xxx cleared", |
| 26 | \ split(execute("hi NewGroup"), "\n")[0]) |
| 27 | call assert_equal("Group2 xxx cleared", |
| 28 | \ split(execute("hi Group2"), "\n")[0]) |
| 29 | hi Group2 NONE |
| 30 | call assert_equal("Group2 xxx cleared", |
| 31 | \ split(execute("hi Group2"), "\n")[0]) |
| 32 | hi clear |
| 33 | call assert_equal("Group3 xxx cleared", |
| 34 | \ split(execute("hi Group3"), "\n")[0]) |
| 35 | call assert_fails("hi Crash term='asdf", "E475:") |
| 36 | endfunc |