changeset 19880:50fa63ca3828 v8.2.0496

patch 8.2.0496: Vim9: disassemble test fails Commit: https://github.com/vim/vim/commit/a4d4cf490e2974843c80598e6f40f83aae658fd3 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 2 13:50:27 2020 +0200 patch 8.2.0496: Vim9: disassemble test fails Problem: Vim9: disassemble test fails. Solution: Separate test cases with recognized constant expressions.
author Bram Moolenaar <Bram@vim.org>
date Thu, 02 Apr 2020 14:00:06 +0200
parents 6b8cb3fd2ba2
children b7cb48d00aa9
files src/testdir/test_vim9_disassemble.vim src/version.c
diffstat 2 files changed, 43 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -728,7 +728,6 @@ def Test_disassemble_compare()
         \ ['111 =~ 222', 'COMPARENR =\~'],
         \ ['111 !~ 222', 'COMPARENR !\~'],
         \
-        \ ['"xx" == "yy"', 'COMPARESTRING =='],
         \ ['"xx" != "yy"', 'COMPARESTRING !='],
         \ ['"xx" > "yy"', 'COMPARESTRING >'],
         \ ['"xx" < "yy"', 'COMPARESTRING <'],
@@ -806,6 +805,47 @@ def Test_disassemble_compare()
   delete('Xdisassemble')
 enddef
 
+def Test_disassemble_compare_const()
+  let cases = [
+        \ ['"xx" == "yy"', false],
+        \ ['"aa" == "aa"', true],
+        \ ]
+
+  let nr = 1
+  for case in cases
+    writefile(['def TestCase' .. nr .. '()',
+             \ '  if ' .. case[0],
+             \ '    echo 42'
+             \ '  endif',
+             \ 'enddef'], 'Xdisassemble')
+    source Xdisassemble
+    let instr = execute('disassemble TestCase' .. nr)
+    if case[1]
+      " condition true, "echo 42" executed
+      assert_match('TestCase' .. nr .. '.*'
+          \ .. 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*'
+          \ .. '\d PUSHNR 42.*'
+          \ .. '\d ECHO 1.*'
+          \ .. '\d PUSHNR 0.*'
+          \ .. '\d RETURN.*'
+          \, instr)
+    else
+      " condition false, function just returns
+      assert_match('TestCase' .. nr .. '.*'
+          \ .. 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '[ \n]*'
+          \ .. 'echo 42[ \n]*'
+          \ .. 'endif[ \n]*'
+          \ .. '\s*\d PUSHNR 0.*'
+          \ .. '\d RETURN.*'
+          \, instr)
+    endif
+
+    nr += 1
+  endfor
+
+  delete('Xdisassemble')
+enddef
+
 def s:Execute()
   execute 'help vim9.txt'
   let cmd = 'help vim9.txt'
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    496,
+/**/
     495,
 /**/
     494,