]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4836: Vim9: some lines not covered by tests v8.2.4836
authorBram Moolenaar <Bram@vim.org>
Thu, 28 Apr 2022 11:00:49 +0000 (12:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 28 Apr 2022 11:00:49 +0000 (12:00 +0100)
Problem:    Vim9: some lines not covered by tests.
Solution:   Remove dead code.  Add disassemble tests.

src/testdir/test_vim9_disassemble.vim
src/version.c
src/vim9.h
src/vim9execute.c

index 086522ea32dda13a0880744a674b10d8d53f1e47..363d731a41d3fa4af17c81b0519d379adaab3376 100644 (file)
@@ -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'
index fa0303c086feaf993e5de3a3cc4d1b99326ea0e3..53afc37768219759cfe516ad9fb9d1c8c0448877 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4836,
 /**/
     4835,
 /**/
index c92b05fcf201268f1bf65f1228117a799cc36a80..3b14ffc7305ddfa473e0b94c6450b08488a96157 100644 (file)
@@ -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;
index 7a65be3315bb9ab010f8040a70471284ed1e2d83..4646968f5f8d3f9f29e63abf4c90999ca162d222 100644 (file)
@@ -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;