]> granicus.if.org Git - vim/commitdiff
patch 8.2.0343: Vim9: using wrong instruction, limited test coverage v8.2.0343
authorBram Moolenaar <Bram@vim.org>
Sun, 1 Mar 2020 16:55:14 +0000 (17:55 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 Mar 2020 16:55:14 +0000 (17:55 +0100)
Problem:    Vim9: using wrong instruction, limited test coverage.
Solution:   Use ISN_PUSHJOB.  Add a few more tests.

src/testdir/test_vim9_disassemble.vim
src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c
src/vim9execute.c

index 9196184a6fca9683793e73f4c35a0e1a8e7dd764..7875e847e7b4fb6e21bafe7fe7afbb1445e0cf86 100644 (file)
@@ -1,5 +1,7 @@
 " Test the :disassemble command, and compilation as a side effect
 
+source check.vim
+
 func NotCompiled()
   echo "not"
 endfunc
@@ -332,6 +334,63 @@ def Test_disassemble_const_expr()
   assert_notmatch('JUMP', instr)
 enddef
 
+def WithFunc()
+  let funky1: func
+  let funky2: func = function("len")
+  let party1: partial
+  let party2: partial = funcref("UserFunc")
+enddef
+
+def Test_disassemble_function()
+  let instr = execute('disassemble WithFunc')
+  assert_match('WithFunc.*'
+        \ .. 'let funky1: func.*'
+        \ .. '0 PUSHFUNC "\[none]".*'
+        \ .. '1 STORE $0.*'
+        \ .. 'let funky2: func = function("len").*'
+        \ .. '2 PUSHS "len".*'
+        \ .. '3 BCALL function(argc 1).*'
+        \ .. '4 STORE $1.*'
+        \ .. 'let party1: partial.*'
+        \ .. '5 PUSHPARTIAL "\[none]".*'
+        \ .. '6 STORE $2.*'
+        \ .. 'let party2: partial = funcref("UserFunc").*'
+        \ .. '7 PUSHS "UserFunc".*'
+        \ .. '8 BCALL funcref(argc 1).*'
+        \ .. '9 STORE $3.*'
+        \ .. '10 PUSHNR 0.*'
+        \ .. '11 RETURN.*'
+        \, instr)
+enddef
+
+if has('channel')
+  def WithChannel()
+    let job1: job
+    let job2: job = job_start("donothing")
+    let chan1: channel
+  enddef
+endif
+
+def Test_disassemble_channel()
+  CheckFeature channel
+
+  let instr = execute('disassemble WithChannel')
+  assert_match('WithChannel.*'
+        \ .. 'let job1: job.*'
+        \ .. '\d PUSHJOB "no process".*'
+        \ .. '\d STORE $0.*'
+        \ .. 'let job2: job = job_start("donothing").*'
+        \ .. '\d PUSHS "donothing".*'
+        \ .. '\d BCALL job_start(argc 1).*'
+        \ .. '\d STORE $1.*'
+        \ .. 'let chan1: channel.*'
+        \ .. '\d PUSHCHANNEL 0.*'
+        \ .. '\d STORE $2.*'
+        \ .. '\d PUSHNR 0.*'
+        \ .. '\d RETURN.*'
+        \, instr)
+enddef
+
 def WithLambda(): string
   let F = {a -> "X" .. a .. "X"}
   return F("x")
index c1865e37f78c4b7e210936e901a559d0ca5bd94d..c01ab8316427406eff35b18940cf2d6960ef16ab 100644 (file)
@@ -56,6 +56,7 @@ def Test_assignment()
   if has('channel')
     let chan1: channel
     let job1: job
+    let job2: job = job_start('willfail')
   endif
   if has('float')
     let float1: float = 3.4
index 6ecd281ac7326755e4ba670c7e8c642f9a2aa7eb..56a0aeeef79d3c6a9c344623ba4923ea960cde85 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    343,
 /**/
     342,
 /**/
index 64ed03800910c609916ec486063a0689b274dda8..158770c3a4255c261ab7ad8acb95ed191d878dd7 100644 (file)
@@ -666,7 +666,7 @@ generate_PUSHJOB(cctx_T *cctx, job_T *job)
 {
     isn_T      *isn;
 
-    if ((isn = generate_instr_type(cctx, ISN_PUSHCHANNEL, &t_channel)) == NULL)
+    if ((isn = generate_instr_type(cctx, ISN_PUSHJOB, &t_channel)) == NULL)
        return FAIL;
     isn->isn_arg.job = job;
 
index be19b1f7ff4a7bae0d9a2f608ea02ea2c6474aca..094ee72ce92c1144830cd61a87b4ad18a970ef21 100644 (file)
@@ -1915,7 +1915,7 @@ ex_disassemble(exarg_T *eap)
                    tv.v_type = VAR_JOB;
                    tv.vval.v_job = iptr->isn_arg.job;
                    name = tv_get_string(&tv);
-                   smsg("%4d PUSHJOB %s", current, name);
+                   smsg("%4d PUSHJOB \"%s\"", current, name);
                }
 #endif
                break;