diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-05-14 21:38:12 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-14 21:38:12 +0100 |
commit | 9d383f30bbd06552ad0bf343b2c03c6a0d1f6df2 (patch) | |
tree | 5eb419bd4d132300b01ffc01c10fd732aedcc2b5 /src | |
parent | cf2610c82b64b1785af0804916789295cae45e93 (diff) | |
download | vim-git-9d383f30bbd06552ad0bf343b2c03c6a0d1f6df2.tar.gz |
patch 9.0.1557: test failures for unreachable codev9.0.1557
Problem: Test failures for unreachable code.
Solution: Add a test override to ignore unreachable code.
Diffstat (limited to 'src')
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 19 | ||||
-rw-r--r-- | src/testing.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9cmds.c | 3 | ||||
-rw-r--r-- | src/vim9compile.c | 3 |
6 files changed, 23 insertions, 7 deletions
diff --git a/src/globals.h b/src/globals.h index 3e8b7532e..69b4343d6 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1914,6 +1914,7 @@ EXTERN int disable_vterm_title_for_testing INIT(= FALSE); EXTERN long override_sysinfo_uptime INIT(= -1); EXTERN int override_autoload INIT(= FALSE); EXTERN int ml_get_alloc_lines INIT(= FALSE); +EXTERN int ignore_unreachable_code_for_testing INIT(= FALSE); EXTERN int in_free_unref_items INIT(= FALSE); #endif diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 3541aa742..d6be8cb69 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -490,7 +490,7 @@ def Test_try_catch_throw() try # comment add(l, '1') throw 'wrong' - add(l, '2') + add(l, '2') # "unreachable code" catch # comment add(l, v:exception) finally # comment @@ -503,7 +503,7 @@ def Test_try_catch_throw() try add(l, '1') throw 'wrong' - add(l, '2') + add(l, '2') # "unreachable code" catch /right/ add(l, v:exception) endtry @@ -754,7 +754,7 @@ def Test_try_catch_throw() var ret = 5 try throw 'getout' - return -1 + return -1 # "unreachable code" catch /getout/ # ret is evaluated here return ret @@ -1082,7 +1082,12 @@ enddef def DeletedFunc(): list<any> return ['delete me'] enddef -defcompile +defcompile DeletedFunc + +call test_override('unreachable', 1) +defcompile Test_try_catch_throw +call test_override('unreachable', 0) + delfunc DeletedFunc def s:ThrowFromDef() @@ -1128,7 +1133,7 @@ def Test_try_catch_nested() try l->add('1') throw 'bad' - l->add('x') + l->add('x') # "unreachable code" catch /bad/ l->add('2') try @@ -1168,6 +1173,10 @@ def Test_try_catch_nested() assert_equal(['1', '2', '3', '4'], l) enddef +call test_override('unreachable', 1) +defcompile Test_try_catch_nested +call test_override('unreachable', 0) + def s:TryOne(): number try return 0 diff --git a/src/testing.c b/src/testing.c index dfa9c606a..fd55927df 100644 --- a/src/testing.c +++ b/src/testing.c @@ -1039,6 +1039,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED) no_wait_return = val; else if (STRCMP(name, (char_u *)"ui_delay") == 0) ui_delay_for_testing = val; + else if (STRCMP(name, (char_u *)"unreachable") == 0) + ignore_unreachable_code_for_testing = val; else if (STRCMP(name, (char_u *)"term_props") == 0) reset_term_props_on_termresponse = val; else if (STRCMP(name, (char_u *)"vterm_title") == 0) diff --git a/src/version.c b/src/version.c index c0c1ca0d9..cf91da553 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1557, +/**/ 1556, /**/ 1555, diff --git a/src/vim9cmds.c b/src/vim9cmds.c index bc01cd83d..c3c900a5b 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1578,7 +1578,8 @@ compile_catch(char_u *arg, cctx_T *cctx UNUSED) return NULL; } - if (scope->se_u.se_try.ts_caught_all) + if (scope->se_u.se_try.ts_caught_all + && !ignore_unreachable_code_for_testing) { emsg(_(e_catch_unreachable_after_catch_all)); return NULL; diff --git a/src/vim9compile.c b/src/vim9compile.c index b894c6f29..03a6e2c27 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -3493,7 +3493,8 @@ compile_def_function( && ea.cmdidx != CMD_endwhile && ea.cmdidx != CMD_catch && ea.cmdidx != CMD_finally - && ea.cmdidx != CMD_endtry) + && ea.cmdidx != CMD_endtry + && !ignore_unreachable_code_for_testing) { emsg(_(e_unreachable_code_after_return)); goto erret; |