aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/busted_runner.lua57
-rw-r--r--test/functional/legacy/crash_spec.lua16
-rw-r--r--test/functional/shada/marks_spec.lua29
-rw-r--r--test/functional/terminal/tui_spec.lua34
-rw-r--r--test/old/testdir/crash/vim_regsub_both10
-rw-r--r--test/old/testdir/test_crash.vim34
-rw-r--r--test/old/testdir/test_functions.vim5
-rw-r--r--test/old/testdir/test_selectmode.vim11
8 files changed, 188 insertions, 8 deletions
diff --git a/test/busted_runner.lua b/test/busted_runner.lua
index d6864c6492..8176292bcf 100644
--- a/test/busted_runner.lua
+++ b/test/busted_runner.lua
@@ -4,4 +4,61 @@ local suffix = (platform and platform.sysname:lower():find'windows') and '.dll'
package.path = deps_install_dir.."/share/lua/5.1/?.lua;"..deps_install_dir.."/share/lua/5.1/?/init.lua;"..package.path
package.cpath = deps_install_dir.."/lib/lua/5.1/?"..suffix..";"..package.cpath;
+local uv = vim.uv
+
+local system = {}
+package.loaded['system.core'] = system
+function system.monotime()
+ uv.update_time()
+ return uv.now()*1e-3
+end
+function system.gettime()
+ local sec, usec = uv.gettimeofday()
+ return sec+usec*1e-6
+end
+function system.sleep(sec)
+ uv.sleep(sec*1e3)
+end
+
+local term = {}
+package.loaded['term.core'] = term
+function term.isatty(_)
+ return uv.guess_handle(1) == 'tty'
+end
+
+local lfs = {}
+package.loaded['lfs'] = lfs
+
+function lfs.attributes(path, attr)
+ if attr == 'mode' then
+ local stat = uv.fs_stat(path)
+ return stat and stat.type or ''
+ else
+ error('not implemented')
+ end
+end
+
+function lfs.currentdir()
+ return uv.cwd()
+end
+
+function lfs.chdir(dir)
+ local status, err = pcall(uv.chdir, dir)
+ if status then
+ return true
+ else
+ return nil, err
+ end
+end
+
+function lfs.dir(path)
+ local fs = uv.fs_scandir(path)
+ return function()
+ if not fs then
+ return
+ end
+ return uv.fs_scandir_next(fs)
+ end
+end
+
require 'busted.runner'({ standalone = false })
diff --git a/test/functional/legacy/crash_spec.lua b/test/functional/legacy/crash_spec.lua
new file mode 100644
index 0000000000..5094f81847
--- /dev/null
+++ b/test/functional/legacy/crash_spec.lua
@@ -0,0 +1,16 @@
+local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
+local clear = helpers.clear
+local command = helpers.command
+local feed = helpers.feed
+
+before_each(clear)
+
+-- oldtest: Test_crash1()
+it('no crash when ending Visual mode while editing buffer closes window', function()
+ command('new')
+ command('autocmd ModeChanged v:n ++once close')
+ feed('v')
+ command('enew')
+ assert_alive()
+end)
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index 07364382e8..7f03022ab8 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -250,7 +250,7 @@ describe('ShaDa support code', function()
eq(0, exc_exec('rshada'))
end)
- it('updates deleted marks', function()
+ it('updates deleted marks with :delmarks', function()
nvim_command('edit ' .. testfilename)
nvim_command('mark A')
@@ -259,14 +259,39 @@ describe('ShaDa support code', function()
-- since it can't be set via :mark
feed('ggifoobar<esc>')
nvim_command('wshada')
- nvim_command('normal! `A`a`.')
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('normal! `A`a`.')
nvim_command('delmarks A a .')
nvim_command('wshada')
reset()
+ nvim_command('edit ' .. testfilename)
eq('Vim(normal):E20: Mark not set', exc_exec('normal! `A'))
eq('Vim(normal):E20: Mark not set', exc_exec('normal! `a'))
eq('Vim(normal):E20: Mark not set', exc_exec('normal! `.'))
end)
+
+ it('updates deleted marks with :delmarks!', function()
+ nvim_command('edit ' .. testfilename)
+
+ nvim_command('mark A')
+ nvim_command('mark a')
+ feed('ggifoobar<esc>')
+ nvim_command('wshada')
+
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('normal! `A`a`.')
+ nvim_command('delmarks!')
+ nvim_command('wshada')
+
+ reset()
+ nvim_command('edit ' .. testfilename)
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `a'))
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `.'))
+ -- Make sure that uppercase marks aren't deleted.
+ nvim_command('normal! `A')
+ end)
end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 1958281592..57dcb14cf8 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -27,8 +27,6 @@ local is_os = helpers.is_os
local new_pipename = helpers.new_pipename
local spawn_argv = helpers.spawn_argv
local set_session = helpers.set_session
-local feed = helpers.feed
-local eval = helpers.eval
local write_file = helpers.write_file
if helpers.skip(helpers.is_os('win')) then return end
@@ -898,7 +896,7 @@ describe('TUI', function()
feed_data('\022\027[107;33u') -- Meta + k
feed_data('\022\027[13;41u') -- Super + Meta + Enter
feed_data('\022\027[127;48u') -- Shift + Alt + Ctrl + Super + Meta + Backspace
- feed('\n')
+ feed_data('\n')
feed_data('\022\027[57376;9u') -- Super + F13
feed_data('\022\027[57377;33u') -- Meta + F14
feed_data('\022\027[57378;41u') -- Super + Meta + F15
@@ -1752,7 +1750,7 @@ describe('TUI', function()
|
{5:-- TERMINAL --} |
]])
- feed('i')
+ feed_data('i')
screen:expect([[
{1: } |
{2:~}{3: }|
@@ -1898,6 +1896,30 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
end)
+
+ it('draws line with many trailing spaces correctly #24955', function()
+ local screen = thelpers.screen_setup(0, '["'..nvim_prog..[[", "-u", "NONE", "-i", "NONE"]]
+ ..[[, "--cmd", "call setline(1, ['1st line' .. repeat(' ', 153), '2nd line'])"]]..']', 80)
+ screen:expect{grid=[[
+ {1:1}st line |
+ |
+ |
+ 2nd line |
+ {5:[No Name] [+] 1,1 All}|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
+ feed_data('$')
+ screen:expect{grid=[[
+ 1st line |
+ |
+ {1: } |
+ 2nd line |
+ {5:[No Name] [+] 1,161 All}|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
+ end)
end)
describe('TUI UIEnter/UILeave', function()
@@ -2703,8 +2725,8 @@ describe("TUI as a client", function()
local client_super = spawn_argv(true)
set_session(server)
- local server_pipe = eval'v:servername'
- feed'iHalloj!<esc>'
+ local server_pipe = meths.get_vvar('servername')
+ server:request('nvim_input', 'iHalloj!<Esc>')
set_session(client_super)
local screen = thelpers.screen_setup(0,
diff --git a/test/old/testdir/crash/vim_regsub_both b/test/old/testdir/crash/vim_regsub_both
new file mode 100644
index 0000000000..a82b205c8f
--- /dev/null
+++ b/test/old/testdir/crash/vim_regsub_both
@@ -0,0 +1,10 @@
+fu R()
+sil!norm0z=
+endf
+cal R()
+s/\%')/\=R()
+d
+no0 normyynore sm:vs0@vvvvvvvvvvse()dir(¼Xtest=csd{so88
+vs
+0scr
+so
diff --git a/test/old/testdir/test_crash.vim b/test/old/testdir/test_crash.vim
new file mode 100644
index 0000000000..445fe8d5a7
--- /dev/null
+++ b/test/old/testdir/test_crash.vim
@@ -0,0 +1,34 @@
+" Some tests, that used to crash Vim
+source check.vim
+source screendump.vim
+
+CheckScreendump
+
+func Test_crash1()
+ " The following used to crash Vim
+ let opts = #{wait_for_ruler: 0, rows: 20}
+ let args = ' -u NONE -i NONE -n -e -s -S '
+ let buf = RunVimInTerminal(args .. ' crash/poc_huaf1', opts)
+ call VerifyScreenDump(buf, 'Test_crash_01', {})
+ exe buf .. "bw!"
+
+ let buf = RunVimInTerminal(args .. ' crash/poc_huaf2', opts)
+ call VerifyScreenDump(buf, 'Test_crash_01', {})
+ exe buf .. "bw!"
+
+ let buf = RunVimInTerminal(args .. ' crash/poc_huaf3', opts)
+ call VerifyScreenDump(buf, 'Test_crash_01', {})
+ exe buf .. "bw!"
+
+endfunc
+
+func Test_crash2()
+ " The following used to crash Vim
+ let opts = #{wait_for_ruler: 0, rows: 20}
+ let args = ' -u NONE -i NONE -n -e -s -S '
+ let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
+ call VerifyScreenDump(buf, 'Test_crash_01', {})
+ exe buf .. "bw!"
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index 37541c4af3..eff4e36f34 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -3273,4 +3273,9 @@ func Test_string_reverse()
let &encoding = save_enc
endfunc
+func Test_fullcommand()
+ " this used to crash vim
+ call assert_equal('', fullcommand(10))
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_selectmode.vim b/test/old/testdir/test_selectmode.vim
index dd341d99d1..59a1deba65 100644
--- a/test/old/testdir/test_selectmode.vim
+++ b/test/old/testdir/test_selectmode.vim
@@ -312,4 +312,15 @@ func Test_selectmode_register()
bw!
endfunc
+func Test_ins_ctrl_o_in_insert_mode_resets_selectmode()
+ new
+ " ctrl-o in insert mode resets restart_VIsual_select
+ call setline(1, 'abcdef')
+ call cursor(1, 1)
+ exe "norm! \<c-v>\<c-g>\<c-o>c\<c-o>\<c-v>\<right>\<right>IABC"
+ call assert_equal('ABCbcdef', getline(1))
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab