comparison src/testdir/test_vim9_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 b0c885507de4
children c428a4e53b9c
comparison
equal deleted inserted replaced
28381:ddc656bfc2b9 28382:f24d4826e6bf
4069 defcompile 4069 defcompile
4070 END 4070 END
4071 v9.CheckScriptFailure(lines, 'E476:') 4071 v9.CheckScriptFailure(lines, 'E476:')
4072 enddef 4072 enddef
4073 4073
4074 " Test for memory allocation failure when defining a new lambda
4075 func Test_lambda_allocation_failure()
4076 new
4077 let lines =<< trim END
4078 vim9script
4079 g:Xlambda = (x): number => {
4080 return x + 1
4081 }
4082 END
4083 call setline(1, lines)
4084 call test_alloc_fail(GetAllocId('get_func'), 0, 0)
4085 call assert_fails('source', 'E342:')
4086 call assert_false(exists('g:Xlambda'))
4087 bw!
4088 endfunc
4089
4074 " The following messes up syntax highlight, keep near the end. 4090 " The following messes up syntax highlight, keep near the end.
4075 if has('python3') 4091 if has('python3')
4076 def Test_python3_command() 4092 def Test_python3_command()
4077 py3 import vim 4093 py3 import vim
4078 py3 vim.command("g:done = 'yes'") 4094 py3 vim.command("g:done = 'yes'")