diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-18 13:41:50 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-18 13:41:50 +0200 |
commit | 1d634542cf5ebcd1d5d83bd124b3e1d5e7c96c58 (patch) | |
tree | dd6ddcf92dd58de13a7e4ca9c12854ae449cb8a9 /src/testing.c | |
parent | 558813314d63dd0263a7a86c0496c1e89b5c8cba (diff) | |
download | vim-git-1d634542cf5ebcd1d5d83bd124b3e1d5e7c96c58.tar.gz |
patch 8.2.1479: Vim9: error for list index uses wrong line numberv8.2.1479
Problem: Vim9: error for list index uses wrong line number.
Solution: Set source line number. (closes #6724) Add a way to assert the
line number of the error with assert_fails().
Diffstat (limited to 'src/testing.c')
-rw-r--r-- | src/testing.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/testing.c b/src/testing.c index 137d5fe9f..09718760a 100644 --- a/src/testing.c +++ b/src/testing.c @@ -142,7 +142,10 @@ fill_assert_error( int did_copy = FALSE; int omitted = 0; - if (opt_msg_tv->v_type != VAR_UNKNOWN) + if (opt_msg_tv->v_type != VAR_UNKNOWN + && !(opt_msg_tv->v_type == VAR_STRING + && (opt_msg_tv->vval.v_string == NULL + || *opt_msg_tv->vval.v_string == NUL))) { ga_concat(gap, echo_string(opt_msg_tv, &tofree, numbuf, 0)); vim_free(tofree); @@ -570,6 +573,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv) char_u buf[NUMBUFLEN]; char_u *expected; int error_found = FALSE; + int lnum_error_found = FALSE; char_u *actual = emsg_assert_fails_msg == NULL ? (char_u *)"[unknown]" : emsg_assert_fails_msg; @@ -611,14 +615,31 @@ f_assert_fails(typval_T *argvars, typval_T *rettv) goto theend; } + if (!error_found && 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; + } + if (error_found) { typval_T actual_tv; prepare_assert_error(&ga); - actual_tv.v_type = VAR_STRING; - actual_tv.vval.v_string = actual; - fill_assert_error(&ga, &argvars[2], NULL, &argvars[1], + if (lnum_error_found) + { + actual_tv.v_type = VAR_NUMBER; + actual_tv.vval.v_number = emsg_assert_fails_lnum; + } + 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); ga_concat(&ga, (char_u *)": "); assert_append_cmd_or_arg(&ga, argvars, cmd); |