aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-16 08:26:42 +0800
committerGitHub <noreply@github.com>2023-04-16 08:26:42 +0800
commit6adfd24a066c207334609a6b149ada19c0f568d4 (patch)
tree81b42fdaa5eb44ddc259fb8b1c10116fc99baebe
parentc08b03076167837cff9eb66c19440d727e6dad31 (diff)
downloadrneovim-6adfd24a066c207334609a6b149ada19c0f568d4.tar.gz
rneovim-6adfd24a066c207334609a6b149ada19c0f568d4.tar.bz2
rneovim-6adfd24a066c207334609a6b149ada19c0f568d4.zip
vim-patch:8.2.4716: memory allocation failure not tested when defining a function (#23117)
Problem: Memory allocation failure not tested when defining a function. Solution: Add a test. (Yegappan Lakshmanan, closes vim/vim#10127) https://github.com/vim/vim/commit/7c7e19cf50d76568e2637ad66b095044a41c6a82 test_alloc_fail() is N/A. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r--test/old/testdir/test_user_func.vim31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim
index 4742293ed5..f475803ce1 100644
--- a/test/old/testdir/test_user_func.vim
+++ b/test/old/testdir/test_user_func.vim
@@ -501,4 +501,35 @@ func Test_func_range()
bwipe!
endfunc
+" Test for memory allocation failure when defining a new function
+func Test_funcdef_alloc_failure()
+ CheckFunction test_alloc_fail
+ 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