Mercurial > vim
diff src/testdir/test_user_func.vim @ 28382:f24d4826e6bf v8.2.4716
patch 8.2.4716: memory allocation failure not tested when defining a function
Commit: https://github.com/vim/vim/commit/7c7e19cf50d76568e2637ad66b095044a41c6a82
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Apr 9 11:09:07 2022 +0100
patch 8.2.4716: memory allocation failure not tested when defining a function
Problem: Memory allocation failure not tested when defining a function.
Solution: Add a test. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/10127)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 09 Apr 2022 12:15:02 +0200 |
parents | 3a2b222107a6 |
children | 6cf788ab844c |
line wrap: on
line diff
--- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -499,4 +499,34 @@ func Test_func_range() bwipe! endfunc +" Test for memory allocation failure when defining a new function +func Test_funcdef_alloc_failure() + new + let lines =<< trim END + func Xtestfunc() + return 321 + endfunc + END + call setline(1, lines) + call test_alloc_fail(GetAllocId('get_func'), 0, 0) + call assert_fails('source', 'E342:') + call assert_false(exists('*Xtestfunc')) + call assert_fails('delfunc Xtestfunc', 'E117:') + %d _ + let lines =<< trim END + def g:Xvim9func(): number + return 456 + enddef + END + call setline(1, lines) + call test_alloc_fail(GetAllocId('get_func'), 0, 0) + call assert_fails('source', 'E342:') + call assert_false(exists('*Xvim9func')) + "call test_alloc_fail(GetAllocId('get_func'), 0, 0) + "call assert_fails('source', 'E342:') + "call assert_false(exists('*Xtestfunc')) + "call assert_fails('delfunc Xtestfunc', 'E117:') + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab