diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/lua/commands_spec.lua | 18 | ||||
-rw-r--r-- | test/old/testdir/test_options.vim | 56 | ||||
-rw-r--r-- | test/old/testdir/test_perl.vim | 15 | ||||
-rw-r--r-- | test/old/testdir/test_python2.vim | 24 | ||||
-rw-r--r-- | test/old/testdir/test_python3.vim | 102 | ||||
-rw-r--r-- | test/old/testdir/test_pyx2.vim | 30 | ||||
-rw-r--r-- | test/old/testdir/test_pyx3.vim | 30 | ||||
-rw-r--r-- | test/old/testdir/test_ruby.vim | 30 | ||||
-rw-r--r-- | test/old/testdir/test_undo.vim | 5 | ||||
-rw-r--r-- | test/old/testdir/test_vimscript.vim | 5 |
10 files changed, 289 insertions, 26 deletions
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua index 5bb9e0281b..0dc6c19fa1 100644 --- a/test/functional/lua/commands_spec.lua +++ b/test/functional/lua/commands_spec.lua @@ -7,6 +7,7 @@ local NIL = helpers.NIL local eval = helpers.eval local feed = helpers.feed local clear = helpers.clear +local matches = helpers.matches local meths = helpers.meths local exec_lua = helpers.exec_lua local exec_capture = helpers.exec_capture @@ -27,22 +28,27 @@ describe(':lua command', function() eq('', exec_capture( 'lua vim.api.nvim_buf_set_lines(1, 1, 2, false, {"TEST"})')) eq({'', 'TEST'}, curbufmeths.get_lines(0, 100, false)) - source(dedent([[ + source([[ lua << EOF vim.api.nvim_buf_set_lines(1, 1, 2, false, {"TSET"}) - EOF]])) + EOF]]) eq({'', 'TSET'}, curbufmeths.get_lines(0, 100, false)) - source(dedent([[ + source([[ lua << EOF - vim.api.nvim_buf_set_lines(1, 1, 2, false, {"SETT"})]])) + vim.api.nvim_buf_set_lines(1, 1, 2, false, {"SETT"})]]) eq({'', 'SETT'}, curbufmeths.get_lines(0, 100, false)) - source(dedent([[ + source([[ lua << EOF vim.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"}) vim.api.nvim_buf_set_lines(1, 2, 3, false, {"TTSE"}) vim.api.nvim_buf_set_lines(1, 3, 4, false, {"STTE"}) - EOF]])) + EOF]]) eq({'', 'ETTS', 'TTSE', 'STTE'}, curbufmeths.get_lines(0, 100, false)) + matches('.*Vim%(lua%):E15: Invalid expression: .*', pcall_err(source, [[ + lua << eval EOF + {} + EOF + ]])) end) it('throws catchable errors', function() eq([[Vim(lua):E5107: Error loading lua [string ":lua"]:0: unexpected symbol near ')']], diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index be794cb845..f101f550d1 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -321,9 +321,54 @@ func Test_set_completion() call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx') call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:) - set tags& + " Expanding the option names + call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal('"set all', @:) + + " Expanding a second set of option names + call feedkeys(":set wrapscan \<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal('"set wrapscan all', @:) + + " Expanding a special keycode + " call feedkeys(":set <Home>\<Tab>\<C-B>\"\<CR>", 'xt') + " call assert_equal('"set <Home>', @:) + + " Expanding an invalid special keycode + call feedkeys(":set <abcd>\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"set <abcd>\<Tab>", @:) + + " Expanding a terminal keycode + " call feedkeys(":set t_AB\<Tab>\<C-B>\"\<CR>", 'xt') + " call assert_equal("\"set t_AB", @:) + + " Expanding an invalid option name + call feedkeys(":set abcde=\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"set abcde=\<Tab>", @:) + + " Expanding after a = for a boolean option + call feedkeys(":set wrapscan=\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"set wrapscan=\<Tab>", @:) + + " Expanding a numeric option + call feedkeys(":set tabstop+=\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"set tabstop+=" .. &tabstop, @:) + + " Expanding a non-boolean option + call feedkeys(":set invtabstop=\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"set invtabstop=", @:) + + " Expand options for 'spellsuggest' + call feedkeys(":set spellsuggest=best,file:xyz\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"set spellsuggest=best,file:xyz", @:) + + " Expand value for 'key' + " set key=abcd + " call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt') + " call assert_equal('"set key=*****', @:) + " set key= + " Expand values for 'filetype' call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt') call assert_equal('"set filetype=sshdconfig', @:) @@ -411,7 +456,14 @@ func Test_set_errors() set backupext& patchmode& call assert_fails('set winminheight=10 winheight=9', 'E591:') + set winminheight& winheight& + set winheight=10 winminheight=10 + call assert_fails('set winheight=9', 'E591:') + set winminheight& winheight& call assert_fails('set winminwidth=10 winwidth=9', 'E592:') + set winminwidth& winwidth& + call assert_fails('set winwidth=9 winminwidth=10', 'E592:') + set winwidth& winminwidth& call assert_fails("set showbreak=\x01", 'E595:') call assert_fails('set t_foo=', 'E846:') call assert_fails('set tabstop??', 'E488:') @@ -944,7 +996,9 @@ endfunc func Test_opt_sandbox() for opt in ['backupdir', 'cdpath', 'exrc'] call assert_fails('sandbox set ' .. opt .. '?', 'E48:') + call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:') endfor + call assert_fails('sandbox let &modelineexpr = 1', 'E48:') endfunc " Test for setting an option with local value to global value diff --git a/test/old/testdir/test_perl.vim b/test/old/testdir/test_perl.vim index 558d0a5d6b..ce2a566f62 100644 --- a/test/old/testdir/test_perl.vim +++ b/test/old/testdir/test_perl.vim @@ -224,11 +224,11 @@ endfunc func Test_stdio() throw 'skipped: TODO: ' redir =>l:out - perl <<EOF + perl << trim EOF VIM::Msg("&VIM::Msg"); print "STDOUT"; print STDERR "STDERR"; -EOF + EOF redir END call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n")) endfunc @@ -305,7 +305,16 @@ END perl << VIM::DoCommand('let s ..= "B"') . - call assert_equal('AB', s) + perl << trim END + VIM::DoCommand('let s ..= "C"') + END + perl << trim + VIM::DoCommand('let s ..= "D"') + . + perl << trim eof + VIM::DoCommand('let s ..= "E"') + eof + call assert_equal('ABCDE', s) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_python2.vim b/test/old/testdir/test_python2.vim index 745b7da086..f21eb2c128 100644 --- a/test/old/testdir/test_python2.vim +++ b/test/old/testdir/test_python2.vim @@ -40,7 +40,7 @@ func Test_set_cursor() endfunc func Test_vim_function() - throw 'skipped: Nvim does not support vim.bindeval()' + throw 'Skipped: Nvim does not support vim.bindeval()' " Check creating vim.Function object py import vim @@ -171,3 +171,25 @@ func Test_Catch_Exception_Message() call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception ) endtry endfunc + +" Test for various heredoc syntax +func Test_python_heredoc() + python << END +s='A' +END + python << +s+='B' +. + python << trim END + s+='C' + END + python << trim + s+='D' + . + python << trim eof + s+='E' + eof + call assert_equal('ABCDE', pyxeval('s')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_python3.vim b/test/old/testdir/test_python3.vim index 69f5f6dcc0..23c63f22d8 100644 --- a/test/old/testdir/test_python3.vim +++ b/test/old/testdir/test_python3.vim @@ -40,7 +40,7 @@ func Test_set_cursor() endfunc func Test_vim_function() - throw 'skipped: Nvim does not support vim.bindeval()' + throw 'Skipped: Nvim does not support vim.bindeval()' " Check creating vim.Function object py3 import vim @@ -68,7 +68,7 @@ func Test_vim_function() endfunc func Test_skipped_python3_command_does_not_affect_pyxversion() - throw 'skipped: Nvim hardcodes pyxversion=3' + throw 'Skipped: Nvim hardcodes pyxversion=3' set pyxversion=0 if 0 python3 import vim @@ -190,3 +190,101 @@ func Test_unicode() set encoding=utf8 endfunc + +" Test for resetting options with local values to global values +func Test_python3_opt_reset_local_to_global() + throw 'Skipped: Nvim does not support vim.bindeval()' + new + + py3 curbuf = vim.current.buffer + py3 curwin = vim.current.window + + " List of buffer-local options. Each list item has [option name, global + " value, buffer-local value, buffer-local value after reset] to use in the + " test. + let bopts = [ + \ ['autoread', 1, 0, -1], + \ ['equalprg', 'geprg', 'leprg', ''], + \ ['keywordprg', 'gkprg', 'lkprg', ''], + \ ['path', 'gpath', 'lpath', ''], + \ ['backupcopy', 'yes', 'no', ''], + \ ['tags', 'gtags', 'ltags', ''], + \ ['tagcase', 'ignore', 'match', ''], + \ ['define', 'gdef', 'ldef', ''], + \ ['include', 'ginc', 'linc', ''], + \ ['dict', 'gdict', 'ldict', ''], + \ ['thesaurus', 'gtsr', 'ltsr', ''], + \ ['formatprg', 'gfprg', 'lfprg', ''], + \ ['errorformat', '%f:%l:%m', '%s-%l-%m', ''], + \ ['grepprg', 'ggprg', 'lgprg', ''], + \ ['makeprg', 'gmprg', 'lmprg', ''], + \ ['balloonexpr', 'gbexpr', 'lbexpr', ''], + \ ['cryptmethod', 'blowfish2', 'zip', ''], + \ ['lispwords', 'abc', 'xyz', ''], + \ ['makeencoding', 'utf-8', 'latin1', ''], + \ ['undolevels', 100, 200, -123456]] + + " Set the global and buffer-local option values and then clear the + " buffer-local option value. + for opt in bopts + py3 << trim END + pyopt = vim.bindeval("opt") + vim.options[pyopt[0]] = pyopt[1] + curbuf.options[pyopt[0]] = pyopt[2] + END + exe "call assert_equal(opt[2], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")" + py3 del curbuf.options[pyopt[0]] + exe "call assert_equal(opt[1], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")" + exe "set " .. opt[0] .. "&" + endfor + + " Set the global and window-local option values and then clear the + " window-local option value. + let wopts = [ + \ ['scrolloff', 5, 10, -1], + \ ['sidescrolloff', 6, 12, -1], + \ ['statusline', '%<%f', '%<%F', '']] + for opt in wopts + py3 << trim + pyopt = vim.bindeval("opt") + vim.options[pyopt[0]] = pyopt[1] + curwin.options[pyopt[0]] = pyopt[2] + . + exe "call assert_equal(opt[2], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")" + py3 del curwin.options[pyopt[0]] + exe "call assert_equal(opt[1], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")" + exe "set " .. opt[0] .. "&" + endfor + + close! +endfunc + +" Test for various heredoc syntax +func Test_python3_heredoc() + python3 << END +s='A' +END + python3 << +s+='B' +. + python3 << trim END + s+='C' + END + python3 << trim + s+='D' + . + python3 << trim eof + s+='E' + eof + call assert_equal('ABCDE', pyxeval('s')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_pyx2.vim b/test/old/testdir/test_pyx2.vim index eee825fa9b..74f4b187f0 100644 --- a/test/old/testdir/test_pyx2.vim +++ b/test/old/testdir/test_pyx2.vim @@ -15,10 +15,10 @@ endfunc func Test_pyx() redir => var - pyx << EOF -import sys -print(sys.version) -EOF + pyx << trim EOF + import sys + print(sys.version) + EOF redir END call assert_match(s:py2pattern, split(var)[0]) endfunc @@ -79,3 +79,25 @@ func Test_Catch_Exception_Message() call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception ) endtry endfunc + +" Test for various heredoc syntaxes +func Test_pyx2_heredoc() + pyx << END +result='A' +END + pyx << +result+='B' +. + pyx << trim END + result+='C' + END + pyx << trim + result+='D' + . + pyx << trim eof + result+='E' + eof + call assert_equal('ABCDE', pyxeval('result')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_pyx3.vim b/test/old/testdir/test_pyx3.vim index db39f5134a..09ece6f812 100644 --- a/test/old/testdir/test_pyx3.vim +++ b/test/old/testdir/test_pyx3.vim @@ -15,10 +15,10 @@ endfunc func Test_pyx() redir => var - pyx << EOF -import sys -print(sys.version) -EOF + pyx << trim EOF + import sys + print(sys.version) + EOF redir END call assert_match(s:py3pattern, split(var)[0]) endfunc @@ -79,3 +79,25 @@ func Test_Catch_Exception_Message() call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception ) endtry endfunc + +" Test for various heredoc syntaxes +func Test_pyx3_heredoc() + pyx << END +result='A' +END + pyx << +result+='B' +. + pyx << trim END + result+='C' + END + pyx << trim + result+='D' + . + pyx << trim eof + result+='E' + eof + call assert_equal('ABCDE', pyxeval('result')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_ruby.vim b/test/old/testdir/test_ruby.vim index 1fbf3392d9..4929496086 100644 --- a/test/old/testdir/test_ruby.vim +++ b/test/old/testdir/test_ruby.vim @@ -341,11 +341,11 @@ func Test_ruby_Vim_evaluate_list() call setline(line('$'), ['2 line 2']) ruby Vim.command("normal /^2\n") let l = ["abc", "def"] - ruby << EOF - curline = $curbuf.line_number - l = Vim.evaluate("l"); - $curbuf.append(curline, l.join("|")) -EOF + ruby << trim EOF + curline = $curbuf.line_number + l = Vim.evaluate("l"); + $curbuf.append(curline, l.join("|")) + EOF normal j .rubydo $_ = $_.gsub(/\|/, '/') call assert_equal('abc/def', getline('$')) @@ -414,4 +414,24 @@ func Test_rubyeval_error() call assert_fails('call rubyeval("(")') endfunc +" Test for various heredoc syntax +func Test_ruby_heredoc() + ruby << END +Vim.command('let s = "A"') +END + ruby << +Vim.command('let s ..= "B"') +. + ruby << trim END + Vim.command('let s ..= "C"') + END + ruby << trim + Vim.command('let s ..= "D"') + . + ruby << trim eof + Vim.command('let s ..= "E"') + eof + call assert_equal('ABCDE', s) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim index ee8b52caaf..4678a51d60 100644 --- a/test/old/testdir/test_undo.vim +++ b/test/old/testdir/test_undo.vim @@ -126,6 +126,11 @@ func Test_global_local_undolevels() call assert_equal(50, &g:undolevels) call assert_equal(-123456, &l:undolevels) + " Resetting the local 'undolevels' value to use the global value + setlocal undolevels=5 + setlocal undolevels< + call assert_equal(-123456, &l:undolevels) + " Drop created windows set ul& new diff --git a/test/old/testdir/test_vimscript.vim b/test/old/testdir/test_vimscript.vim index 055a2bd2f2..68ce493927 100644 --- a/test/old/testdir/test_vimscript.vim +++ b/test/old/testdir/test_vimscript.vim @@ -6705,6 +6705,11 @@ func Test_echo_and_string() let l = split(result, "\n") call assert_equal(["{'a': [], 'b': []}", \ "{'a': [], 'b': []}"], l) + + call assert_fails('echo &:', 'E112:') + call assert_fails('echo &g:', 'E112:') + call assert_fails('echo &l:', 'E112:') + endfunc "------------------------------------------------------------------------------- |