Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 26658:ed73553992bf v8.2.3858
patch 8.2.3858: Vim9: not enough tests
Commit: https://github.com/vim/vim/commit/003312b1d2ee2f4922f473b8bf50af6663c0efac
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 20 10:55:35 2021 +0000
patch 8.2.3858: Vim9: not enough tests
Problem: Vim9: not enough tests.
Solution: Add tests for :try/:catch and :redir. Add missing type check.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 20 Dec 2021 12:00:04 +0100 |
parents | a07323eb647f |
children | 2b17f87b7bd1 |
comparison
equal
deleted
inserted
replaced
26657:2fd1f389d13c | 26658:ed73553992bf |
---|---|
609 assert_equal(4, counter) | 609 assert_equal(4, counter) |
610 | 610 |
611 # no requirement for spaces before | | 611 # no requirement for spaces before | |
612 try|echo 0|catch|endtry | 612 try|echo 0|catch|endtry |
613 | 613 |
614 # return in try with finally | |
615 def ReturnInTry(): number | |
616 var ret = 4 | |
617 try | |
618 return ret | |
619 catch /this/ | |
620 return -1 | |
621 catch /that/ | |
622 return -1 | |
623 finally | |
624 # changing ret has no effect | |
625 ret = 7 | |
626 endtry | |
627 return -2 | |
628 enddef | |
629 assert_equal(4, ReturnInTry()) | |
630 | |
631 # return in catch with finally | |
632 def ReturnInCatch(): number | |
633 var ret = 5 | |
634 try | |
635 throw 'getout' | |
636 return -1 | |
637 catch /getout/ | |
638 # ret is evaluated here | |
639 return ret | |
640 finally | |
641 # changing ret later has no effect | |
642 ret = -3 | |
643 endtry | |
644 return -2 | |
645 enddef | |
646 assert_equal(5, ReturnInCatch()) | |
647 | |
614 # return in finally after empty catch | 648 # return in finally after empty catch |
615 def ReturnInFinally(): number | 649 def ReturnInFinally(): number |
616 try | 650 try |
617 finally | 651 finally |
618 return 4 | 652 return 6 |
619 endtry | 653 endtry |
620 return 2 | 654 return -1 |
621 enddef | 655 enddef |
622 assert_equal(4, ReturnInFinally()) | 656 assert_equal(6, ReturnInFinally()) |
623 | 657 |
624 var lines =<< trim END | 658 var lines =<< trim END |
625 vim9script | 659 vim9script |
626 try | 660 try |
627 acos('0.5') | 661 acos('0.5') |