diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-12-01 15:32:56 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-12-01 15:32:56 +0100 |
commit | bbfbaf9741deebb9f1ed790885bd571c4cbce17a (patch) | |
tree | 05863a56e4267dbdc0468e603b146775fe06df28 /src | |
parent | 683fa185a4b4ed7595e5942901548b8239ed5cdb (diff) | |
download | vim-git-bbfbaf9741deebb9f1ed790885bd571c4cbce17a.tar.gz |
patch 7.4.946v7.4.946
Problem: Missing changes in source file.
Solution: Include changes to the eval.c file.
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 135 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 84 insertions, 53 deletions
diff --git a/src/eval.c b/src/eval.c index c99501aaa..a2a99869e 100644 --- a/src/eval.c +++ b/src/eval.c @@ -473,9 +473,9 @@ static void f_argc __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv)); static void f_arglistid __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argv __ARGS((typval_T *argvars, typval_T *rettv)); -static void f_assertEqual __ARGS((typval_T *argvars, typval_T *rettv)); -static void f_assertFalse __ARGS((typval_T *argvars, typval_T *rettv)); -static void f_assertTrue __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_assert_equal __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_assert_false __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_assert_true __ARGS((typval_T *argvars, typval_T *rettv)); #ifdef FEAT_FLOAT static void f_asin __ARGS((typval_T *argvars, typval_T *rettv)); static void f_atan __ARGS((typval_T *argvars, typval_T *rettv)); @@ -8072,9 +8072,9 @@ static struct fst {"argidx", 0, 0, f_argidx}, {"arglistid", 0, 2, f_arglistid}, {"argv", 0, 1, f_argv}, - {"assertEqual", 2, 3, f_assertEqual}, - {"assertFalse", 1, 2, f_assertFalse}, - {"assertTrue", 1, 2, f_assertTrue}, + {"assert_equal", 2, 3, f_assert_equal}, + {"assert_false", 1, 2, f_assert_false}, + {"assert_true", 1, 2, f_assert_true}, #ifdef FEAT_FLOAT {"asin", 1, 1, f_asin}, /* WJMc */ {"atan", 1, 1, f_atan}, @@ -9131,111 +9131,140 @@ f_argv(argvars, rettv) alist_name(&ARGLIST[idx]), -1); } -static void assertError __ARGS((garray_T *gap)); -static void prepareForAssertError __ARGS((garray_T*gap)); -static void assertBool __ARGS((typval_T *argvars, int isTrue)); +static void prepare_assert_error __ARGS((garray_T*gap)); +static void fill_assert_error __ARGS((garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typval_T *exp_tv, typval_T *got_tv)); +static void assert_error __ARGS((garray_T *gap)); +static void assert_bool __ARGS((typval_T *argvars, int isTrue)); /* - * Add an assert error to v:errors. + * Prepare "gap" for an assert error and add the sourcing position. */ static void -assertError(gap) +prepare_assert_error(gap) garray_T *gap; { - struct vimvar *vp = &vimvars[VV_ERRORS]; + char buf[NUMBUFLEN]; - if (vp->vv_type != VAR_LIST || vimvars[VV_ERRORS].vv_list == NULL) - /* Make sure v:errors is a list. */ - set_vim_var_list(VV_ERRORS, list_alloc()); - list_append_string(vimvars[VV_ERRORS].vv_list, gap->ga_data, gap->ga_len); + ga_init2(gap, 1, 100); + ga_concat(gap, sourcing_name); + sprintf(buf, " line %ld", (long)sourcing_lnum); + ga_concat(gap, (char_u *)buf); + ga_concat(gap, (char_u *)": "); } +/* + * Fill "gap" with information about an assert error. + */ static void -prepareForAssertError(gap) +fill_assert_error(gap, opt_msg_tv, exp_str, exp_tv, got_tv) garray_T *gap; + typval_T *opt_msg_tv; + char_u *exp_str; + typval_T *exp_tv; + typval_T *got_tv; { - char buf[NUMBUFLEN]; + char_u numbuf[NUMBUFLEN]; + char_u *tofree; - ga_init2(gap, 1, 100); - ga_concat(gap, sourcing_name); - sprintf(buf, " line %ld", (long)sourcing_lnum); - ga_concat(gap, (char_u *)buf); + if (opt_msg_tv->v_type != VAR_UNKNOWN) + { + ga_concat(gap, tv2string(opt_msg_tv, &tofree, numbuf, 0)); + vim_free(tofree); + } + else + { + ga_concat(gap, (char_u *)"Expected "); + if (exp_str == NULL) + { + ga_concat(gap, tv2string(exp_tv, &tofree, numbuf, 0)); + vim_free(tofree); + } + else + ga_concat(gap, exp_str); + ga_concat(gap, (char_u *)" but got "); + ga_concat(gap, tv2string(got_tv, &tofree, numbuf, 0)); + vim_free(tofree); + } } /* - * "assertEqual(expected, actual[, msg])" function + * Add an assert error to v:errors. */ static void -f_assertEqual(argvars, rettv) +assert_error(gap) + garray_T *gap; +{ + struct vimvar *vp = &vimvars[VV_ERRORS]; + + if (vp->vv_type != VAR_LIST || vimvars[VV_ERRORS].vv_list == NULL) + /* Make sure v:errors is a list. */ + set_vim_var_list(VV_ERRORS, list_alloc()); + list_append_string(vimvars[VV_ERRORS].vv_list, gap->ga_data, gap->ga_len); +} + +/* + * "assert_equal(expected, actual[, msg])" function + */ + static void +f_assert_equal(argvars, rettv) typval_T *argvars; typval_T *rettv UNUSED; { garray_T ga; - char_u *tofree; - char_u numbuf[NUMBUFLEN]; if (!tv_equal(&argvars[0], &argvars[1], FALSE, FALSE)) { - prepareForAssertError(&ga); - ga_concat(&ga, (char_u *)": Expected "); - ga_concat(&ga, tv2string(&argvars[0], &tofree, numbuf, 0)); - vim_free(tofree); - ga_concat(&ga, (char_u *)" but got "); - ga_concat(&ga, tv2string(&argvars[1], &tofree, numbuf, 0)); - vim_free(tofree); - assertError(&ga); + prepare_assert_error(&ga); + fill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1]); + assert_error(&ga); ga_clear(&ga); } } +/* + * Common for assert_true() and assert_false(). + */ static void -assertBool(argvars, isTrue) +assert_bool(argvars, isTrue) typval_T *argvars; int isTrue; { int error = FALSE; garray_T ga; - char_u *tofree; - char_u numbuf[NUMBUFLEN]; if (argvars[0].v_type != VAR_NUMBER || (get_tv_number_chk(&argvars[0], &error) == 0) == isTrue || error) { - prepareForAssertError(&ga); - ga_concat(&ga, (char_u *)": Expected "); - if (isTrue) - ga_concat(&ga, (char_u *)"True "); - else - ga_concat(&ga, (char_u *)"False "); - ga_concat(&ga, (char_u *)"but got "); - ga_concat(&ga, tv2string(&argvars[0], &tofree, numbuf, 0)); - vim_free(tofree); - assertError(&ga); + prepare_assert_error(&ga); + fill_assert_error(&ga, &argvars[1], + (char_u *)(isTrue ? "True " : "False "), + NULL, &argvars[0]); + assert_error(&ga); ga_clear(&ga); } } /* - * "assertFalse(actual[, msg])" function + * "assert_false(actual[, msg])" function */ static void -f_assertFalse(argvars, rettv) +f_assert_false(argvars, rettv) typval_T *argvars; typval_T *rettv UNUSED; { - assertBool(argvars, FALSE); + assert_bool(argvars, FALSE); } /* - * "assertTrue(actual[, msg])" function + * "assert_true(actual[, msg])" function */ static void -f_assertTrue(argvars, rettv) +f_assert_true(argvars, rettv) typval_T *argvars; typval_T *rettv UNUSED; { - assertBool(argvars, TRUE); + assert_bool(argvars, TRUE); } #ifdef FEAT_FLOAT diff --git a/src/version.c b/src/version.c index 89a298607..2fbc3c7b3 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 946, +/**/ 945, /**/ 944, |