aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/README.md6
-rw-r--r--test/functional/autocmd/cursormoved_spec.lua8
-rw-r--r--test/functional/autocmd/recording_spec.lua52
-rw-r--r--test/functional/editor/macro_spec.lua27
-rw-r--r--test/functional/plugin/health_spec.lua6
-rw-r--r--test/functional/terminal/channel_spec.lua28
6 files changed, 107 insertions, 20 deletions
diff --git a/test/README.md b/test/README.md
index 37aa54c157..c6e173ead2 100644
--- a/test/README.md
+++ b/test/README.md
@@ -116,7 +116,7 @@ Filtering Tests
### Filter by name
-Another filter method is by setting a pattern of test name to `TEST_FILTER`.
+Another filter method is by setting a pattern of test name to `TEST_FILTER` or `TEST_FILTER_OUT`.
``` lua
it('foo api',function()
@@ -131,6 +131,10 @@ To run only test with filter name:
TEST_FILTER='foo.*api' make functionaltest
+To run all tests except ones matching a filter:
+
+ TEST_FILTER_OUT='foo.*api' make functionaltest
+
### Filter by file
To run a *specific* unit test:
diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua
index d0f46e689b..9641d4b096 100644
--- a/test/functional/autocmd/cursormoved_spec.lua
+++ b/test/functional/autocmd/cursormoved_spec.lua
@@ -31,4 +31,12 @@ describe('CursorMoved', function()
eq({'aaa'}, funcs.nvim_buf_get_lines(eval('g:buf'), 0, -1, true))
eq(0, eval('g:cursormoved'))
end)
+
+ it("is not triggered by cursor movement prior to first CursorMoved instantiation", function()
+ source([[
+ let g:cursormoved = 0
+ autocmd CursorMoved * let g:cursormoved += 1
+ ]])
+ eq(0, eval('g:cursormoved'))
+ end)
end)
diff --git a/test/functional/autocmd/recording_spec.lua b/test/functional/autocmd/recording_spec.lua
new file mode 100644
index 0000000000..81152758de
--- /dev/null
+++ b/test/functional/autocmd/recording_spec.lua
@@ -0,0 +1,52 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local clear = helpers.clear
+local eq = helpers.eq
+local eval = helpers.eval
+local source_vim = helpers.source
+
+describe('RecordingEnter', function()
+ before_each(clear)
+ it('works', function()
+ source_vim [[
+ let g:recorded = 0
+ autocmd RecordingEnter * let g:recorded += 1
+ execute "normal! qqyyq"
+ ]]
+ eq(1, eval('g:recorded'))
+ end)
+
+ it('gives a correct reg_recording()', function()
+ source_vim [[
+ let g:recording = ''
+ autocmd RecordingEnter * let g:recording = reg_recording()
+ execute "normal! qqyyq"
+ ]]
+ eq('q', eval('g:recording'))
+ end)
+end)
+
+describe('RecordingLeave', function()
+ before_each(clear)
+ it('works', function()
+ source_vim [[
+ let g:recorded = 0
+ autocmd RecordingLeave * let g:recorded += 1
+ execute "normal! qqyyq"
+ ]]
+ eq(1, eval('g:recorded'))
+ end)
+
+ it('gives the correct reg_recorded()', function()
+ source_vim [[
+ let g:recorded = 'a'
+ let g:recording = ''
+ autocmd RecordingLeave * let g:recording = reg_recording()
+ autocmd RecordingLeave * let g:recorded = reg_recorded()
+ execute "normal! qqyyq"
+ ]]
+ eq('q', eval 'g:recording')
+ eq('', eval 'g:recorded')
+ eq('q', eval 'reg_recorded()')
+ end)
+end)
diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua
index 102d8fc723..c0c9256af2 100644
--- a/test/functional/editor/macro_spec.lua
+++ b/test/functional/editor/macro_spec.lua
@@ -6,6 +6,8 @@ local feed = helpers.feed
local clear = helpers.clear
local expect = helpers.expect
local command = helpers.command
+local insert = helpers.insert
+local curbufmeths = helpers.curbufmeths
describe('macros', function()
before_each(clear)
@@ -27,4 +29,29 @@ describe('macros', function()
expect('llllll')
eq(eval('@i'), 'lxxx')
end)
+
+ it('can be replayed with Q', function()
+ insert [[hello
+hello
+hello]]
+ feed [[gg]]
+
+ feed [[qqAFOO<esc>q]]
+ eq({'helloFOO', 'hello', 'hello'}, curbufmeths.get_lines(0, -1, false))
+
+ feed[[Q]]
+ eq({'helloFOOFOO', 'hello', 'hello'}, curbufmeths.get_lines(0, -1, false))
+
+ feed[[G3Q]]
+ eq({'helloFOOFOO', 'hello', 'helloFOOFOOFOO'}, curbufmeths.get_lines(0, -1, false))
+ end)
+end)
+
+describe('reg_recorded()', function()
+ before_each(clear)
+
+ it('returns the correct value', function()
+ feed [[qqyyq]]
+ eq('q', eval('reg_recorded()'))
+ end)
end)
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index b567b3e20c..37de5d0ce6 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -156,7 +156,7 @@ describe('health.vim', function()
test_plug.submodule_failed: require("test_plug.submodule_failed.health").check()
========================================================================
- ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception:
- function health#check, line 24]])
+ function health#check, line 20]])
eq(expected, received)
end)
@@ -167,7 +167,7 @@ describe('health.vim', function()
broken: health#broken#check
========================================================================
- ERROR: Failed to run healthcheck for "broken" plugin. Exception:
- function health#check[24]..health#broken#check, line 1
+ function health#check[20]..health#broken#check, line 1
caused an error
]])
end)
@@ -186,7 +186,7 @@ describe('health.vim', function()
test_plug.submodule_failed: require("test_plug.submodule_failed.health").check()
========================================================================
- ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception:
- function health#check, line 24]])
+ function health#check, line 20]])
eq(expected, received)
end)
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua
index 7d37dcccc8..7223f5ba61 100644
--- a/test/functional/terminal/channel_spec.lua
+++ b/test/functional/terminal/channel_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local command = helpers.command
-local exc_exec = helpers.exc_exec
+local pcall_err = helpers.pcall_err
local feed = helpers.feed
local sleep = helpers.sleep
local poke_eventloop = helpers.poke_eventloop
@@ -13,24 +13,22 @@ describe('associated channel is closed and later freed for terminal', function()
it('opened by nvim_open_term() and deleted by :bdelete!', function()
command([[let id = nvim_open_term(0, {})]])
-- channel hasn't been freed yet
- eq("Vim(call):Can't send data to closed stream", exc_exec([[bdelete! | call chansend(id, 'test')]]))
- -- process free_channel_event
- poke_eventloop()
- -- channel has been freed
- eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[bdelete! | call chansend(id, 'test')]]))
+ -- channel has been freed after one main loop iteration
+ eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[call chansend(id, 'test')]]))
end)
it('opened by termopen(), exited, and deleted by pressing a key', function()
command([[let id = termopen('echo')]])
sleep(500)
-- process has exited
- eq("Vim(call):Can't send data to closed stream", exc_exec([[call chansend(id, 'test')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[call chansend(id, 'test')]]))
-- delete terminal
feed('i<CR>')
- -- process term_delayed_free and free_channel_event
+ -- need to first process input
poke_eventloop()
- -- channel has been freed
- eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ -- channel has been freed after another main loop iteration
+ eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[call chansend(id, 'test')]]))
end)
-- This indirectly covers #16264
@@ -38,12 +36,10 @@ describe('associated channel is closed and later freed for terminal', function()
command([[let id = termopen('echo')]])
sleep(500)
-- process has exited
- eq("Vim(call):Can't send data to closed stream", exc_exec([[call chansend(id, 'test')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[call chansend(id, 'test')]]))
-- channel hasn't been freed yet
- eq("Vim(call):Can't send data to closed stream", exc_exec([[bdelete | call chansend(id, 'test')]]))
- -- process term_delayed_free and free_channel_event
- poke_eventloop()
- -- channel has been freed
- eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[bdelete | call chansend(id, 'test')]]))
+ -- channel has been freed after one main loop iteration
+ eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[call chansend(id, 'test')]]))
end)
end)