From 86b138b25de6b0699329fab25df152bbf7ddab63 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Tue, 31 May 2016 05:46:32 -0400 Subject: synIDattr(): return RRGGBB value for [fg|bg|sp]# #4851 add tests for synIDattr() with [fg|bg|sp]# add tests for synIDattr and various #RGB colors synIDattr: test for ui_rgb_attached() test: fix tests for synIDattr fg/bg/sp --- test/functional/terminal/highlight_spec.lua | 31 ++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 8876c68673..79b2bf0bc4 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -165,24 +165,49 @@ end) describe('synIDattr()', function() local screen - before_each(function() clear() screen = Screen.new(50, 7) - execute('highlight Normal ctermfg=1 guifg=#ff0000') + execute('highlight Normal ctermfg=1 guifg=#ff0000 guibg=Black') + -- Salmon #fa8072 Maroon #800000 + execute('highlight Keyword ctermfg=2 guifg=Salmon guisp=Maroon') end) after_each(function() screen:detach() end) - it('returns RGB number if GUI', function() + it('returns gui-color if GUI', function() + eq('1', eval('synIDattr(hlID("Normal"), "fg")')) + eq('-1', eval('synIDattr(hlID("Normal"), "bg")')) + + eq('2', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('', eval('synIDattr(hlID("Keyword"), "sp")')) screen:attach(true) eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) + eq('Black', eval('synIDattr(hlID("Normal"), "bg")')) + + eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")')) + end) + + it('returns #RRGGBB value for [fg|bg|sp]#', function() + eq('1', eval('synIDattr(hlID("Normal"), "fg#")')) + eq('-1', eval('synIDattr(hlID("Normal"), "bg#")')) + + eq('2', eval('synIDattr(hlID("Keyword"), "fg#")')) + eq('', eval('synIDattr(hlID("Keyword"), "sp#")')) + screen:attach(true) + eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")')) + eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")')) + + eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")')) + eq('#800000', eval('synIDattr(hlID("Keyword"), "sp#")')) end) it('returns color number if non-GUI', function() screen:attach(false) eq('1', eval('synIDattr(hlID("Normal"), "fg")')) + eq('2', eval('synIDattr(hlID("Keyword"), "fg")')) end) end) -- cgit From abeb2f020fe5cd265b8098d5fe000ca0ec20dcfe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 18 Jun 2016 12:49:50 -0400 Subject: test/highlight_spec: Test "gui" arg of synIDattr(). Also use less "regular" values for cterm colors. --- test/functional/terminal/highlight_spec.lua | 46 ++++++++++++++--------------- test/functional/ui/highlight_spec.lua | 1 - 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 79b2bf0bc4..8d7c7451d3 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -168,46 +168,46 @@ describe('synIDattr()', function() before_each(function() clear() screen = Screen.new(50, 7) - execute('highlight Normal ctermfg=1 guifg=#ff0000 guibg=Black') + execute('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black') -- Salmon #fa8072 Maroon #800000 - execute('highlight Keyword ctermfg=2 guifg=Salmon guisp=Maroon') + execute('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon') end) - after_each(function() - screen:detach() + it('returns cterm-color if RGB-capable UI is _not_ attached', function() + eq('252', eval('synIDattr(hlID("Normal"), "fg")')) + eq('252', eval('synIDattr(hlID("Normal"), "fg#")')) + eq('-1', eval('synIDattr(hlID("Normal"), "bg")')) + eq('-1', eval('synIDattr(hlID("Normal"), "bg#")')) + eq('79', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('79', eval('synIDattr(hlID("Keyword"), "fg#")')) + eq('', eval('synIDattr(hlID("Keyword"), "sp")')) + eq('', eval('synIDattr(hlID("Keyword"), "sp#")')) end) - it('returns gui-color if GUI', function() - eq('1', eval('synIDattr(hlID("Normal"), "fg")')) - eq('-1', eval('synIDattr(hlID("Normal"), "bg")')) + it('returns gui-color if "gui" arg is passed', function() + eq('Black', eval('synIDattr(hlID("Normal"), "bg", "gui")')) + eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp", "gui")')) + end) - eq('2', eval('synIDattr(hlID("Keyword"), "fg")')) - eq('', eval('synIDattr(hlID("Keyword"), "sp")')) + it('returns gui-color if RGB-capable UI is attached', function() screen:attach(true) - eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) - eq('Black', eval('synIDattr(hlID("Normal"), "bg")')) - - eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")')) - eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")')) + eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) + eq('Black', eval('synIDattr(hlID("Normal"), "bg")')) + eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")')) end) - it('returns #RRGGBB value for [fg|bg|sp]#', function() - eq('1', eval('synIDattr(hlID("Normal"), "fg#")')) - eq('-1', eval('synIDattr(hlID("Normal"), "bg#")')) - - eq('2', eval('synIDattr(hlID("Keyword"), "fg#")')) - eq('', eval('synIDattr(hlID("Keyword"), "sp#")')) + it('returns #RRGGBB value for fg#/bg#/sp#', function() screen:attach(true) eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")')) eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")')) - eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")')) eq('#800000', eval('synIDattr(hlID("Keyword"), "sp#")')) end) it('returns color number if non-GUI', function() screen:attach(false) - eq('1', eval('synIDattr(hlID("Normal"), "fg")')) - eq('2', eval('synIDattr(hlID("Keyword"), "fg")')) + eq('252', eval('synIDattr(hlID("Normal"), "fg")')) + eq('79', eval('synIDattr(hlID("Keyword"), "fg")')) end) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index b156f13885..6ef40fff62 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -38,7 +38,6 @@ describe('manual syntax highlight', function() os.remove('Xtest-functional-ui-highlight.tmp.vim') end) - -- test with "set hidden" even if the bug did not occur this way it("works with buffer switch and 'hidden'", function() execute('e tmp1.vim') execute('e Xtest-functional-ui-highlight.tmp.vim') -- cgit