mirror of
https://github.com/neovim/neovim.git
synced 2025-12-10 08:32:42 +00:00
eval: executable(), exepath() accept strings only
Cherry-pick f_executable(), f_exepath(), check_for_string() from patch 8.2.2117.
Rename check_for_string() to tv_check_for_string().
7bb4e74c38
Close https://github.com/neovim/neovim/issues/13485
This commit is contained in:
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
local eq, clear, call, iswin, write_file, command =
|
||||
helpers.eq, helpers.clear, helpers.call, helpers.iswin, helpers.write_file,
|
||||
helpers.command
|
||||
local exc_exec = helpers.exc_exec
|
||||
local eval = helpers.eval
|
||||
|
||||
describe('executable()', function()
|
||||
@@ -12,6 +13,16 @@ describe('executable()', function()
|
||||
eq(1, call('executable', exe))
|
||||
end)
|
||||
|
||||
it('fails for invalid values', function()
|
||||
for _, input in ipairs({'""', 'v:null', 'v:true', 'v:false', '{}', '[]'}) do
|
||||
eq('Vim(call):E928: String required', exc_exec('call executable('..input..')'))
|
||||
end
|
||||
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
|
||||
for _, input in ipairs({'v:null', 'v:true', 'v:false'}) do
|
||||
eq('Vim(call):E928: String required', exc_exec('call executable('..input..')'))
|
||||
end
|
||||
end)
|
||||
|
||||
it('returns 0 for non-existent files', function()
|
||||
eq(0, call('executable', 'no_such_file_exists_209ufq23f'))
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user