aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmark/bench_re_freeze_spec.lua21
-rw-r--r--test/functional/api/buffer_spec.lua2
-rw-r--r--test/functional/api/tabpage_spec.lua2
-rw-r--r--test/functional/api/vim_spec.lua111
-rw-r--r--test/functional/api/window_spec.lua2
-rw-r--r--test/functional/eval/system_spec.lua108
-rw-r--r--test/functional/ex_cmds/ctrl_c_spec.lua2
-rw-r--r--test/functional/ex_cmds/file_spec.lua35
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua47
-rw-r--r--test/functional/ex_cmds/print_commands_spec.lua12
-rw-r--r--test/functional/ex_cmds/recover_spec.lua41
-rw-r--r--test/functional/fixtures/api_level_2.mpackbin0 -> 16949 bytes
-rw-r--r--test/functional/fixtures/printargs-test.c3
-rw-r--r--test/functional/fixtures/shell-test.c3
-rw-r--r--test/functional/fixtures/tty-test.c3
-rw-r--r--test/functional/helpers.lua49
-rw-r--r--test/functional/insert/ctrl_r_spec.lua19
-rw-r--r--test/functional/normal/fold_spec.lua19
-rw-r--r--test/functional/normal/lang_spec.lua36
-rw-r--r--test/functional/options/defaults_spec.lua41
-rw-r--r--test/functional/provider/python3_spec.lua10
-rw-r--r--test/functional/spell/spellfile_spec.lua4
-rw-r--r--test/functional/terminal/edit_spec.lua5
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua2
-rw-r--r--test/functional/terminal/scrollback_spec.lua7
-rw-r--r--test/functional/terminal/tui_spec.lua12
-rw-r--r--test/functional/ui/cursor_spec.lua284
-rw-r--r--test/functional/ui/highlight_spec.lua45
-rw-r--r--test/functional/ui/inccommand_spec.lua25
-rw-r--r--test/functional/ui/mode_spec.lua227
-rw-r--r--test/functional/ui/screen.lua35
-rw-r--r--test/functional/ui/screen_basic_spec.lua131
-rw-r--r--test/functional/ui/tabline_spec.lua57
-rw-r--r--test/functional/ui/wildmode_spec.lua21
-rw-r--r--test/functional/viml/completion_spec.lua4
-rw-r--r--test/helpers.lua9
-rw-r--r--test/unit/eval/typval_spec.lua4
-rw-r--r--test/unit/fixtures/multiqueue.c3
-rw-r--r--test/unit/fixtures/rbuffer.c3
-rw-r--r--test/unit/os/env_spec.lua27
-rw-r--r--test/unit/os/fs_spec.lua52
-rw-r--r--test/unit/path_spec.lua81
42 files changed, 1127 insertions, 477 deletions
diff --git a/test/benchmark/bench_re_freeze_spec.lua b/test/benchmark/bench_re_freeze_spec.lua
index 53041b042b..ea41953014 100644
--- a/test/benchmark/bench_re_freeze_spec.lua
+++ b/test/benchmark/bench_re_freeze_spec.lua
@@ -1,8 +1,8 @@
-- Test for benchmarking RE engine.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
-local clear, execute, wait = helpers.clear, helpers.execute, helpers.wait
+local clear, command = helpers.clear, helpers.command
-- Temporary file for gathering benchmarking results for each regexp engine.
local result_file = 'benchmark.out'
@@ -31,7 +31,7 @@ describe('regexp search', function()
clear()
source(measure_script)
insert('" Benchmark_results:')
- execute('write! ' .. result_file)
+ command('write! ' .. result_file)
end)
-- At the end of the test run we just print the contents of the result file
@@ -46,22 +46,19 @@ describe('regexp search', function()
it('is working with regexpengine=0', function()
local regexpengine = 0
- execute(string.format(measure_cmd, regexpengine))
- execute('write')
- wait()
+ command(string.format(measure_cmd, regexpengine))
+ command('write')
end)
it('is working with regexpengine=1', function()
local regexpengine = 1
- execute(string.format(measure_cmd, regexpengine))
- execute('write')
- wait()
+ command(string.format(measure_cmd, regexpengine))
+ command('write')
end)
it('is working with regexpengine=2', function()
local regexpengine = 2
- execute(string.format(measure_cmd, regexpengine))
- execute('write')
- wait()
+ command(string.format(measure_cmd, regexpengine))
+ command('write')
end)
end)
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index c3002618b0..9699ea8f85 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -271,7 +271,7 @@ describe('api/buf', function()
eq(1, funcs.exists('b:lua'))
curbufmeths.del_var('lua')
eq(0, funcs.exists('b:lua'))
- eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curbufmeths.del_var, 'lua'))
+ eq({false, 'Key does not exist: lua'}, meth_pcall(curbufmeths.del_var, 'lua'))
curbufmeths.set_var('lua', 1)
command('lockvar b:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.del_var, 'lua'))
diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua
index d7ef53a88f..260a91a80c 100644
--- a/test/functional/api/tabpage_spec.lua
+++ b/test/functional/api/tabpage_spec.lua
@@ -34,7 +34,7 @@ describe('api/tabpage', function()
eq(1, funcs.exists('t:lua'))
curtabmeths.del_var('lua')
eq(0, funcs.exists('t:lua'))
- eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curtabmeths.del_var, 'lua'))
+ eq({false, 'Key does not exist: lua'}, meth_pcall(curtabmeths.del_var, 'lua'))
curtabmeths.set_var('lua', 1)
command('lockvar t:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.del_var, 'lua'))
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 8f9f155110..7c79d8832f 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -119,7 +119,7 @@ describe('api', function()
eq(1, funcs.exists('g:lua'))
meths.del_var('lua')
eq(0, funcs.exists('g:lua'))
- eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(meths.del_var, 'lua'))
+ eq({false, 'Key does not exist: lua'}, meth_pcall(meths.del_var, 'lua'))
meths.set_var('lua', 1)
command('lockvar lua')
eq({false, 'Key is locked: lua'}, meth_pcall(meths.del_var, 'lua'))
@@ -221,6 +221,102 @@ describe('api', function()
end)
end)
+ describe('nvim_get_mode', function()
+ it("during normal-mode `g` returns blocking=true", function()
+ nvim("input", "o") -- add a line
+ eq({mode='i', blocking=false}, nvim("get_mode"))
+ nvim("input", [[<C-\><C-N>]])
+ eq(2, nvim("eval", "line('.')"))
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+
+ nvim("input", "g")
+ eq({mode='n', blocking=true}, nvim("get_mode"))
+
+ nvim("input", "k") -- complete the operator
+ eq(1, nvim("eval", "line('.')")) -- verify the completed operator
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end)
+
+ it("returns the correct result multiple consecutive times", function()
+ for _ = 1,5 do
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end
+ nvim("input", "g")
+ for _ = 1,4 do
+ eq({mode='n', blocking=true}, nvim("get_mode"))
+ end
+ nvim("input", "g")
+ for _ = 1,7 do
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end
+ end)
+
+ it("during normal-mode CTRL-W, returns blocking=true", function()
+ nvim("input", "<C-W>")
+ eq({mode='n', blocking=true}, nvim("get_mode"))
+
+ nvim("input", "s") -- complete the operator
+ eq(2, nvim("eval", "winnr('$')")) -- verify the completed operator
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end)
+
+ it("during press-enter prompt returns blocking=true", function()
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ command("echom 'msg1'")
+ command("echom 'msg2'")
+ command("echom 'msg3'")
+ command("echom 'msg4'")
+ command("echom 'msg5'")
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ nvim("input", ":messages<CR>")
+ eq({mode='r', blocking=true}, nvim("get_mode"))
+ end)
+
+ it("during getchar() returns blocking=false", function()
+ nvim("input", ":let g:test_input = nr2char(getchar())<CR>")
+ -- Events are enabled during getchar(), RPC calls are *not* blocked. #5384
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ eq(0, nvim("eval", "exists('g:test_input')"))
+ nvim("input", "J")
+ eq("J", nvim("eval", "g:test_input"))
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ end)
+
+ -- TODO: bug #6247#issuecomment-286403810
+ it("batched with input", function()
+ eq({mode='n', blocking=false}, nvim("get_mode"))
+ command("echom 'msg1'")
+ command("echom 'msg2'")
+ command("echom 'msg3'")
+ command("echom 'msg4'")
+ command("echom 'msg5'")
+
+ local req = {
+ {'nvim_get_mode', {}},
+ {'nvim_input', {':messages<CR>'}},
+ {'nvim_get_mode', {}},
+ {'nvim_eval', {'1'}},
+ }
+ eq({{{mode='n', blocking=false},
+ 13,
+ {mode='n', blocking=false}, -- TODO: should be blocked=true
+ 1},
+ NIL}, meths.call_atomic(req))
+ eq({mode='r', blocking=true}, nvim("get_mode"))
+ end)
+ -- TODO: bug #6166
+ it("during insert-mode map-pending, returns blocking=true #6166", function()
+ command("inoremap xx foo")
+ nvim("input", "ix")
+ eq({mode='i', blocking=true}, nvim("get_mode"))
+ end)
+ -- TODO: bug #6166
+ it("during normal-mode gU, returns blocking=false #6166", function()
+ nvim("input", "gu")
+ eq({mode='no', blocking=false}, nvim("get_mode"))
+ end)
+ end)
+
describe('nvim_replace_termcodes', function()
it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
eq('\128\254X', helpers.nvim('replace_termcodes', '\128', true, true, true))
@@ -412,7 +508,7 @@ describe('api', function()
eq(5, meths.get_var('avar'))
end)
- it('throws error on malformated arguments', function()
+ it('throws error on malformed arguments', function()
local req = {
{'nvim_set_var', {'avar', 1}},
{'nvim_set_var'},
@@ -439,7 +535,7 @@ describe('api', function()
}
status, err = pcall(meths.call_atomic, req)
eq(false, status)
- ok(err:match('args must be Array') ~= nil)
+ ok(err:match('Args must be Array') ~= nil)
-- call before was done, but not after
eq(1, meths.get_var('avar'))
eq({''}, meths.buf_get_lines(0, 0, -1, true))
@@ -452,7 +548,14 @@ describe('api', function()
ok(err:match('Invalid option name') ~= nil)
end)
- it("doesn't leak memory on incorrect argument types", function()
+ it('does not truncate error message <1 MB #5984', function()
+ local very_long_name = 'A'..('x'):rep(10000)..'Z'
+ local status, err = pcall(nvim, 'get_option', very_long_name)
+ eq(false, status)
+ eq(very_long_name, err:match('Ax+Z?'))
+ end)
+
+ it("does not leak memory on incorrect argument types", function()
local status, err = pcall(nvim, 'set_current_dir',{'not', 'a', 'dir'})
eq(false, status)
ok(err:match(': Wrong type for argument 1, expecting String') ~= nil)
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index deffc68994..6882f50a3e 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -139,7 +139,7 @@ describe('api/win', function()
eq(1, funcs.exists('w:lua'))
curwinmeths.del_var('lua')
eq(0, funcs.exists('w:lua'))
- eq({false, 'Key "lua" doesn\'t exist'}, meth_pcall(curwinmeths.del_var, 'lua'))
+ eq({false, 'Key does not exist: lua'}, meth_pcall(curwinmeths.del_var, 'lua'))
curwinmeths.set_var('lua', 1)
command('lockvar w:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.del_var, 'lua'))
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index bf95752e3b..7e213e2156 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -4,6 +4,8 @@ local nvim_dir = helpers.nvim_dir
local eq, call, clear, eval, feed_command, feed, nvim =
helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command,
helpers.feed, helpers.nvim
+local command = helpers.command
+local iswin = helpers.iswin
local Screen = require('test.functional.ui.screen')
@@ -33,8 +35,7 @@ describe('system()', function()
describe('command passed as a List', function()
local function printargs_path()
- return nvim_dir..'/printargs-test'
- .. (helpers.os_name() == 'windows' and '.exe' or '')
+ return nvim_dir..'/printargs-test' .. (iswin() and '.exe' or '')
end
it('sets v:shell_error if cmd[0] is not executable', function()
@@ -88,23 +89,32 @@ describe('system()', function()
end)
it('does NOT run in shell', function()
- if helpers.os_name() ~= 'windows' then
+ if not iswin() then
eq("* $PATH %PATH%\n", eval("system(['echo', '*', '$PATH', '%PATH%'])"))
end
end)
end)
- if helpers.pending_win32(pending) then return end
-
it('sets v:shell_error', function()
- eval([[system("sh -c 'exit'")]])
- eq(0, eval('v:shell_error'))
- eval([[system("sh -c 'exit 1'")]])
- eq(1, eval('v:shell_error'))
- eval([[system("sh -c 'exit 5'")]])
- eq(5, eval('v:shell_error'))
- eval([[system('this-should-not-exist')]])
- eq(127, eval('v:shell_error'))
+ if iswin() then
+ eval([[system("cmd.exe /c exit")]])
+ eq(0, eval('v:shell_error'))
+ eval([[system("cmd.exe /c exit 1")]])
+ eq(1, eval('v:shell_error'))
+ eval([[system("cmd.exe /c exit 5")]])
+ eq(5, eval('v:shell_error'))
+ eval([[system('this-should-not-exist')]])
+ eq(1, eval('v:shell_error'))
+ else
+ eval([[system("sh -c 'exit'")]])
+ eq(0, eval('v:shell_error'))
+ eval([[system("sh -c 'exit 1'")]])
+ eq(1, eval('v:shell_error'))
+ eval([[system("sh -c 'exit 5'")]])
+ eq(5, eval('v:shell_error'))
+ eval([[system('this-should-not-exist')]])
+ eq(127, eval('v:shell_error'))
+ end
end)
describe('executes shell function if passed a string', function()
@@ -120,6 +130,40 @@ describe('system()', function()
screen:detach()
end)
+ if iswin() then
+ it('with shell=cmd.exe', function()
+ command('set shell=cmd.exe')
+ eq('""\n', eval([[system('echo ""')]]))
+ eq('"a b"\n', eval([[system('echo "a b"')]]))
+ eq('a \nb\n', eval([[system('echo a & echo b')]]))
+ eq('a \n', eval([[system('echo a 2>&1')]]))
+ eval([[system('cd "C:\Program Files"')]])
+ eq(0, eval('v:shell_error'))
+ end)
+
+ it('with shell=cmd', function()
+ command('set shell=cmd')
+ eq('"a b"\n', eval([[system('echo "a b"')]]))
+ end)
+
+ it('with shell=$COMSPEC', function()
+ local comspecshell = eval("fnamemodify($COMSPEC, ':t')")
+ if comspecshell == 'cmd.exe' then
+ command('set shell=$COMSPEC')
+ eq('"a b"\n', eval([[system('echo "a b"')]]))
+ else
+ pending('$COMSPEC is not cmd.exe: ' .. comspecshell)
+ end
+ end)
+
+ it('works with powershell', function()
+ helpers.set_shell_powershell()
+ eq('a\nb\n', eval([[system('echo a b')]]))
+ eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]]))
+ eq('a b\n', eval([[system('echo "a b"')]]))
+ end)
+ end
+
it('`echo` and waits for its return', function()
feed(':call system("echo")<cr>')
screen:expect([[
@@ -180,7 +224,11 @@ describe('system()', function()
describe('passing no input', function()
it('returns the program output', function()
- eq("echoed", eval('system("echo -n echoed")'))
+ if iswin() then
+ eq("echoed\n", eval('system("echo echoed")'))
+ else
+ eq("echoed", eval('system("echo -n echoed")'))
+ end
end)
it('to backgrounded command does not crash', function()
-- This is indeterminate, just exercise the codepath. May get E5677.
@@ -277,21 +325,30 @@ describe('system()', function()
end)
end)
-if helpers.pending_win32(pending) then return end
-
describe('systemlist()', function()
-- Similar to `system()`, but returns List instead of String.
before_each(clear)
- it('sets the v:shell_error variable', function()
- eval([[systemlist("sh -c 'exit'")]])
- eq(0, eval('v:shell_error'))
- eval([[systemlist("sh -c 'exit 1'")]])
- eq(1, eval('v:shell_error'))
- eval([[systemlist("sh -c 'exit 5'")]])
- eq(5, eval('v:shell_error'))
- eval([[systemlist('this-should-not-exist')]])
- eq(127, eval('v:shell_error'))
+ it('sets v:shell_error', function()
+ if iswin() then
+ eval([[systemlist("cmd.exe /c exit")]])
+ eq(0, eval('v:shell_error'))
+ eval([[systemlist("cmd.exe /c exit 1")]])
+ eq(1, eval('v:shell_error'))
+ eval([[systemlist("cmd.exe /c exit 5")]])
+ eq(5, eval('v:shell_error'))
+ eval([[systemlist('this-should-not-exist')]])
+ eq(1, eval('v:shell_error'))
+ else
+ eval([[systemlist("sh -c 'exit'")]])
+ eq(0, eval('v:shell_error'))
+ eval([[systemlist("sh -c 'exit 1'")]])
+ eq(1, eval('v:shell_error'))
+ eval([[systemlist("sh -c 'exit 5'")]])
+ eq(5, eval('v:shell_error'))
+ eval([[systemlist('this-should-not-exist')]])
+ eq(127, eval('v:shell_error'))
+ end
end)
describe('exectues shell function', function()
@@ -389,6 +446,7 @@ describe('systemlist()', function()
after_each(delete_file(fname))
it('replaces NULs by newline characters', function()
+ if helpers.pending_win32(pending) then return end
eq({'part1\npart2\npart3'}, eval('systemlist("cat '..fname..'")'))
end)
end)
diff --git a/test/functional/ex_cmds/ctrl_c_spec.lua b/test/functional/ex_cmds/ctrl_c_spec.lua
index 993bfa0dba..091a008814 100644
--- a/test/functional/ex_cmds/ctrl_c_spec.lua
+++ b/test/functional/ex_cmds/ctrl_c_spec.lua
@@ -41,7 +41,7 @@ describe("CTRL-C (mapped)", function()
local function test_ctrl_c(ms)
feed(":global/^/p<CR>")
- helpers.sleep(ms)
+ screen:sleep(ms)
feed("<C-C>")
screen:expect([[Interrupt]], nil, nil, nil, true)
end
diff --git a/test/functional/ex_cmds/file_spec.lua b/test/functional/ex_cmds/file_spec.lua
new file mode 100644
index 0000000000..771c283134
--- /dev/null
+++ b/test/functional/ex_cmds/file_spec.lua
@@ -0,0 +1,35 @@
+local helpers = require('test.functional.helpers')(after_each)
+local lfs = require('lfs')
+local clear = helpers.clear
+local command = helpers.command
+local eq = helpers.eq
+local funcs = helpers.funcs
+local rmdir = helpers.rmdir
+
+describe(':file', function()
+ local swapdir = lfs.currentdir()..'/Xtest-file_spec'
+ before_each(function()
+ clear()
+ rmdir(swapdir)
+ lfs.mkdir(swapdir)
+ end)
+ after_each(function()
+ command('%bwipeout!')
+ rmdir(swapdir)
+ end)
+
+ it("rename does not lose swapfile #6487", function()
+ local testfile = 'test-file_spec'
+ local testfile_renamed = testfile..'-renamed'
+ -- Note: `set swapfile` *must* go after `set directory`: otherwise it may
+ -- attempt to create a swapfile in different directory.
+ command('set directory^='..swapdir..'//')
+ command('set swapfile fileformat=unix undolevels=-1')
+
+ command('edit! '..testfile)
+ -- Before #6487 this gave "E301: Oops, lost the swap file !!!" on Windows.
+ command('file '..testfile_renamed)
+ eq(testfile_renamed..'.swp',
+ string.match(funcs.execute('swapname'), '[^%%]+$'))
+ end)
+end)
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index 656b3f9bae..4002855c24 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -4,13 +4,15 @@ local helpers = require('test.functional.helpers')(after_each)
local buf, eq, feed_command = helpers.curbufmeths, helpers.eq, helpers.feed_command
local feed, nvim_prog, wait = helpers.feed, helpers.nvim_prog, helpers.wait
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
+local eval = helpers.eval
-local shada_file = 'test.shada'
+local shada_file = 'Xtest.shada'
local function _clear()
- set_session(spawn({nvim_prog, '--embed', '-u', 'NONE', '--cmd',
+ set_session(spawn({nvim_prog, '--embed', '-u', 'NONE',
-- Need shada for these tests.
- 'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'}))
+ '-i', shada_file,
+ '--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'}))
end
describe(':oldfiles', function()
@@ -29,8 +31,8 @@ describe(':oldfiles', function()
screen:attach()
feed_command('edit testfile1')
feed_command('edit testfile2')
- feed_command('wshada ' .. shada_file)
- feed_command('rshada! ' .. shada_file)
+ feed_command('wshada')
+ feed_command('rshada!')
local oldfiles = helpers.meths.get_vvar('oldfiles')
feed_command('oldfiles')
screen:expect([[
@@ -41,6 +43,38 @@ describe(':oldfiles', function()
Press ENTER or type command to continue^ |
]])
end)
+
+ it('can be filtered with :filter', function()
+ feed_command('edit file_one.txt')
+ local file1 = buf.get_name()
+ feed_command('edit file_two.txt')
+ local file2 = buf.get_name()
+ feed_command('edit another.txt')
+ local another = buf.get_name()
+ feed_command('wshada')
+ feed_command('rshada!')
+
+ local function get_oldfiles(cmd)
+ local t = eval([[split(execute(']]..cmd..[['), "\n")]])
+ for i, _ in ipairs(t) do
+ t[i] = t[i]:gsub('^%d+:%s+', '')
+ end
+ table.sort(t)
+ return t
+ end
+
+ local oldfiles = get_oldfiles('oldfiles')
+ eq({another, file1, file2}, oldfiles)
+
+ oldfiles = get_oldfiles('filter file_ oldfiles')
+ eq({file1, file2}, oldfiles)
+
+ oldfiles = get_oldfiles('filter /another/ oldfiles')
+ eq({another}, oldfiles)
+
+ oldfiles = get_oldfiles('filter! file_ oldfiles')
+ eq({another}, oldfiles)
+ end)
end)
describe(':browse oldfiles', function()
@@ -54,10 +88,9 @@ describe(':browse oldfiles', function()
filename = buf.get_name()
feed_command('edit testfile2')
filename2 = buf.get_name()
- feed_command('wshada ' .. shada_file)
+ feed_command('wshada')
wait()
_clear()
- feed_command('rshada! ' .. shada_file)
-- Ensure nvim is out of "Press ENTER..." prompt.
feed('<cr>')
diff --git a/test/functional/ex_cmds/print_commands_spec.lua b/test/functional/ex_cmds/print_commands_spec.lua
new file mode 100644
index 0000000000..98c0f74635
--- /dev/null
+++ b/test/functional/ex_cmds/print_commands_spec.lua
@@ -0,0 +1,12 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear, eq, command, funcs =
+ helpers.clear, helpers.eq, helpers.command, helpers.funcs
+
+describe(':z^', function()
+ before_each(clear)
+
+ it('correctly sets the cursor after :z^', function()
+ command('z^')
+ eq(1, funcs.line('.'))
+ end)
+end)
diff --git a/test/functional/ex_cmds/recover_spec.lua b/test/functional/ex_cmds/recover_spec.lua
index 36bf85015a..cb68c29b9a 100644
--- a/test/functional/ex_cmds/recover_spec.lua
+++ b/test/functional/ex_cmds/recover_spec.lua
@@ -1,12 +1,11 @@
--- Tests for :recover
-
local helpers = require('test.functional.helpers')(after_each)
local lfs = require('lfs')
local feed_command, eq, clear, eval, feed, expect, source =
helpers.feed_command, helpers.eq, helpers.clear, helpers.eval, helpers.feed,
helpers.expect, helpers.source
-
-if helpers.pending_win32(pending) then return end
+local command = helpers.command
+local ok = helpers.ok
+local rmdir = helpers.rmdir
describe(':recover', function()
before_each(clear)
@@ -23,30 +22,29 @@ describe(':preserve', function()
local swapdir = lfs.currentdir()..'/testdir_recover_spec'
before_each(function()
clear()
- helpers.rmdir(swapdir)
+ rmdir(swapdir)
lfs.mkdir(swapdir)
end)
after_each(function()
- helpers.rmdir(swapdir)
+ command('%bwipeout!')
+ rmdir(swapdir)
end)
it("saves to custom 'directory' and (R)ecovers (issue #1836)", function()
local testfile = 'testfile_recover_spec'
+ -- Put swapdir at the start of the 'directory' list. #1836
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
-- attempt to create a swapfile in different directory.
local init = [[
- set directory^=]]..swapdir..[[//
+ set directory^=]]..swapdir:gsub([[\]], [[\\]])..[[//
set swapfile fileformat=unix undolevels=-1
]]
source(init)
- feed_command('set swapfile fileformat=unix undolevels=-1')
- -- Put swapdir at the start of the 'directory' list. #1836
- feed_command('set directory^='..swapdir..'//')
- feed_command('edit '..testfile)
+ command('edit! '..testfile)
feed('isometext<esc>')
- feed_command('preserve')
- source('redir => g:swapname | swapname | redir END')
+ command('preserve')
+ source('redir => g:swapname | silent swapname | redir END')
local swappath1 = eval('g:swapname')
@@ -59,19 +57,20 @@ describe(':preserve', function()
source(init)
-- Use the "SwapExists" event to choose the (R)ecover choice at the dialog.
- feed_command('autocmd SwapExists * let v:swapchoice = "r"')
- feed_command('silent edit '..testfile)
- source('redir => g:swapname | swapname | redir END')
+ command('autocmd SwapExists * let v:swapchoice = "r"')
+ command('silent edit! '..testfile)
+ source('redir => g:swapname | silent swapname | redir END')
local swappath2 = eval('g:swapname')
+ expect('sometext')
-- swapfile from session 1 should end in .swp
- assert(testfile..'.swp' == string.match(swappath1, '[^%%]+$'))
-
+ eq(testfile..'.swp', string.match(swappath1, '[^%%]+$'))
-- swapfile from session 2 should end in .swo
- assert(testfile..'.swo' == string.match(swappath2, '[^%%]+$'))
-
- expect('sometext')
+ eq(testfile..'.swo', string.match(swappath2, '[^%%]+$'))
+ -- Verify that :swapname was not truncated (:help 'shortmess').
+ ok(nil == string.find(swappath1, '%.%.%.'))
+ ok(nil == string.find(swappath2, '%.%.%.'))
end)
end)
diff --git a/test/functional/fixtures/api_level_2.mpack b/test/functional/fixtures/api_level_2.mpack
new file mode 100644
index 0000000000..0ca2ba8866
--- /dev/null
+++ b/test/functional/fixtures/api_level_2.mpack
Binary files differ
diff --git a/test/functional/fixtures/printargs-test.c b/test/functional/fixtures/printargs-test.c
index 2c25cf8447..be54605817 100644
--- a/test/functional/fixtures/printargs-test.c
+++ b/test/functional/fixtures/printargs-test.c
@@ -1,3 +1,6 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check
+// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+
#include <stdio.h>
int main(int argc, char **argv)
diff --git a/test/functional/fixtures/shell-test.c b/test/functional/fixtures/shell-test.c
index 3f3976ece5..8dbec2aaee 100644
--- a/test/functional/fixtures/shell-test.c
+++ b/test/functional/fixtures/shell-test.c
@@ -1,3 +1,6 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check
+// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+
#include <stdio.h>
#include <string.h>
#include <stdint.h>
diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c
index 778e7f3cd3..3406b3a202 100644
--- a/test/functional/fixtures/tty-test.c
+++ b/test/functional/fixtures/tty-test.c
@@ -1,3 +1,6 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check
+// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 13b06e7f1b..2919165280 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -32,20 +32,15 @@ local nvim_set = 'set shortmess+=I background=light noswapfile noautoindent'
..' belloff= noshowcmd noruler nomore'
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
'--cmd', nvim_set, '--embed'}
-
-local mpack = require('mpack')
-
-local tmpname = global_helpers.tmpname
-local uname = global_helpers.uname
-
--- Formulate a path to the directory containing nvim. We use this to
--- help run test executables. It helps to keep the tests working, even
--- when the build is not in the default location.
+-- Directory containing nvim.
local nvim_dir = nvim_prog:gsub("[/\\][^/\\]+$", "")
if nvim_dir == nvim_prog then
nvim_dir = "."
end
+local mpack = require('mpack')
+local tmpname = global_helpers.tmpname
+local uname = global_helpers.uname
local prepend_argv
if os.getenv('VALGRIND') then
@@ -353,7 +348,7 @@ end
local function set_shell_powershell()
source([[
set shell=powershell shellquote=\" shellpipe=\| shellredir=>
- set shellcmdflag=\ -ExecutionPolicy\ RemoteSigned\ -Command
+ set shellcmdflag=\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command
let &shellxquote=' '
]])
end
@@ -390,14 +385,21 @@ local function curbuf(method, ...)
end
local function wait()
- -- Execute 'vim_eval' (a deferred function) to block
+ -- Execute 'nvim_eval' (a deferred function) to block
-- until all pending input is processed.
- session:request('vim_eval', '1')
+ session:request('nvim_eval', '1')
end
-- sleeps the test runner (_not_ the nvim instance)
local function sleep(ms)
- run(nil, nil, nil, ms)
+ local function notification_cb(method, _)
+ if method == "redraw" then
+ error("Screen is attached; use screen:sleep() instead.")
+ end
+ return true
+ end
+
+ run(nil, notification_cb, nil, ms)
end
local function curbuf_contents()
@@ -430,21 +432,27 @@ end
local function do_rmdir(path)
if lfs.attributes(path, 'mode') ~= 'directory' then
- return nil
+ return -- Don't complain.
end
for file in lfs.dir(path) do
if file ~= '.' and file ~= '..' then
local abspath = path..'/'..file
if lfs.attributes(abspath, 'mode') == 'directory' then
- local ret = do_rmdir(abspath) -- recurse
- if not ret then
- return nil
- end
+ do_rmdir(abspath) -- recurse
else
local ret, err = os.remove(abspath)
if not ret then
- error('os.remove: '..err)
- return nil
+ if not session then
+ error('os.remove: '..err)
+ else
+ -- Try Nvim delete(): it handles `readonly` attribute on Windows,
+ -- and avoids Lua cross-version/platform incompatibilities.
+ if -1 == nvim_call('delete', abspath) then
+ local hint = (os_name() == 'windows'
+ and ' (hint: try :%bwipeout! before rmdir())' or '')
+ error('delete() failed'..hint..': '..abspath)
+ end
+ end
end
end
end
@@ -453,7 +461,6 @@ local function do_rmdir(path)
if not ret then
error('lfs.rmdir('..path..'): '..err)
end
- return ret
end
local function rmdir(path)
diff --git a/test/functional/insert/ctrl_r_spec.lua b/test/functional/insert/ctrl_r_spec.lua
new file mode 100644
index 0000000000..adc3c4b406
--- /dev/null
+++ b/test/functional/insert/ctrl_r_spec.lua
@@ -0,0 +1,19 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear, feed = helpers.clear, helpers.feed
+local expect, command = helpers.expect, helpers.command
+
+describe('insert-mode Ctrl-R', function()
+ before_each(clear)
+
+ it('works', function()
+ command("let @@ = 'test'")
+ feed('i<C-r>"')
+ expect('test')
+ end)
+
+ it('works with multi-byte text', function()
+ command("let @@ = 'påskägg'")
+ feed('i<C-r>"')
+ expect('påskägg')
+ end)
+end)
diff --git a/test/functional/normal/fold_spec.lua b/test/functional/normal/fold_spec.lua
index 85e4631b61..00e83bedc8 100644
--- a/test/functional/normal/fold_spec.lua
+++ b/test/functional/normal/fold_spec.lua
@@ -232,6 +232,25 @@ a
a]], '2,3m0')
eq({1, 2, 0, 0, 0}, get_folds())
end)
+ it('handles shifting all remaining folds', function()
+ test_move_indent([[
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+ a
+a]], '13m7')
+ eq({1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0}, get_folds())
+ end)
end)
it('updates correctly on :read', function()
-- luacheck: ignore 621
diff --git a/test/functional/normal/lang_spec.lua b/test/functional/normal/lang_spec.lua
index 464b85d684..24d1262f5f 100644
--- a/test/functional/normal/lang_spec.lua
+++ b/test/functional/normal/lang_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, insert, eq = helpers.clear, helpers.insert, helpers.eq
-local execute, expect = helpers.execute, helpers.expect
+local command, expect = helpers.command, helpers.expect
local feed, eval = helpers.feed, helpers.eval
local exc_exec = helpers.exc_exec
@@ -17,13 +17,7 @@ describe('gu and gU', function()
end)
describe('works in Turkish locale', function()
- if helpers.pending_win32(pending) then return end
-
clear()
- if eval('has("mac")') ~= 0 then
- pending("not yet on macOS", function() end)
- return
- end
local err = exc_exec('lang ctype tr_TR.UTF-8')
if err ~= 0 then
@@ -32,7 +26,7 @@ describe('gu and gU', function()
end
before_each(function()
- execute('lang ctype tr_TR.UTF-8')
+ command('lang ctype tr_TR.UTF-8')
end)
it('with default casemap', function()
@@ -46,14 +40,24 @@ describe('gu and gU', function()
end)
it('with casemap=""', function()
- execute('set casemap=')
- -- expect Turkish locale behavior
- insert("iI")
- feed("VgU")
- expect("İI")
- feed("Vgu")
- expect("iı")
+ command('set casemap=')
+ -- expect either Turkish locale behavior or ASCII behavior
+ local iupper = eval("toupper('i')")
+ if iupper == "İ" then
+ insert("iI")
+ feed("VgU")
+ expect("İI")
+ feed("Vgu")
+ expect("iı")
+ elseif iupper == "I" then
+ insert("iI")
+ feed("VgU")
+ expect("II")
+ feed("Vgu")
+ expect("ii")
+ else
+ error("expected toupper('i') to be either 'I' or 'İ'")
+ end
end)
-
end)
end)
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index f43d8eeafa..dc73679bb4 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -23,13 +23,13 @@ describe('startup defaults', function()
if helpers.pending_win32(pending) then return end
local function expect_filetype(expected)
- local screen = Screen.new(48, 4)
+ local screen = Screen.new(50, 4)
screen:attach()
command('filetype')
screen:expect([[
- ^ |
- ~ |
- ~ |
+ ^ |
+ ~ |
+ ~ |
]]..expected
)
end
@@ -37,31 +37,49 @@ describe('startup defaults', function()
it('enabled by `-u NORC`', function()
init_session('-u', 'NORC')
expect_filetype(
- 'filetype detection:ON plugin:ON indent:ON |')
+ 'filetype detection:ON plugin:ON indent:ON |')
end)
it('disabled by `-u NONE`', function()
init_session('-u', 'NONE')
expect_filetype(
- 'filetype detection:OFF plugin:OFF indent:OFF |')
+ 'filetype detection:OFF plugin:OFF indent:OFF |')
end)
it('overridden by early `filetype on`', function()
init_session('-u', 'NORC', '--cmd', 'filetype on')
expect_filetype(
- 'filetype detection:ON plugin:OFF indent:OFF |')
+ 'filetype detection:ON plugin:OFF indent:OFF |')
end)
it('overridden by early `filetype plugin on`', function()
init_session('-u', 'NORC', '--cmd', 'filetype plugin on')
expect_filetype(
- 'filetype detection:ON plugin:ON indent:OFF |')
+ 'filetype detection:ON plugin:ON indent:OFF |')
end)
it('overridden by early `filetype indent on`', function()
init_session('-u', 'NORC', '--cmd', 'filetype indent on')
expect_filetype(
- 'filetype detection:ON plugin:OFF indent:ON |')
+ 'filetype detection:ON plugin:OFF indent:ON |')
+ end)
+
+ it('adjusted by late `filetype off`', function()
+ init_session('-u', 'NORC', '-c', 'filetype off')
+ expect_filetype(
+ 'filetype detection:OFF plugin:(on) indent:(on) |')
+ end)
+
+ it('adjusted by late `filetype plugin off`', function()
+ init_session('-u', 'NORC', '-c', 'filetype plugin off')
+ expect_filetype(
+ 'filetype detection:ON plugin:OFF indent:ON |')
+ end)
+
+ it('adjusted by late `filetype indent off`', function()
+ init_session('-u', 'NORC', '-c', 'filetype indent off')
+ expect_filetype(
+ 'filetype detection:ON plugin:ON indent:OFF |')
end)
end)
@@ -80,6 +98,11 @@ describe('startup defaults', function()
init_session('-u', 'NORC', '--cmd', 'syntax off')
eq(0, eval('exists("g:syntax_on")'))
end)
+
+ it('adjusted by late `syntax off`', function()
+ init_session('-u', 'NORC', '-c', 'syntax off')
+ eq(0, eval('exists("g:syntax_on")'))
+ end)
end)
describe('packpath', function()
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index a4e9a49c8a..89a546675f 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local eval, command, feed = helpers.eval, helpers.command, helpers.feed
local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert
local expect, write_file = helpers.expect, helpers.write_file
+local feed_command = helpers.feed_command
do
clear()
@@ -30,6 +31,15 @@ describe('python3 commands and functions', function()
eq({100, 0}, eval('g:set_by_python3'))
end)
+ it('does not truncate error message <1 MB', function()
+ -- XXX: Python limits the error name to 200 chars, so this test is
+ -- mostly bogus.
+ local very_long_symbol = string.rep('a', 1200)
+ feed_command(':silent! py3 print('..very_long_symbol..' b)')
+ -- Truncated error message would not contain this (last) line.
+ eq('SyntaxError: invalid syntax', eval('v:errmsg'))
+ end)
+
it('python3_execute with nested commands', function()
command([[python3 vim.command('python3 vim.command("python3 vim.command(\'let set_by_nested_python3 = 555\')")')]])
eq(555, eval('g:set_by_nested_python3'))
diff --git a/test/functional/spell/spellfile_spec.lua b/test/functional/spell/spellfile_spec.lua
index e7cd10d2ac..afd2c1bce4 100644
--- a/test/functional/spell/spellfile_spec.lua
+++ b/test/functional/spell/spellfile_spec.lua
@@ -5,6 +5,7 @@ local eq = helpers.eq
local clear = helpers.clear
local meths = helpers.meths
local exc_exec = helpers.exc_exec
+local rmdir = helpers.rmdir
local write_file = helpers.write_file
local testdir = 'Xtest-functional-spell-spellfile.d'
@@ -12,11 +13,12 @@ local testdir = 'Xtest-functional-spell-spellfile.d'
describe('spellfile', function()
before_each(function()
clear()
+ rmdir(testdir)
lfs.mkdir(testdir)
lfs.mkdir(testdir .. '/spell')
end)
after_each(function()
- lfs.rmdir(testdir)
+ rmdir(testdir)
end)
-- ┌ Magic string (#VIMSPELLMAGIC)
-- │ ┌ Spell file version (#VIMSPELLVERSION)
diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua
index 42a5c768bb..d2b2d8a60c 100644
--- a/test/functional/terminal/edit_spec.lua
+++ b/test/functional/terminal/edit_spec.lua
@@ -45,11 +45,8 @@ describe(':edit term://*', function()
local bufcontents = {}
local winheight = curwinmeths.get_height()
local buf_cont_start = rep_size - sb - winheight + 2
- local function bufline (i)
- return ('%d: foobar'):format(i)
- end
for i = buf_cont_start,(rep_size - 1) do
- bufcontents[#bufcontents + 1] = bufline(i)
+ bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i)
end
bufcontents[#bufcontents + 1] = ''
bufcontents[#bufcontents + 1] = '[Process exited 0]'
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 154374cda9..be0fd9f8ff 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -26,7 +26,7 @@ describe(':terminal', function()
feed_command([[terminal while true; do echo X; done]])
helpers.feed([[<C-\><C-N>]])
wait()
- helpers.sleep(10) -- Let some terminal activity happen.
+ screen:sleep(10) -- Let some terminal activity happen.
feed_command("messages")
screen:expect([[
msg1 |
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 32f25d4086..05f81295c2 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -451,6 +451,13 @@ describe("'scrollback' option", function()
it(':setlocal in a normal buffer is an error', function()
command('new')
+
+ -- :setlocal to -1 is NOT an error.
+ feed_command('setlocal scrollback=-1')
+ eq(nil, string.match(eval("v:errmsg"), "E%d*:"))
+ feed('<CR>')
+
+ -- :setlocal to anything except -1 is an error.
feed_command('setlocal scrollback=42')
feed('<CR>')
eq('E474:', string.match(eval("v:errmsg"), "E%d*:"))
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index b14bceecdd..3ed63f68e9 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -356,9 +356,17 @@ describe("tui 't_Co' (terminal colors)", function()
assert_term_colors("yet-another-term", "screen-256color", 256)
end)
- it("TERM=linux uses 8 colors", function()
+ it("TERM=linux uses 256 colors", function()
if is_linux then
- assert_term_colors("linux", nil, 8)
+ assert_term_colors("linux", nil, 256)
+ else
+ pending()
+ end
+ end)
+
+ it("TERM=linux-16color uses 256 colors", function()
+ if is_linux then
+ assert_term_colors("linux-16color", nil, 256)
else
pending()
end
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 02e9422781..e6036a6b79 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -18,138 +18,155 @@ describe('ui/cursor', function()
end)
it("'guicursor' is published as a UI event", function()
- local expected_cursor_style = {
- cmdline_hover = {
- mouse_shape = 0,
- short_name = 'e' },
- cmdline_insert = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 25,
- cursor_shape = 'vertical',
- hl_id = 46,
- id_lm = 47,
- mouse_shape = 0,
- short_name = 'ci' },
- cmdline_normal = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ local expected_mode_info = {
+ [1] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
- hl_id = 46,
- id_lm = 47,
+ name = 'normal',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'c' },
- cmdline_replace = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 20,
- cursor_shape = 'horizontal',
- hl_id = 46,
- id_lm = 47,
+ short_name = 'n' },
+ [2] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 0,
+ cursor_shape = 'block',
+ name = 'visual',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'cr' },
- insert = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ short_name = 'v' },
+ [3] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 25,
cursor_shape = 'vertical',
- hl_id = 46,
- id_lm = 47,
+ name = 'insert',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'i' },
- more = {
- mouse_shape = 0,
- short_name = 'm' },
- more_lastline = {
+ [4] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 20,
+ cursor_shape = 'horizontal',
+ name = 'replace',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'ml' },
- normal = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ short_name = 'r' },
+ [5] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
- hl_id = 46,
- id_lm = 47,
+ name = 'cmdline_normal',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'n' },
- operator = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 50,
+ short_name = 'c' },
+ [6] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 25,
+ cursor_shape = 'vertical',
+ name = 'cmdline_insert',
+ hl_id = 0,
+ id_lm = 0,
+ mouse_shape = 0,
+ short_name = 'ci' },
+ [7] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 20,
cursor_shape = 'horizontal',
- hl_id = 46,
- id_lm = 46,
+ name = 'cmdline_replace',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'o' },
- replace = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ short_name = 'cr' },
+ [8] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 20,
cursor_shape = 'horizontal',
- hl_id = 46,
- id_lm = 47,
+ name = 'operator',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'r' },
- showmatch = {
- blinkoff = 150,
- blinkon = 175,
- blinkwait = 175,
- cell_percentage = 0,
- cursor_shape = 'block',
- hl_id = 46,
- id_lm = 46,
- short_name = 'sm' },
- statusline_drag = {
+ short_name = 'o' },
+ [9] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 25,
+ cursor_shape = 'vertical',
+ name = 'visual_select',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'sd' },
- statusline_hover = {
+ short_name = 've' },
+ [10] = {
+ name = 'cmdline_hover',
+ mouse_shape = 0,
+ short_name = 'e' },
+ [11] = {
+ name = 'statusline_hover',
mouse_shape = 0,
short_name = 's' },
- visual = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 0,
- cursor_shape = 'block',
- hl_id = 46,
- id_lm = 47,
+ [12] = {
+ name = 'statusline_drag',
mouse_shape = 0,
- short_name = 'v' },
- visual_select = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 35,
- cursor_shape = 'vertical',
- hl_id = 46,
- id_lm = 46,
+ short_name = 'sd' },
+ [13] = {
+ name = 'vsep_hover',
mouse_shape = 0,
- short_name = 've' },
- vsep_drag = {
+ short_name = 'vs' },
+ [14] = {
+ name = 'vsep_drag',
mouse_shape = 0,
short_name = 'vd' },
- vsep_hover = {
+ [15] = {
+ name = 'more',
mouse_shape = 0,
- short_name = 'vs' }
- }
+ short_name = 'm' },
+ [16] = {
+ name = 'more_lastline',
+ mouse_shape = 0,
+ short_name = 'ml' },
+ [17] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 0,
+ cursor_shape = 'block',
+ name = 'showmatch',
+ hl_id = 0,
+ id_lm = 0,
+ short_name = 'sm' },
+ }
screen:expect(function()
- -- Default 'guicursor' published on startup.
- eq(expected_cursor_style, screen._cursor_style)
+ -- Default 'guicursor', published on startup.
+ eq(expected_mode_info, screen._mode_info)
eq(true, screen._cursor_style_enabled)
eq('normal', screen.mode)
end)
-- Event is published ONLY if the cursor style changed.
- screen._cursor_style = nil
+ screen._mode_info = nil
command("echo 'test'")
screen:expect([[
^ |
@@ -158,20 +175,57 @@ describe('ui/cursor', function()
~ |
test |
]], nil, nil, function()
- eq(nil, screen._cursor_style)
+ eq(nil, screen._mode_info)
end)
-- Change the cursor style.
- meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173,ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42')
+ helpers.command('set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20'
+ ..',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor'
+ ..',sm:block-blinkwait175-blinkoff150-blinkon175')
+
+ -- Update the expected values.
+ for _, m in ipairs(expected_mode_info) do
+ if m.name == 'showmatch' then
+ if m.blinkon then m.blinkon = 175 end
+ if m.blinkoff then m.blinkoff = 150 end
+ if m.blinkwait then m.blinkwait = 175 end
+ else
+ if m.blinkon then m.blinkon = 250 end
+ if m.blinkoff then m.blinkoff = 400 end
+ if m.blinkwait then m.blinkwait = 700 end
+ end
+ if m.hl_id then m.hl_id = 46 end
+ if m.id_lm then m.id_lm = 47 end
+ end
+
+ -- Assert the new expectation.
screen:expect(function()
- eq('vertical', screen._cursor_style.normal.cursor_shape)
- eq('horizontal', screen._cursor_style.visual_select.cursor_shape)
- eq('vertical', screen._cursor_style.operator.cursor_shape)
- eq('block', screen._cursor_style.insert.cursor_shape)
- eq('vertical', screen._cursor_style.showmatch.cursor_shape)
- eq(171, screen._cursor_style.normal.blinkwait)
- eq(172, screen._cursor_style.normal.blinkoff)
- eq(173, screen._cursor_style.normal.blinkon)
+ eq(expected_mode_info, screen._mode_info)
+ eq(true, screen._cursor_style_enabled)
+ eq('normal', screen.mode)
+ end)
+
+ -- Another cursor style.
+ meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
+ ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42')
+ screen:expect(function()
+ local named = {}
+ for _, m in ipairs(screen._mode_info) do
+ named[m.name] = m
+ end
+ eq('vertical', named.normal.cursor_shape)
+ eq(35, named.normal.cell_percentage)
+ eq('horizontal', named.visual_select.cursor_shape)
+ eq(35, named.visual_select.cell_percentage)
+ eq('vertical', named.operator.cursor_shape)
+ eq(50, named.operator.cell_percentage)
+ eq('block', named.insert.cursor_shape)
+ eq('vertical', named.showmatch.cursor_shape)
+ eq(90, named.cmdline_replace.cell_percentage)
+ eq(171, named.normal.blinkwait)
+ eq(172, named.normal.blinkoff)
+ eq(173, named.normal.blinkon)
+ eq(42, named.showmatch.cell_percentage)
end)
end)
@@ -180,11 +234,11 @@ describe('ui/cursor', function()
screen:expect(function()
-- Empty 'guicursor' sets enabled=false.
eq(false, screen._cursor_style_enabled)
- for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert',
- 'showmatch', 'normal', 'replace', 'visual',
- 'visual_select', }) do
- eq('block', screen._cursor_style[m].cursor_shape)
- eq(0, screen._cursor_style[m].blinkon)
+ for _, m in ipairs(screen._mode_info) do
+ if m['cursor_shape'] ~= nil then
+ eq('block', m.cursor_shape)
+ eq(0, m.blinkon)
+ end
end
end)
end)
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 5f8fafef07..2bda907c33 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -2,23 +2,23 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local os = require('os')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local command = helpers.command
+local eval = helpers.eval
local feed_command, request, eq = helpers.feed_command, helpers.request, helpers.eq
-if helpers.pending_win32(pending) then return end
-
-describe('color scheme compatibility', function()
+describe('colorscheme compatibility', function()
before_each(function()
clear()
end)
it('t_Co is set to 256 by default', function()
- eq('256', request('vim_eval', '&t_Co'))
+ eq('256', eval('&t_Co'))
request('nvim_set_option', 't_Co', '88')
- eq('88', request('vim_eval', '&t_Co'))
+ eq('88', eval('&t_Co'))
end)
end)
-describe('manual syntax highlight', function()
+describe('highlight: `:syntax manual`', function()
-- When using manual syntax highlighting, it should be preserved even when
-- switching buffers... bug did only occur without :set hidden
-- Ref: vim patch 7.4.1236
@@ -63,32 +63,32 @@ describe('manual syntax highlight', function()
end)
it("works with buffer switch and 'nohidden'", function()
- feed_command('e tmp1.vim')
- feed_command('e Xtest-functional-ui-highlight.tmp.vim')
- feed_command('filetype on')
- feed_command('syntax manual')
- feed_command('set ft=vim')
- feed_command('set syntax=ON')
+ command('e tmp1.vim')
+ command('e Xtest-functional-ui-highlight.tmp.vim')
+ command('filetype on')
+ command('syntax manual')
+ command('set filetype=vim fileformat=unix')
+ command('set syntax=ON')
feed('iecho 1<esc>0')
- feed_command('set nohidden')
- feed_command('w')
- feed_command('bn')
- feed_command('bp')
+ command('set nohidden')
+ command('w')
+ command('silent bn')
+ eq("tmp1.vim", eval("fnamemodify(bufname('%'), ':t')"))
+ feed_command('silent bp')
+ eq("Xtest-functional-ui-highlight.tmp.vim", eval("fnamemodify(bufname('%'), ':t')"))
screen:expect([[
{1:^echo} 1 |
{0:~ }|
{0:~ }|
{0:~ }|
- <ht.tmp.vim" 1L, 7C |
+ :silent bp |
]])
end)
end)
-describe('Default highlight groups', function()
- -- Test the default attributes for highlight groups shown by the :highlight
- -- command
+describe('highlight defaults', function()
local screen
before_each(function()
@@ -281,6 +281,11 @@ describe('Default highlight groups', function()
]], {[0] = {bold=true, foreground=Screen.colors.Blue}})
end)
+ it('Cursor after `:hi clear|syntax reset` #6508', function()
+ command('highlight clear|syntax reset')
+ eq('guifg=bg guibg=fg', eval([[matchstr(execute('hi Cursor'), '\v(gui|cterm).*$')]]))
+ end)
+
it('Whitespace highlight', function()
screen:try_resize(53, 4)
feed_command('highlight NonText gui=NONE guifg=#FF0000')
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index b7a33cb64d..8bdc4601c0 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
+local command = helpers.command
local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
local eval = helpers.eval
@@ -21,9 +22,9 @@ local default_text = [[
local function common_setup(screen, inccommand, text)
if screen then
- feed_command("syntax on")
- feed_command("set nohlsearch")
- feed_command("hi Substitute guifg=red guibg=yellow")
+ command("syntax on")
+ command("set nohlsearch")
+ command("hi Substitute guifg=red guibg=yellow")
screen:attach()
screen:set_default_attr_ids({
[1] = {foreground = Screen.colors.Fuchsia},
@@ -46,7 +47,7 @@ local function common_setup(screen, inccommand, text)
})
end
- feed_command("set inccommand=" .. (inccommand and inccommand or ""))
+ command("set inccommand=" .. (inccommand and inccommand or ""))
if text then
insert(text)
@@ -456,7 +457,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
insert("X")
feed("IY<esc>")
feed(":%s/tw/MO/<esc>")
- -- execute("undo") here would cause "Press ENTER".
+ -- feed_command("undo") here would cause "Press ENTER".
feed("u")
expect(default_text:gsub("Inc", "XInc"))
feed("u")
@@ -514,7 +515,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed("Ay<esc>")
feed("Az<esc>")
feed(":%s/tw/AR<esc>")
- -- using execute("undo") here will result in a "Press ENTER" prompt
+ -- feed_command("undo") here would cause "Press ENTER".
feed("u")
expect(default_text:gsub("lines", "linesxy"))
feed("u")
@@ -603,7 +604,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed_command("set undolevels=-1")
feed(":%s/tw/MO/g<enter>")
- -- using execute("undo") here will result in a "Press ENTER" prompt
+ -- feed_command("undo") here will result in a "Press ENTER" prompt
feed("u")
if case == "split" then
screen:expect([[
@@ -804,7 +805,7 @@ describe(":substitute, inccommand=split", function()
it('does not show split window for :s/', function()
feed("2gg")
feed(":s/tw")
- wait()
+ screen:sleep(1)
screen:expect([[
Inc substitution on |
two lines |
@@ -1291,14 +1292,14 @@ describe("'inccommand' and :cnoremap", function()
it('work with remapped characters', function()
for _, case in pairs(cases) do
refresh(case)
- local command = "%s/lines/LINES/g"
+ local cmd = "%s/lines/LINES/g"
- for i = 1, string.len(command) do
- local c = string.sub(command, i, i)
+ for i = 1, string.len(cmd) do
+ local c = string.sub(cmd, i, i)
feed_command("cnoremap ".. c .. " " .. c)
end
- feed_command(command)
+ feed_command(cmd)
expect([[
Inc substitution on
two LINES
diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua
new file mode 100644
index 0000000000..f0cedfeeb5
--- /dev/null
+++ b/test/functional/ui/mode_spec.lua
@@ -0,0 +1,227 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local command, eval = helpers.command, helpers.eval
+local eq = helpers.eq
+
+describe('ui mode_change event', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(25, 4)
+ screen:attach({rgb= true})
+ screen:set_default_attr_ids( {
+ [0] = {bold=true, foreground=255},
+ [1] = {bold=true, reverse=true},
+ [2] = {bold=true},
+ [3] = {reverse=true},
+ })
+ end)
+
+ it('works in normal mode', function()
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+
+ feed('d')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("operator", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+
+ it('works in insert mode', function()
+ feed('i')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]],nil,nil,function ()
+ eq("insert", screen.mode)
+ end)
+
+ feed('word<esc>')
+ screen:expect([[
+ wor^d |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]], nil, nil, function ()
+ eq("normal", screen.mode)
+ end)
+
+ command("set showmatch")
+ eq(eval('&matchtime'), 5) -- tenths of seconds
+ feed('a(stuff')
+ screen:expect([[
+ word(stuff^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]], nil, nil, function ()
+ eq("insert", screen.mode)
+ end)
+
+ feed(')')
+ screen:expect([[
+ word^(stuff) |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]], nil, nil, function ()
+ eq("showmatch", screen.mode)
+ end)
+
+ screen:sleep(400)
+ screen:expect([[
+ word(stuff)^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]], nil, nil, function ()
+ eq("insert", screen.mode)
+ end)
+ end)
+
+ it('works in replace mode', function()
+ feed('R')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- REPLACE --} |
+ ]], nil, nil, function ()
+ eq("replace", screen.mode)
+ end)
+
+ feed('word<esc>')
+ screen:expect([[
+ wor^d |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]], nil, nil, function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+
+ it('works in cmdline mode', function()
+ feed(':')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :^ |
+ ]],nil,nil,function ()
+ eq("cmdline_normal", screen.mode)
+ end)
+
+ feed('x<left>')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :^x |
+ ]],nil,nil,function ()
+ eq("cmdline_insert", screen.mode)
+ end)
+
+ feed('<insert>')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :^x |
+ ]],nil,nil,function ()
+ eq("cmdline_replace", screen.mode)
+ end)
+
+
+ feed('<right>')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :x^ |
+ ]],nil,nil,function ()
+ eq("cmdline_normal", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+
+ it('works in visal mode', function()
+ insert("text")
+ feed('v')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]],nil,nil,function ()
+ eq("visual", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+
+ command('set selection=exclusive')
+ feed('v')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]],nil,nil,function ()
+ eq("visual_select", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+end)
+
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 2f2cc85dab..7d9cd6c026 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -284,18 +284,13 @@ function Screen:wait(check, timeout)
if failure_after_success then
print([[
-Warning: Screen changes have been received after the expected state was seen.
-This is probably due to an indeterminism in the test. Try adding
-`wait()` (or even a separate `screen:expect(...)`) at a point of possible
-indeterminism, typically in between a `feed()` or `execute()` which is non-
-synchronous, and a synchronous api call.
-
-Note that sometimes a `wait` can trigger redraws and consequently generate more
-indeterminism. If adding `wait` calls seems to increase the frequency of these
-messages, try removing every `wait` call in the test.
-
-If everything else fails, use Screen:redraw_debug to help investigate what is
- causing the problem.
+
+Warning: Screen changes were received after the expected state. This indicates
+indeterminism in the test. Try adding wait() (or screen:expect(...)) between
+asynchronous (feed(), nvim_input()) and synchronous API calls.
+ - Use Screen:redraw_debug() to investigate the problem.
+ - wait() can trigger redraws and consequently generate more indeterminism.
+ In that case try removing every wait().
]])
local tb = debug.traceback()
local index = string.find(tb, '\n%s*%[C]')
@@ -317,12 +312,13 @@ function Screen:_redraw(updates)
-- print(require('inspect')(update))
local method = update[1]
for i = 2, #update do
- local handler = self['_handle_'..method]
+ local handler_name = '_handle_'..method
+ local handler = self[handler_name]
if handler ~= nil then
handler(self, unpack(update[i]))
else
assert(self._on_event,
- "Add Screen:_handle_XXX method or call Screen:set_on_event_handler")
+ "Add Screen:"..handler_name.." or call Screen:set_on_event_handler")
self._on_event(method, update[i])
end
end
@@ -353,9 +349,9 @@ function Screen:_handle_resize(width, height)
}
end
-function Screen:_handle_cursor_style_set(enabled, style)
- self._cursor_style_enabled = enabled
- self._cursor_style = style
+function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info)
+ self._cursor_style_enabled = cursor_style_enabled
+ self._mode_info = mode_info
end
function Screen:_handle_clear()
@@ -389,9 +385,8 @@ function Screen:_handle_mouse_off()
self._mouse_enabled = false
end
-function Screen:_handle_mode_change(mode)
- assert(mode == 'insert' or mode == 'replace'
- or mode == 'normal' or mode == 'cmdline')
+function Screen:_handle_mode_change(mode, idx)
+ assert(mode == self._mode_info[idx+1].name)
self.mode = mode
end
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 8182190b5f..5d89416e4a 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -6,7 +6,7 @@ local insert = helpers.insert
local eq = helpers.eq
local eval = helpers.eval
-describe('Initial screen', function()
+describe('screen', function()
local screen
local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
'--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
@@ -27,7 +27,7 @@ describe('Initial screen', function()
screen:detach()
end)
- it('is the default initial screen', function()
+ it('default initial screen', function()
screen:expect([[
^ |
{0:~ }|
@@ -565,125 +565,22 @@ describe('Screen', function()
]])
end)
end)
+end)
- describe('mode change', function()
- before_each(function()
- screen:try_resize(25, 5)
- end)
-
- it('works in normal mode', function()
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]],nil,nil,function ()
- eq("normal", screen.mode)
- end)
- end)
-
- it('works in insert mode', function()
- feed('i')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {2:-- INSERT --} |
- ]],nil,nil,function ()
- eq("insert", screen.mode)
- end)
-
- feed('word<esc>')
- screen:expect([[
- wor^d |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]], nil, nil, function ()
- eq("normal", screen.mode)
- end)
- end)
-
- it('works in replace mode', function()
- feed('R')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {2:-- REPLACE --} |
- ]], nil, nil, function ()
- eq("replace", screen.mode)
- end)
-
- feed('word<esc>')
- screen:expect([[
- wor^d |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]], nil, nil, function ()
- eq("normal", screen.mode)
- end)
- end)
-
- it('works in cmdline mode', function()
- feed(':')
- screen:expect([[
- |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- :^ |
- ]],nil,nil,function ()
- eq("cmdline", screen.mode)
- end)
-
- feed('<esc>/')
- screen:expect([[
- |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- /^ |
- ]],nil,nil,function ()
- eq("cmdline", screen.mode)
- end)
-
-
- feed('<esc>?')
- screen:expect([[
- |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- ?^ |
- ]],nil,nil,function ()
- eq("cmdline", screen.mode)
- end)
-
- feed('<esc>')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]],nil,nil,function ()
- eq("normal", screen.mode)
- end)
- end)
+describe('nvim_ui_attach()', function()
+ before_each(function()
+ clear()
end)
-
- it('nvim_ui_attach() handles very large width/height #2180', function()
- screen:detach()
- screen = Screen.new(999, 999)
+ it('handles very large width/height #2180', function()
+ local screen = Screen.new(999, 999)
screen:attach()
eq(999, eval('&lines'))
eq(999, eval('&columns'))
end)
+ it('invalid option returns error', function()
+ local screen = Screen.new()
+ local status, rv = pcall(function() screen:attach({foo={'foo'}}) end)
+ eq(false, status)
+ eq('No such ui option', rv:match("No such .*"))
+ end)
end)
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
new file mode 100644
index 0000000000..56331a33b5
--- /dev/null
+++ b/test/functional/ui/tabline_spec.lua
@@ -0,0 +1,57 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local clear, command, eq = helpers.clear, helpers.command, helpers.eq
+
+describe('ui/tabline', function()
+ local screen
+ local event_tabs, event_curtab
+
+ before_each(function()
+ clear()
+ screen = Screen.new(25, 5)
+ screen:attach({rgb=true, ext_tabline=true})
+ screen:set_on_event_handler(function(name, data)
+ if name == "tabline_update" then
+ event_curtab, event_tabs = unpack(data)
+ end
+ end)
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ describe('externalized', function()
+ it('publishes UI events', function()
+ command("tabedit another-tab")
+
+ local expected_tabs = {
+ {tab = { id = 1 }, name = '[No Name]'},
+ {tab = { id = 2 }, name = 'another-tab'},
+ }
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq({ id = 2 }, event_curtab)
+ eq(expected_tabs, event_tabs)
+ end)
+
+ command("tabNext")
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq({ id = 1 }, event_curtab)
+ eq(expected_tabs, event_tabs)
+ end)
+
+ end)
+ end)
+end)
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index 6639bf272d..052cdd55a1 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -31,6 +31,27 @@ describe("'wildmode'", function()
:sign define^ |
]])
end)
+
+ it('does not crash after cycling back to original text', function()
+ command('set wildmode=full')
+ feed(':j<Tab><Tab><Tab>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ join jumps |
+ :j^ |
+ ]])
+ -- This would cause nvim to crash before #6650
+ feed('<BS><Tab>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ! # & < = > @ > |
+ :!^ |
+ ]])
+ end)
end)
end)
diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua
index b35e8d4f94..0e5278345c 100644
--- a/test/functional/viml/completion_spec.lua
+++ b/test/functional/viml/completion_spec.lua
@@ -868,13 +868,13 @@ describe('completion', function()
end)
end)
-describe('External completion popupmenu', function()
+describe('ui/externalized/popupmenu', function()
local screen
local items, selected, anchor
before_each(function()
clear()
screen = Screen.new(60, 8)
- screen:attach({rgb=true, popupmenu_external=true})
+ screen:attach({rgb=true, ext_popupmenu=true})
screen:set_default_attr_ids({
[1] = {bold=true, foreground=Screen.colors.Blue},
[2] = {bold = true},
diff --git a/test/helpers.lua b/test/helpers.lua
index d0b1ad552b..d60d5ba242 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -32,6 +32,9 @@ local function glob(initial_path, re, exc_re)
return false
end
+ if is_excluded(initial_path) then
+ return ret
+ end
while #paths_to_check > 0 do
local cur_path = paths_to_check[#paths_to_check]
paths_to_check[#paths_to_check] = nil
@@ -185,7 +188,11 @@ local function check_cores(app, force)
local gdb_db_cmd = 'gdb -n -batch -ex "thread apply all bt full" "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
local lldb_db_cmd = 'lldb -Q -o "bt all" -f "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
local random_skip = false
- local local_tmpdir = tmpdir_is_local(tmpdir_get()) and tmpdir_get() or nil
+ -- Workspace-local $TMPDIR, scrubbed and pattern-escaped.
+ -- "./Xtest-tmpdir/" => "Xtest%-tmpdir"
+ local local_tmpdir = (tmpdir_is_local(tmpdir_get())
+ and tmpdir_get():gsub('^[ ./]+',''):gsub('%/+$',''):gsub('([^%w])', '%%%1')
+ or nil)
local db_cmd
if hasenv('NVIM_TEST_CORE_GLOB_DIRECTORY') then
initial_path = os.getenv('NVIM_TEST_CORE_GLOB_DIRECTORY')
diff --git a/test/unit/eval/typval_spec.lua b/test/unit/eval/typval_spec.lua
index a1edfcfb7c..6308ae7367 100644
--- a/test/unit/eval/typval_spec.lua
+++ b/test/unit/eval/typval_spec.lua
@@ -2450,6 +2450,10 @@ describe('typval.c', function()
'E741: Value is locked: Unknown'))
eq(true, tv_check_lock(lib.VAR_FIXED, nil, 0,
'E742: Cannot change value of Unknown'))
+ eq(true, tv_check_lock(lib.VAR_LOCKED, nil, lib.kTVCstring,
+ 'E741: Value is locked: Unknown'))
+ eq(true, tv_check_lock(lib.VAR_FIXED, 'test', lib.kTVCstring,
+ 'E742: Cannot change value of test'))
end)
end)
describe('equal()', function()
diff --git a/test/unit/fixtures/multiqueue.c b/test/unit/fixtures/multiqueue.c
index da63e55919..a8dca0a844 100644
--- a/test/unit/fixtures/multiqueue.c
+++ b/test/unit/fixtures/multiqueue.c
@@ -1,3 +1,6 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check
+// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+
#include <string.h>
#include <stdlib.h>
#include "nvim/event/multiqueue.h"
diff --git a/test/unit/fixtures/rbuffer.c b/test/unit/fixtures/rbuffer.c
index d587d6b054..3f4062fa18 100644
--- a/test/unit/fixtures/rbuffer.c
+++ b/test/unit/fixtures/rbuffer.c
@@ -1,3 +1,6 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check
+// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+
#include "nvim/rbuffer.h"
#include "rbuffer.h"
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua
index 823b6d6a85..575787a25e 100644
--- a/test/unit/os/env_spec.lua
+++ b/test/unit/os/env_spec.lua
@@ -67,12 +67,37 @@ describe('env function', function()
end)
end)
+ describe('os_shell_is_cmdexe', function()
+ itp('returns true for expected names', function()
+ eq(true, cimp.os_shell_is_cmdexe(to_cstr('cmd.exe')))
+ eq(true, cimp.os_shell_is_cmdexe(to_cstr('cmd')))
+ eq(true, cimp.os_shell_is_cmdexe(to_cstr('CMD.EXE')))
+ eq(true, cimp.os_shell_is_cmdexe(to_cstr('CMD')))
+
+ os_setenv('COMSPEC', '/foo/bar/cmd.exe', 0)
+ eq(true, cimp.os_shell_is_cmdexe(to_cstr('$COMSPEC')))
+ os_setenv('COMSPEC', [[C:\system32\cmd.exe]], 0)
+ eq(true, cimp.os_shell_is_cmdexe(to_cstr('$COMSPEC')))
+ end)
+ itp('returns false for unexpected names', function()
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr('')))
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr('powershell')))
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr(' cmd.exe ')))
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr('cm')))
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr('md')))
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr('cmd.ex')))
+
+ os_setenv('COMSPEC', '/foo/bar/cmd', 0)
+ eq(false, cimp.os_shell_is_cmdexe(to_cstr('$COMSPEC')))
+ end)
+ end)
+
describe('os_getenv', function()
itp('reads an env variable', function()
local name = 'NVIM_UNIT_TEST_GETENV_1N'
local value = 'NVIM_UNIT_TEST_GETENV_1V'
eq(NULL, os_getenv(name))
- -- need to use os_setenv, because lua dosn't have a setenv function
+ -- Use os_setenv because Lua dosen't have setenv.
os_setenv(name, value, 1)
eq(value, os_getenv(name))
end)
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 860ebfdbcb..23eb05b4b8 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -35,7 +35,6 @@ for i = 0, 255 do
end
local fcontents = s:rep(16)
-local buffer = ""
local directory = nil
local absolute_executable = nil
local executable_name = nil
@@ -65,7 +64,11 @@ local function os_getperm(filename)
return tonumber(perm)
end
-describe('fs function', function()
+describe('fs.c', function()
+ local function os_isdir(name)
+ return fs.os_isdir(to_cstr(name))
+ end
+
before_each(function()
lfs.mkdir('unit-test-directory');
@@ -91,32 +94,37 @@ describe('fs function', function()
end)
describe('os_dirname', function()
- local length
-
- local function os_dirname(buf, len)
- return fs.os_dirname(buf, len)
- end
-
- before_each(function()
- length = (string.len(lfs.currentdir())) + 1
- buffer = cstr(length, '')
+ itp('returns OK and writes current directory to the buffer', function()
+ local length = string.len(lfs.currentdir()) + 1
+ local buf = cstr(length, '')
+ eq(OK, fs.os_dirname(buf, length))
+ eq(lfs.currentdir(), ffi.string(buf))
end)
- itp('returns OK and writes current directory into the buffer if it is large\n enough', function()
- eq(OK, (os_dirname(buffer, length)))
- eq(lfs.currentdir(), (ffi.string(buffer)))
- end)
-
- -- What kind of other failing cases are possible?
itp('returns FAIL if the buffer is too small', function()
- local buf = cstr((length - 1), '')
- eq(FAIL, (os_dirname(buf, (length - 1))))
+ local length = string.len(lfs.currentdir()) + 1
+ local buf = cstr(length - 1, '')
+ eq(FAIL, fs.os_dirname(buf, length - 1))
end)
end)
- local function os_isdir(name)
- return fs.os_isdir((to_cstr(name)))
- end
+ describe('os_chdir', function()
+ itp('fails with path="~"', function()
+ eq(false, os_isdir('~')) -- sanity check: no literal "~" directory.
+ local length = 4096
+ local expected_cwd = cstr(length, '')
+ local cwd = cstr(length, '')
+ eq(OK, fs.os_dirname(expected_cwd, length))
+
+ -- os_chdir returns 0 for success, not OK (1).
+ neq(0, fs.os_chdir('~')) -- fail
+ neq(0, fs.os_chdir('~/')) -- fail
+
+ eq(OK, fs.os_dirname(cwd, length))
+ -- CWD did not change.
+ eq(ffi.string(expected_cwd), ffi.string(cwd))
+ end)
+ end)
describe('os_isdir', function()
itp('returns false if an empty string is given', function()
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 470f971e68..6b9e2c8695 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -13,7 +13,7 @@ local OK = helpers.OK
local FAIL = helpers.FAIL
cimport('string.h')
-local path = cimport('./src/nvim/path.h')
+local cimp = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
local length = 0
local buffer = nil
@@ -30,7 +30,7 @@ describe('path function', function()
local function path_full_dir_name(directory, buf, len)
directory = to_cstr(directory)
- return path.path_full_dir_name(directory, buf, len)
+ return cimp.path_full_dir_name(directory, buf, len)
end
before_each(function()
@@ -69,7 +69,7 @@ describe('path function', function()
local function path_full_compare(s1, s2, cn)
s1 = to_cstr(s1)
s2 = to_cstr(s2)
- return path.path_full_compare(s1, s2, cn or 0)
+ return cimp.path_full_compare(s1, s2, cn or 0)
end
local f1 = 'f1.o'
@@ -86,31 +86,31 @@ describe('path function', function()
end)
itp('returns kEqualFiles when passed the same file', function()
- eq(path.kEqualFiles, (path_full_compare(f1, f1)))
+ eq(cimp.kEqualFiles, (path_full_compare(f1, f1)))
end)
itp('returns kEqualFileNames when files that dont exist and have same name', function()
- eq(path.kEqualFileNames, (path_full_compare('null.txt', 'null.txt', true)))
+ eq(cimp.kEqualFileNames, (path_full_compare('null.txt', 'null.txt', true)))
end)
itp('returns kBothFilesMissing when files that dont exist', function()
- eq(path.kBothFilesMissing, (path_full_compare('null.txt', 'null.txt')))
+ eq(cimp.kBothFilesMissing, (path_full_compare('null.txt', 'null.txt')))
end)
itp('returns kDifferentFiles when passed different files', function()
- eq(path.kDifferentFiles, (path_full_compare(f1, f2)))
- eq(path.kDifferentFiles, (path_full_compare(f2, f1)))
+ eq(cimp.kDifferentFiles, (path_full_compare(f1, f2)))
+ eq(cimp.kDifferentFiles, (path_full_compare(f2, f1)))
end)
itp('returns kOneFileMissing if only one does not exist', function()
- eq(path.kOneFileMissing, (path_full_compare(f1, 'null.txt')))
- eq(path.kOneFileMissing, (path_full_compare('null.txt', f1)))
+ eq(cimp.kOneFileMissing, (path_full_compare(f1, 'null.txt')))
+ eq(cimp.kOneFileMissing, (path_full_compare('null.txt', f1)))
end)
end)
describe('path_tail', function()
local function path_tail(file)
- local res = path.path_tail((to_cstr(file)))
+ local res = cimp.path_tail((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
end
@@ -126,7 +126,7 @@ describe('path function', function()
describe('path_tail_with_sep', function()
local function path_tail_with_sep(file)
- local res = path.path_tail_with_sep((to_cstr(file)))
+ local res = cimp.path_tail_with_sep((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
end
@@ -159,11 +159,11 @@ describe('path function', function()
-- strcmp.
local function invocation_path_tail(invk)
local plen = ffi.new('size_t[?]', 1)
- local ptail = path.invocation_path_tail((to_cstr(invk)), plen)
+ local ptail = cimp.invocation_path_tail((to_cstr(invk)), plen)
neq(NULL, ptail)
-- it does not change the output if len==NULL
- local tail2 = path.invocation_path_tail((to_cstr(invk)), NULL)
+ local tail2 = cimp.invocation_path_tail((to_cstr(invk)), NULL)
neq(NULL, tail2)
eq((ffi.string(ptail)), (ffi.string(tail2)))
return ptail, plen[0]
@@ -204,7 +204,7 @@ describe('path function', function()
end)
itp('is equivalent to path_tail when args do not contain a path separator', function()
- local ptail = path.path_tail(to_cstr("a/b/c x y z"))
+ local ptail = cimp.path_tail(to_cstr("a/b/c x y z"))
neq(NULL, ptail)
local tail = ffi.string(ptail)
local invk, _ = invocation_path_tail("a/b/c x y z")
@@ -212,7 +212,7 @@ describe('path function', function()
end)
itp('is not equivalent to path_tail when args contain a path separator', function()
- local ptail = path.path_tail(to_cstr("a/b/c x y/z"))
+ local ptail = cimp.path_tail(to_cstr("a/b/c x y/z"))
neq(NULL, ptail)
local invk, _ = invocation_path_tail("a/b/c x y/z")
neq((ffi.string(ptail)), (ffi.string(invk)))
@@ -221,7 +221,7 @@ describe('path function', function()
describe('path_next_component', function()
local function path_next_component(file)
- local res = path.path_next_component((to_cstr(file)))
+ local res = cimp.path_next_component((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
end
@@ -238,25 +238,25 @@ describe('path function', function()
describe('path_shorten_fname', function()
itp('returns NULL if `full_path` is NULL', function()
local dir = to_cstr('some/directory/file.txt')
- eq(NULL, (path.path_shorten_fname(NULL, dir)))
+ eq(NULL, (cimp.path_shorten_fname(NULL, dir)))
end)
itp('returns NULL if the path and dir does not match', function()
local dir = to_cstr('not/the/same')
local full = to_cstr('as/this.txt')
- eq(NULL, (path.path_shorten_fname(full, dir)))
+ eq(NULL, (cimp.path_shorten_fname(full, dir)))
end)
itp('returns NULL if the path is not separated properly', function()
local dir = to_cstr('some/very/long/')
local full = to_cstr('some/very/long/directory/file.txt')
- eq(NULL, (path.path_shorten_fname(full, dir)))
+ eq(NULL, (cimp.path_shorten_fname(full, dir)))
end)
itp('shortens the filename if `dir_name` is the start of `full_path`', function()
local full = to_cstr('some/very/long/directory/file.txt')
local dir = to_cstr('some/very/long')
- eq('directory/file.txt', (ffi.string(path.path_shorten_fname(full, dir))))
+ eq('directory/file.txt', (ffi.string(cimp.path_shorten_fname(full, dir))))
end)
end)
end)
@@ -277,23 +277,23 @@ describe('path_shorten_fname_if_possible', function()
itp('returns shortened path if possible', function()
lfs.chdir('ut_directory')
local full = to_cstr(lfs.currentdir() .. '/subdir/file.txt')
- eq('subdir/file.txt', (ffi.string(path.path_shorten_fname_if_possible(full))))
+ eq('subdir/file.txt', (ffi.string(cimp.path_shorten_fname_if_possible(full))))
end)
itp('returns `full_path` if a shorter version is not possible', function()
local old = lfs.currentdir()
lfs.chdir('ut_directory')
local full = old .. '/subdir/file.txt'
- eq(full, (ffi.string(path.path_shorten_fname_if_possible(to_cstr(full)))))
+ eq(full, (ffi.string(cimp.path_shorten_fname_if_possible(to_cstr(full)))))
end)
itp('returns NULL if `full_path` is NULL', function()
- eq(NULL, (path.path_shorten_fname_if_possible(NULL)))
+ eq(NULL, (cimp.path_shorten_fname_if_possible(NULL)))
end)
end)
end)
-describe('more path function', function()
+describe('path.c', function()
setup(function()
lfs.mkdir('unit-test-directory');
io.open('unit-test-directory/test.file', 'w').close()
@@ -315,7 +315,7 @@ describe('more path function', function()
describe('vim_FullName', function()
local function vim_FullName(filename, buf, len, force)
filename = to_cstr(filename)
- return path.vim_FullName(filename, buf, len, force)
+ return cimp.vim_FullName(filename, buf, len, force)
end
before_each(function()
@@ -326,7 +326,7 @@ describe('more path function', function()
itp('fails if given filename is NULL', function()
local force_expansion = 1
- local result = path.vim_FullName(NULL, buffer, length, force_expansion)
+ local result = cimp.vim_FullName(NULL, buffer, length, force_expansion)
eq(FAIL, result)
end)
@@ -335,7 +335,7 @@ describe('more path function', function()
local filename = 'foo/bar/bazzzzzzz/buz/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/a'
local too_short_len = 8
local buf = cstr(too_short_len, '')
- local result = path.vim_FullName(filename, buf, too_short_len, force_expansion)
+ local result = cimp.vim_FullName(filename, buf, too_short_len, force_expansion)
local expected = string.sub(filename, 1, (too_short_len - 1))
eq(expected, (ffi.string(buf)))
eq(FAIL, result)
@@ -357,7 +357,7 @@ describe('more path function', function()
eq(FAIL, result)
end)
- itp('concatenates given filename if it does not contain a slash', function()
+ itp('concatenates filename if it does not contain a slash', function()
local force_expansion = 1
local result = vim_FullName('test.file', buffer, length, force_expansion)
local expected = lfs.currentdir() .. '/test.file'
@@ -365,7 +365,7 @@ describe('more path function', function()
eq(OK, result)
end)
- itp('concatenates given filename if it is a directory but does not contain a\n slash', function()
+ itp('concatenates directory name if it does not contain a slash', function()
local force_expansion = 1
local result = vim_FullName('..', buffer, length, force_expansion)
local expected = lfs.currentdir() .. '/..'
@@ -395,6 +395,7 @@ describe('more path function', function()
end)
itp('fails and uses filename when the path is relative to HOME', function()
+ eq(false, cimp.os_isdir('~')) -- sanity check: no literal "~" directory.
local force_expansion = 1
local absolute_path = '~/home.file'
local result = vim_FullName(absolute_path, buffer, length, force_expansion)
@@ -414,7 +415,7 @@ describe('more path function', function()
local filename = to_cstr('unit-test-directory/test.file')
-- Don't use the wrapper here but pass a cstring directly to the c
-- function.
- local result = path.vim_FullName(filename, buffer, length, force_expansion)
+ local result = cimp.vim_FullName(filename, buffer, length, force_expansion)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
eq('unit-test-directory/test.file', (ffi.string(filename)))
eq(OK, result)
@@ -423,7 +424,7 @@ describe('more path function', function()
itp('works with directories that have one path component', function()
local force_expansion = 1
local filename = to_cstr('/tmp')
- local result = path.vim_FullName(filename, buffer, length, force_expansion)
+ local result = cimp.vim_FullName(filename, buffer, length, force_expansion)
eq('/tmp', ffi.string(buffer))
eq(OK, result)
end)
@@ -432,7 +433,7 @@ describe('more path function', function()
describe('path_fix_case', function()
local function fix_case(file)
local c_file = to_cstr(file)
- path.path_fix_case(c_file)
+ cimp.path_fix_case(c_file)
return ffi.string(c_file)
end
@@ -456,41 +457,41 @@ describe('more path function', function()
itp('joins given paths with a slash', function()
local path1 = cstr(100, 'path1')
local to_append = to_cstr('path2')
- eq(OK, (path.append_path(path1, to_append, 100)))
+ eq(OK, (cimp.append_path(path1, to_append, 100)))
eq("path1/path2", (ffi.string(path1)))
end)
itp('joins given paths without adding an unnecessary slash', function()
local path1 = cstr(100, 'path1/')
local to_append = to_cstr('path2')
- eq(OK, path.append_path(path1, to_append, 100))
+ eq(OK, cimp.append_path(path1, to_append, 100))
eq("path1/path2", (ffi.string(path1)))
end)
itp('fails and uses filename if there is not enough space left for to_append', function()
local path1 = cstr(11, 'path1/')
local to_append = to_cstr('path2')
- eq(FAIL, (path.append_path(path1, to_append, 11)))
+ eq(FAIL, (cimp.append_path(path1, to_append, 11)))
end)
itp('does not append a slash if to_append is empty', function()
local path1 = cstr(6, 'path1')
local to_append = to_cstr('')
- eq(OK, (path.append_path(path1, to_append, 6)))
+ eq(OK, (cimp.append_path(path1, to_append, 6)))
eq('path1', (ffi.string(path1)))
end)
itp('does not append unnecessary dots', function()
local path1 = cstr(6, 'path1')
local to_append = to_cstr('.')
- eq(OK, (path.append_path(path1, to_append, 6)))
+ eq(OK, (cimp.append_path(path1, to_append, 6)))
eq('path1', (ffi.string(path1)))
end)
itp('copies to_append to path, if path is empty', function()
local path1 = cstr(7, '')
local to_append = to_cstr('/path2')
- eq(OK, (path.append_path(path1, to_append, 7)))
+ eq(OK, (cimp.append_path(path1, to_append, 7)))
eq('/path2', (ffi.string(path1)))
end)
end)
@@ -498,7 +499,7 @@ describe('more path function', function()
describe('path_is_absolute_path', function()
local function path_is_absolute_path(filename)
filename = to_cstr(filename)
- return path.path_is_absolute_path(filename)
+ return cimp.path_is_absolute_path(filename)
end
itp('returns true if filename starts with a slash', function()