]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0496: Vim9: disassemble test fails v8.2.0496
authorBram Moolenaar <Bram@vim.org>
Thu, 2 Apr 2020 11:50:27 +0000 (13:50 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 2 Apr 2020 11:50:27 +0000 (13:50 +0200)
Problem:    Vim9: disassemble test fails.
Solution:   Separate test cases with recognized constant expressions.

src/testdir/test_vim9_disassemble.vim
src/version.c

index 62602956bad6abaea4582e6e2e434617adf04442..95cd2894fe20ef80b6d0a39c3d7e027c22014750 100644 (file)
@@ -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'
index 454dbd4661318918689ee5b9691a413f27fdcf0d..8973af793ca347efe9d3b076cc7690c32ab8eb0e 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    496,
 /**/
     495,
 /**/