Skip to content

Commit 8ed0458

Browse files
committed
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Problem: Vim9: ISN_STORE with argument not tested. Some cases in tv2bool() not tested. Solution: Add tests. Add test_unknown() and test_void().
1 parent 0c6ceaf commit 8ed0458

8 files changed

Lines changed: 61 additions & 0 deletions

File tree

runtime/doc/eval.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,8 @@ test_null_job() Job null value for testing
28642864
test_null_list() List null value for testing
28652865
test_null_partial() Funcref null value for testing
28662866
test_null_string() String null value for testing
2867+
test_unknown() any unknown value for testing
2868+
test_void() any void value for testing
28672869
test_option_not_set({name}) none reset flag indicating option was set
28682870
test_override({expr}, {val}) none test with Vim internal overrides
28692871
test_refcount({expr}) Number get the reference count of {expr}

runtime/doc/testing.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ test_null_string() *test_null_string()*
123123
Return a |String| that is null. Only useful for testing.
124124

125125

126+
test_unknown() *test_unknown()*
127+
Return a value with unknown type. Only useful for testing.
128+
129+
test_void() *test_void()*
130+
Return a value with void type. Only useful for testing.
131+
132+
126133
test_option_not_set({name}) *test_option_not_set()*
127134
Reset the flag that indicates option {name} was set. Thus it
128135
looks like it still has the default value. Use like this: >

src/evalfunc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,8 @@ static funcentry_T global_functions[] =
821821
{"test_setmouse", 2, 2, 0, &t_void, f_test_setmouse},
822822
{"test_settime", 1, 1, FEARG_1, &t_void, f_test_settime},
823823
{"test_srand_seed", 0, 1, FEARG_1, &t_void, f_test_srand_seed},
824+
{"test_unknown", 0, 0, 0, &t_any, f_test_unknown},
825+
{"test_void", 0, 0, 0, &t_any, f_test_void},
824826
#ifdef FEAT_TIMERS
825827
{"timer_info", 0, 1, FEARG_1, &t_list_dict_any, f_timer_info},
826828
{"timer_pause", 2, 2, FEARG_1, &t_void, f_timer_pause},

src/proto/testing.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ void f_test_null_job(typval_T *argvars, typval_T *rettv);
2828
void f_test_null_list(typval_T *argvars, typval_T *rettv);
2929
void f_test_null_partial(typval_T *argvars, typval_T *rettv);
3030
void f_test_null_string(typval_T *argvars, typval_T *rettv);
31+
void f_test_unknown(typval_T *argvars, typval_T *rettv);
32+
void f_test_void(typval_T *argvars, typval_T *rettv);
3133
void f_test_scrollbar(typval_T *argvars, typval_T *rettv);
3234
void f_test_setmouse(typval_T *argvars, typval_T *rettv);
3335
void f_test_settime(typval_T *argvars, typval_T *rettv);

src/testdir/test_vim9_disassemble.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ def Test_disassemble_call()
221221
\, res)
222222
enddef
223223

224+
225+
def FuncWithDefault(arg: string = 'default'): string
226+
return arg
227+
enddef
228+
229+
def Test_disassemble_call_default()
230+
let res = execute('disass FuncWithDefault')
231+
assert_match('FuncWithDefault.*'
232+
\ .. '\d PUSHS "default".*'
233+
\ .. '\d STORE arg\[-1].*'
234+
\ .. 'return arg.*'
235+
\ .. '\d LOAD arg\[-1].*'
236+
\ .. '\d RETURN.*'
237+
\, res)
238+
enddef
239+
240+
224241
def HasEval()
225242
if has("eval")
226243
echo "yes"

src/testdir/test_vim9_expr.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,23 @@ def Test_expr7_not()
765765
assert_equal(false, ![2])
766766
assert_equal(true, !!'asdf')
767767
assert_equal(true, !![2])
768+
769+
assert_equal(true, !test_null_partial())
770+
assert_equal(false, !{-> 'yes'})
771+
772+
assert_equal(true, !test_null_dict())
773+
assert_equal(true, !{})
774+
assert_equal(false, !{'yes': 'no'})
775+
776+
assert_equal(true, !test_null_job())
777+
assert_equal(true, !test_null_channel())
778+
779+
assert_equal(true, !test_null_blob())
780+
assert_equal(true, !0z)
781+
assert_equal(false, !0z01)
782+
783+
assert_equal(true, !test_void())
784+
assert_equal(true, !test_unknown())
768785
enddef
769786

770787
func Test_expr7_fails()

src/testing.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,18 @@ f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv)
896896
rettv->vval.v_string = NULL;
897897
}
898898

899+
void
900+
f_test_unknown(typval_T *argvars UNUSED, typval_T *rettv)
901+
{
902+
rettv->v_type = VAR_UNKNOWN;
903+
}
904+
905+
void
906+
f_test_void(typval_T *argvars UNUSED, typval_T *rettv)
907+
{
908+
rettv->v_type = VAR_VOID;
909+
}
910+
899911
#ifdef FEAT_GUI
900912
void
901913
f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
299,
741743
/**/
742744
298,
743745
/**/

0 commit comments

Comments
 (0)