aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/autocmd_spec.lua30
-rw-r--r--test/functional/api/command_spec.lua7
2 files changed, 22 insertions, 15 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua
index a58ca00a75..3b14ae9bf7 100644
--- a/test/functional/api/autocmd_spec.lua
+++ b/test/functional/api/autocmd_spec.lua
@@ -168,7 +168,7 @@ describe('autocmd api', function()
})
]]
- meths.do_autocmd("User", {pattern = "Test"})
+ meths.exec_autocmd("User", {pattern = "Test"})
eq({{
buflocal = false,
command = 'A test autocommand',
@@ -179,7 +179,7 @@ describe('autocmd api', function()
pattern = 'Test',
}}, meths.get_autocmds({event = "User", pattern = "Test"}))
meths.set_var("some_condition", true)
- meths.do_autocmd("User", {pattern = "Test"})
+ meths.exec_autocmd("User", {pattern = "Test"})
eq({}, meths.get_autocmds({event = "User", pattern = "Test"}))
end)
end)
@@ -490,7 +490,7 @@ describe('autocmd api', function()
end)
end)
- describe('nvim_do_autocmd', function()
+ describe('nvim_exec_autocmd', function()
it("can trigger builtin autocmds", function()
meths.set_var("autocmd_executed", false)
@@ -500,7 +500,7 @@ describe('autocmd api', function()
})
eq(false, meths.get_var("autocmd_executed"))
- meths.do_autocmd("BufReadPost", {})
+ meths.exec_autocmd("BufReadPost", {})
eq(true, meths.get_var("autocmd_executed"))
end)
@@ -514,10 +514,10 @@ describe('autocmd api', function()
})
-- Doesn't execute for other non-matching events
- meths.do_autocmd("CursorHold", { buffer = 1 })
+ meths.exec_autocmd("CursorHold", { buffer = 1 })
eq(-1, meths.get_var("buffer_executed"))
- meths.do_autocmd("BufLeave", { buffer = 1 })
+ meths.exec_autocmd("BufLeave", { buffer = 1 })
eq(1, meths.get_var("buffer_executed"))
end)
@@ -531,7 +531,7 @@ describe('autocmd api', function()
})
-- Doesn't execute for other non-matching events
- meths.do_autocmd("CursorHold", { buffer = 1 })
+ meths.exec_autocmd("CursorHold", { buffer = 1 })
eq('none', meths.get_var("filename_executed"))
meths.command('edit __init__.py')
@@ -539,7 +539,7 @@ describe('autocmd api', function()
end)
it('cannot pass buf and fname', function()
- local ok = pcall(meths.do_autocmd, "BufReadPre", { pattern = "literally_cannot_error.rs", buffer = 1 })
+ local ok = pcall(meths.exec_autocmd, "BufReadPre", { pattern = "literally_cannot_error.rs", buffer = 1 })
eq(false, ok)
end)
@@ -557,16 +557,16 @@ describe('autocmd api', function()
})
-- Doesn't execute for other non-matching events
- meths.do_autocmd("CursorHoldI", { buffer = 1 })
+ meths.exec_autocmd("CursorHoldI", { buffer = 1 })
eq('none', meths.get_var("filename_executed"))
- meths.do_autocmd("CursorHoldI", { buffer = tonumber(meths.get_current_buf()) })
+ meths.exec_autocmd("CursorHoldI", { buffer = tonumber(meths.get_current_buf()) })
eq('__init__.py', meths.get_var("filename_executed"))
-- Reset filename
meths.set_var("filename_executed", 'none')
- meths.do_autocmd("CursorHoldI", { pattern = '__init__.py' })
+ meths.exec_autocmd("CursorHoldI", { pattern = '__init__.py' })
eq('__init__.py', meths.get_var("filename_executed"))
end)
@@ -578,9 +578,9 @@ describe('autocmd api', function()
command = 'let g:matched = "matched"'
})
- meths.do_autocmd("User", { pattern = "OtherCommand" })
+ meths.exec_autocmd("User", { pattern = "OtherCommand" })
eq('none', meths.get_var('matched'))
- meths.do_autocmd("User", { pattern = "TestCommand" })
+ meths.exec_autocmd("User", { pattern = "TestCommand" })
eq('matched', meths.get_var('matched'))
end)
@@ -594,7 +594,7 @@ describe('autocmd api', function()
})
eq(false, meths.get_var("group_executed"))
- meths.do_autocmd("FileType", { group = auid })
+ meths.exec_autocmd("FileType", { group = auid })
eq(true, meths.get_var("group_executed"))
end)
@@ -609,7 +609,7 @@ describe('autocmd api', function()
})
eq(false, meths.get_var("group_executed"))
- meths.do_autocmd("FileType", { group = auname })
+ meths.exec_autocmd("FileType", { group = auname })
eq(true, meths.get_var("group_executed"))
end)
end)
diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua
index b80004f67c..94176fc2ce 100644
--- a/test/functional/api/command_spec.lua
+++ b/test/functional/api/command_spec.lua
@@ -65,6 +65,7 @@ describe('nvim_get_commands', function()
local cmd3 = { addr=NIL, bang=false, bar=true, complete=NIL, complete_arg=NIL, count=NIL, definition='call \128\253R3_ohyeah()', name='Cmd3', nargs='0', range=NIL, register=false, keepscript=false, script_id=3, }
local cmd4 = { addr=NIL, bang=false, bar=false, complete=NIL, complete_arg=NIL, count=NIL, definition='call \128\253R4_just_great()', name='Cmd4', nargs='0', range=NIL, register=true, keepscript=false, script_id=4, }
source([[
+ let s:foo = 1
command -complete=custom,ListUsers -nargs=+ Finger !finger <args>
]])
eq({Finger=cmd1}, meths.get_commands({builtin=false}))
@@ -72,12 +73,18 @@ describe('nvim_get_commands', function()
eq({Finger=cmd1, TestCmd=cmd0}, meths.get_commands({builtin=false}))
source([[
+ function! s:foo() abort
+ endfunction
command -bang -nargs=* Cmd2 call <SID>foo(<q-args>)
]])
source([[
+ function! s:ohyeah() abort
+ endfunction
command -bar -nargs=0 Cmd3 call <SID>ohyeah()
]])
source([[
+ function! s:just_great() abort
+ endfunction
command -register Cmd4 call <SID>just_great()
]])
-- TODO(justinmk): Order is stable but undefined. Sort before return?