To: vim_dev@googlegroups.com Subject: Patch 9.0.0475 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0475 Problem: Not using deferred delete in tests. Solution: Use deferred delete more often. Files: src/testdir/test_vim9_script.vim *** ../vim-9.0.0474/src/testdir/test_vim9_script.vim 2022-09-14 00:30:47.081316534 +0100 --- src/testdir/test_vim9_script.vim 2022-09-15 22:22:51.742580991 +0100 *************** *** 400,410 **** # need to execute this with a separate Vim instance to avoid the current # context gets garbage collected. ! writefile(lines, 'Xscript') g:RunVim([], [], '-S Xscript') assert_equal(['ok'], readfile('Xdidit')) - delete('Xscript') delete('Xdidit') enddef --- 400,409 ---- # need to execute this with a separate Vim instance to avoid the current # context gets garbage collected. ! writefile(lines, 'Xscript', 'D') g:RunVim([], [], '-S Xscript') assert_equal(['ok'], readfile('Xdidit')) delete('Xdidit') enddef *************** *** 991,1003 **** writefile([getqflist({idx: 0}).idx], 'Xcncresult') qall END ! writefile(lines, 'XCatchCnext') g:RunVim([], [], '--clean -S XCatchCnext') assert_equal(['1'], readfile('Xcncresult')) delete('Xcncfile1') delete('Xcncfile2') - delete('XCatchCnext') delete('Xcncresult') enddef --- 990,1001 ---- writefile([getqflist({idx: 0}).idx], 'Xcncresult') qall END ! writefile(lines, 'XCatchCnext', 'D') g:RunVim([], [], '--clean -S XCatchCnext') assert_equal(['1'], readfile('Xcncresult')) delete('Xcncfile1') delete('Xcncfile2') delete('Xcncresult') enddef *************** *** 1015,1023 **** enddef silent! Func() END ! writefile(lines, 'XthrowSilenced') source XthrowSilenced - delete('XthrowSilenced') enddef def DeletedFunc(): list --- 1013,1020 ---- enddef silent! Func() END ! writefile(lines, 'XthrowSilenced', 'D') source XthrowSilenced enddef def DeletedFunc(): list *************** *** 1473,1479 **** END # FuncNo() is defined ! writefile(first_lines + withno_lines, 'Xreloaded.vim') source Xreloaded.vim g:DoCheck(true) --- 1470,1476 ---- END # FuncNo() is defined ! writefile(first_lines + withno_lines, 'Xreloaded.vim', 'D') source Xreloaded.vim g:DoCheck(true) *************** *** 1486,1493 **** writefile(first_lines + withno_lines, 'Xreloaded.vim') source Xreloaded.vim g:DoCheck(false) - - delete('Xreloaded.vim') enddef def Test_vim9script_reload_delvar() --- 1483,1488 ---- *************** *** 1496,1502 **** vim9script var name = 'string' END ! writefile(lines, 'XreloadVar.vim') source XreloadVar.vim # now write the script using the same variable locally - works --- 1491,1497 ---- vim9script var name = 'string' END ! writefile(lines, 'XreloadVar.vim', 'D') source XreloadVar.vim # now write the script using the same variable locally - works *************** *** 1508,1515 **** END writefile(lines, 'XreloadVar.vim') source XreloadVar.vim - - delete('XreloadVar.vim') enddef def Test_func_redefine_error() --- 1503,1508 ---- *************** *** 1520,1526 **** 'enddef', 'Func()', ] ! writefile(lines, 'Xtestscript.vim') for count in range(3) try --- 1513,1519 ---- 'enddef', 'Func()', ] ! writefile(lines, 'Xtestscript.vim', 'D') for count in range(3) try *************** *** 1531,1538 **** assert_match('function \d\+_Func, line 1', v:throwpoint) endtry endfor - - delete('Xtestscript.vim') enddef def Test_func_redefine_fails() --- 1524,1529 ---- *************** *** 2035,2043 **** endfor assert_equal(' loop 1 loop 2 loop 3', result) END ! writefile(lines, 'Xvim9for.vim') source Xvim9for.vim - delete('Xvim9for.vim') enddef def Test_for_skipped_block() --- 2026,2033 ---- endfor assert_equal(' loop 1 loop 2 loop 3', result) END ! writefile(lines, 'Xvim9for.vim', 'D') source Xvim9for.vim enddef def Test_for_skipped_block() *************** *** 2271,2276 **** --- 2261,2278 ---- END v9.CheckDefAndScriptSuccess(lines) + # also works when the loop variable is used only once halfway the loops + lines =<< trim END + var Clo: func + for i in range(5) + if i == 3 + Clo = () => i + endif + endfor + assert_equal(4, Clo()) + END + v9.CheckDefAndScriptSuccess(lines) + # using a local variable set to the loop variable in a closure results in the # value at that moment lines =<< trim END *************** *** 3330,3341 **** finish g:res = 'three' END ! writefile(lines, 'Xfinished') source Xfinished assert_equal('two', g:res) unlet g:res - delete('Xfinished') enddef def Test_forward_declaration() --- 3332,3342 ---- finish g:res = 'three' END ! writefile(lines, 'Xfinished', 'D') source Xfinished assert_equal('two', g:res) unlet g:res enddef def Test_forward_declaration() *************** *** 3349,3362 **** theVal = 'else' g:laterVal = GetValue() END ! writefile(lines, 'Xforward') source Xforward assert_equal('something', g:initVal) assert_equal('else', g:laterVal) unlet g:initVal unlet g:laterVal - delete('Xforward') enddef def Test_declare_script_var_in_func() --- 3350,3362 ---- theVal = 'else' g:laterVal = GetValue() END ! writefile(lines, 'Xforward', 'D') source Xforward assert_equal('something', g:initVal) assert_equal('else', g:laterVal) unlet g:initVal unlet g:laterVal enddef def Test_declare_script_var_in_func() *************** *** 3408,3414 **** echo 'local' enddef END ! call writefile(vim9lines, 'Xvim9script.vim') source Xvim9script.vim try echo g:var --- 3408,3414 ---- echo 'local' enddef END ! call writefile(vim9lines, 'Xvim9script.vim', 'D') source Xvim9script.vim try echo g:var *************** *** 3428,3435 **** catch /E117:/ " caught endtry - - call delete('Xvim9script.vim') endfunc def Test_vim9_copen() --- 3428,3433 ---- *************** *** 3459,3465 **** var save_rtp = &rtp var dir = getcwd() .. '/Xruntime' &rtp = dir ! mkdir(dir .. '/autoload', 'p') var lines =<< trim END vim9script noclear --- 3457,3463 ---- var save_rtp = &rtp var dir = getcwd() .. '/Xruntime' &rtp = dir ! mkdir(dir .. '/autoload', 'pR') var lines =<< trim END vim9script noclear *************** *** 3492,3503 **** v9.CheckScriptSuccess(lines) &rtp = save_rtp - delete(dir, 'rf') enddef def Test_error_in_autoload_script_foldexpr() var save_rtp = &rtp ! mkdir('Xvim/autoload', 'p') &runtimepath = 'Xvim' var lines =<< trim END --- 3490,3500 ---- v9.CheckScriptSuccess(lines) &rtp = save_rtp enddef def Test_error_in_autoload_script_foldexpr() var save_rtp = &rtp ! mkdir('Xvim/autoload', 'pR') &runtimepath = 'Xvim' var lines =<< trim END *************** *** 3515,3522 **** redraw END v9.CheckScriptFailure(lines, 'E684: List index out of range: 0') - - delete('Xvim', 'rf') enddef def Test_invalid_sid() --- 3512,3517 ---- *************** *** 3529,3544 **** enddef def Test_restoring_cpo() ! writefile(['vim9script', 'set nocp'], 'Xsourced') ! writefile(['call writefile(["done"], "Xdone")', 'quit!'], 'Xclose') if g:RunVim([], [], '-u NONE +"set cpo+=a" -S Xsourced -S Xclose') assert_equal(['done'], readfile('Xdone')) endif - delete('Xsourced') - delete('Xclose') delete('Xdone') ! writefile(['vim9script', 'g:cpoval = &cpo'], 'XanotherScript') set cpo=aABceFsMny> edit XanotherScript so % --- 3524,3537 ---- enddef def Test_restoring_cpo() ! writefile(['vim9script', 'set nocp'], 'Xsourced', 'D') ! writefile(['call writefile(["done"], "Xdone")', 'quit!'], 'Xclose', 'D') if g:RunVim([], [], '-u NONE +"set cpo+=a" -S Xsourced -S Xclose') assert_equal(['done'], readfile('Xdone')) endif delete('Xdone') ! writefile(['vim9script', 'g:cpoval = &cpo'], 'XanotherScript', 'D') set cpo=aABceFsMny> edit XanotherScript so % *************** *** 3551,3557 **** assert_equal('aABceFsMny>', &cpo) assert_equal('aABceFsMny>', g:cpoval) - delete('XanotherScript') set cpo&vim unlet g:cpoval --- 3544,3549 ---- *************** *** 3559,3565 **** # 'cpo' is not restored in main vimrc var save_HOME = $HOME $HOME = getcwd() .. '/Xhome' ! mkdir('Xhome') var lines =<< trim END vim9script writefile(['before: ' .. &cpo], 'Xrporesult') --- 3551,3557 ---- # 'cpo' is not restored in main vimrc var save_HOME = $HOME $HOME = getcwd() .. '/Xhome' ! mkdir('Xhome', 'R') var lines =<< trim END vim9script writefile(['before: ' .. &cpo], 'Xrporesult') *************** *** 3571,3584 **** lines =<< trim END call writefile(['later: ' .. &cpo], 'Xrporesult', 'a') END ! writefile(lines, 'Xlegacy') lines =<< trim END vim9script call writefile(['vim9: ' .. &cpo], 'Xrporesult', 'a') qa END ! writefile(lines, 'Xvim9') var cmd = g:GetVimCommand() .. " -S Xlegacy -S Xvim9" cmd = substitute(cmd, '-u NONE', '', '') --- 3563,3576 ---- lines =<< trim END call writefile(['later: ' .. &cpo], 'Xrporesult', 'a') END ! writefile(lines, 'Xlegacy', 'D') lines =<< trim END vim9script call writefile(['vim9: ' .. &cpo], 'Xrporesult', 'a') qa END ! writefile(lines, 'Xvim9', 'D') var cmd = g:GetVimCommand() .. " -S Xlegacy -S Xvim9" cmd = substitute(cmd, '-u NONE', '', '') *************** *** 3591,3599 **** 'vim9: aABceFs'], readfile('Xrporesult')) $HOME = save_HOME - delete('Xhome', 'rf') - delete('Xlegacy') - delete('Xvim9') delete('Xrporesult') endif enddef --- 3583,3588 ---- *************** *** 3611,3617 **** export def Func() enddef END ! mkdir('Xnordir/autoload', 'p') writefile(lines, 'Xnordir/autoload/script.vim') lines =<< trim END --- 3600,3606 ---- export def Func() enddef END ! mkdir('Xnordir/autoload', 'pR') writefile(lines, 'Xnordir/autoload/script.vim') lines =<< trim END *************** *** 3621,3627 **** au CmdlineEnter : ++once timer_start(0, (_) => script#Func()) setline(1, 'some text') END ! writefile(lines, 'XTest_redraw_cpo') var buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) term_sendkeys(buf, "V:") g:VerifyScreenDump(buf, 'Test_vim9_no_redraw', {}) --- 3610,3616 ---- au CmdlineEnter : ++once timer_start(0, (_) => script#Func()) setline(1, 'some text') END ! writefile(lines, 'XTest_redraw_cpo', 'D') var buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) term_sendkeys(buf, "V:") g:VerifyScreenDump(buf, 'Test_vim9_no_redraw', {}) *************** *** 3629,3636 **** # clean up term_sendkeys(buf, "\u") g:StopVimInTerminal(buf) - delete('XTest_redraw_cpo') - delete('Xnordir', 'rf') enddef func Test_reject_declaration() --- 3618,3623 ---- *************** *** 3731,3738 **** call writefile(['errors: ' .. string(v:errors)], 'Xdidcmd') endfunc END ! writefile([''], 'Xdidcmd') ! writefile(lines, 'XcallFunc') var buf = g:RunVimInTerminal('-S XcallFunc', {rows: 6}) # define Afunc() on the command line term_sendkeys(buf, ":def Afunc()\Bfunc()\enddef\") --- 3718,3725 ---- call writefile(['errors: ' .. string(v:errors)], 'Xdidcmd') endfunc END ! writefile([''], 'Xdidcmd', 'D') ! writefile(lines, 'XcallFunc', 'D') var buf = g:RunVimInTerminal('-S XcallFunc', {rows: 6}) # define Afunc() on the command line term_sendkeys(buf, ":def Afunc()\Bfunc()\enddef\") *************** *** 3740,3747 **** g:WaitForAssert(() => assert_equal(['errors: []'], readfile('Xdidcmd'))) call g:StopVimInTerminal(buf) - delete('XcallFunc') - delete('Xdidcmd') enddef def Test_script_var_scope() --- 3727,3732 ---- *************** *** 3869,3877 **** sleep 10m endfor END ! writefile(lines, 'Xdef') assert_fails('so Xdef', ['E684:', 'E1012:']) - delete('Xdef') enddef def InvokeNormal() --- 3854,3861 ---- sleep 10m endfor END ! writefile(lines, 'Xdef', 'D') assert_fails('so Xdef', ['E684:', 'E1012:']) enddef def InvokeNormal() *************** *** 3914,3920 **** name = arg enddef END ! writefile(lines, 'XscriptTwice.vim') so XscriptTwice.vim assert_equal('thename', g:GetName()) g:SetName('newname') --- 3898,3904 ---- name = arg enddef END ! writefile(lines, 'XscriptTwice.vim', 'D') so XscriptTwice.vim assert_equal('thename', g:GetName()) g:SetName('newname') *************** *** 3925,3931 **** delfunc g:GetName delfunc g:SetName - delete('XscriptTwice.vim') unlet g:guard enddef --- 3909,3914 ---- *************** *** 4102,4108 **** breakadd func Func Func() END ! writefile(lines, 'XdebugFunc') var buf = g:RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) --- 4085,4091 ---- breakadd func Func Func() END ! writefile(lines, 'XdebugFunc', 'D') var buf = g:RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) *************** *** 4110,4116 **** g:WaitForAssert(() => assert_match('\[0\]', term_getline(buf, 5))) g:StopVimInTerminal(buf) - delete('XdebugFunc') enddef func Test_debug_running_out_of_lines() --- 4093,4098 ---- *************** *** 4138,4144 **** breakadd func Crash Crash() END ! writefile(lines, 'XdebugFunc') var buf = g:RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) --- 4120,4126 ---- breakadd func Crash Crash() END ! writefile(lines, 'XdebugFunc', 'D') var buf = g:RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) *************** *** 4150,4156 **** g:TermWait(buf) g:StopVimInTerminal(buf) - delete('XdebugFunc') enddef def Test_ambigous_command_error() --- 4132,4137 ---- *************** *** 4239,4245 **** writefile([result], 'Xdidprofile') endtry END ! writefile(lines, 'Xprofile.vim') call system(g:GetVimCommand() .. ' --clean' .. ' -c "so Xprofile.vim"' --- 4220,4226 ---- writefile([result], 'Xdidprofile') endtry END ! writefile(lines, 'Xprofile.vim', 'D') call system(g:GetVimCommand() .. ' --clean' .. ' -c "so Xprofile.vim"' *************** *** 4250,4256 **** assert_true(filereadable('Xprofile.log')) delete('Xdidprofile') delete('Xprofile.log') - delete('Xprofile.vim') enddef func Test_misplaced_type() --- 4231,4236 ---- *************** *** 4323,4332 **** assert_equal('otherthing', getline(1)) bwipe! END ! writefile(lines, 'Xvim9lines') source Xvim9lines - - delete('Xvim9lines') enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker --- 4303,4310 ---- assert_equal('otherthing', getline(1)) bwipe! END ! writefile(lines, 'Xvim9lines', 'D') source Xvim9lines enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-9.0.0474/src/version.c 2022-09-15 22:03:53.044239596 +0100 --- src/version.c 2022-09-15 22:24:08.166471909 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 475, /**/ -- From "know your smileys": ¯\_(ツ)_/¯ Shrug /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///