Mercurial > vim
comparison src/testdir/test_vim9_script.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 | 6b1a59e71f85 |
comparison
equal
deleted
inserted
replaced
19331:fbd4e8f02f82 | 19332:d6e8a9e80be4 |
---|---|
457 def do_something(): | 457 def do_something(): |
458 return 1 | 458 return 1 |
459 EOF | 459 EOF |
460 endfunc | 460 endfunc |
461 | 461 |
462 def HasEval() | 462 def IfElse(what: number): string |
463 if has('eval') | 463 let res = '' |
464 echo 'yes' | 464 if what == 1 |
465 res = "one" | |
466 elseif what == 2 | |
467 res = "two" | |
465 else | 468 else |
466 echo 'no' | 469 res = "three" |
467 endif | 470 endif |
468 enddef | 471 return res |
469 | 472 enddef |
470 def HasNothing() | 473 |
471 if has('nothing') | 474 def Test_if_elseif_else() |
472 echo 'yes' | 475 assert_equal('one', IfElse(1)) |
473 else | 476 assert_equal('two', IfElse(2)) |
474 echo 'no' | 477 assert_equal('three', IfElse(3)) |
475 endif | |
476 enddef | |
477 | |
478 def Test_compile_const_expr() | |
479 assert_equal("\nyes", execute('call HasEval()')) | |
480 let instr = execute('disassemble HasEval') | |
481 assert_match('PUSHS "yes"', instr) | |
482 assert_notmatch('PUSHS "no"', instr) | |
483 assert_notmatch('JUMP', instr) | |
484 | |
485 assert_equal("\nno", execute('call HasNothing()')) | |
486 instr = execute('disassemble HasNothing') | |
487 assert_notmatch('PUSHS "yes"', instr) | |
488 assert_match('PUSHS "no"', instr) | |
489 assert_notmatch('JUMP', instr) | |
490 enddef | 478 enddef |
491 | 479 |
492 | 480 |
493 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 481 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |