diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/vim_spec.lua | 43 | ||||
-rw-r--r-- | test/functional/shell/viml_system_spec.lua | 6 | ||||
-rw-r--r-- | test/unit/helpers.lua | 24 |
3 files changed, 48 insertions, 25 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) diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua index 84c8765b48..8d212c1375 100644 --- a/test/functional/shell/viml_system_spec.lua +++ b/test/functional/shell/viml_system_spec.lua @@ -22,11 +22,9 @@ end -- Some tests require the xclip program and a x server. local xclip = nil -do +do if os.getenv('DISPLAY') then - local proc = io.popen('which xclip') - xclip = proc:read() - proc:close() + xclip = (os.execute('command -v xclip > /dev/null 2>&1') == 0) end end diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 544a53fa10..1b97a2f15a 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -139,26 +139,10 @@ local function vim_init() if vim_init_called ~= nil then return end - -- import os_unix.h for mch_early_init(), which initializes some globals - local all = cimport('./src/nvim/os_unix.h', - './src/nvim/misc1.h', - './src/nvim/eval.h', - './src/nvim/os_unix.h', - './src/nvim/option.h', - './src/nvim/ex_cmds2.h', - './src/nvim/window.h', - './src/nvim/ops.h', - './src/nvim/normal.h', - './src/nvim/mbyte.h') - all.mch_early_init() - all.mb_init() - all.eval_init() - all.init_normal_cmds() - all.win_alloc_first() - all.init_yank() - all.init_homedir() - all.set_init_1() - all.set_lang_var() + local main = cimport('./src/nvim/main.h') + local time = cimport('./src/nvim/os/time.h') + time.time_init() + main.early_init() vim_init_called = true end |