From f6ced9863f931758a4cee0b6546e77d21150806d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 28 Apr 2022 12:00:49 +0100 Subject: patch 8.2.4836: Vim9: some lines not covered by tests Problem: Vim9: some lines not covered by tests. Solution: Remove dead code. Add disassemble tests. --- src/testdir/test_vim9_disassemble.vim | 65 +++++++++++++++++++++++++++++++++-- src/version.c | 2 ++ src/vim9.h | 1 - src/vim9execute.c | 20 +++-------- 4 files changed, 69 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index 086522ea3..363d731a4 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -265,6 +265,7 @@ enddef def s:PutRange() :$-2put a + :$-3put! b enddef def Test_disassemble_put_range() @@ -273,6 +274,10 @@ def Test_disassemble_put_range() ' :$-2put a\_s*' .. '\d RANGE $-2\_s*' .. '\d PUT a range\_s*' .. + + ' :$-3put! b\_s*' .. + '\d RANGE $-3\_s*' .. + '\d PUT b above range\_s*' .. '\d RETURN void', res) enddef @@ -684,6 +689,10 @@ def s:ScriptFuncUnlet() unlet g:somevar unlet! g:somevar unlet $SOMEVAR + + var l = [1, 2, 3] + unlet l[2] + unlet l[0 : 1] enddef def Test_disassemble_unlet() @@ -697,13 +706,33 @@ def Test_disassemble_unlet() 'unlet! g:somevar\_s*' .. '\d UNLET! g:somevar\_s*' .. 'unlet $SOMEVAR\_s*' .. - '\d UNLETENV $SOMEVAR\_s*', + '\d UNLETENV $SOMEVAR\_s*' .. + + 'var l = \[1, 2, 3]\_s*' .. + '\d\+ PUSHNR 1\_s*' .. + '\d\+ PUSHNR 2\_s*' .. + '\d\+ PUSHNR 3\_s*' .. + '\d\+ NEWLIST size 3\_s*' .. + '\d\+ SETTYPE list\_s*' .. + '\d\+ STORE $0\_s*' .. + + 'unlet l\[2]\_s*' .. + '\d\+ PUSHNR 2\_s*' .. + '\d\+ LOAD $0\_s*' .. + '\d\+ UNLETINDEX\_s*' .. + + 'unlet l\[0 : 1]\_s*' .. + '\d\+ PUSHNR 0\_s*' .. + '\d\+ PUSHNR 1\_s*' .. + '\d\+ LOAD $0\_s*' .. + '\d\+ UNLETRANGE\_s*', res) enddef def s:LockLocal() var d = {a: 1} lockvar d.a + const nr = 22 enddef def Test_disassemble_lock_local() @@ -717,7 +746,12 @@ def Test_disassemble_lock_local() '\d STORE $0\_s*' .. 'lockvar d.a\_s*' .. '\d LOAD $0\_s*' .. - '\d LOCKUNLOCK lockvar 2 d.a\_s*', + '\d LOCKUNLOCK lockvar 2 d.a\_s*' .. + + 'const nr = 22\_s*' .. + '\d\+ PUSHNR 22\_s*' .. + '\d\+ LOCKCONST\_s*' .. + '\d\+ STORE $1', res) enddef @@ -2186,6 +2220,33 @@ def Test_disassemble_range_only() res) enddef +def s:StoreRange() + var l = [1, 2] + l[0 : 1] = [7, 8] +enddef + +def Test_disassemble_store_range() + var res = execute('disass s:StoreRange') + assert_match('\\d*_StoreRange\_s*' .. + 'var l = \[1, 2]\_s*' .. + '\d PUSHNR 1\_s*' .. + '\d PUSHNR 2\_s*' .. + '\d NEWLIST size 2\_s*' .. + '\d SETTYPE list\_s*' .. + '\d STORE $0\_s*' .. + + 'l\[0 : 1] = \[7, 8]\_s*' .. + '\d\+ PUSHNR 7\_s*' .. + '\d\+ PUSHNR 8\_s*' .. + '\d\+ NEWLIST size 2\_s*' .. + '\d\+ PUSHNR 0\_s*' .. + '\d\+ PUSHNR 1\_s*' .. + '\d\+ LOAD $0\_s*' .. + '\d\+ STORERANGE\_s*' .. + '\d\+ RETURN void', + res) +enddef + def s:Echomsg() echomsg 'some' 'message' echoconsole 'nothing' diff --git a/src/version.c b/src/version.c index fa0303c08..53afc3776 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4836, /**/ 4835, /**/ diff --git a/src/vim9.h b/src/vim9.h index c92b05fcf..3b14ffc73 100644 --- a/src/vim9.h +++ b/src/vim9.h @@ -239,7 +239,6 @@ typedef enum { JUMP_NEVER, JUMP_IF_FALSE, // pop and jump if false JUMP_AND_KEEP_IF_TRUE, // jump if top of stack is truthy, drop if not - JUMP_AND_KEEP_IF_FALSE, // jump if top of stack is falsy, drop if not JUMP_IF_COND_TRUE, // jump if top of stack is true, drop if not JUMP_IF_COND_FALSE, // jump if top of stack is false, drop if not } jumpwhen_T; diff --git a/src/vim9execute.c b/src/vim9execute.c index 7a65be331..4646968f5 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -3788,9 +3788,7 @@ exec_instructions(ectx_T *ectx) } else jump = tv2bool(tv); - if (when == JUMP_IF_FALSE - || when == JUMP_AND_KEEP_IF_FALSE - || when == JUMP_IF_COND_FALSE) + if (when == JUMP_IF_FALSE || when == JUMP_IF_COND_FALSE) jump = !jump; if (when == JUMP_IF_FALSE || !jump) { @@ -5662,16 +5660,9 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc) iptr->isn_arg.number); break; case ISN_STOREOUTER: - { - if (iptr->isn_arg.number < 0) - smsg("%s%4d STOREOUTEr level %d arg[%d]", pfx, current, - iptr->isn_arg.outer.outer_depth, - iptr->isn_arg.outer.outer_idx + STACK_FRAME_SIZE); - else - smsg("%s%4d STOREOUTER level %d $%d", pfx, current, - iptr->isn_arg.outer.outer_depth, - iptr->isn_arg.outer.outer_idx); - } + smsg("%s%4d STOREOUTER level %d $%d", pfx, current, + iptr->isn_arg.outer.outer_depth, + iptr->isn_arg.outer.outer_idx); break; case ISN_STOREV: smsg("%s%4d STOREV v:%s", pfx, current, @@ -5935,9 +5926,6 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc) case JUMP_IF_FALSE: when = "JUMP_IF_FALSE"; break; - case JUMP_AND_KEEP_IF_FALSE: - when = "JUMP_AND_KEEP_IF_FALSE"; - break; case JUMP_IF_COND_FALSE: when = "JUMP_IF_COND_FALSE"; break; -- cgit v1.2.1