diff src/testdir/test_vim9_disassemble.vim @ 26905:c2186e32ae42 v8.2.3981

patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts Commit: https://github.com/vim/vim/commit/2b4ecc2c31c00df6e1c8ad46a3e4eabb1f1f84e3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 2 14:08:18 2022 +0000 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts Problem: Vim9: debugging a for loop doesn't stop before it starts. Solution: Keep the DEBUG instruction before the expression is evaluated. (closes #9456)
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Jan 2022 15:15:03 +0100
parents 47ad45fb433a
children 7045e9308ca3
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -2434,6 +2434,43 @@ def Test_debug_elseif()
         res)
 enddef
 
+def s:DebugFor()
+  echo "hello"
+  for a in [0]
+    echo a
+  endfor
+enddef
+
+def Test_debug_for()
+  var res = execute('disass debug s:DebugFor')
+  assert_match('<SNR>\d*_DebugFor\_s*' ..
+          'echo "hello"\_s*' ..
+          '0 DEBUG line 1-1 varcount 0\_s*' ..
+          '1 PUSHS "hello"\_s*' ..
+          '2 ECHO 1\_s*' ..
+
+          'for a in \[0\]\_s*' ..
+          '3 DEBUG line 2-2 varcount 0\_s*' ..
+          '4 STORE -1 in $0\_s*' ..
+          '5 PUSHNR 0\_s*' ..
+          '6 NEWLIST size 1\_s*' ..
+          '7 DEBUG line 2-2 varcount 2\_s*' ..
+          '8 FOR $0 -> 15\_s*' ..
+          '9 STORE $1\_s*' ..
+
+          'echo a\_s*' ..
+          '10 DEBUG line 3-3 varcount 2\_s*' ..
+          '11 LOAD $1\_s*' ..
+          '12 ECHO 1\_s*' ..
+
+          'endfor\_s*' ..
+          '13 DEBUG line 4-4 varcount 2\_s*' ..
+          '14 JUMP -> 7\_s*' ..
+          '15 DROP\_s*' ..
+          '16 RETURN void*',
+        res)
+enddef
+
 func Legacy() dict
   echo 'legacy'
 endfunc