changeset 28625:56860e29ce5d v8.2.4836

patch 8.2.4836: Vim9: some lines not covered by tests Commit: https://github.com/vim/vim/commit/f6ced9863f931758a4cee0b6546e77d21150806d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 28 12:00:49 2022 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Thu, 28 Apr 2022 13:15:04 +0200
parents cfe842c7e379
children 46322b66ebb6
files src/testdir/test_vim9_disassemble.vim src/version.c src/vim9.h src/vim9execute.c
diffstat 4 files changed, 69 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- 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<number>\_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('\<SNR>\d*_StoreRange\_s*' ..
+        'var l = \[1, 2]\_s*' ..
+        '\d PUSHNR 1\_s*' ..
+        '\d PUSHNR 2\_s*' ..
+        '\d NEWLIST size 2\_s*' ..
+        '\d SETTYPE list<number>\_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'
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4836,
+/**/
     4835,
 /**/
     4834,
--- 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;
--- 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 *inst
 							 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 *inst
 			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;