1
0
forked from aniani/vim

patch 8.2.0496: Vim9: disassemble test fails

Problem:    Vim9: disassemble test fails.
Solution:   Separate test cases with recognized constant expressions.
This commit is contained in:
Bram Moolenaar
2020-04-02 13:50:27 +02:00
parent 80c34ca312
commit a4d4cf490e
2 changed files with 43 additions and 1 deletions

View 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'

View File

@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
496,
/**/
495,
/**/