comparison src/testdir/test_vim9_script.vim @ 19253:a8d2d3c8f0b3 v8.2.0185

patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines Commit: https://github.com/vim/vim/commit/a259d8d30bc289764925fc42db1dbe774f0bb3f8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 31 20:10:50 2020 +0100 patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines Problem: Vim9 script: cannot use "if has()" to skip lines. Solution: Evaluate constant expression at runtime.
author Bram Moolenaar <Bram@vim.org>
date Fri, 31 Jan 2020 20:15:05 +0100
parents 17d878a2ddaa
children 9fcdeaa18bd1
comparison
equal deleted inserted replaced
19252:2f4b2122c7d1 19253:a8d2d3c8f0b3
366 def do_something(): 366 def do_something():
367 return 1 367 return 1
368 EOF 368 EOF
369 endfunc 369 endfunc
370 370
371 def HasEval()
372 if has('eval')
373 echo 'yes'
374 else
375 echo 'no'
376 endif
377 enddef
378
379 def HasNothing()
380 if has('nothing')
381 echo 'yes'
382 else
383 echo 'no'
384 endif
385 enddef
386
387 def Test_compile_const_expr()
388 assert_equal("\nyes", execute('call HasEval()'))
389 let instr = execute('disassemble HasEval')
390 call assert_match('PUSHS "yes"', instr)
391 call assert_notmatch('PUSHS "no"', instr)
392 call assert_notmatch('JUMP', instr)
393
394 assert_equal("\nno", execute('call HasNothing()'))
395 instr = execute('disassemble HasNothing')
396 call assert_notmatch('PUSHS "yes"', instr)
397 call assert_match('PUSHS "no"', instr)
398 call assert_notmatch('JUMP', instr)
399 enddef
400
371 401
372 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 402 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker