0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 8.2.0224: compiling :elseif not tested yet

Problem:    compiling :elseif not tested yet.
Solution:   Add test for :elseif.  Fix generating jumps.
This commit is contained in:
Bram Moolenaar
2020-02-06 20:39:45 +01:00
parent 5cab73f8cc
commit 158906cffc
4 changed files with 79 additions and 26 deletions

View File

@@ -459,34 +459,22 @@ def do_something():
EOF
endfunc
def HasEval()
if has('eval')
echo 'yes'
def IfElse(what: number): string
let res = ''
if what == 1
res = "one"
elseif what == 2
res = "two"
else
echo 'no'
res = "three"
endif
return res
enddef
def HasNothing()
if has('nothing')
echo 'yes'
else
echo 'no'
endif
enddef
def Test_compile_const_expr()
assert_equal("\nyes", execute('call HasEval()'))
let instr = execute('disassemble HasEval')
assert_match('PUSHS "yes"', instr)
assert_notmatch('PUSHS "no"', instr)
assert_notmatch('JUMP', instr)
assert_equal("\nno", execute('call HasNothing()'))
instr = execute('disassemble HasNothing')
assert_notmatch('PUSHS "yes"', instr)
assert_match('PUSHS "no"', instr)
assert_notmatch('JUMP', instr)
def Test_if_elseif_else()
assert_equal('one', IfElse(1))
assert_equal('two', IfElse(2))
assert_equal('three', IfElse(3))
enddef