Bram Moolenaar | fabaf75 | 2017-12-23 17:26:11 +0100 | [diff] [blame] | 1 | " Tests for various eval things. |
| 2 | |
| 3 | function s:foo() abort |
| 4 | try |
| 5 | return [] == 0 |
| 6 | catch |
| 7 | return 1 |
| 8 | endtry |
| 9 | endfunction |
| 10 | |
| 11 | func Test_catch_return_with_error() |
| 12 | call assert_equal(1, s:foo()) |
| 13 | endfunc |
Bram Moolenaar | 2be5733 | 2018-02-13 18:05:18 +0100 | [diff] [blame] | 14 | |
| 15 | func Test_nocatch_restore_silent_emsg() |
| 16 | silent! try |
| 17 | throw 1 |
| 18 | catch |
| 19 | endtry |
| 20 | echoerr 'wrong' |
| 21 | let c1 = nr2char(screenchar(&lines, 1)) |
| 22 | let c2 = nr2char(screenchar(&lines, 2)) |
| 23 | let c3 = nr2char(screenchar(&lines, 3)) |
| 24 | let c4 = nr2char(screenchar(&lines, 4)) |
| 25 | let c5 = nr2char(screenchar(&lines, 5)) |
| 26 | call assert_equal('wrong', c1 . c2 . c3 . c4 . c5) |
| 27 | endfunc |