aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2014-10-20 10:21:24 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-11-27 08:33:53 -0300
commit84eb118f62126c67092a6aa2585da51c824013d0 (patch)
tree32844c9832b8f0fa7275b17e6d7c6908f22515c5 /test/functional/api/vim_spec.lua
parente644369f6e67b6520e9c55026f8671985d70c166 (diff)
downloadrneovim-84eb118f62126c67092a6aa2585da51c824013d0.tar.gz
rneovim-84eb118f62126c67092a6aa2585da51c824013d0.tar.bz2
rneovim-84eb118f62126c67092a6aa2585da51c824013d0.zip
Functional tests for feedkeys CSI escaping
- tests for vim_feedkeys and replace_termcodes
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua43
1 files changed, 42 insertions, 1 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index abf9c9efcd..f34df8cefb 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1,6 +1,6 @@
-- Sanity checks for vim_* API calls via msgpack-rpc
local helpers = require('test.functional.helpers')
-local clear, nvim, eq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.ok
+local clear, nvim, eq, neq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.neq, helpers.ok
describe('vim_* functions', function()
@@ -106,6 +106,47 @@ describe('vim_* functions', function()
end)
end)
+ describe('replace_termcodes', function()
+ it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
+ eq(helpers.nvim('replace_termcodes', '\x80', true, true, true), '\x80\xfeX')
+ end)
+
+ it('leaves non K_SPECIAL string unchanged', function()
+ eq(helpers.nvim('replace_termcodes', 'abc', true, true, true), 'abc')
+ end)
+
+ it('converts <expressions>', function()
+ eq(helpers.nvim('replace_termcodes', '<Leader>', true, true, true), '\\')
+ end)
+ end)
+
+ describe('feedkeys', function()
+ it('CSI escaping', function()
+ local function on_setup()
+ -- notice the special char(…) \xe2\80\xa6
+ nvim('feedkeys', ':let x1="…"\n', '', true)
+
+ -- Both replace_termcodes and feedkeys escape \x80
+ local inp = helpers.nvim('replace_termcodes', ':let x2="…"<CR>', true, true, true)
+ nvim('feedkeys', inp, '', true)
+
+ -- Disabling CSI escaping in feedkeys
+ inp = helpers.nvim('replace_termcodes', ':let x3="…"<CR>', true, true, true)
+ nvim('feedkeys', inp, '', false)
+
+ helpers.stop()
+ end
+
+ -- spin the loop a bit
+ helpers.run(nil, nil, on_setup)
+
+ eq(nvim('get_var', 'x1'), '…')
+ -- Because of the double escaping this is neq
+ neq(nvim('get_var', 'x2'), '…')
+ eq(nvim('get_var', 'x3'), '…')
+ end)
+ end)
+
it('can throw exceptions', function()
local status, err = pcall(nvim, 'get_option', 'invalid-option')
eq(false, status)