diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-05-09 00:39:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-09 00:39:17 +0200 |
commit | 0e873a30f3072dbacfb700f1e331a8c8396f2e1f (patch) | |
tree | 557792d454fef510a90975bed4e7d1650ee26c4f /test/functional/api | |
parent | a9981e0e7e9439340bb8c0162f860b78d8002559 (diff) | |
parent | 5b6d598ca8301682d931539ecd6da6a9fabae569 (diff) | |
download | rneovim-0e873a30f3072dbacfb700f1e331a8c8396f2e1f.tar.gz rneovim-0e873a30f3072dbacfb700f1e331a8c8396f2e1f.tar.bz2 rneovim-0e873a30f3072dbacfb700f1e331a8c8396f2e1f.zip |
Merge #4411 from ZyX-I/luaviml'/lua
Diffstat (limited to 'test/functional/api')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/api/window_spec.lua | 7 |
3 files changed, 28 insertions, 0 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 9699ea8f85..823c134ebd 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -10,6 +10,7 @@ local insert = helpers.insert local NIL = helpers.NIL local meth_pcall = helpers.meth_pcall local command = helpers.command +local bufmeths = helpers.bufmeths describe('api/buf', function() before_each(clear) @@ -121,6 +122,15 @@ describe('api/buf', function() local get_lines, set_lines = curbufmeths.get_lines, curbufmeths.set_lines local line_count = curbufmeths.line_count + it('fails correctly when input is not valid', function() + eq(1, curbufmeths.get_number()) + local err, emsg = pcall(bufmeths.set_lines, 1, 1, 2, false, {'b\na'}) + eq(false, err) + local exp_emsg = 'String cannot contain newlines' + -- Expected {filename}:{lnum}: {exp_emsg} + eq(': ' .. exp_emsg, emsg:sub(-#exp_emsg - 2)) + end) + it('has correct line_count when inserting and deleting', function() eq(1, line_count()) set_lines(-1, -1, true, {'line'}) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 7c79d8832f..282ecbfd87 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -337,6 +337,17 @@ describe('api', function() eq('\128\253\44', helpers.nvim('replace_termcodes', '<LeftMouse>', true, true, true)) end) + + it('does not crash when transforming an empty string', function() + -- Actually does not test anything, because current code will use NULL for + -- an empty string. + -- + -- Problem here is that if String argument has .data in allocated memory + -- then `return str` in vim_replace_termcodes body will make Neovim free + -- `str.data` twice: once when freeing arguments, then when freeing return + -- value. + eq('', meths.replace_termcodes('', true, true, true)) + end) end) describe('nvim_feedkeys', function() diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 6882f50a3e..8a65d3f71e 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -9,6 +9,7 @@ local funcs = helpers.funcs local request = helpers.request local NIL = helpers.NIL local meth_pcall = helpers.meth_pcall +local meths = helpers.meths local command = helpers.command -- check if str is visible at the beginning of some line @@ -55,6 +56,12 @@ describe('api/win', function() eq('typing\n some dumb text', curbuf_contents()) end) + it('does not leak memory when using invalid window ID with invalid pos', + function() + eq({false, 'Invalid window id'}, + meth_pcall(meths.win_set_cursor, 1, {"b\na"})) + end) + it('updates the screen, and also when the window is unfocused', function() insert("prologue") feed('100o<esc>') |