comparison src/testdir/test_user_func.vim @ 30140:3b42bdfff7cb v9.0.0406

patch 9.0.0406: deferred functions not invoked when partial func exits Commit: https://github.com/vim/vim/commit/9667b2c888351b04751bdb43cba0d4ffc8c13ab1 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 7 17:28:09 2022 +0100 patch 9.0.0406: deferred functions not invoked when partial func exits Problem: Deferred functions not invoked when partial func exits. Solution: Create a funccall_T when calling a :def function.
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Sep 2022 18:30:03 +0200
parents 6575d0bf6061
children d1c04b4dc60d
comparison
equal deleted inserted replaced
30139:8ad813820fa0 30140:3b42bdfff7cb
623 call assert_equal(0, v:shell_error) 623 call assert_equal(0, v:shell_error)
624 call assert_false(filereadable('XQuitallOne')) 624 call assert_false(filereadable('XQuitallOne'))
625 call assert_false(filereadable('XQuitallTwo')) 625 call assert_false(filereadable('XQuitallTwo'))
626 endfunc 626 endfunc
627 627
628 func Test_defer_quitall_in_expr_func()
629 let lines =<< trim END
630 def DefIndex(idx: number, val: string): bool
631 call writefile([idx .. ': ' .. val], 'Xentry' .. idx, 'D')
632 if val == 'b'
633 qa!
634 endif
635 return val == 'c'
636 enddef
637
638 def Test_defer_in_funcref()
639 assert_equal(2, indexof(['a', 'b', 'c'], funcref('g:DefIndex')))
640 enddef
641 call Test_defer_in_funcref()
642 END
643 call writefile(lines, 'XdeferQuitallExpr', 'D')
644 let res = system(GetVimCommandClean() .. ' -X -S XdeferQuitallExpr')
645 call assert_equal(0, v:shell_error)
646 call assert_false(filereadable('Xentry0'))
647 call assert_false(filereadable('Xentry1'))
648 call assert_false(filereadable('Xentry2'))
649 endfunc
650
628 func FuncIndex(idx, val) 651 func FuncIndex(idx, val)
629 call writefile([a:idx .. ': ' .. a:val], 'Xentry' .. a:idx, 'D') 652 call writefile([a:idx .. ': ' .. a:val], 'Xentry' .. a:idx, 'D')
630 return a:val == 'c' 653 return a:val == 'c'
631 endfunc 654 endfunc
632 655