mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.1953: Vim9: extra "unknown" error after other error
Problem: Vim9: extra "unknown" error after other error. Solution: Restore did_emsg count after EXEC instruction. (closes #7254) Improve error message from assert_fails()
This commit is contained in:
@@ -6,11 +6,11 @@ func Test_assert_false()
|
|||||||
call assert_equal(0, v:false->assert_false())
|
call assert_equal(0, v:false->assert_false())
|
||||||
|
|
||||||
call assert_equal(1, assert_false(123))
|
call assert_equal(1, assert_false(123))
|
||||||
call assert_match("Expected False but got 123", v:errors[0])
|
call assert_match("Expected 'False' but got 123", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
call assert_equal(1, 123->assert_false())
|
call assert_equal(1, 123->assert_false())
|
||||||
call assert_match("Expected False but got 123", v:errors[0])
|
call assert_match("Expected 'False' but got 123", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ func Test_assert_true()
|
|||||||
call assert_equal(0, v:true->assert_true())
|
call assert_equal(0, v:true->assert_true())
|
||||||
|
|
||||||
call assert_equal(1, assert_true(0))
|
call assert_equal(1, assert_true(0))
|
||||||
call assert_match("Expected True but got 0", v:errors[0])
|
call assert_match("Expected 'True' but got 0", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
call assert_equal(1, 0->assert_true())
|
call assert_equal(1, 0->assert_true())
|
||||||
call assert_match("Expected True but got 0", v:errors[0])
|
call assert_match("Expected 'True' but got 0", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -234,11 +234,11 @@ func Test_assert_fail_fails()
|
|||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
call assert_equal(1, assert_fails('xxx', ['E9876']))
|
call assert_equal(1, assert_fails('xxx', ['E9876']))
|
||||||
call assert_match("Expected \\['E9876'\\] but got 'E492:", v:errors[0])
|
call assert_match("Expected 'E9876' but got 'E492:", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
call assert_equal(1, assert_fails('xxx', ['E492:', 'E9876']))
|
call assert_equal(1, assert_fails('xxx', ['E492:', 'E9876']))
|
||||||
call assert_match("Expected \\['E492:', 'E9876'\\] but got 'E492:", v:errors[0])
|
call assert_match("Expected 'E9876' but got 'E492:", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
call assert_equal(1, assert_fails('echo', '', 'echo command'))
|
call assert_equal(1, assert_fails('echo', '', 'echo command'))
|
||||||
|
@@ -2859,6 +2859,28 @@ def Test_catch_exception_in_callback()
|
|||||||
unlet g:caught
|
unlet g:caught
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_no_unknown_error_after_error()
|
||||||
|
if !has('unix') || !has('job')
|
||||||
|
throw 'Skipped: not unix of missing +job feature'
|
||||||
|
endif
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var source: list<number>
|
||||||
|
def Out_cb(...l: any)
|
||||||
|
eval [][0]
|
||||||
|
enddef
|
||||||
|
def Exit_cb(...l: any)
|
||||||
|
sleep 1m
|
||||||
|
source += l
|
||||||
|
enddef
|
||||||
|
var myjob = job_start('echo burp', #{out_cb: Out_cb, exit_cb: Exit_cb, mode: 'raw'})
|
||||||
|
sleep 100m
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xdef')
|
||||||
|
assert_fails('so Xdef', ['E684:', 'E1012:'])
|
||||||
|
delete('Xdef')
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_put_with_linebreak()
|
def Test_put_with_linebreak()
|
||||||
new
|
new
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
|
@@ -220,7 +220,11 @@ fill_assert_error(
|
|||||||
vim_free(tofree);
|
vim_free(tofree);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ga_concat(gap, (char_u *)"'");
|
||||||
ga_concat_shorten_esc(gap, exp_str);
|
ga_concat_shorten_esc(gap, exp_str);
|
||||||
|
ga_concat(gap, (char_u *)"'");
|
||||||
|
}
|
||||||
if (atype != ASSERT_NOTEQUAL)
|
if (atype != ASSERT_NOTEQUAL)
|
||||||
{
|
{
|
||||||
if (atype == ASSERT_MATCH)
|
if (atype == ASSERT_MATCH)
|
||||||
@@ -571,6 +575,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
|
|||||||
{
|
{
|
||||||
char_u buf[NUMBUFLEN];
|
char_u buf[NUMBUFLEN];
|
||||||
char_u *expected;
|
char_u *expected;
|
||||||
|
char_u *expected_str = NULL;
|
||||||
int error_found = FALSE;
|
int error_found = FALSE;
|
||||||
int error_found_index = 1;
|
int error_found_index = 1;
|
||||||
char_u *actual = emsg_assert_fails_msg == NULL ? (char_u *)"[unknown]"
|
char_u *actual = emsg_assert_fails_msg == NULL ? (char_u *)"[unknown]"
|
||||||
@@ -598,6 +603,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
|
|||||||
if (!pattern_match(expected, actual, FALSE))
|
if (!pattern_match(expected, actual, FALSE))
|
||||||
{
|
{
|
||||||
error_found = TRUE;
|
error_found = TRUE;
|
||||||
|
expected_str = expected;
|
||||||
}
|
}
|
||||||
else if (list->lv_len == 2)
|
else if (list->lv_len == 2)
|
||||||
{
|
{
|
||||||
@@ -605,7 +611,10 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
|
|||||||
actual = get_vim_var_str(VV_ERRMSG);
|
actual = get_vim_var_str(VV_ERRMSG);
|
||||||
expected = tv_get_string_buf_chk(tv, buf);
|
expected = tv_get_string_buf_chk(tv, buf);
|
||||||
if (!pattern_match(expected, actual, FALSE))
|
if (!pattern_match(expected, actual, FALSE))
|
||||||
|
{
|
||||||
error_found = TRUE;
|
error_found = TRUE;
|
||||||
|
expected_str = expected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -665,7 +674,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
|
|||||||
actual_tv.v_type = VAR_STRING;
|
actual_tv.v_type = VAR_STRING;
|
||||||
actual_tv.vval.v_string = actual;
|
actual_tv.vval.v_string = actual;
|
||||||
}
|
}
|
||||||
fill_assert_error(&ga, &argvars[2], NULL,
|
fill_assert_error(&ga, &argvars[2], expected_str,
|
||||||
&argvars[error_found_index], &actual_tv, ASSERT_OTHER);
|
&argvars[error_found_index], &actual_tv, ASSERT_OTHER);
|
||||||
ga_concat(&ga, (char_u *)": ");
|
ga_concat(&ga, (char_u *)": ");
|
||||||
assert_append_cmd_or_arg(&ga, argvars, cmd);
|
assert_append_cmd_or_arg(&ga, argvars, cmd);
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
1953,
|
||||||
/**/
|
/**/
|
||||||
1952,
|
1952,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1071,8 +1071,15 @@ call_def_function(
|
|||||||
{
|
{
|
||||||
// execute Ex command line
|
// execute Ex command line
|
||||||
case ISN_EXEC:
|
case ISN_EXEC:
|
||||||
|
{
|
||||||
|
int save_did_emsg = did_emsg;
|
||||||
|
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
do_cmdline_cmd(iptr->isn_arg.string);
|
do_cmdline_cmd(iptr->isn_arg.string);
|
||||||
|
// do_cmdline_cmd() will reset did_emsg, but we want to
|
||||||
|
// keep track of the count to compare with did_emsg_before.
|
||||||
|
did_emsg += save_did_emsg;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// execute Ex command from pieces on the stack
|
// execute Ex command from pieces on the stack
|
||||||
|
Reference in New Issue
Block a user