diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-22 19:07:28 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-22 19:07:28 +0100 |
commit | 8ed04587d3cd53e29be20fde9c36e619ea7da4dc (patch) | |
tree | 6a66f8036d567d984190c19f5372eff719ff6477 /src | |
parent | 0c6ceaf90389b41545d803458c4813013811c756 (diff) |
patch 8.2.0299: Vim9: ISN_STORE with argument not testedv8.2.0299
Problem: Vim9: ISN_STORE with argument not tested. Some cases in tv2bool()
not tested.
Solution: Add tests. Add test_unknown() and test_void().
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 2 | ||||
-rw-r--r-- | src/proto/testing.pro | 2 | ||||
-rw-r--r-- | src/testdir/test_vim9_disassemble.vim | 17 | ||||
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 17 | ||||
-rw-r--r-- | src/testing.c | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 52 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index f1a06caaac..cad7a969f9 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -821,6 +821,8 @@ static funcentry_T global_functions[] = {"test_setmouse", 2, 2, 0, &t_void, f_test_setmouse}, {"test_settime", 1, 1, FEARG_1, &t_void, f_test_settime}, {"test_srand_seed", 0, 1, FEARG_1, &t_void, f_test_srand_seed}, + {"test_unknown", 0, 0, 0, &t_any, f_test_unknown}, + {"test_void", 0, 0, 0, &t_any, f_test_void}, #ifdef FEAT_TIMERS {"timer_info", 0, 1, FEARG_1, &t_list_dict_any, f_timer_info}, {"timer_pause", 2, 2, FEARG_1, &t_void, f_timer_pause}, diff --git a/src/proto/testing.pro b/src/proto/testing.pro index 2b001a543a..7542ccb446 100644 --- a/src/proto/testing.pro +++ b/src/proto/testing.pro @@ -28,6 +28,8 @@ void f_test_null_job(typval_T *argvars, typval_T *rettv); void f_test_null_list(typval_T *argvars, typval_T *rettv); void f_test_null_partial(typval_T *argvars, typval_T *rettv); void f_test_null_string(typval_T *argvars, typval_T *rettv); +void f_test_unknown(typval_T *argvars, typval_T *rettv); +void f_test_void(typval_T *argvars, typval_T *rettv); void f_test_scrollbar(typval_T *argvars, typval_T *rettv); void f_test_setmouse(typval_T *argvars, typval_T *rettv); void f_test_settime(typval_T *argvars, typval_T *rettv); diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index c608a5daaa..cf3dd8c450 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -221,6 +221,23 @@ def Test_disassemble_call() \, res) enddef + +def FuncWithDefault(arg: string = 'default'): string + return arg +enddef + +def Test_disassemble_call_default() + let res = execute('disass FuncWithDefault') + assert_match('FuncWithDefault.*' + \ .. '\d PUSHS "default".*' + \ .. '\d STORE arg\[-1].*' + \ .. 'return arg.*' + \ .. '\d LOAD arg\[-1].*' + \ .. '\d RETURN.*' + \, res) +enddef + + def HasEval() if has("eval") echo "yes" diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 312d6338c2..a5b6e44d69 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -765,6 +765,23 @@ def Test_expr7_not() assert_equal(false, ![2]) assert_equal(true, !!'asdf') assert_equal(true, !![2]) + + assert_equal(true, !test_null_partial()) + assert_equal(false, !{-> 'yes'}) + + assert_equal(true, !test_null_dict()) + assert_equal(true, !{}) + assert_equal(false, !{'yes': 'no'}) + + assert_equal(true, !test_null_job()) + assert_equal(true, !test_null_channel()) + + assert_equal(true, !test_null_blob()) + assert_equal(true, !0z) + assert_equal(false, !0z01) + + assert_equal(true, !test_void()) + assert_equal(true, !test_unknown()) enddef func Test_expr7_fails() diff --git a/src/testing.c b/src/testing.c index 5dacf073b3..8a64ce85e7 100644 --- a/src/testing.c +++ b/src/testing.c @@ -896,6 +896,18 @@ f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv) rettv->vval.v_string = NULL; } + void +f_test_unknown(typval_T *argvars UNUSED, typval_T *rettv) +{ + rettv->v_type = VAR_UNKNOWN; +} + + void +f_test_void(typval_T *argvars UNUSED, typval_T *rettv) +{ + rettv->v_type = VAR_VOID; +} + #ifdef FEAT_GUI void f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED) diff --git a/src/version.c b/src/version.c index d889ce7e8a..95a098bea1 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 299, +/**/ 298, /**/ 297, |