comparison src/testdir/test_vim9_disassemble.vim @ 19332:d6e8a9e80be4 v8.2.0224

patch 8.2.0224: compiling :elseif not tested yet Commit: https://github.com/vim/vim/commit/158906cffc62bc82bc38198c2104967f2a70542c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 6 20:39:45 2020 +0100 patch 8.2.0224: compiling :elseif not tested yet Problem: compiling :elseif not tested yet. Solution: Add test for :elseif. Fix generating jumps.
author Bram Moolenaar <Bram@vim.org>
date Thu, 06 Feb 2020 20:45:03 +0100
parents 9c8b803fe598
children 61646c189622
comparison
equal deleted inserted replaced
19331:fbd4e8f02f82 19332:d6e8a9e80be4
214 \ .. ' PUSHS "yes".*' 214 \ .. ' PUSHS "yes".*'
215 \ .. ' RETURN.*' 215 \ .. ' RETURN.*'
216 \, res) 216 \, res)
217 enddef 217 enddef
218 218
219 def HasEval()
220 if has("eval")
221 echo "yes"
222 else
223 echo "no"
224 endif
225 enddef
226
227 def HasNothing()
228 if has("nothing")
229 echo "yes"
230 else
231 echo "no"
232 endif
233 enddef
234
235 def HasSomething()
236 if has("nothing")
237 echo "nothing"
238 elseif has("something")
239 echo "something"
240 elseif has("eval")
241 echo "eval"
242 elseif has("less")
243 echo "less"
244 endif
245 enddef
246
247 def Test_compile_const_expr()
248 assert_equal("\nyes", execute('call HasEval()'))
249 let instr = execute('disassemble HasEval')
250 assert_match('HasEval.*'
251 \ .. 'if has("eval").*'
252 \ .. ' PUSHS "yes".*'
253 \, instr)
254 assert_notmatch('JUMP', instr)
255
256 assert_equal("\nno", execute('call HasNothing()'))
257 instr = execute('disassemble HasNothing')
258 assert_match('HasNothing.*'
259 \ .. 'if has("nothing").*'
260 \ .. 'else.*'
261 \ .. ' PUSHS "no".*'
262 \, instr)
263 assert_notmatch('PUSHS "yes"', instr)
264 assert_notmatch('JUMP', instr)
265
266 assert_equal("\neval", execute('call HasSomething()'))
267 instr = execute('disassemble HasSomething')
268 assert_match('HasSomething.*'
269 \ .. 'if has("nothing").*'
270 \ .. 'elseif has("something").*'
271 \ .. 'elseif has("eval").*'
272 \ .. ' PUSHS "eval".*'
273 \ .. 'elseif has("less").*'
274 \, instr)
275 assert_notmatch('PUSHS "nothing"', instr)
276 assert_notmatch('PUSHS "something"', instr)
277 assert_notmatch('PUSHS "less"', instr)
278 assert_notmatch('JUMP', instr)
279 enddef
280
219 281
220 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 282 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker