diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-05 12:41:36 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-05 12:45:43 +0800 |
commit | 02f80d9a8a560a93142bcebf324ba14cde4dd1b5 (patch) | |
tree | 3a581c5518bdd20b09a70afa944b3325c96fe824 /src/nvim/testing.c | |
parent | 8ba7a966a1339767b19a5ca4449b38ef0cae49c7 (diff) | |
download | rneovim-02f80d9a8a560a93142bcebf324ba14cde4dd1b5.tar.gz rneovim-02f80d9a8a560a93142bcebf324ba14cde4dd1b5.tar.bz2 rneovim-02f80d9a8a560a93142bcebf324ba14cde4dd1b5.zip |
vim-patch:8.2.1631: test_fails() does not check the context of the line number
Problem: test_fails() does not check the context of the line number.
Solution: Use another argument to specify the context of the line number.
https://github.com/vim/vim/commit/9bd5d879c2ecfbdbb168b090e12f4b89724a302e
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/testing.c')
-rw-r--r-- | src/nvim/testing.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 4ab1367f26..9dfd828a67 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -500,7 +500,7 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) char buf[NUMBUFLEN]; const char *expected; bool error_found = false; - bool lnum_error_found = false; + int error_found_index = 1; char *actual = emsg_assert_fails_msg == NULL ? "[unknown]" : emsg_assert_fails_msg; if (argvars[1].v_type == VAR_STRING) { @@ -530,26 +530,36 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } if (!error_found && argvars[2].v_type != VAR_UNKNOWN - && argvars[3].v_type == VAR_NUMBER - && argvars[3].vval.v_number >= 0 - && argvars[3].vval.v_number != emsg_assert_fails_lnum) { - error_found = true; - lnum_error_found = true; + && argvars[3].v_type == VAR_NUMBER) { + if (argvars[3].vval.v_number >= 0 + && argvars[3].vval.v_number != emsg_assert_fails_lnum) { + error_found = true; + error_found_index = 3; + } + if (!error_found && argvars[4].v_type == VAR_STRING + && argvars[4].vval.v_string != NULL + && !pattern_match(argvars[4].vval.v_string, + emsg_assert_fails_context, false)) { + error_found = true; + error_found_index = 4; + } } if (error_found) { typval_T actual_tv; prepare_assert_error(&ga); - if (lnum_error_found) { + if (error_found_index == 3) { actual_tv.v_type = VAR_NUMBER; actual_tv.vval.v_number = emsg_assert_fails_lnum; + } else if (error_found_index == 4) { + actual_tv.v_type = VAR_STRING; + actual_tv.vval.v_string = emsg_assert_fails_context; } else { actual_tv.v_type = VAR_STRING; actual_tv.vval.v_string = actual; } fill_assert_error(&ga, &argvars[2], NULL, - &argvars[lnum_error_found ? 3 : 1], - &actual_tv, ASSERT_OTHER); + &argvars[error_found_index], &actual_tv, ASSERT_OTHER); ga_concat(&ga, ": "); assert_append_cmd_or_arg(&ga, argvars, cmd); assert_error(&ga); |