aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/keymap_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-07-02 19:28:44 +0300
committerZyX <kp-pav@yandex.ru>2017-07-02 19:28:44 +0300
commita1fee487ba5199ff672a87c5830732c224fa59eb (patch)
treedf6baaba688b6b3b1c54af0f9cede52bf9eb49a8 /test/functional/api/keymap_spec.lua
parent4b8bdd953e2b7928af80e8b97118d52f99f0d95a (diff)
downloadrneovim-a1fee487ba5199ff672a87c5830732c224fa59eb.tar.gz
rneovim-a1fee487ba5199ff672a87c5830732c224fa59eb.tar.bz2
rneovim-a1fee487ba5199ff672a87c5830732c224fa59eb.zip
functests: Add tests for new behaviour
Apparently it is not working yet.
Diffstat (limited to 'test/functional/api/keymap_spec.lua')
-rw-r--r--test/functional/api/keymap_spec.lua72
1 files changed, 62 insertions, 10 deletions
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua
index 7d6445f49c..b7858888c4 100644
--- a/test/functional/api/keymap_spec.lua
+++ b/test/functional/api/keymap_spec.lua
@@ -17,16 +17,16 @@ describe('get_keymap', function()
-- Basic mapping and table to be used to describe results
local foo_bar_string = 'nnoremap foo bar'
local foo_bar_map_table = {
- lhs='foo',
- silent=0,
- rhs='bar',
- expr=0,
- sid=0,
- buffer=0,
- nowait=0,
- mode='n',
- noremap=1,
- }
+ lhs='foo',
+ silent=0,
+ rhs='bar',
+ expr=0,
+ sid=0,
+ buffer=0,
+ nowait=0,
+ mode='n',
+ noremap=1,
+ }
it('returns empty list when no map', function()
eq({}, meths.get_keymap('n'))
@@ -238,4 +238,56 @@ describe('get_keymap', function()
eq('<F12>', meths.get_keymap('n')[1]['lhs'])
eq(':let g:maparg_test_var = 1<CR>', meths.get_keymap('n')[1]['rhs'])
end)
+
+ it('works correctly despite various &cpo settings', function()
+ local cpo_table = {
+ silent=0,
+ expr=0,
+ sid=0,
+ buffer=0,
+ nowait=0,
+ noremap=1,
+ }
+ local function cpomap(lhs, rhs, mode)
+ local ret = shallowcopy(cpo_table)
+ ret.lhs = lhs
+ ret.rhs = rhs
+ ret.mode = mode
+ return ret
+ end
+
+ command('set cpo-=< cpo+=B')
+ command('nnoremap \\<C-a> \\<C-b>')
+ command('nnoremap <special> \\<C-c> \\<C-d>')
+
+ command('set cpo+=B<')
+ command('xnoremap \\<C-a> \\<C-b>')
+ command('xnoremap <special> \\<C-c> \\<C-d>')
+
+ command('set cpo-=B<')
+ command('snoremap \\<C-a> \\<C-b>')
+ command('snoremap <special> \\<C-c> \\<C-d>')
+
+ command('set cpo-=B cpo+=<')
+ command('onoremap \\<C-a> \\<C-b>')
+ command('onoremap <special> \\<C-c> \\<C-d>')
+
+ for _, cmd in ipairs({
+ 'set cpo-=B cpo+=<',
+ 'set cpo-=B<',
+ 'set cpo+=B<',
+ 'set cpo-=< cpo+=B',
+ }) do
+ command(cmd)
+ eq({cpomap('\\<C-C>', '\\<C-D>', 'n'), cpomap('\\<C-A>', '\\<C-B>', 'n')},
+ meths.get_keymap('n'))
+ -- FIXME
+ -- eq({cpomap('\\<C-C>', '\\<C-D>', 'x'), cpomap('\\<LT>C-A>', '\\<LT>C-B>', 'x')},
+ -- meths.get_keymap('x'))
+ -- eq({cpomap('<LT>C-C>', '<LT>C-D>', 's'), cpomap('<LT>C-A>', '<LT>C-B>', 's')},
+ -- meths.get_keymap('x'))
+ -- eq({cpomap('<LT>C-C>', '<LT>C-D>', 'o'), cpomap('<LT>C-A>', '<LT>C-B>', 'o')},
+ -- meths.get_keymap('x'))
+ end
+ end)
end)