mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.1557: test failures for unreachable code
Problem: Test failures for unreachable code. Solution: Add a test override to ignore unreachable code.
This commit is contained in:
@@ -369,6 +369,7 @@ test_override({name}, {val}) *test_override()*
|
|||||||
string is detected
|
string is detected
|
||||||
ui_delay time in msec to use in ui_delay(); overrules a
|
ui_delay time in msec to use in ui_delay(); overrules a
|
||||||
wait time of up to 3 seconds for messages
|
wait time of up to 3 seconds for messages
|
||||||
|
unreachable no error for code after `:throw` and `:return`
|
||||||
uptime overrules sysinfo.uptime
|
uptime overrules sysinfo.uptime
|
||||||
vterm_title setting the window title by a job running in a
|
vterm_title setting the window title by a job running in a
|
||||||
terminal window
|
terminal window
|
||||||
@@ -378,13 +379,18 @@ test_override({name}, {val}) *test_override()*
|
|||||||
"starting" is to be used when a test should behave like
|
"starting" is to be used when a test should behave like
|
||||||
startup was done. Since the tests are run by sourcing a
|
startup was done. Since the tests are run by sourcing a
|
||||||
script the "starting" variable is non-zero. This is usually a
|
script the "starting" variable is non-zero. This is usually a
|
||||||
good thing (tests run faster), but sometimes changes behavior
|
good thing (tests run faster), but sometimes this changes
|
||||||
in a way that the test doesn't work properly.
|
behavior in a way that the test doesn't work properly.
|
||||||
When using: >
|
When using: >
|
||||||
call test_override('starting', 1)
|
call test_override('starting', 1)
|
||||||
< The value of "starting" is saved. It is restored by: >
|
< The value of "starting" is saved. It is restored by: >
|
||||||
call test_override('starting', 0)
|
call test_override('starting', 0)
|
||||||
|
|
||||||
|
< To make sure the flag is reset later using `:defer` can be
|
||||||
|
useful: >
|
||||||
|
call test_override('unreachable', 1)
|
||||||
|
defer call test_override('unreachable', 0)
|
||||||
|
|
||||||
< Can also be used as a |method|: >
|
< Can also be used as a |method|: >
|
||||||
GetOverrideVal()-> test_override('starting')
|
GetOverrideVal()-> test_override('starting')
|
||||||
|
|
||||||
|
@@ -1914,6 +1914,7 @@ EXTERN int disable_vterm_title_for_testing INIT(= FALSE);
|
|||||||
EXTERN long override_sysinfo_uptime INIT(= -1);
|
EXTERN long override_sysinfo_uptime INIT(= -1);
|
||||||
EXTERN int override_autoload INIT(= FALSE);
|
EXTERN int override_autoload INIT(= FALSE);
|
||||||
EXTERN int ml_get_alloc_lines 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);
|
EXTERN int in_free_unref_items INIT(= FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -490,7 +490,7 @@ def Test_try_catch_throw()
|
|||||||
try # comment
|
try # comment
|
||||||
add(l, '1')
|
add(l, '1')
|
||||||
throw 'wrong'
|
throw 'wrong'
|
||||||
add(l, '2')
|
add(l, '2') # "unreachable code"
|
||||||
catch # comment
|
catch # comment
|
||||||
add(l, v:exception)
|
add(l, v:exception)
|
||||||
finally # comment
|
finally # comment
|
||||||
@@ -503,7 +503,7 @@ def Test_try_catch_throw()
|
|||||||
try
|
try
|
||||||
add(l, '1')
|
add(l, '1')
|
||||||
throw 'wrong'
|
throw 'wrong'
|
||||||
add(l, '2')
|
add(l, '2') # "unreachable code"
|
||||||
catch /right/
|
catch /right/
|
||||||
add(l, v:exception)
|
add(l, v:exception)
|
||||||
endtry
|
endtry
|
||||||
@@ -754,7 +754,7 @@ def Test_try_catch_throw()
|
|||||||
var ret = 5
|
var ret = 5
|
||||||
try
|
try
|
||||||
throw 'getout'
|
throw 'getout'
|
||||||
return -1
|
return -1 # "unreachable code"
|
||||||
catch /getout/
|
catch /getout/
|
||||||
# ret is evaluated here
|
# ret is evaluated here
|
||||||
return ret
|
return ret
|
||||||
@@ -1082,7 +1082,12 @@ enddef
|
|||||||
def DeletedFunc(): list<any>
|
def DeletedFunc(): list<any>
|
||||||
return ['delete me']
|
return ['delete me']
|
||||||
enddef
|
enddef
|
||||||
defcompile
|
defcompile DeletedFunc
|
||||||
|
|
||||||
|
call test_override('unreachable', 1)
|
||||||
|
defcompile Test_try_catch_throw
|
||||||
|
call test_override('unreachable', 0)
|
||||||
|
|
||||||
delfunc DeletedFunc
|
delfunc DeletedFunc
|
||||||
|
|
||||||
def s:ThrowFromDef()
|
def s:ThrowFromDef()
|
||||||
@@ -1128,7 +1133,7 @@ def Test_try_catch_nested()
|
|||||||
try
|
try
|
||||||
l->add('1')
|
l->add('1')
|
||||||
throw 'bad'
|
throw 'bad'
|
||||||
l->add('x')
|
l->add('x') # "unreachable code"
|
||||||
catch /bad/
|
catch /bad/
|
||||||
l->add('2')
|
l->add('2')
|
||||||
try
|
try
|
||||||
@@ -1168,6 +1173,10 @@ def Test_try_catch_nested()
|
|||||||
assert_equal(['1', '2', '3', '4'], l)
|
assert_equal(['1', '2', '3', '4'], l)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
call test_override('unreachable', 1)
|
||||||
|
defcompile Test_try_catch_nested
|
||||||
|
call test_override('unreachable', 0)
|
||||||
|
|
||||||
def s:TryOne(): number
|
def s:TryOne(): number
|
||||||
try
|
try
|
||||||
return 0
|
return 0
|
||||||
|
@@ -1039,6 +1039,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
no_wait_return = val;
|
no_wait_return = val;
|
||||||
else if (STRCMP(name, (char_u *)"ui_delay") == 0)
|
else if (STRCMP(name, (char_u *)"ui_delay") == 0)
|
||||||
ui_delay_for_testing = val;
|
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)
|
else if (STRCMP(name, (char_u *)"term_props") == 0)
|
||||||
reset_term_props_on_termresponse = val;
|
reset_term_props_on_termresponse = val;
|
||||||
else if (STRCMP(name, (char_u *)"vterm_title") == 0)
|
else if (STRCMP(name, (char_u *)"vterm_title") == 0)
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1557,
|
||||||
/**/
|
/**/
|
||||||
1556,
|
1556,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1578,7 +1578,8 @@ compile_catch(char_u *arg, cctx_T *cctx UNUSED)
|
|||||||
return NULL;
|
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));
|
emsg(_(e_catch_unreachable_after_catch_all));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -3493,7 +3493,8 @@ compile_def_function(
|
|||||||
&& ea.cmdidx != CMD_endwhile
|
&& ea.cmdidx != CMD_endwhile
|
||||||
&& ea.cmdidx != CMD_catch
|
&& ea.cmdidx != CMD_catch
|
||||||
&& ea.cmdidx != CMD_finally
|
&& ea.cmdidx != CMD_finally
|
||||||
&& ea.cmdidx != CMD_endtry)
|
&& ea.cmdidx != CMD_endtry
|
||||||
|
&& !ignore_unreachable_code_for_testing)
|
||||||
{
|
{
|
||||||
emsg(_(e_unreachable_code_after_return));
|
emsg(_(e_unreachable_code_after_return));
|
||||||
goto erret;
|
goto erret;
|
||||||
|
Reference in New Issue
Block a user