Mercurial > vim
diff src/testdir/test_vim9_disassemble.vim @ 24220:a7a9176bb542 v8.2.2651
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Commit: https://github.com/vim/vim/commit/a91a71322dc2e6a1640e73b6da1f1a2f94f39a54
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 25 21:12:15 2021 +0100
patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Problem: Vim9: restoring command modifiers happens after jump.
Solution: Move the restore instruction to before the jump. (closes https://github.com/vim/vim/issues/8006)
Also handle for and while.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Mar 2021 21:15:04 +0100 |
parents | c308076e225e |
children | a2e6029d354e |
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -1896,7 +1896,95 @@ def Test_silent() '\d PUSHS "error"\_s*' .. '\d ECHOERR 1\_s*' .. '\d CMDMOD_REV\_s*' .. - '\d RETURN 0', + '\d\+ RETURN 0', + res) +enddef + +def s:SilentIf() + silent if 4 == g:five + silent elseif 4 == g:five + silent endif +enddef + +def Test_silent_if() + var res = execute('disass s:SilentIf') + assert_match('<SNR>\d*_SilentIf\_s*' .. + 'silent if 4 == g:five\_s*' .. + '\d\+ CMDMOD silent\_s*' .. + '\d\+ PUSHNR 4\_s*' .. + '\d\+ LOADG g:five\_s*' .. + '\d\+ COMPAREANY ==\_s*' .. + '\d\+ CMDMOD_REV\_s*' .. + '\d\+ JUMP_IF_FALSE -> \d\+\_s*' .. + 'silent elseif 4 == g:five\_s*' .. + '\d\+ JUMP -> \d\+\_s*' .. + '\d\+ CMDMOD silent\_s*' .. + '\d\+ PUSHNR 4\_s*' .. + '\d\+ LOADG g:five\_s*' .. + '\d\+ COMPAREANY ==\_s*' .. + '\d\+ CMDMOD_REV\_s*' .. + '\d\+ JUMP_IF_FALSE -> \d\+\_s*' .. + 'silent endif\_s*' .. + '\d\+ RETURN 0', + res) +enddef + +def s:SilentFor() + silent for i in [0] + silent endfor +enddef + +def Test_silent_for() + var res = execute('disass s:SilentFor') + assert_match('<SNR>\d*_SilentFor\_s*' .. + 'silent for i in \[0\]\_s*' .. + '\d CMDMOD silent\_s*' .. + '\d STORE -1 in $0\_s*' .. + '\d PUSHNR 0\_s*' .. + '\d NEWLIST size 1\_s*' .. + '\d CMDMOD_REV\_s*' .. + '5 FOR $0 -> 8\_s*' .. + '\d STORE $1\_s*' .. + 'silent endfor\_s*' .. + '\d JUMP -> 5\_s*' .. + '8 DROP\_s*' .. + '\d RETURN 0\_s*', + res) +enddef + +def s:SilentWhile() + silent while g:not + silent endwhile +enddef + +def Test_silent_while() + var res = execute('disass s:SilentWhile') + assert_match('<SNR>\d*_SilentWhile\_s*' .. + 'silent while g:not\_s*' .. + '0 CMDMOD silent\_s*' .. + '\d LOADG g:not\_s*' .. + '\d COND2BOOL\_s*' .. + '\d CMDMOD_REV\_s*' .. + '\d JUMP_IF_FALSE -> 6\_s*' .. + + 'silent endwhile\_s*' .. + '\d JUMP -> 0\_s*' .. + '6 RETURN 0\_s*', + res) +enddef + +def s:SilentReturn(): string + silent return "done" +enddef + +def Test_silent_return() + var res = execute('disass s:SilentReturn') + assert_match('<SNR>\d*_SilentReturn\_s*' .. + 'silent return "done"\_s*' .. + '\d CMDMOD silent\_s*' .. + '\d PUSHS "done"\_s*' .. + '\d CMDMOD_REV\_s*' .. + '\d RETURN', res) enddef @@ -1924,19 +2012,5 @@ def Test_profiled() res) enddef -def s:SilentReturn(): string - silent return "done" -enddef - -def Test_silent_return() - var res = execute('disass s:SilentReturn') - assert_match('<SNR>\d*_SilentReturn\_s*' .. - 'silent return "done"\_s*' .. - '\d CMDMOD silent\_s*' .. - '\d PUSHS "done"\_s*' .. - '\d CMDMOD_REV\_s*' .. - '\d RETURN', - res) -enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker