# HG changeset patch # User Bram Moolenaar # Date 1585828806 -7200 # Node ID 50fa63ca38282c14ab5e56910faf56011f15933a # Parent 6b8cb3fd2ba2dc8430f5bb7b50eff8e5d72613d6 patch 8.2.0496: Vim9: disassemble test fails Commit: https://github.com/vim/vim/commit/a4d4cf490e2974843c80598e6f40f83aae658fd3 Author: Bram Moolenaar 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. diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim --- 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' diff --git a/src/version.c b/src/version.c --- 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,