From 3d25200127bfec90982e82cb3d1fb65f8faff257 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 04:04:23 +0300 Subject: functests: Start adding some tests --- test/functional/ui/cmdline_highlight_spec.lua | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 test/functional/ui/cmdline_highlight_spec.lua (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua new file mode 100644 index 0000000000..812841ab7e --- /dev/null +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -0,0 +1,101 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') + +local feed = helpers.feed +local clear = helpers.clear +local meths = helpers.meths +local source = helpers.source + +local screen + +before_each(function() + clear() + screen = Screen.new(40, 2) + screen:attach() + source([[ + highlight RBP1 guifg=Red + highlight RBP2 guifg=Yellow + highlight RBP3 guifg=Green + highlight RBP4 guifg=Blue + let g:NUM_LVLS = 4 + function Redraw() + redraw! + return '' + endfunction + cnoremap {REDRAW} Redraw() + function RainBowParens(cmdline) + let ret = [] + let i = 0 + let lvl = 0 + while i < len(a:cmdline) + if a:cmdline[i] is# '(' + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) + let lvl += 1 + elseif a:cmdline[i] is# ')' + let lvl -= 1 + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) + endif + let i += 1 + endwhile + return ret + endfunction + ]]) + screen:set_default_attr_ids({ + RBP1={foreground = Screen.colors.Red}, + RBP2={foreground = Screen.colors.Yellow}, + RBP3={foreground = Screen.colors.Green}, + RBP4={foreground = Screen.colors.Blue}, + }) +end) + +describe('Command-line coloring', function() + it('works', function() + meths.set_var('Nvim_color_cmdline', 'RainBowParens') + meths.set_option('more', false) + feed(':') + screen:expect([[ + | + :^ | + ]]) + feed('e') + screen:expect([[ + | + :e^ | + ]]) + feed('cho ') + screen:expect([[ + | + :echo ^ | + ]]) + feed('(') + screen:expect([[ + | + :echo {RBP1:(}^ | + ]]) + feed('(') + screen:expect([[ + | + :echo {RBP1:(}{RBP2:(}^ | + ]]) + feed('42') + screen:expect([[ + | + :echo {RBP1:(}{RBP2:(}42^ | + ]]) + feed('))') + screen:expect([[ + | + :echo {RBP1:(}{RBP2:(}42{RBP2:)}{RBP1:)}^ | + ]]) + feed('') + screen:expect([[ + | + :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | + ]]) + feed('{REDRAW}') + screen:expect([[ + | + :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | + ]]) + end) +end) -- cgit From d82741f8c04d003bb9925d9c46d7e07179810ed4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 17:25:03 +0300 Subject: ex_getln: Add some more tests, fix some found errors --- test/functional/ui/cmdline_highlight_spec.lua | 246 +++++++++++++++++++++++++- 1 file changed, 245 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 812841ab7e..eb0a65bea7 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -1,16 +1,18 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local eq = helpers.eq local feed = helpers.feed local clear = helpers.clear local meths = helpers.meths +local funcs = helpers.funcs local source = helpers.source local screen before_each(function() clear() - screen = Screen.new(40, 2) + screen = Screen.new(40, 8) screen:attach() source([[ highlight RBP1 guifg=Red @@ -39,12 +41,74 @@ before_each(function() endwhile return ret endfunction + function SplittedMultibyteStart(cmdline) + let ret = [] + let i = 0 + while i < len(a:cmdline) + let char = nr2char(char2nr(a:cmdline[i:])) + if a:cmdline[i:i + len(char) - 1] is# char + if len(char) > 1 + call add(ret, [i + 1, i + len(char), 'RBP2']) + endif + let i += len(char) + else + let i += 1 + endif + endwhile + return ret + endfunction + function SplittedMultibyteEnd(cmdline) + let ret = [] + let i = 0 + while i < len(a:cmdline) + let char = nr2char(char2nr(a:cmdline[i:])) + if a:cmdline[i:i + len(char) - 1] is# char + if len(char) > 1 + call add(ret, [i, i + 1, 'RBP1']) + endif + let i += len(char) + else + let i += 1 + endif + endwhile + return ret + endfunction + function Echoing(cmdline) + echo 'HERE' + return v:_null_list + endfunction + function Echoning(cmdline) + echon 'HERE' + return v:_null_list + endfunction + function Echomsging(cmdline) + echomsg 'HERE' + return v:_null_list + endfunction + function Echoerring(cmdline) + echoerr 'HERE' + return v:_null_list + endfunction + function Redrawing(cmdline) + redraw! + return v:_null_list + endfunction + function Throwing(cmdline) + throw "ABC" + return v:_null_list + endfunction + function Halting(cmdline) + while 1 + endwhile + endfunction ]]) screen:set_default_attr_ids({ RBP1={foreground = Screen.colors.Red}, RBP2={foreground = Screen.colors.Yellow}, RBP3={foreground = Screen.colors.Green}, RBP4={foreground = Screen.colors.Blue}, + EOB={bold = true, foreground = Screen.colors.Blue1}, + ERR={foreground = Screen.colors.Grey100, background = Screen.colors.Red}, }) end) @@ -55,47 +119,227 @@ describe('Command-line coloring', function() feed(':') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :^ | ]]) feed('e') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :e^ | ]]) feed('cho ') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo ^ | ]]) feed('(') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo {RBP1:(}^ | ]]) feed('(') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo {RBP1:(}{RBP2:(}^ | ]]) feed('42') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo {RBP1:(}{RBP2:(}42^ | ]]) feed('))') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo {RBP1:(}{RBP2:(}42{RBP2:)}{RBP1:)}^ | ]]) feed('') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | ]]) feed('{REDRAW}') screen:expect([[ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | ]]) end) + for _, func_part in ipairs({'', 'n', 'msg'}) do + it('disables :echo' .. func_part .. ' messages', function() + meths.set_var('Nvim_color_cmdline', 'Echo' .. func_part .. 'ing') + feed(':echo') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :echo^ | + ]]) + end) + end + it('does the right thing when hl start appears to split multibyte char', + function() + meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') + feed(':echo "«') + screen:expect([[ + {EOB:~ }| + :echo " | + {ERR:E5405: Chunk 0 start 7 splits multibyte }| + {ERR:character} | + :echo "« | + {ERR:E5405: Chunk 0 start 7 splits multibyte }| + {ERR:character} | + :echo "«^ | + ]]) + feed('»') + -- FIXME Does not work well with too much error messages: they overwrite + -- cmdline. + end) + it('does the right thing when hl end appears to split multibyte char', + function() + meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteEnd') + feed(':echo "«') + screen:expect([[ + {EOB:~ }| + :echo " | + {ERR:E5406: Chunk 0 end 7 splits multibyte ch}| + {ERR:aracter} | + :echo "« | + {ERR:E5406: Chunk 0 end 7 splits multibyte ch}| + {ERR:aracter} | + :echo "«^ | + ]]) + end) + it('does the right thing when errorring', function() + meths.set_var('Nvim_color_cmdline', 'Echoerring') + feed(':e') + -- FIXME Does not work well with :echoerr: error message overwrites cmdline. + end) + it('does the right thing when throwing', function() + meths.set_var('Nvim_color_cmdline', 'Throwing') + feed(':e') + -- FIXME Does not work well with :throw: error message overwrites cmdline. + end) + it('still executes command-line even if errored out', function() + meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') + feed(':let x = "«"\n') + eq('«', meths.get_var('x')) + local msg = 'E5405: Chunk 0 start 10 splits multibyte character' + eq('\n'..msg..'\n'..msg, funcs.execute('messages')) + end) + it('stops executing callback after a number of errors', function() + meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') + feed(':let x = "«»«»«»«»«»"\n') + eq('«»«»«»«»«»', meths.get_var('x')) + local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' + eq(msg:rep(5), funcs.execute('messages')) + end) + it('allows interrupting callback with ', function() + meths.set_var('Nvim_color_cmdline', 'Halting') + feed(':echo 42') + for i = 1, 6 do + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + feed('') + end + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + Type :quit to exit Nvim | + ]]) + feed(':echo 42') + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + 42 | + ]]) + end) + it('works fine with NUL, NL, CR', function() + meths.set_var('Nvim_color_cmdline', 'RainBowParens') + feed(':echo ("")') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :echo {RBP1:(}"{RBP4:^M^@^@}"{RBP1:)}^ | + ]]) + end) + -- TODO Check for all other errors end) -- cgit From 407abb3a6c5c1c706bf8797a1431e57e97a6b797 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Apr 2017 01:00:40 +0300 Subject: eval,ex_getln: Add support for coloring input() prompts --- test/functional/eval/input_spec.lua | 57 +++++++++++++++++++++++++++ test/functional/ui/cmdline_highlight_spec.lua | 50 ++++++++++++++--------- 2 files changed, 88 insertions(+), 19 deletions(-) (limited to 'test') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 74ad32bc6c..f0c1314754 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -23,10 +23,41 @@ before_each(function() function CustomListCompl(...) return ['FOO'] endfunction + + highlight RBP1 guibg=Red + highlight RBP2 guibg=Yellow + highlight RBP3 guibg=Green + highlight RBP4 guibg=Blue + let g:NUM_LVLS = 4 + function Redraw() + redraw! + return '' + endfunction + cnoremap {REDRAW} Redraw() + function RainBowParens(cmdline) + let ret = [] + let i = 0 + let lvl = 0 + while i < len(a:cmdline) + if a:cmdline[i] is# '(' + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) + let lvl += 1 + elseif a:cmdline[i] is# ')' + let lvl -= 1 + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) + endif + let i += 1 + endwhile + return ret + endfunction ]]) screen:set_default_attr_ids({ EOB={bold = true, foreground = Screen.colors.Blue1}, T={foreground=Screen.colors.Red}, + RBP1={background=Screen.colors.Red}, + RBP2={background=Screen.colors.Yellow}, + RBP3={background=Screen.colors.Green}, + RBP4={background=Screen.colors.Blue}, }) end) @@ -196,6 +227,19 @@ describe('input()', function() eq('Vim(call):E118: Too many arguments for function: input', exc_exec('call input("prompt> ", "default", "file", "extra")')) end) + it('supports highlighting', function() + feed([[:call input({"highlight": "RainBowParens"})]]) + wait() + feed('(())') + wait() + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + {RBP1:(}{RBP2:()}{RBP1:)}^ | + ]]) + end) end) describe('inputdialog()', function() it('works with multiline prompts', function() @@ -363,4 +407,17 @@ describe('inputdialog()', function() eq('Vim(call):E118: Too many arguments for function: inputdialog', exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) + it('supports highlighting', function() + feed([[:call inputdialog({"highlight": "RainBowParens"})]]) + wait() + feed('(())') + wait() + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + {RBP1:(}{RBP2:()}{RBP1:)}^ | + ]]) + end) end) diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index eb0a65bea7..4ccfb44261 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -15,10 +15,10 @@ before_each(function() screen = Screen.new(40, 8) screen:attach() source([[ - highlight RBP1 guifg=Red - highlight RBP2 guifg=Yellow - highlight RBP3 guifg=Green - highlight RBP4 guifg=Blue + highlight RBP1 guibg=Red + highlight RBP2 guibg=Yellow + highlight RBP3 guibg=Green + highlight RBP4 guibg=Blue let g:NUM_LVLS = 4 function Redraw() redraw! @@ -103,12 +103,13 @@ before_each(function() endfunction ]]) screen:set_default_attr_ids({ - RBP1={foreground = Screen.colors.Red}, - RBP2={foreground = Screen.colors.Yellow}, - RBP3={foreground = Screen.colors.Green}, - RBP4={foreground = Screen.colors.Blue}, + RBP1={background = Screen.colors.Red}, + RBP2={background = Screen.colors.Yellow}, + RBP3={background = Screen.colors.Green}, + RBP4={background = Screen.colors.Blue}, EOB={bold = true, foreground = Screen.colors.Blue1}, ERR={foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + SK={foreground = Screen.colors.Blue}, }) end) @@ -237,40 +238,50 @@ describe('Command-line coloring', function() meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') feed(':echo "«') screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| {EOB:~ }| :echo " | {ERR:E5405: Chunk 0 start 7 splits multibyte }| {ERR:character} | - :echo "« | - {ERR:E5405: Chunk 0 start 7 splits multibyte }| - {ERR:character} | :echo "«^ | ]]) feed('»') - -- FIXME Does not work well with too much error messages: they overwrite - -- cmdline. + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :echo " | + {ERR:E5405: Chunk 0 start 7 splits multibyte }| + {ERR:character} | + :echo "«»^ | + ]]) end) it('does the right thing when hl end appears to split multibyte char', function() meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteEnd') feed(':echo "«') screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| {EOB:~ }| :echo " | {ERR:E5406: Chunk 0 end 7 splits multibyte ch}| {ERR:aracter} | - :echo "« | - {ERR:E5406: Chunk 0 end 7 splits multibyte ch}| - {ERR:aracter} | :echo "«^ | ]]) end) it('does the right thing when errorring', function() + if true then return pending('echoerr does not work well now') end meths.set_var('Nvim_color_cmdline', 'Echoerring') feed(':e') -- FIXME Does not work well with :echoerr: error message overwrites cmdline. end) it('does the right thing when throwing', function() + if true then return pending('Throwing does not work well now') end meths.set_var('Nvim_color_cmdline', 'Throwing') feed(':e') -- FIXME Does not work well with :throw: error message overwrites cmdline. @@ -280,16 +291,17 @@ describe('Command-line coloring', function() feed(':let x = "«"\n') eq('«', meths.get_var('x')) local msg = 'E5405: Chunk 0 start 10 splits multibyte character' - eq('\n'..msg..'\n'..msg, funcs.execute('messages')) + eq('\n'..msg, funcs.execute('messages')) end) it('stops executing callback after a number of errors', function() meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') feed(':let x = "«»«»«»«»«»"\n') eq('«»«»«»«»«»', meths.get_var('x')) local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' - eq(msg:rep(5), funcs.execute('messages')) + eq(msg:rep(1), funcs.execute('messages')) end) it('allows interrupting callback with ', function() + if true then return pending(' does not work well enough now') end meths.set_var('Nvim_color_cmdline', 'Halting') feed(':echo 42') for i = 1, 6 do @@ -338,7 +350,7 @@ describe('Command-line coloring', function() {EOB:~ }| {EOB:~ }| {EOB:~ }| - :echo {RBP1:(}"{RBP4:^M^@^@}"{RBP1:)}^ | + :echo {RBP1:(}"{SK:^M^@^@}"{RBP1:)}^ | ]]) end) -- TODO Check for all other errors -- cgit From 95fe5614a02948bcd0993c751acede34d2acb3c8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 22 May 2017 03:25:46 +0300 Subject: functests: Add missing wait() --- test/functional/eval/input_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index f0c1314754..5b259d5440 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq +local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear -- cgit From 71616fce0b3db6618ef47e231f34853eef79fea0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 27 Jun 2017 01:54:08 +0300 Subject: functests: Abstract away some ways to enter cmdline coloring mode Reason: should actually switch to using input() coloring because other coloring variants are eventually going away. --- test/functional/ui/cmdline_highlight_spec.lua | 49 +++++++++++++++------------ 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 4ccfb44261..278acf0bdf 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -113,11 +113,18 @@ before_each(function() }) end) +local function set_color_cb(funcname) + meths.set_var('Nvim_color_cmdline', funcname) +end +local function start_prompt(text) + feed(':' .. (text or '')) +end + describe('Command-line coloring', function() it('works', function() - meths.set_var('Nvim_color_cmdline', 'RainBowParens') + set_color_cb('RainBowParens') meths.set_option('more', false) - feed(':') + start_prompt() screen:expect([[ | {EOB:~ }| @@ -219,8 +226,8 @@ describe('Command-line coloring', function() end) for _, func_part in ipairs({'', 'n', 'msg'}) do it('disables :echo' .. func_part .. ' messages', function() - meths.set_var('Nvim_color_cmdline', 'Echo' .. func_part .. 'ing') - feed(':echo') + set_color_cb('Echo' .. func_part .. 'ing') + start_prompt('echo') screen:expect([[ | {EOB:~ }| @@ -235,8 +242,8 @@ describe('Command-line coloring', function() end it('does the right thing when hl start appears to split multibyte char', function() - meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') - feed(':echo "«') + set_color_cb('SplittedMultibyteStart') + start_prompt('echo "«') screen:expect([[ {EOB:~ }| {EOB:~ }| @@ -261,8 +268,8 @@ describe('Command-line coloring', function() end) it('does the right thing when hl end appears to split multibyte char', function() - meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteEnd') - feed(':echo "«') + set_color_cb('SplittedMultibyteEnd') + start_prompt('echo "«') screen:expect([[ {EOB:~ }| {EOB:~ }| @@ -276,34 +283,34 @@ describe('Command-line coloring', function() end) it('does the right thing when errorring', function() if true then return pending('echoerr does not work well now') end - meths.set_var('Nvim_color_cmdline', 'Echoerring') - feed(':e') + set_color_cb('Echoerring') + start_prompt('e') -- FIXME Does not work well with :echoerr: error message overwrites cmdline. end) it('does the right thing when throwing', function() if true then return pending('Throwing does not work well now') end - meths.set_var('Nvim_color_cmdline', 'Throwing') - feed(':e') + set_color_cb('Throwing') + start_prompt('e') -- FIXME Does not work well with :throw: error message overwrites cmdline. end) it('still executes command-line even if errored out', function() - meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') - feed(':let x = "«"\n') + set_color_cb('SplittedMultibyteStart') + start_prompt('let x = "«"\n') eq('«', meths.get_var('x')) local msg = 'E5405: Chunk 0 start 10 splits multibyte character' eq('\n'..msg, funcs.execute('messages')) end) it('stops executing callback after a number of errors', function() - meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') - feed(':let x = "«»«»«»«»«»"\n') + set_color_cb('SplittedMultibyteStart') + start_prompt('let x = "«»«»«»«»«»"\n') eq('«»«»«»«»«»', meths.get_var('x')) local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' eq(msg:rep(1), funcs.execute('messages')) end) it('allows interrupting callback with ', function() if true then return pending(' does not work well enough now') end - meths.set_var('Nvim_color_cmdline', 'Halting') - feed(':echo 42') + set_color_cb('Halting') + start_prompt('echo 42') for i = 1, 6 do screen:expect([[ ^ | @@ -327,7 +334,7 @@ describe('Command-line coloring', function() {EOB:~ }| Type :quit to exit Nvim | ]]) - feed(':echo 42') + start_prompt('echo 42') screen:expect([[ ^ | {EOB:~ }| @@ -340,8 +347,8 @@ describe('Command-line coloring', function() ]]) end) it('works fine with NUL, NL, CR', function() - meths.set_var('Nvim_color_cmdline', 'RainBowParens') - feed(':echo ("")') + set_color_cb('RainBowParens') + start_prompt('echo ("")') screen:expect([[ | {EOB:~ }| -- cgit From 8e5134784c8e15aabd458480bee1e445e8a04e94 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 27 Jun 2017 01:55:21 +0300 Subject: functests: Comment out failing test --- test/functional/ui/cmdline_highlight_spec.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 278acf0bdf..a30489ec97 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -212,17 +212,18 @@ describe('Command-line coloring', function() {EOB:~ }| :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | ]]) - feed('{REDRAW}') - screen:expect([[ - | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | - ]]) + -- FIXME + -- feed('{REDRAW}') + -- screen:expect([[ + -- | + -- {EOB:~ }| + -- {EOB:~ }| + -- {EOB:~ }| + -- {EOB:~ }| + -- {EOB:~ }| + -- {EOB:~ }| + -- :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | + -- ]]) end) for _, func_part in ipairs({'', 'n', 'msg'}) do it('disables :echo' .. func_part .. ' messages', function() -- cgit From edc2a7ee460b9a77705c87ecccc41a22f6134bf8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 27 Jun 2017 02:15:49 +0300 Subject: functests: Make tests work with input() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are still some issues: specifically, new “pending” test hangs busted. --- test/functional/ui/cmdline_highlight_spec.lua | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index a30489ec97..6bb06b2ed3 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -25,6 +25,7 @@ before_each(function() return '' endfunction cnoremap {REDRAW} Redraw() + nnoremap {PROMPT} input({"prompt": ":", "highlight": g:Nvim_color_input})[1:0] function RainBowParens(cmdline) let ret = [] let i = 0 @@ -114,10 +115,10 @@ before_each(function() end) local function set_color_cb(funcname) - meths.set_var('Nvim_color_cmdline', funcname) + meths.set_var('Nvim_color_input', funcname) end local function start_prompt(text) - feed(':' .. (text or '')) + feed('{PROMPT}' .. (text or '')) end describe('Command-line coloring', function() @@ -294,20 +295,13 @@ describe('Command-line coloring', function() start_prompt('e') -- FIXME Does not work well with :throw: error message overwrites cmdline. end) - it('still executes command-line even if errored out', function() - set_color_cb('SplittedMultibyteStart') - start_prompt('let x = "«"\n') - eq('«', meths.get_var('x')) - local msg = 'E5405: Chunk 0 start 10 splits multibyte character' - eq('\n'..msg, funcs.execute('messages')) - end) - it('stops executing callback after a number of errors', function() + pending('stops executing callback after a number of errors'--[[, function() set_color_cb('SplittedMultibyteStart') start_prompt('let x = "«»«»«»«»«»"\n') eq('«»«»«»«»«»', meths.get_var('x')) local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' eq(msg:rep(1), funcs.execute('messages')) - end) + end]]) it('allows interrupting callback with ', function() if true then return pending(' does not work well enough now') end set_color_cb('Halting') @@ -363,3 +357,14 @@ describe('Command-line coloring', function() end) -- TODO Check for all other errors end) +describe('Ex commands coloring support', function() + it('still executes command-line even if errored out', function() + meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') + feed(':let x = "«"\n') + eq('«', meths.get_var('x')) + local msg = 'E5405: Chunk 0 start 10 splits multibyte character' + eq('\n'..msg, funcs.execute('messages')) + end) +end) + +-- TODO Specifically test for coloring in cmdline and expr modes -- cgit From 36a84d8f4ab104050e6ec52da9ca6e10f9361a0c Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 13:54:04 +0300 Subject: functests: Fix typo --- test/functional/ui/screen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 5408e1e195..a6b7fb2997 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -251,7 +251,7 @@ function Screen:expect(expected, attr_ids, attr_ignore, condition, any) ..'Expected:\n |'..table.concat(msg_expected_rows, '|\n |')..'|\n' ..'Actual:\n |'..table.concat(actual_rows, '|\n |')..'|\n\n'..[[ To print the expect() call that would assert the current screen state, use -screen:snaphot_util(). In case of non-deterministic failures, use +screen:snapshot_util(). In case of non-deterministic failures, use screen:redraw_debug() to show all intermediate screen states. ]]) end end -- cgit From 493d250446e5323e64c80399f0c5a15621c4f15c Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 13:58:51 +0300 Subject: functests: Make “stops executing callback” test work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Needed to be adjusted to use input() (previously relied on side-effects of executing `:cmd`) and dismiss something (hidden “Press ENTER” message?). --- test/functional/ui/cmdline_highlight_spec.lua | 30 +++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 6bb06b2ed3..12577a4db4 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -24,8 +24,9 @@ before_each(function() redraw! return '' endfunction + let g:EMPTY = '' cnoremap {REDRAW} Redraw() - nnoremap {PROMPT} input({"prompt": ":", "highlight": g:Nvim_color_input})[1:0] + nnoremap {PROMPT} extend(g:, {"out": input({"prompt": ":", "highlight": g:Nvim_color_input})}).EMPTY function RainBowParens(cmdline) let ret = [] let i = 0 @@ -295,13 +296,34 @@ describe('Command-line coloring', function() start_prompt('e') -- FIXME Does not work well with :throw: error message overwrites cmdline. end) - pending('stops executing callback after a number of errors'--[[, function() + it('stops executing callback after a number of errors', function() set_color_cb('SplittedMultibyteStart') start_prompt('let x = "«»«»«»«»«»"\n') - eq('«»«»«»«»«»', meths.get_var('x')) + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :let x = " | + {ERR:E5405: Chunk 0 start 10 splits multibyte}| + {ERR: character} | + ^:let x = "«»«»«»«»«»" | + ]]) + feed('\n') + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + eq('let x = "«»«»«»«»«»"', meths.get_var('out')) local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' eq(msg:rep(1), funcs.execute('messages')) - end]]) + end) it('allows interrupting callback with ', function() if true then return pending(' does not work well enough now') end set_color_cb('Halting') -- cgit From 0ed95423de714edac11ccff177b8aee6b7987bac Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 14:26:23 +0300 Subject: ex_getln: Call highlight callback inside :try --- test/functional/ui/cmdline_highlight_spec.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 12577a4db4..8207a903f4 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -285,16 +285,23 @@ describe('Command-line coloring', function() ]]) end) it('does the right thing when errorring', function() - if true then return pending('echoerr does not work well now') end set_color_cb('Echoerring') start_prompt('e') - -- FIXME Does not work well with :echoerr: error message overwrites cmdline. + -- FIXME Does not work well with :echoerr: error message not shown. end) it('does the right thing when throwing', function() - if true then return pending('Throwing does not work well now') end set_color_cb('Throwing') start_prompt('e') - -- FIXME Does not work well with :throw: error message overwrites cmdline. + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + : | + {ERR:E5407: Callback has thrown an exception:}| + {ERR: ABC} | + :e^ | + ]]) end) it('stops executing callback after a number of errors', function() set_color_cb('SplittedMultibyteStart') -- cgit From 5e4976559a0f3e104b3f349593ad184d08c56a89 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 14:34:12 +0300 Subject: functests: Partially uncomment test --- test/functional/ui/cmdline_highlight_spec.lua | 40 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 8207a903f4..f356db88b5 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -332,22 +332,34 @@ describe('Command-line coloring', function() eq(msg:rep(1), funcs.execute('messages')) end) it('allows interrupting callback with ', function() - if true then return pending(' does not work well enough now') end set_color_cb('Halting') start_prompt('echo 42') - for i = 1, 6 do - screen:expect([[ - ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - | - ]]) - feed('') - end + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + feed('') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + : | + {ERR:E5407: Callback has thrown an exception:}| + {ERR: Keyboard interrupt} | + ^ | + ]]) + if true then return pending(' should only cancel callback, not input()') end + feed('{REDRAW}') + screen:snapshot_util() + feed('') + eq('echo 42', meths.get_var('out')) screen:expect([[ ^ | {EOB:~ }| -- cgit From 9ccb3abbb55ec8ed7f3b4d2d2516fd451eca9a68 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 14:39:52 +0300 Subject: functests: Uncomment `{REDRAW}` part of “works” test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/functional/ui/cmdline_highlight_spec.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index f356db88b5..a3dc9af360 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -214,18 +214,20 @@ describe('Command-line coloring', function() {EOB:~ }| :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | ]]) - -- FIXME - -- feed('{REDRAW}') - -- screen:expect([[ - -- | - -- {EOB:~ }| - -- {EOB:~ }| - -- {EOB:~ }| - -- {EOB:~ }| - -- {EOB:~ }| - -- {EOB:~ }| - -- :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | - -- ]]) + -- Bug in input() handling: {REDRAW} will erase the whole prompt up until + -- user types something. It exists in Vim as well, so using `h` as + -- a workaround. + feed('{REDRAW}h') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | + ]]) end) for _, func_part in ipairs({'', 'n', 'msg'}) do it('disables :echo' .. func_part .. ' messages', function() -- cgit From 3da49cd68e7d5c968cc99a926819038ff57f488f Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 22:09:10 +0300 Subject: ex_getln: Fix “echoerr msg not shown” problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also attempted to fix problem with cancelling input() on error by avoiding standard error printing facilities (assumed thrown error message is the problem), but with no luck so far. --- test/functional/ui/cmdline_highlight_spec.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index a3dc9af360..dbabf65b68 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -289,7 +289,16 @@ describe('Command-line coloring', function() it('does the right thing when errorring', function() set_color_cb('Echoerring') start_prompt('e') - -- FIXME Does not work well with :echoerr: error message not shown. + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + : | + {ERR:E5407: Callback has thrown an exception:}| + {ERR: Vim(echoerr):HERE} | + :e^ | + ]]) end) it('does the right thing when throwing', function() set_color_cb('Throwing') -- cgit From ea75966e4232dc4a3693cbc4a572f2116c49b138 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 22:54:13 +0300 Subject: ex_getln: Do not make interrupt input() after interrupting hl cb --- test/functional/ui/cmdline_highlight_spec.lua | 42 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index dbabf65b68..671490e668 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -10,6 +10,13 @@ local source = helpers.source local screen +-- Bug in input() handling: {REDRAW} will erase the whole prompt up until +-- user types something. It exists in Vim as well, so using `h` as +-- a workaround. +local function redraw_input() + feed('{REDRAW}h') +end + before_each(function() clear() screen = Screen.new(40, 8) @@ -214,10 +221,7 @@ describe('Command-line coloring', function() {EOB:~ }| :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | ]]) - -- Bug in input() handling: {REDRAW} will erase the whole prompt up until - -- user types something. It exists in Vim as well, so using `h` as - -- a workaround. - feed('{REDRAW}h') + redraw_input() screen:expect([[ | {EOB:~ }| @@ -364,24 +368,33 @@ describe('Command-line coloring', function() : | {ERR:E5407: Callback has thrown an exception:}| {ERR: Keyboard interrupt} | - ^ | + :echo 42^ | ]]) - if true then return pending(' should only cancel callback, not input()') end - feed('{REDRAW}') - screen:snapshot_util() - feed('') - eq('echo 42', meths.get_var('out')) + redraw_input() screen:expect([[ - ^ | + | {EOB:~ }| {EOB:~ }| {EOB:~ }| {EOB:~ }| {EOB:~ }| {EOB:~ }| - Type :quit to exit Nvim | + :echo 42^ | ]]) - start_prompt('echo 42') + feed('\n') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + ^:echo 42 | + ]]) + feed('\n') + eq('echo 42', meths.get_var('out')) + feed('') screen:expect([[ ^ | {EOB:~ }| @@ -390,7 +403,7 @@ describe('Command-line coloring', function() {EOB:~ }| {EOB:~ }| {EOB:~ }| - 42 | + Type :quit to exit Nvim | ]]) end) it('works fine with NUL, NL, CR', function() @@ -420,3 +433,4 @@ describe('Ex commands coloring support', function() end) -- TODO Specifically test for coloring in cmdline and expr modes +-- TODO Check using highlighted input() from inside highlighted input() -- cgit From 7ab152aaa58f493e54d03a15960b8a288196e588 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 1 Jul 2017 15:34:25 +0300 Subject: ex_getln: Save and restore try state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: when processing cycle such as :for pat in [' \ze*', ' \zs*'] : try : let l = matchlist('x x', pat) : $put ='E888 NOT detected for ' . pat : catch : $put ='E888 detected for ' . pat : endtry :endfor `:let l = …` throwing an error causes this error to be caught after color_cmdline attempts to get callback for highlighting next line (the one with `$put = 'E888 NOT…`). Saving/restoring state prevents this from happening. --- test/functional/ui/cmdline_highlight_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 671490e668..62c0694c8c 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -7,6 +7,8 @@ local clear = helpers.clear local meths = helpers.meths local funcs = helpers.funcs local source = helpers.source +local dedent = helpers.dedent +local curbufmeths = helpers.curbufmeths local screen @@ -421,6 +423,8 @@ describe('Command-line coloring', function() ]]) end) -- TODO Check for all other errors + -- TODO Check for colored input() called in a cycle which previously errorred + -- out end) describe('Ex commands coloring support', function() it('still executes command-line even if errored out', function() @@ -430,7 +434,27 @@ describe('Ex commands coloring support', function() local msg = 'E5405: Chunk 0 start 10 splits multibyte character' eq('\n'..msg, funcs.execute('messages')) end) + it('does not error out when called from a errorred out cycle', function() + -- Apparently when there is a cycle in which one of the commands errors out + -- this error may be caught by color_cmdline before it is presented to the + -- user. + feed(dedent([[ + :set regexpengine=2 + :for pat in [' \ze*', ' \zs*'] + : try + : let l = matchlist('x x', pat) + : $put ='E888 NOT detected for ' . pat + : catch + : $put ='E888 detected for ' . pat + : endtry + :endfor + ]])) + eq({'', 'E888 detected for \\ze*', 'E888 detected for \\zs*'}, + curbufmeths.get_lines(0, -1, false)) + eq('', funcs.execute('messages')) + end) end) -- TODO Specifically test for coloring in cmdline and expr modes +-- TODO Check for errors from tv_dict_get_callback() -- TODO Check using highlighted input() from inside highlighted input() -- cgit From f4744e18219726d2eaa57b26198166ea255c62a4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 17 Jul 2017 01:55:10 +0300 Subject: ex_getln: Do not goto color_cmdline_end without first cleaning up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue with debug mode was actually not cleaning up after `try_enter`: location `&tstate` was pointing to got invalidated and received some “garbage” (actually, values that got stored on the stack afterwards). But pointer to that garbage was still stored in `msg_list`, so next attempt to check it resulted in a crash. --- test/functional/ui/cmdline_highlight_spec.lua | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 62c0694c8c..0621b990de 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -121,6 +121,7 @@ before_each(function() EOB={bold = true, foreground = Screen.colors.Blue1}, ERR={foreground = Screen.colors.Grey100, background = Screen.colors.Red}, SK={foreground = Screen.colors.Blue}, + PE={bold = true, foreground = Screen.colors.SeaGreen4} }) end) @@ -453,6 +454,41 @@ describe('Ex commands coloring support', function() curbufmeths.get_lines(0, -1, false)) eq('', funcs.execute('messages')) end) + it('does not crash when using `n` in debug mode', function() + feed(':debug execute "echo 1"\n') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + Entering Debug mode. Type "cont" to con| + tinue. | + cmd: execute "echo 1" | + >^ | + ]]) + feed('n\n') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + Entering Debug mode. Type "cont" to con| + tinue. | + cmd: execute "echo 1" | + >n | + 1 | + {PE:Press ENTER or type command to continue}^ | + ]]) + feed('\n') + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + end) end) -- TODO Specifically test for coloring in cmdline and expr modes -- cgit From cfb1d937a64fcec836fdf26d6ea67024aeafabeb Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 00:08:57 +0300 Subject: api helpers: Also save and restore did_emsg --- test/functional/ui/cmdline_highlight_spec.lua | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 0621b990de..6698ced596 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -489,6 +489,44 @@ describe('Ex commands coloring support', function() | ]]) end) + it('does not prevent mapping error from cancelling prompt', function() + meths.command("cnoremap x execute('throw 42')[-1]") + feed(':#x') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :# | + {ERR:Error detected while processing :} | + {ERR:E605: Exception not caught: 42} | + :#^ | + ]]) + feed('') + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + feed('') + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + eq('\nError detected while processing :\nE605: Exception not caught: 42', + meths.command_output('messages')) + end) end) -- TODO Specifically test for coloring in cmdline and expr modes -- cgit From 8a581b918b339b84b5abd80919416a84932eb13f Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 00:20:21 +0300 Subject: ex_getln: Check prev_prompt_errors before running redrawcmdline Otherwise there will be infinite recursion and shortly a crash. Running redrawcmdline recursively occurs under color_cmdline_error label. --- test/functional/ui/cmdline_highlight_spec.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 6698ced596..e12961039a 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -527,6 +527,22 @@ describe('Ex commands coloring support', function() eq('\nError detected while processing :\nE605: Exception not caught: 42', meths.command_output('messages')) end) + it('errors out when failing to get callback', function() + meths.set_var('Nvim_color_cmdline', 42) + feed(':#') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + : | + {ERR:E5408: Unable to get Nvim_color_cmdline }| + {ERR:callback from g:: Vim:E6000: Argument is}| + {ERR: not a function or function name} | + :#^ | + ]]) + end) +end) +describe('Expressions coloring support', function() end) -- TODO Specifically test for coloring in cmdline and expr modes -- cgit From 759f71d50e506112f63d3db80ce823e013681476 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 00:34:39 +0300 Subject: functests: Check for previously unchecked errors --- test/functional/ui/cmdline_highlight_spec.lua | 100 +++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index e12961039a..8bfeaf35ab 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -8,6 +8,7 @@ local meths = helpers.meths local funcs = helpers.funcs local source = helpers.source local dedent = helpers.dedent +local command = helpers.command local curbufmeths = helpers.curbufmeths local screen @@ -112,6 +113,12 @@ before_each(function() while 1 endwhile endfunction + function ReturningGlobal(cmdline) + return g:callback_return + endfunction + function ReturningGlobal2(cmdline) + return g:callback_return[:len(a:cmdline)-1] + endfunction ]]) screen:set_default_attr_ids({ RBP1={background = Screen.colors.Red}, @@ -125,8 +132,11 @@ before_each(function() }) end) -local function set_color_cb(funcname) +local function set_color_cb(funcname, callback_return) meths.set_var('Nvim_color_input', funcname) + if callback_return then + meths.set_var('callback_return', callback_return) + end end local function start_prompt(text) feed('{PROMPT}' .. (text or '')) @@ -423,7 +433,77 @@ describe('Command-line coloring', function() :echo {RBP1:(}"{SK:^M^@^@}"{RBP1:)}^ | ]]) end) - -- TODO Check for all other errors + it('errors out when callback returns something wrong', function() + command('cnoremap + ++') + set_color_cb('ReturningGlobal', '') + start_prompt('#') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + : | + {ERR:E5400: Callback should return list} | + :#^ | + ]]) + + feed('') + set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}, 42}) + start_prompt('#') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + : | + {ERR:E5401: List item 1 is not a List} | + :#^ | + ]]) + + feed('') + set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1}}) + start_prompt('+') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :+ | + {ERR:E5402: List item 1 has incorrect length:}| + {ERR: 1 /= 3} | + :++^ | + ]]) + + feed('') + set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {2, 3, 'Normal'}}) + start_prompt('+') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :+ | + {ERR:E5403: Chunk 1 start 2 not in range [1, }| + {ERR:2)} | + :++^ | + ]]) + + feed('') + set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1, 3, 'Normal'}}) + start_prompt('+') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :+ | + {ERR:E5404: Chunk 1 end 3 not in range (1, 2]}| + | + :++^ | + ]]) + end) -- TODO Check for colored input() called in a cycle which previously errorred -- out end) @@ -490,7 +570,7 @@ describe('Ex commands coloring support', function() ]]) end) it('does not prevent mapping error from cancelling prompt', function() - meths.command("cnoremap x execute('throw 42')[-1]") + command("cnoremap x execute('throw 42')[-1]") feed(':#x') screen:expect([[ {EOB:~ }| @@ -543,6 +623,20 @@ describe('Ex commands coloring support', function() end) end) describe('Expressions coloring support', function() + it('errors out when failing to get callback', function() + meths.set_var('Nvim_color_expr', 42) + feed(':=1') + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + = | + {ERR:E5409: Unable to get Nvim_color_expr cal}| + {ERR:lback from g:: Vim:E6000: Argument is no}| + {ERR:t a function or function name} | + =1^ | + ]]) + end) end) -- TODO Specifically test for coloring in cmdline and expr modes -- cgit From 25f669049cced029e1530a74e9490e61432433ac Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 01:16:38 +0300 Subject: functests: Test input() nesting support --- test/functional/ui/cmdline_highlight_spec.lua | 196 ++++++++++++++++++++++++-- 1 file changed, 184 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 8bfeaf35ab..82d4fdffd2 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -34,9 +34,17 @@ before_each(function() redraw! return '' endfunction - let g:EMPTY = '' + let g:id = '' cnoremap {REDRAW} Redraw() - nnoremap {PROMPT} extend(g:, {"out": input({"prompt": ":", "highlight": g:Nvim_color_input})}).EMPTY + function DoPrompt(do_return) abort + let id = g:id + let Cb = g:Nvim_color_input{g:id} + let out = input({'prompt': ':', 'highlight': Cb}) + let g:out{id} = out + return (a:do_return ? out : '') + endfunction + nnoremap {PROMPT} DoPrompt(0) + cnoremap {PROMPT} DoPrompt(1) function RainBowParens(cmdline) let ret = [] let i = 0 @@ -119,6 +127,9 @@ before_each(function() function ReturningGlobal2(cmdline) return g:callback_return[:len(a:cmdline)-1] endfunction + function ReturningGlobalN(n, cmdline) + return g:callback_return{a:n} + endfunction ]]) screen:set_default_attr_ids({ RBP1={background = Screen.colors.Red}, @@ -132,10 +143,19 @@ before_each(function() }) end) -local function set_color_cb(funcname, callback_return) - meths.set_var('Nvim_color_input', funcname) - if callback_return then - meths.set_var('callback_return', callback_return) +local function set_color_cb(funcname, callback_return, id) + meths.set_var('id', id or '') + if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then + command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format( + id, funcname, id)) + if callback_return then + meths.set_var('callback_return' .. id, callback_return) + end + else + meths.set_var('Nvim_color_input', funcname) + if callback_return then + meths.set_var('callback_return', callback_return) + end end end local function start_prompt(text) @@ -504,10 +524,152 @@ describe('Command-line coloring', function() :++^ | ]]) end) - -- TODO Check for colored input() called in a cycle which previously errorred - -- out + it('does not error out when called from a errorred out cycle', function() + set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}}) + feed(dedent([[ + :set regexpengine=2 + :for pat in [' \ze*', ' \zs*'] + : try + : let l = matchlist('x x', pat) + : $put =input({'prompt':'>','highlight':'ReturningGlobal'}) + : + : $put ='E888 NOT detected for ' . pat + : catch + : $put =input({'prompt':'>','highlight':'ReturningGlobal'}) + : + : $put ='E888 detected for ' . pat + : endtry + :endfor + : + : + : + : + : + : + ]])) + eq({'', ':', 'E888 detected for \\ze*', ':', 'E888 detected for \\zs*'}, + curbufmeths.get_lines(0, -1, false)) + eq('', funcs.execute('messages')) + end) + it('allows nesting input()s', function() + set_color_cb('ReturningGlobal', {{0, 1, 'RBP1'}}, '') + start_prompt('1') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP1:1}^ | + ]]) + + set_color_cb('ReturningGlobal', {{0, 1, 'RBP2'}}, '1') + start_prompt('2') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP2:2}^ | + ]]) + + set_color_cb('ReturningGlobal', {{0, 1, 'RBP3'}}, '2') + start_prompt('3') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP3:3}^ | + ]]) + + set_color_cb('ReturningGlobal', {{0, 1, 'RBP4'}}, '3') + start_prompt('4') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP4:4}^ | + ]]) + + feed('') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP3:3}4^ | + ]]) + feed('') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP2:2}34^ | + ]]) + feed('') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :{RBP1:1}234^ | + ]]) + feed('') + screen:expect([[ + ^ | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + ]]) + eq('1234', meths.get_var('out')) + eq('234', meths.get_var('out1')) + eq('34', meths.get_var('out2')) + eq('4', meths.get_var('out3')) + eq(0, funcs.exists('g:out4')) + end) end) describe('Ex commands coloring support', function() + it('works', function() + meths.set_var('Nvim_color_cmdline', 'RainBowParens') + feed(':echo (((1)))') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :echo {RBP1:(}{RBP2:(}{RBP3:(}1{RBP3:)}{RBP2:)}{RBP1:)}^ | + ]]) + end) it('still executes command-line even if errored out', function() meths.set_var('Nvim_color_cmdline', 'SplittedMultibyteStart') feed(':let x = "«"\n') @@ -623,6 +785,20 @@ describe('Ex commands coloring support', function() end) end) describe('Expressions coloring support', function() + it('works', function() + meths.set_var('Nvim_color_expr', 'RainBowParens') + feed(':echo =(((1)))') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + ={RBP1:(}{RBP2:(}{RBP3:(}1{RBP3:)}{RBP2:)}{RBP1:)}^ | + ]]) + end) it('errors out when failing to get callback', function() meths.set_var('Nvim_color_expr', 42) feed(':=1') @@ -638,7 +814,3 @@ describe('Expressions coloring support', function() ]]) end) end) - --- TODO Specifically test for coloring in cmdline and expr modes --- TODO Check for errors from tv_dict_get_callback() --- TODO Check using highlighted input() from inside highlighted input() -- cgit From 0a46ae3c0a7b2ca53ce16c3f5c5ecb8ae7bfee80 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 01:29:41 +0300 Subject: functests: Add sleep to test --- test/functional/ui/cmdline_highlight_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 82d4fdffd2..a81d671119 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -392,6 +392,7 @@ describe('Command-line coloring', function() {EOB:~ }| | ]]) + screen:sleep(500) feed('') screen:expect([[ {EOB:~ }| -- cgit From 1ba21b4a31ea5853673ba3d1baae3e862c1ef04a Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 13:02:45 +0300 Subject: functests: Remove unneeded wait()s --- test/functional/eval/input_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 5b259d5440..0571043efe 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -232,7 +232,6 @@ describe('input()', function() feed([[:call input({"highlight": "RainBowParens"})]]) wait() feed('(())') - wait() screen:expect([[ {EOB:~ }| {EOB:~ }| @@ -412,7 +411,6 @@ describe('inputdialog()', function() feed([[:call inputdialog({"highlight": "RainBowParens"})]]) wait() feed('(())') - wait() screen:expect([[ {EOB:~ }| {EOB:~ }| -- cgit From e129607988b88719935bc4af517e7ee2689f5871 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 22:04:39 +0300 Subject: functests: Replace wait() with nvim_async --- test/functional/eval/input_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 0571043efe..cfb91983c1 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,13 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq -local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec +local nvim_async = helpers.nvim_async local screen @@ -229,16 +229,16 @@ describe('input()', function() exc_exec('call input("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call input({"highlight": "RainBowParens"})]]) - wait() + nvim_async('command', 'call input({"highlight": "RainBowParens"})') feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) + feed('') end) end) describe('inputdialog()', function() @@ -408,15 +408,15 @@ describe('inputdialog()', function() exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call inputdialog({"highlight": "RainBowParens"})]]) - wait() + nvim_async('command', 'call inputdialog({"highlight": "RainBowParens"})') feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) + feed('') end) end) -- cgit From c5857e3f3807d305598d7639949793d44b380e23 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 22:56:48 +0300 Subject: ex_getln: Cache highlight callback calling results --- test/functional/ui/cmdline_highlight_spec.lua | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index a81d671119..b6288b746e 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -130,6 +130,11 @@ before_each(function() function ReturningGlobalN(n, cmdline) return g:callback_return{a:n} endfunction + let g:recording_calls = [] + function Recording(cmdline) + call add(g:recording_calls, a:cmdline) + return [] + endfunction ]]) screen:set_default_attr_ids({ RBP1={background = Screen.colors.Red}, @@ -655,6 +660,32 @@ describe('Command-line coloring', function() eq('4', meths.get_var('out3')) eq(0, funcs.exists('g:out4')) end) + it('runs callback with the same data only once', function() + local function new_recording_calls(...) + eq({...}, meths.get_var('recording_calls')) + meths.set_var('recording_calls', {}) + end + set_color_cb('Recording') + start_prompt('') + -- Regression test. Disambiguation: + -- + -- new_recording_calls(expected_result) -- (actual_before_fix) + -- + feed('a') + new_recording_calls('a') -- ('a', 'a') + feed('b') + new_recording_calls('ab') -- ('a', 'ab', 'ab') + feed('c') + new_recording_calls('abc') -- ('ab', 'abc', 'abc') + feed('') + new_recording_calls('ab') -- ('abc', 'ab', 'ab') + feed('') + new_recording_calls('a') -- ('ab', 'a', 'a') + feed('') + new_recording_calls() -- ('a') + feed('') + eq('', meths.get_var('out')) + end) end) describe('Ex commands coloring support', function() it('works', function() -- cgit From 1011462b40502e6039494e70a870f0360f152b1b Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 27 Jul 2017 18:49:13 +0300 Subject: Revert "functests: Replace wait() with nvim_async" This reverts commit e129607988b88719935bc4af517e7ee2689f5871. Tests stopped working in CI. --- test/functional/eval/input_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index cfb91983c1..0571043efe 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,13 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq +local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec -local nvim_async = helpers.nvim_async local screen @@ -229,16 +229,16 @@ describe('input()', function() exc_exec('call input("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - nvim_async('command', 'call input({"highlight": "RainBowParens"})') + feed([[:call input({"highlight": "RainBowParens"})]]) + wait() feed('(())') screen:expect([[ - | {EOB:~ }| {EOB:~ }| {EOB:~ }| + | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) - feed('') end) end) describe('inputdialog()', function() @@ -408,15 +408,15 @@ describe('inputdialog()', function() exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - nvim_async('command', 'call inputdialog({"highlight": "RainBowParens"})') + feed([[:call inputdialog({"highlight": "RainBowParens"})]]) + wait() feed('(())') screen:expect([[ - | {EOB:~ }| {EOB:~ }| {EOB:~ }| + | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) - feed('') end) end) -- cgit From efb03903eb667bc14992dffcd77d04385371abed Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 6 Aug 2017 14:43:46 +0300 Subject: functests: Remove wait() from input_spec --- test/functional/eval/input_spec.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 0571043efe..5ae23e17d0 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq -local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear @@ -229,14 +228,14 @@ describe('input()', function() exc_exec('call input("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call input({"highlight": "RainBowParens"})]]) - wait() + command('nnoremap X input({"highlight": "RainBowParens"})[-1]') + feed([[X]]) feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) end) @@ -408,14 +407,14 @@ describe('inputdialog()', function() exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call inputdialog({"highlight": "RainBowParens"})]]) - wait() + command('nnoremap X inputdialog({"highlight": "RainBowParens"})[-1]') + feed([[X]]) feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) end) -- cgit From a5449f79ac21919d45544c1e9ce86ae003e04298 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 14 Aug 2017 01:17:16 +0300 Subject: functests: Check that input is correctly silenced --- test/functional/ui/cmdline_highlight_spec.lua | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index b6288b746e..262d706e4e 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -342,6 +342,51 @@ describe('Command-line coloring', function() :e^ | ]]) end) + it('silences :echo', function() + set_color_cb('Echoing') + start_prompt('e') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :e^ | + ]]) + eq('', meths.command_output('messages')) + end) + it('silences :echon', function() + set_color_cb('Echoning') + start_prompt('e') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :e^ | + ]]) + eq('', meths.command_output('messages')) + end) + it('silences :echomsg', function() + set_color_cb('Echomsging') + start_prompt('e') + screen:expect([[ + | + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + :e^ | + ]]) + eq('', meths.command_output('messages')) + end) it('does the right thing when throwing', function() set_color_cb('Throwing') start_prompt('e') -- cgit From 0571b8cb0eba8f8ec10b33910bb5164a123af44d Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 14 Aug 2017 01:22:10 +0300 Subject: functests: Alter comment --- test/functional/ui/cmdline_highlight_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 262d706e4e..1d2a06b7f0 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -13,7 +13,7 @@ local curbufmeths = helpers.curbufmeths local screen --- Bug in input() handling: {REDRAW} will erase the whole prompt up until +-- Bug in input() handling: :redraw! will erase the whole prompt up until -- user types something. It exists in Vim as well, so using `h` as -- a workaround. local function redraw_input() -- cgit From 19a28352a925b0a8502d57ec4f42b1412639aa6c Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 14 Aug 2017 01:56:48 +0300 Subject: ex_getln: Make error messages look better --- test/functional/ui/cmdline_highlight_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 1d2a06b7f0..d87ce72599 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -854,9 +854,9 @@ describe('Ex commands coloring support', function() {EOB:~ }| {EOB:~ }| : | - {ERR:E5408: Unable to get Nvim_color_cmdline }| - {ERR:callback from g:: Vim:E6000: Argument is}| - {ERR: not a function or function name} | + {ERR:E5408: Unable to get g:Nvim_color_cmdlin}| + {ERR:e callback: Vim:E6000: Argument is not a}| + {ERR: function or function name} | :#^ | ]]) end) @@ -884,9 +884,9 @@ describe('Expressions coloring support', function() {EOB:~ }| {EOB:~ }| = | - {ERR:E5409: Unable to get Nvim_color_expr cal}| - {ERR:lback from g:: Vim:E6000: Argument is no}| - {ERR:t a function or function name} | + {ERR:E5409: Unable to get g:Nvim_color_expr c}| + {ERR:allback: Vim:E6000: Argument is not a fu}| + {ERR:nction or function name} | =1^ | ]]) end) -- cgit