From 8b171b8c507dd9db01abee169d3a71e33f8e8ff4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 12 May 2017 20:03:05 +0300 Subject: functests: Test invalid behaviour Test correctly fail for oneline ruby, python and python3. --- test/functional/ex_cmds/script_spec.lua | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/functional/ex_cmds/script_spec.lua (limited to 'test/functional/ex_cmds/script_spec.lua') diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua new file mode 100644 index 0000000000..0ee25d802c --- /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 check_provider = helpers.check_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', check_provider('ruby')) + test_garbage_exec('python', check_provider('python')) + test_garbage_exec('python3', check_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) -- cgit From 19d38c4d0f98004e8b2c39821f9bee8ca7e2f5d2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 12 May 2017 20:47:33 +0300 Subject: functests: Replace check_provider -> missing_provider with err report --- test/functional/ex_cmds/script_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ex_cmds/script_spec.lua') diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua index 0ee25d802c..4e57d2755d 100644 --- a/test/functional/ex_cmds/script_spec.lua +++ b/test/functional/ex_cmds/script_spec.lua @@ -7,7 +7,7 @@ local clear = helpers.clear local dedent = helpers.dedent local source = helpers.source local exc_exec = helpers.exc_exec -local check_provider = helpers.check_provider +local missing_provider = helpers.missing_provider before_each(clear) @@ -61,9 +61,9 @@ describe('script_get-based command', function() test_garbage_exec('lua', true) -- Provider-based scripts - test_garbage_exec('ruby', check_provider('ruby')) - test_garbage_exec('python', check_provider('python')) - test_garbage_exec('python3', check_provider('python3')) + 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) -- cgit