aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/004_bufenter_with_modelines_spec.lua11
-rw-r--r--test/functional/shell/viml_system_spec.lua152
-rw-r--r--test/unit/formatc.lua6
-rw-r--r--test/unit/os/fs_spec.lua4
4 files changed, 167 insertions, 6 deletions
diff --git a/test/functional/legacy/004_bufenter_with_modelines_spec.lua b/test/functional/legacy/004_bufenter_with_modelines_spec.lua
index 6f009b52dd..34e702b798 100644
--- a/test/functional/legacy/004_bufenter_with_modelines_spec.lua
+++ b/test/functional/legacy/004_bufenter_with_modelines_spec.lua
@@ -46,6 +46,12 @@ describe('BufEnter with modelines', function()
-- Include Xxx in the current file
feed('G:r Xxx<CR>')
+ -- Vim issue #57 do not move cursor on <c-o> when autoindent is set
+ execute('set fo+=r')
+ feed('G')
+ feed('o# abcdef<Esc>2hi<CR><c-o>d0<Esc>')
+ feed('o# abcdef<Esc>2hi<c-o>d0<Esc>')
+
expect([[
startstart
start of test file Xxx
@@ -63,7 +69,10 @@ describe('BufEnter with modelines', function()
this is a test
this is a test
this should be in column 1
- end of test file Xxx]])
+ end of test file Xxx
+ # abc
+ def
+ def]])
end)
teardown(function()
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 48dc518d7b..25d2b5bc2c 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -6,6 +6,8 @@ local helpers = require('test.functional.helpers')
local eq, clear, eval, feed, nvim =
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim
+local Screen = require('test.functional.ui.screen')
+
local function create_file_with_nuls(name)
return function()
@@ -42,6 +44,81 @@ describe('system()', function()
eq(127, eval('v:shell_error'))
end)
+ describe('executes shell function', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('`echo` and waits for its return', function()
+ feed(':call system("echo")<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :call system("echo") |
+ ]])
+ end)
+
+ it('`yes` and is directly interrupted with CTRL-C', function()
+ feed(':call system("yes")<cr><c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+
+ it('`yes` and is a little bit later interrupted with CTRL-C', function()
+ feed(':call system("yes")<cr>')
+ feed('<c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+ end)
+
describe('passing no input', function()
it('returns the program output', function()
eq("echoed", eval('system("echo -n echoed")'))
@@ -137,6 +214,81 @@ describe('systemlist()', function()
eq(127, eval('v:shell_error'))
end)
+ describe('exectues shell function', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('`echo` and waits for its return', function()
+ feed(':call systemlist("echo")<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :call systemlist("echo") |
+ ]])
+ end)
+
+ it('`yes` and is directly interrupted with CTRL-C', function()
+ feed(':call systemlist("echo")<cr><c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+
+ it('`yes` and is a little bit later interrupted with CTRL-C', function()
+ feed(':call systemlist("echo")<cr>')
+ feed('<c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+ end)
+
describe('passing string with linefeed characters as input', function()
it('splits the output on linefeed characters', function()
eq({'abc', 'def', 'ghi'}, eval([[systemlist("cat -", "abc\ndef\nghi")]]))
diff --git a/test/unit/formatc.lua b/test/unit/formatc.lua
index 792894f349..f9397eaec6 100644
--- a/test/unit/formatc.lua
+++ b/test/unit/formatc.lua
@@ -149,8 +149,7 @@ local C_keywords = set {
-- };
--
-- would become:
--- struct mystruct
--- { int a; int b; };
+-- struct mystruct { int a; int b; };
--
-- The first one will have a lot of false positives (the line '{' for
-- example), the second one is more unique.
@@ -179,7 +178,8 @@ local function formatc(str)
-- static and/or inline usually indicate an inline header function,
-- which has no trailing ';', so we have to add a newline after the
-- '}' ourselves.
- if token[1] == 'static' or token[1] == 'inline' then
+ local tok = token[1]
+ if tok == 'static' or tok == 'inline' or tok == '__inline' then
end_at_brace = true
end
elseif typ == 'preprocessor' then
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 2d54dc6003..90f5a0b7de 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -33,11 +33,11 @@ local absolute_executable = nil
local executable_name = nil
local function assert_file_exists(filepath)
- eq(false, nil == (lfs.attributes(filepath, 'r')))
+ neq(nil, lfs.attributes(filepath))
end
local function assert_file_does_not_exist(filepath)
- eq(true, nil == (lfs.attributes(filepath, 'r')))
+ eq(nil, lfs.attributes(filepath))
end
describe('fs function', function()