aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/append_spec.lua54
-rw-r--r--test/functional/ex_cmds/write_spec.lua38
-rw-r--r--test/functional/ui/wildmode_spec.lua32
-rw-r--r--test/functional/viml/completion_spec.lua50
-rw-r--r--test/unit/os/fs_spec.lua2
5 files changed, 173 insertions, 3 deletions
diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua
new file mode 100644
index 0000000000..2d5ab8e8c8
--- /dev/null
+++ b/test/functional/ex_cmds/append_spec.lua
@@ -0,0 +1,54 @@
+local helpers = require('test.functional.helpers')
+
+local eq = helpers.eq
+local feed = helpers.feed
+local clear = helpers.clear
+local funcs = helpers.funcs
+local command = helpers.command
+local curbufmeths = helpers.curbufmeths
+
+before_each(function()
+ clear()
+ curbufmeths.set_lines(0, 1, true, { 'foo', 'bar', 'baz' })
+end)
+
+local buffer_contents = function()
+ return curbufmeths.get_lines(0, -1, false)
+end
+
+local cmdtest = function(cmd, prep, ret1)
+ describe(':' .. cmd, function()
+ it(cmd .. 's' .. prep .. ' the current line by default', function()
+ command(cmd .. '\nabc\ndef\n')
+ eq(ret1, buffer_contents())
+ end)
+ -- Used to crash because this invokes history processing which uses
+ -- hist_char2type which after fdb68e35e4c729c7ed097d8ade1da29e5b3f4b31
+ -- crashed.
+ it(cmd .. 's' .. prep .. ' the current line by default when feeding',
+ function()
+ feed(':' .. cmd .. '\nabc\ndef\n.\n')
+ eq(ret1, buffer_contents())
+ end)
+ -- This used to crash since that commit as well.
+ it('opens empty cmdline window', function()
+ local hisline = '" Some comment to be stored in history'
+ feed(':' .. hisline .. '<CR>')
+ feed(':' .. cmd .. '<CR>abc<CR>def<C-f>')
+ eq({ 'def' }, buffer_contents())
+ eq(hisline, funcs.histget(':', -2))
+ eq(cmd, funcs.histget(':'))
+ -- Test that command-line window was launched
+ eq('nofile', curbufmeths.get_option('buftype'))
+ eq('n', funcs.mode(1))
+ feed('<CR>')
+ eq('c', funcs.mode(1))
+ feed('.<CR>')
+ eq('n', funcs.mode(1))
+ eq(ret1, buffer_contents())
+ end)
+ end)
+end
+cmdtest('insert', ' before', { 'abc', 'def', 'foo', 'bar', 'baz' })
+cmdtest('append', ' after', { 'foo', 'abc', 'def', 'bar', 'baz' })
+cmdtest('change', '', { 'abc', 'def', 'bar', 'baz' })
diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua
new file mode 100644
index 0000000000..d90b297ca8
--- /dev/null
+++ b/test/functional/ex_cmds/write_spec.lua
@@ -0,0 +1,38 @@
+-- Specs for :write
+
+local helpers = require('test.functional.helpers')
+local eq, eval, clear, write_file, execute, source =
+ helpers.eq, helpers.eval, helpers.clear, helpers.write_file,
+ helpers.execute, helpers.source
+
+describe(':write', function()
+ it('&backupcopy=auto preserves symlinks', function()
+ clear('set backupcopy=auto')
+ os.remove('test_bkc_file.txt')
+ os.remove('test_bkc_link.txt')
+ write_file('test_bkc_file.txt', 'content0')
+ execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
+ source([[
+ edit test_bkc_link.txt
+ call setline(1, ['content1'])
+ write
+ ]])
+ eq(eval("['content1']"), eval("readfile('test_bkc_file.txt')"))
+ eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')"))
+ end)
+
+ it('&backupcopy=no replaces symlink with new file', function()
+ clear('set backupcopy=no')
+ os.remove('test_bkc_file.txt')
+ os.remove('test_bkc_link.txt')
+ write_file('test_bkc_file.txt', 'content0')
+ execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
+ source([[
+ edit test_bkc_link.txt
+ call setline(1, ['content1'])
+ write
+ ]])
+ eq(eval("['content0']"), eval("readfile('test_bkc_file.txt')"))
+ eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')"))
+ end)
+end)
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index de2f3e469d..c57d4abcbf 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
+local funcs = helpers.funcs
describe("'wildmode'", function()
local screen
@@ -30,3 +31,34 @@ describe("'wildmode'", function()
end)
end)
end)
+
+describe('command line completion', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(40, 5)
+ screen:attach()
+ screen:set_default_attr_ignore({{bold=true, foreground=Screen.colors.Blue}})
+ end)
+
+ after_each(function()
+ os.remove('Xtest-functional-viml-compl-dir')
+ end)
+
+ it('lists directories with empty PATH', function()
+ local tmp = funcs.tempname()
+ execute('e '.. tmp)
+ execute('cd %:h')
+ execute("call mkdir('Xtest-functional-viml-compl-dir')")
+ execute('let $PATH=""')
+ feed(':!<tab><bs>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ :!Xtest-functional-viml-compl-dir^ |
+ ]])
+ end)
+end)
diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua
index 322d777ab6..0271540fe3 100644
--- a/test/functional/viml/completion_spec.lua
+++ b/test/functional/viml/completion_spec.lua
@@ -1,8 +1,8 @@
-
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed = helpers.clear, helpers.feed
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
+local insert = helpers.insert
local execute, source, expect = helpers.execute, helpers.source, helpers.expect
describe('completion', function()
@@ -714,6 +714,52 @@ describe('completion', function()
{3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
]])
end)
+
+ describe('from the commandline window', function()
+ it('is cleared after CTRL-C', function ()
+ feed('q:')
+ feed('ifoo faa fee f')
+ screen:expect([[
+ |
+ {8:[No Name] }|
+ :foo faa fee f^ |
+ :~ |
+ :~ |
+ :~ |
+ {9:[Command Line] }|
+ {3:-- INSERT --} |
+ ]], {[3] = {bold = true},
+ [4] = {bold = true, foreground = Screen.colors.SeaGreen},
+ [8] = {reverse = true},
+ [9] = {bold = true, reverse = true}})
+ feed('<c-x><c-n>')
+ screen:expect([[
+ |
+ {8:[No Name] }|
+ :foo faa fee foo^ |
+ :~ {2: foo } |
+ :~ {1: faa } |
+ :~ {1: fee } |
+ {9:[Command Line] }|
+ {3:-- Keyword Local completion (^N^P) }{4:match 1 of 3} |
+ ]],{[1] = {background = Screen.colors.LightMagenta},
+ [2] = {background = Screen.colors.Grey},
+ [3] = {bold = true},
+ [4] = {bold = true, foreground = Screen.colors.SeaGreen},
+ [8] = {reverse = true},
+ [9] = {bold = true, reverse = true}})
+ feed('<c-c>')
+ screen:expect([[
+ |
+ {8:[No Name] }|
+ :foo faa fee foo |
+ :~ |
+ :~ |
+ :~ |
+ {9:[Command Line] }|
+ :foo faa fee foo^ |
+ ]], {[8] = {reverse = true}, [9] = {bold = true, reverse = true}})
+ end)
+ end)
end)
-
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 2f393d353d..71b5e7f576 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -148,7 +148,7 @@ describe('fs function', function()
local function os_can_exe(name)
local buf = ffi.new('char *[1]')
buf[0] = NULL
- local ok = fs.os_can_exe(to_cstr(name), buf)
+ local ok = fs.os_can_exe(to_cstr(name), buf, true)
-- When os_can_exe returns true, it must set the path.
-- When it returns false, the path must be NULL.