diff src/testdir/test_vim9_disassemble.vim @ 19572:6b6e97d0185e v8.2.0343

patch 8.2.0343: Vim9: using wrong instruction, limited test coverage Commit: https://github.com/vim/vim/commit/f51cb4e08ef904d137c27fe7cddb4702d8dcb2a2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 1 17:55:14 2020 +0100 patch 8.2.0343: Vim9: using wrong instruction, limited test coverage Problem: Vim9: using wrong instruction, limited test coverage. Solution: Use ISN_PUSHJOB. Add a few more tests.
author Bram Moolenaar <Bram@vim.org>
date Sun, 01 Mar 2020 18:00:04 +0100
parents b8f778dda1a1
children aae19dd172c0
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -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")