aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/commands_spec.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-22 19:55:31 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-01-23 19:34:13 +0100
commitf7b174eb711a8d1d54338d6189d7d993e4526997 (patch)
tree0d67c62aa210dab97a7d974e466ea48eb307801a /test/functional/lua/commands_spec.lua
parent27b78130252be59416f0ce29111e59a2de99b93e (diff)
downloadrneovim-f7b174eb711a8d1d54338d6189d7d993e4526997.tar.gz
rneovim-f7b174eb711a8d1d54338d6189d7d993e4526997.tar.bz2
rneovim-f7b174eb711a8d1d54338d6189d7d993e4526997.zip
tests/lua: test for multiline error messages in lua
Diffstat (limited to 'test/functional/lua/commands_spec.lua')
-rw-r--r--test/functional/lua/commands_spec.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index 017ee55729..26dcbe0534 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -1,13 +1,17 @@
-- Test suite for checking :lua* commands
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local NIL = helpers.NIL
+local eval = helpers.eval
+local feed = helpers.feed
local clear = helpers.clear
local meths = helpers.meths
local funcs = helpers.funcs
local source = helpers.source
local dedent = helpers.dedent
+local command = helpers.command
local exc_exec = helpers.exc_exec
local write_file = helpers.write_file
local redir_exec = helpers.redir_exec
@@ -76,6 +80,64 @@ describe(':lua command', function()
eq('', redir_exec(('lua vim.api.nvim_buf_set_lines(1, 1, 2, false, {"%s"})'):format(s)))
eq({'', s}, curbufmeths.get_lines(0, -1, false))
end)
+
+ it('can show multiline error messages', function()
+ local screen = Screen.new(50,10)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [1] = {bold = true, foreground = Screen.colors.Blue1},
+ [2] = {bold = true, reverse = true},
+ [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
+ [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
+ })
+
+ feed(':lua error("fail\\nmuch error\\nsuch details")<cr>')
+ screen:expect([[
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2: }|
+ {3:E5105: Error while calling lua chunk: [string "<Vi}|
+ {3:mL compiled string>"]:1: fail} |
+ {3:much error} |
+ {3:such details} |
+ {4:Press ENTER or type command to continue}^ |
+ ]])
+ feed('<cr>')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ eq('E5105: Error while calling lua chunk: [string "<VimL compiled string>"]:1: fail\nmuch error\nsuch details', eval('v:errmsg'))
+
+ local status, err = pcall(command,'lua error("some error\\nin a\\nAPI command")')
+ local expected = 'Vim(lua):E5105: Error while calling lua chunk: [string "<VimL compiled string>"]:1: some error\nin a\nAPI command'
+ eq(false, status)
+ eq(expected, string.sub(err, -string.len(expected)))
+
+ feed(':messages<cr>')
+ screen:expect([[
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2: }|
+ {3:E5105: Error while calling lua chunk: [string "<Vi}|
+ {3:mL compiled string>"]:1: fail} |
+ {3:much error} |
+ {3:such details} |
+ {4:Press ENTER or type command to continue}^ |
+ ]])
+ end)
end)
describe(':luado command', function()