Mercurial > vim
diff src/testdir/test_viml.vim @ 10573:3f777388b6ad v8.0.0176
patch 8.0.0176: cannot use :change inside a function definition
commit https://github.com/vim/vim/commit/70bcd7336f9f19304f32c52a86ed5b4b3de852c2
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 12 22:20:54 2017 +0100
patch 8.0.0176: cannot use :change inside a function definition
Problem: Using :change in between :function and :endfunction fails.
Solution: Recognize :change inside a function. (ichizok, closes https://github.com/vim/vim/issues/1374)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 12 Jan 2017 22:30:04 +0100 |
parents | 05a56bbe34a1 |
children | 77d66e9ac0ab |
line wrap: on
line diff
--- a/src/testdir/test_viml.vim +++ b/src/testdir/test_viml.vim @@ -1239,6 +1239,77 @@ func Test_num64() endfunc "------------------------------------------------------------------------------- +" Test 95: lines of :append, :change, :insert {{{1 +"------------------------------------------------------------------------------- + +function! DefineFunction(name, body) + let func = join(['function! ' . a:name . '()'] + a:body + ['endfunction'], "\n") + exec func +endfunction + +func Test_script_lines() + " :append + try + call DefineFunction('T_Append', [ + \ 'append', + \ 'py <<EOS', + \ '.', + \ ]) + catch + call assert_false(1, "Can't define function") + endtry + try + call DefineFunction('T_Append', [ + \ 'append', + \ 'abc', + \ ]) + call assert_false(1, "Shouldn't be able to define function") + catch + call assert_exception('Vim(function):E126: Missing :endfunction') + endtry + + " :change + try + call DefineFunction('T_Change', [ + \ 'change', + \ 'py <<EOS', + \ '.', + \ ]) + catch + call assert_false(1, "Can't define function") + endtry + try + call DefineFunction('T_Change', [ + \ 'change', + \ 'abc', + \ ]) + call assert_false(1, "Shouldn't be able to define function") + catch + call assert_exception('Vim(function):E126: Missing :endfunction') + endtry + + " :insert + try + call DefineFunction('T_Insert', [ + \ 'insert', + \ 'py <<EOS', + \ '.', + \ ]) + catch + call assert_false(1, "Can't define function") + endtry + try + call DefineFunction('T_Insert', [ + \ 'insert', + \ 'abc', + \ ]) + call assert_false(1, "Shouldn't be able to define function") + catch + call assert_exception('Vim(function):E126: Missing :endfunction') + endtry +endfunc + +"------------------------------------------------------------------------------- " Modelines {{{1 " vim: ts=8 sw=4 tw=80 fdm=marker " vim: fdt=substitute(substitute(foldtext(),\ '\\%(^+--\\)\\@<=\\(\\s*\\)\\(.\\{-}\\)\:\ \\%(\"\ \\)\\=\\(Test\ \\d*\\)\:\\s*',\ '\\3\ (\\2)\:\ \\1',\ \"\"),\ '\\(Test\\s*\\)\\(\\d\\)\\D\\@=',\ '\\1\ \\2',\ "")