aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/timer_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/vimscript/timer_spec.lua')
-rw-r--r--test/functional/vimscript/timer_spec.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua
index 9ee0735e40..20f2afb20f 100644
--- a/test/functional/vimscript/timer_spec.lua
+++ b/test/functional/vimscript/timer_spec.lua
@@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run
local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs
+local exc_exec = helpers.exc_exec
local curbufmeths = helpers.curbufmeths
local load_adjust = helpers.load_adjust
local retry = helpers.retry
@@ -262,4 +263,21 @@ describe('timers', function()
eq(2, eval('g:val'))
end)
+
+ it("timer_start can't be used in the sandbox", function()
+ source [[
+ function! Scary(timer) abort
+ call execute('echo ''execute() should be disallowed''', '')
+ endfunction
+ ]]
+ eq("Vim(call):E48: Not allowed in sandbox", exc_exec("sandbox call timer_start(0, 'Scary')"))
+ end)
+
+ it('can be triggered after an empty string <expr> mapping #17257', function()
+ local screen = Screen.new(40, 6)
+ screen:attach()
+ command([=[imap <expr> <F2> [timer_start(0, { _ -> execute("throw 'x'", "") }), ''][-1]]=])
+ feed('i<F2>')
+ screen:expect({any='E605: Exception not caught: x'})
+ end)
end)