diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/core/startup_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/eval/executable_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/eval/exepath_spec.lua | 40 | ||||
-rw-r--r-- | test/functional/eval/function_spec.lua | 8 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/false | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/false.cmd | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/null | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/null.cmd | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/true | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/true.cmd | 0 | ||||
-rw-r--r-- | test/functional/fixtures/lua/syntax_error.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/treesitter_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 2 |
14 files changed, 79 insertions, 10 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index ff0fdbea45..d5f03db03a 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -428,9 +428,9 @@ end) describe('clean', function() clear() - ok(string.match(meths.get_option('runtimepath'), funcs.stdpath('config')) ~= nil) + ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) ~= nil) clear('--clean') - ok(string.match(meths.get_option('runtimepath'), funcs.stdpath('config')) == nil) + ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) == nil) end) describe('user config init', function() diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua index a1cf056907..28aefb72e5 100644 --- a/test/functional/eval/executable_spec.lua +++ b/test/functional/eval/executable_spec.lua @@ -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() @@ -10,6 +11,20 @@ describe('executable()', function() it('returns 1 for commands in $PATH', function() local exe = iswin() and 'ping' or 'ls' eq(1, call('executable', exe)) + command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') + eq(1, call('executable', 'null')) + eq(1, call('executable', 'true')) + eq(1, call('executable', 'false')) + 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() diff --git a/test/functional/eval/exepath_spec.lua b/test/functional/eval/exepath_spec.lua index 10a11aeacc..08d2c59af8 100644 --- a/test/functional/eval/exepath_spec.lua +++ b/test/functional/eval/exepath_spec.lua @@ -1,14 +1,40 @@ local helpers = require('test.functional.helpers')(after_each) local eq, clear, call, iswin = helpers.eq, helpers.clear, helpers.call, helpers.iswin +local command = helpers.command +local exc_exec = helpers.exc_exec +local matches = helpers.matches -describe('exepath() (Windows)', function() - if not iswin() then return end -- N/A for Unix. +describe('exepath()', function() + before_each(clear) - it('append extension if omitted', function() - local filename = 'cmd' - local pathext = '.exe' - clear({env={PATHEXT=pathext}}) - eq(call('exepath', filename..pathext), call('exepath', filename)) + it('returns 1 for commands in $PATH', function() + local exe = iswin() and 'ping' or 'ls' + local ext_pat = iswin() and '%.EXE$' or '$' + matches(exe .. ext_pat, call('exepath', exe)) + command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') + ext_pat = iswin() and '%.CMD$' or '$' + matches('null' .. ext_pat, call('exepath', 'null')) + matches('true' .. ext_pat, call('exepath', 'true')) + matches('false' .. ext_pat, call('exepath', 'false')) 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 exepath('..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 exepath('..input..')')) + end + end) + + if iswin() then + it('append extension if omitted', function() + local filename = 'cmd' + local pathext = '.exe' + clear({env={PATHEXT=pathext}}) + eq(call('exepath', filename..pathext), call('exepath', filename)) + end) + end end) diff --git a/test/functional/eval/function_spec.lua b/test/functional/eval/function_spec.lua index 776e760aaf..ce8850fcc2 100644 --- a/test/functional/eval/function_spec.lua +++ b/test/functional/eval/function_spec.lua @@ -2,7 +2,10 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local eq = helpers.eq +local matches = helpers.matches local exc_exec = helpers.exc_exec +local iswin = helpers.iswin +local eval = helpers.eval describe('Up to MAX_FUNC_ARGS arguments are handled by', function() local max_func_args = 20 -- from eval.h @@ -27,3 +30,8 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function() eq('Vim(call):E740: Too many arguments for function rpcnotify', ret) end) end) + +it('windowsversion()', function() + clear() + matches(iswin() and '^%d+%.%d+$' or '^$', eval('windowsversion()')) +end) diff --git a/test/functional/fixtures/bin/false b/test/functional/fixtures/bin/false new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/false diff --git a/test/functional/fixtures/bin/false.cmd b/test/functional/fixtures/bin/false.cmd new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/false.cmd diff --git a/test/functional/fixtures/bin/null b/test/functional/fixtures/bin/null new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/null diff --git a/test/functional/fixtures/bin/null.cmd b/test/functional/fixtures/bin/null.cmd new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/null.cmd diff --git a/test/functional/fixtures/bin/true b/test/functional/fixtures/bin/true new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/true diff --git a/test/functional/fixtures/bin/true.cmd b/test/functional/fixtures/bin/true.cmd new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/true.cmd diff --git a/test/functional/fixtures/lua/syntax_error.lua b/test/functional/fixtures/lua/syntax_error.lua new file mode 100644 index 0000000000..8c0cf026ee --- /dev/null +++ b/test/functional/fixtures/lua/syntax_error.lua @@ -0,0 +1 @@ +- <= the syntax error diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua index 0e823426ae..f34cbbb65b 100644 --- a/test/functional/lua/treesitter_spec.lua +++ b/test/functional/lua/treesitter_spec.lua @@ -22,6 +22,10 @@ describe('treesitter API', function() matches("Error executing lua: Failed to load parser: uv_dlopen: .+", pcall_err(exec_lua, "parser = vim.treesitter.require_language('borklang', 'borkbork.so')")) + -- Should not throw an error when silent + eq(false, exec_lua("return vim.treesitter.require_language('borklang', nil, true)")) + eq(false, exec_lua("return vim.treesitter.require_language('borklang', 'borkbork.so', true)")) + eq("Error executing lua: .../language.lua:0: no parser for 'borklang' language, see :help treesitter-parsers", pcall_err(exec_lua, "parser = vim.treesitter.inspect_language('borklang')")) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index e9e1f7ec12..e253db5297 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1453,3 +1453,18 @@ describe('lua stdlib', function() end) end) end) + +describe('lua: require("mod") from packages', function() + before_each(function() + command('set rtp+=test/functional/fixtures') + end) + + it('propagates syntax error', function() + local syntax_error_msg = exec_lua [[ + local _, err = pcall(require, "syntax_error") + return err + ]] + + matches("unexpected symbol", syntax_error_msg) + end) +end) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 3ef41fde1d..8a5dd7ef18 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1477,7 +1477,7 @@ describe("TUI", function() retry(nil, 3000, function() -- Wait for log file to be flushed. local log = read_file('Xtest_tui_verbose_log') or '' - eq('--- Terminal info --- {{{\n', string.match(log, '--- Terminal.-\n')) + eq('--- Terminal info --- {{{\n', string.match(log, '%-%-%- Terminal.-\n')) ok(#log > 50) end) end) |