diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/api/vim_spec.lua | 30 | ||||
-rw-r--r-- | test/functional/eval/api_functions_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/eval/msgpack_functions_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ex_cmds/script_spec.lua | 75 | ||||
-rw-r--r-- | test/functional/helpers.lua | 14 | ||||
-rw-r--r-- | test/functional/legacy/036_regexp_character_classes_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/provider/python3_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/provider/python_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/provider/ruby_spec.lua | 6 |
9 files changed, 143 insertions, 14 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 282ecbfd87..61ec6ea829 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -81,6 +81,36 @@ describe('api', function() end) end) + describe('nvim_execute_lua', function() + it('works', function() + meths.execute_lua('vim.api.nvim_set_var("test", 3)', {}) + eq(3, meths.get_var('test')) + + eq(17, meths.execute_lua('a, b = ...\nreturn a + b', {10,7})) + + eq(NIL, meths.execute_lua('function xx(a,b)\nreturn a..b\nend',{})) + eq("xy", meths.execute_lua('return xx(...)', {'x','y'})) + end) + + it('reports errors', function() + eq({false, 'Error loading lua: [string "<nvim>"]:1: '.. + "'=' expected near '+'"}, + meth_pcall(meths.execute_lua, 'a+*b', {})) + + eq({false, 'Error loading lua: [string "<nvim>"]:1: '.. + "unexpected symbol near '1'"}, + meth_pcall(meths.execute_lua, '1+2', {})) + + eq({false, 'Error loading lua: [string "<nvim>"]:1: '.. + "unexpected symbol"}, + meth_pcall(meths.execute_lua, 'aa=bb\0', {})) + + eq({false, 'Error executing lua: [string "<nvim>"]:1: '.. + "attempt to call global 'bork' (a nil value)"}, + meth_pcall(meths.execute_lua, 'bork()', {})) + end) + end) + describe('nvim_input', function() it("VimL error: does NOT fail, updates v:errmsg", function() local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>") diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index 7f6f53d226..fea4a87a26 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -106,7 +106,7 @@ describe('api functions', function() it('have metadata accessible with api_info()', function() local api_keys = eval("sort(keys(api_info()))") - eq({'error_types', 'functions', 'types', 'version'}, api_keys) + eq({'error_types', 'functions', 'types', 'ui_events', 'version'}, api_keys) end) it('are highlighted by vim.vim syntax file', function() diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua index c5520deb73..4a052b4aff 100644 --- a/test/functional/eval/msgpack_functions_spec.lua +++ b/test/functional/eval/msgpack_functions_spec.lua @@ -461,7 +461,7 @@ describe('msgpackparse() function', function() eval(cmd) eval(cmd) -- do it again (try to force segfault) local api_info = eval(cmd) -- do it again - eq({'error_types', 'functions', 'types', 'version'}, api_info) + eq({'error_types', 'functions', 'types', 'ui_events', 'version'}, api_info) end) it('fails when called with no arguments', function() diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua new file mode 100644 index 0000000000..4e57d2755d --- /dev/null +++ b/test/functional/ex_cmds/script_spec.lua @@ -0,0 +1,75 @@ +local helpers = require('test.functional.helpers')(after_each) + +local eq = helpers.eq +local neq = helpers.neq +local meths = helpers.meths +local clear = helpers.clear +local dedent = helpers.dedent +local source = helpers.source +local exc_exec = helpers.exc_exec +local missing_provider = helpers.missing_provider + +before_each(clear) + +describe('script_get-based command', function() + local garbage = ')}{+*({}]*[;(+}{&[]}{*])(' + + local function test_garbage_exec(cmd, check_neq) + describe(cmd, function() + it('works correctly when skipping oneline variant', function() + eq(true, pcall(source, (dedent([[ + if 0 + %s %s + endif + ]])):format(cmd, garbage))) + eq('', meths.command_output('messages')) + if check_neq then + neq(0, exc_exec(dedent([[ + %s %s + ]])):format(cmd, garbage)) + end + end) + it('works correctly when skipping HEREdoc variant', function() + eq(true, pcall(source, (dedent([[ + if 0 + %s << EOF + %s + EOF + endif + ]])):format(cmd, garbage))) + eq('', meths.command_output('messages')) + if check_neq then + eq(true, pcall(source, (dedent([[ + let g:exc = 0 + try + %s << EOF + %s + EOF + catch + let g:exc = v:exception + endtry + ]])):format(cmd, garbage))) + neq(0, meths.get_var('exc')) + end + end) + end) + end + + clear() + + -- Built-in scripts + test_garbage_exec('lua', true) + + -- Provider-based scripts + test_garbage_exec('ruby', not missing_provider('ruby')) + test_garbage_exec('python', not missing_provider('python')) + test_garbage_exec('python3', not missing_provider('python3')) + + -- Missing scripts + test_garbage_exec('tcl', false) + test_garbage_exec('mzscheme', false) + test_garbage_exec('perl', false) + + -- Not really a script + test_garbage_exec('xxxinvalidlanguagexxx', true) +end) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 1be70f917c..b03840b3fe 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -566,6 +566,19 @@ local function get_pathsep() return funcs.fnamemodify('.', ':p'):sub(-1) end +local function missing_provider(provider) + if provider == 'ruby' then + local prog = funcs['provider#' .. provider .. '#Detect']() + return prog == '' and (provider .. ' not detected') or false + elseif provider == 'python' or provider == 'python3' then + local py_major_version = (provider == 'python3' and 3 or 2) + local errors = funcs['provider#pythonx#Detect'](py_major_version)[2] + return errors ~= '' and errors or false + else + assert(false, 'Unknown provider: ' .. provider) + end +end + local module = { prepend_argv = prepend_argv, clear = clear, @@ -632,6 +645,7 @@ local module = { meth_pcall = meth_pcall, NIL = mpack.NIL, get_pathsep = get_pathsep, + missing_provider = missing_provider, } return function(after_each) diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua index 110f7dd852..38e8145d1c 100644 --- a/test/functional/legacy/036_regexp_character_classes_spec.lua +++ b/test/functional/legacy/036_regexp_character_classes_spec.lua @@ -275,4 +275,16 @@ describe('character classes in regexp', function() diff(sixlines(string.sub(punct1, 1)..digits..punct2..upper..punct3.. lower..punct4..ctrl2..iso_text)) end) + it('does not convert character class ranges to an incorrect class', function() + source([[ + 1 s/\%#=0[0-z]//g + 2 s/\%#=1[0-z]//g + 3 s/\%#=2[0-z]//g + 4 s/\%#=0[^0-z]//g + 5 s/\%#=1[^0-z]//g + 6 s/\%#=2[^0-z]//g + ]]) + diff(string.rep(ctrl1..punct1..punct4..ctrl2..iso_text..'\n', 3) + ..string.rep(digits..punct2..upper..punct3..lower..'\n', 3)) + end) end) diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua index 89a546675f..aa50f53451 100644 --- a/test/functional/provider/python3_spec.lua +++ b/test/functional/provider/python3_spec.lua @@ -3,14 +3,14 @@ local eval, command, feed = helpers.eval, helpers.command, helpers.feed local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert local expect, write_file = helpers.expect, helpers.write_file local feed_command = helpers.feed_command +local missing_provider = helpers.missing_provider do clear() - command('let [g:interp, g:errors] = provider#pythonx#Detect(3)') - local errors = eval('g:errors') - if errors ~= '' then + local err = missing_provider('python3') + if err then pending( - 'Python 3 (or the Python 3 neovim module) is broken or missing:\n' .. errors, + 'Python 3 (or the Python 3 neovim module) is broken or missing:\n' .. err, function() end) return end diff --git a/test/functional/provider/python_spec.lua b/test/functional/provider/python_spec.lua index 94dfa90ea8..25f5e0a6d0 100644 --- a/test/functional/provider/python_spec.lua +++ b/test/functional/provider/python_spec.lua @@ -12,14 +12,14 @@ local command = helpers.command local exc_exec = helpers.exc_exec local write_file = helpers.write_file local curbufmeths = helpers.curbufmeths +local missing_provider = helpers.missing_provider do clear() - command('let [g:interp, g:errors] = provider#pythonx#Detect(2)') - local errors = meths.get_var('errors') - if errors ~= '' then + local err = missing_provider('python') + if err then pending( - 'Python 2 (or the Python 2 neovim module) is broken or missing:\n' .. errors, + 'Python 2 (or the Python 2 neovim module) is broken or missing:\n' .. err, function() end) return end diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua index 7b0e17688d..9f5ef3b3fc 100644 --- a/test/functional/provider/ruby_spec.lua +++ b/test/functional/provider/ruby_spec.lua @@ -10,13 +10,11 @@ local expect = helpers.expect local command = helpers.command local write_file = helpers.write_file local curbufmeths = helpers.curbufmeths +local missing_provider = helpers.missing_provider do clear() - command('let g:prog = provider#ruby#Detect()') - local prog = meths.get_var('prog') - - if prog == '' then + if missing_provider('ruby') then pending( "Cannot find the neovim RubyGem. Try :CheckHealth", function() end) |