summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testdir/test_assert.vim12
-rw-r--r--src/testdir/test_vim9_script.vim22
-rw-r--r--src/testing.c11
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c11
5 files changed, 49 insertions, 9 deletions
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index 04fde2d65..04bd87729 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -6,11 +6,11 @@ func Test_assert_false()
call assert_equal(0, v:false->assert_false())
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 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)
endfunc
@@ -21,11 +21,11 @@ func Test_assert_true()
call assert_equal(0, v:true->assert_true())
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 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)
endfunc
@@ -234,11 +234,11 @@ func Test_assert_fail_fails()
call remove(v:errors, 0)
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 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 assert_equal(1, assert_fails('echo', '', 'echo command'))
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 38f24d349..ea9c7c614 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -2859,6 +2859,28 @@ def Test_catch_exception_in_callback()
unlet g:caught
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()
new
var lines =<< trim END
diff --git a/src/testing.c b/src/testing.c
index 919b91182..6d4f588f8 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -220,7 +220,11 @@ fill_assert_error(
vim_free(tofree);
}
else
+ {
+ ga_concat(gap, (char_u *)"'");
ga_concat_shorten_esc(gap, exp_str);
+ ga_concat(gap, (char_u *)"'");
+ }
if (atype != ASSERT_NOTEQUAL)
{
if (atype == ASSERT_MATCH)
@@ -571,6 +575,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
{
char_u buf[NUMBUFLEN];
char_u *expected;
+ char_u *expected_str = NULL;
int error_found = FALSE;
int error_found_index = 1;
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))
{
error_found = TRUE;
+ expected_str = expected;
}
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);
expected = tv_get_string_buf_chk(tv, buf);
if (!pattern_match(expected, actual, FALSE))
+ {
error_found = TRUE;
+ expected_str = expected;
+ }
}
}
else
@@ -665,7 +674,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
actual_tv.v_type = VAR_STRING;
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);
ga_concat(&ga, (char_u *)": ");
assert_append_cmd_or_arg(&ga, argvars, cmd);
diff --git a/src/version.c b/src/version.c
index 98a3ab153..a55d2f3ee 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1953,
+/**/
1952,
/**/
1951,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index eb0e1db63..c9ae709d6 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -1071,8 +1071,15 @@ call_def_function(
{
// execute Ex command line
case ISN_EXEC:
- SOURCING_LNUM = iptr->isn_lnum;
- do_cmdline_cmd(iptr->isn_arg.string);
+ {
+ int save_did_emsg = did_emsg;
+
+ SOURCING_LNUM = iptr->isn_lnum;
+ 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;
// execute Ex command from pieces on the stack