aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2015-07-27 13:39:38 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2015-09-16 21:42:57 +0200
commitc8aaabc09c9cd27aeadf395fc025260054490081 (patch)
treee29474a57388a7e1cf8269f553c5be8c2ff36aa1 /test/functional/api/vim_spec.lua
parent8c2481806d9d4cc7641968e04be5e9c87e034752 (diff)
downloadrneovim-c8aaabc09c9cd27aeadf395fc025260054490081.tar.gz
rneovim-c8aaabc09c9cd27aeadf395fc025260054490081.tar.bz2
rneovim-c8aaabc09c9cd27aeadf395fc025260054490081.zip
api: vim_err_write: add tests for multiline handling
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua102
1 files changed, 101 insertions, 1 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 9e880a4f04..8d4e183653 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1,6 +1,8 @@
-- Sanity checks for vim_* API calls via msgpack-rpc
local helpers = require('test.functional.helpers')
-local clear, nvim, eq, neq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.neq, helpers.ok
+local Screen = require('test.functional.ui.screen')
+local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
+local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
describe('vim_* functions', function()
@@ -177,6 +179,104 @@ describe('vim_* functions', function()
end)
end)
+ describe('err_write', function()
+ before_each(function()
+ clear()
+ screen = Screen.new(40, 8)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [1] = {foreground = Screen.colors.White, background = Screen.colors.Red},
+ [2] = {bold = true, foreground = Screen.colors.SeaGreen}
+ })
+ screen:set_default_attr_ignore( {{bold=true, foreground=Screen.colors.Blue}} )
+ end)
+
+ it('can show one line', function()
+ nvim_async('err_write', 'has bork\n')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ {1:has bork} |
+ ]])
+ end)
+
+ it('shows return prompt when more than &cmdheight lines', function()
+ nvim_async('err_write', 'something happened\nvery bad\n')
+ screen:expect([[
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ {1:something happened} |
+ {1:very bad} |
+ {2:Press ENTER or type command to continue}^ |
+ ]])
+ end)
+
+ it('shows return prompt after all lines are shown', function()
+ nvim_async('err_write', 'FAILURE\nERROR\nEXCEPTION\nTRACEBACK\n')
+ screen:expect([[
+ ~ |
+ ~ |
+ ~ |
+ {1:FAILURE} |
+ {1:ERROR} |
+ {1:EXCEPTION} |
+ {1:TRACEBACK} |
+ {2:Press ENTER or type command to continue}^ |
+ ]])
+ end)
+
+ it('handles multiple calls', function()
+ -- without linebreak text is joined to one line
+ nvim_async('err_write', 'very ')
+ nvim_async('err_write', 'fail\n')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ {1:very fail} |
+ ]])
+
+ -- shows up to &cmdheight lines
+ nvim_async('err_write', 'more fail\n')
+ nvim_async('err_write', 'too fail\n')
+ screen:expect([[
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ {1:very fail} |
+ {1:more fail} |
+ {2:Press ENTER or type command to continue}^ |
+ ]])
+
+ -- shows the rest after return
+ feed('<cr>')
+ screen:expect([[
+ ~ |
+ ~ |
+ ~ |
+ {1:very fail} |
+ {1:more fail} |
+ {2:Press ENTER or type command to continue} |
+ {1:too fail} |
+ {2:Press ENTER or type command to continue}^ |
+ ]])
+ end)
+ end)
+
it('can throw exceptions', function()
local status, err = pcall(nvim, 'get_option', 'invalid-option')
eq(false, status)