summaryrefslogtreecommitdiff
path: root/src/testing.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-04 15:07:16 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-04 15:07:16 +0100
commit631e8f93458b102091d54c502f489c03e454d4da (patch)
tree93dad9375b29d35290540616bc1350cc2c32af02 /src/testing.c
parentc7f7f6db3e9d3b6b723ed17d5244c83859583832 (diff)
downloadvim-git-631e8f93458b102091d54c502f489c03e454d4da.tar.gz
patch 8.2.1953: Vim9: extra "unknown" error after other errorv8.2.1953
Problem: Vim9: extra "unknown" error after other error. Solution: Restore did_emsg count after EXEC instruction. (closes #7254) Improve error message from assert_fails()
Diffstat (limited to 'src/testing.c')
-rw-r--r--src/testing.c11
1 files changed, 10 insertions, 1 deletions
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);