Skip to content

Commit eb992cb

Browse files
committed
patch 8.0.0440: not enough test coverage in Insert mode
Problem: Not enough test coverage in Insert mode. Solution: Add lots of tests. Add test_override(). (Christian Brabandt, closes #1521)
1 parent 69a92fb commit eb992cb

File tree

13 files changed

+1386
-15
lines changed

13 files changed

+1386
-15
lines changed

runtime/doc/eval.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2360,7 +2360,6 @@ tempname() String name for a temporary file
23602360
test_alloc_fail({id}, {countdown}, {repeat})
23612361
none make memory allocation fail
23622362
test_autochdir() none enable 'autochdir' during startup
2363-
test_disable_char_avail({expr}) none test without typeahead
23642363
test_garbagecollect_now() none free memory right now for testing
23652364
test_ignore_error({expr}) none ignore a specific error
23662365
test_null_channel() Channel null value for testing
@@ -2369,6 +2368,7 @@ test_null_job() Job null value for testing
23692368
test_null_list() List null value for testing
23702369
test_null_partial() Funcref null value for testing
23712370
test_null_string() String null value for testing
2371+
test_override({expr}, {val}) none test with Vim internal overrides
23722372
test_settime({expr}) none set current time for testing
23732373
timer_info([{id}]) List information about timers
23742374
timer_pause({id}, {pause}) none pause or unpause a timer

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,7 @@ test_arglist \
21112111
test_digraph \
21122112
test_functions \
21132113
test_display \
2114+
test_edit \
21142115
test_ex_undo \
21152116
test_execute_func \
21162117
test_expand \

src/edit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,10 @@ has_compl_option(int dict_opt)
22622262
vim_beep(BO_COMPL);
22632263
setcursor();
22642264
out_flush();
2265-
ui_delay(2000L, FALSE);
2265+
#ifdef FEAT_EVAL
2266+
if (!get_vim_var_nr(VV_TESTING))
2267+
#endif
2268+
ui_delay(2000L, FALSE);
22662269
}
22672270
return FALSE;
22682271
}

src/evalfunc.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static void f_tagfiles(typval_T *argvars, typval_T *rettv);
390390
static void f_tempname(typval_T *argvars, typval_T *rettv);
391391
static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
392392
static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
393-
static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
393+
static void f_test_override(typval_T *argvars, typval_T *rettv);
394394
static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
395395
static void f_test_ignore_error(typval_T *argvars, typval_T *rettv);
396396
#ifdef FEAT_JOB_CHANNEL
@@ -828,7 +828,6 @@ static struct fst
828828
{"tempname", 0, 0, f_tempname},
829829
{"test_alloc_fail", 3, 3, f_test_alloc_fail},
830830
{"test_autochdir", 0, 0, f_test_autochdir},
831-
{"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
832831
{"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now},
833832
{"test_ignore_error", 1, 1, f_test_ignore_error},
834833
#ifdef FEAT_JOB_CHANNEL
@@ -841,6 +840,7 @@ static struct fst
841840
{"test_null_list", 0, 0, f_test_null_list},
842841
{"test_null_partial", 0, 0, f_test_null_partial},
843842
{"test_null_string", 0, 0, f_test_null_string},
843+
{"test_override", 2, 2, f_test_override},
844844
{"test_settime", 1, 1, f_test_settime},
845845
#ifdef FEAT_TIMERS
846846
{"timer_info", 0, 1, f_timer_info},
@@ -12326,12 +12326,34 @@ f_test_autochdir(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
1232612326
}
1232712327

1232812328
/*
12329-
* "test_disable_char_avail({expr})" function
12329+
* "test_disable({name}, {val})" function
1233012330
*/
1233112331
static void
12332-
f_test_disable_char_avail(typval_T *argvars, typval_T *rettv UNUSED)
12332+
f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
1233312333
{
12334-
disable_char_avail_for_testing = (int)get_tv_number(&argvars[0]);
12334+
char_u *name = (char_u *)"";
12335+
int val;
12336+
12337+
if (argvars[0].v_type != VAR_STRING
12338+
|| (argvars[1].v_type) != VAR_NUMBER)
12339+
EMSG(_(e_invarg));
12340+
else
12341+
{
12342+
name = get_tv_string_chk(&argvars[0]);
12343+
val = (int)get_tv_number(&argvars[1]);
12344+
12345+
if (STRCMP(name, (char_u *)"redraw") == 0)
12346+
disable_redraw_for_testing = val;
12347+
else if (STRCMP(name, (char_u *)"char_avail") == 0)
12348+
disable_char_avail_for_testing = val;
12349+
else if (STRCMP(name, (char_u *)"ALL") == 0)
12350+
{
12351+
disable_char_avail_for_testing = FALSE;
12352+
disable_redraw_for_testing = FALSE;
12353+
}
12354+
else
12355+
EMSG2(_(e_invarg2), name);
12356+
}
1233512357
}
1233612358

1233712359
/*

src/globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,9 @@ EXTERN int alloc_fail_countdown INIT(= -1);
16481648
/* set by alloc_fail(), number of times alloc() returns NULL */
16491649
EXTERN int alloc_fail_repeat INIT(= 0);
16501650

1651+
/* flags set by test_override() */
16511652
EXTERN int disable_char_avail_for_testing INIT(= 0);
1653+
EXTERN int disable_redraw_for_testing INIT(= 0);
16521654

16531655
EXTERN int in_free_unref_items INIT(= FALSE);
16541656
#endif

src/screen.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10580,7 +10580,12 @@ fillchar_vsep(int *attr)
1058010580
int
1058110581
redrawing(void)
1058210582
{
10583-
return (!RedrawingDisabled
10583+
#ifdef FEAT_EVAL
10584+
if (disable_redraw_for_testing)
10585+
return 0;
10586+
else
10587+
#endif
10588+
return (!RedrawingDisabled
1058410589
&& !(p_lz && char_avail() && !KeyTyped && !do_redraw));
1058510590
}
1058610591

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ NEW_TESTS = test_arabic.res \
151151
test_diffmode.res \
152152
test_digraph.res \
153153
test_display.res \
154+
test_edit.res \
154155
test_farsi.res \
155156
test_fnameescape.res \
156157
test_fold.res \

src/testdir/runtest.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ source setup.vim
4949
" This also enables use of line continuation.
5050
set nocp viminfo+=nviminfo
5151

52-
" Use utf-8 or latin1 be default, instead of whatever the system default
52+
" Use utf-8 or latin1 by default, instead of whatever the system default
5353
" happens to be. Individual tests can overrule this at the top of the file.
5454
if has('multi_byte')
5555
set encoding=utf-8
@@ -96,6 +96,9 @@ function RunTheTest(test)
9696
" mode message.
9797
set noshowmode
9898

99+
" Clear any overrides.
100+
call test_override('ALL', 0)
101+
99102
if exists("*SetUp")
100103
try
101104
call SetUp()

src/testdir/test_assert.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ func Test_assert_with_msg()
127127
call remove(v:errors, 0)
128128
endfunc
129129

130+
func Test_override()
131+
call test_override('char_avail', 1)
132+
call test_override('redraw', 1)
133+
call test_override('ALL', 0)
134+
call assert_fails("call test_override('xxx', 1)", 'E475')
135+
call assert_fails("call test_override('redraw', 'yes')", 'E474')
136+
endfunc
137+
130138
func Test_user_is_happy()
131139
smile
132140
sleep 300m

src/testdir/test_cursor_func.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ func Test_curswant_with_autocommand()
4444
new
4545
call setline(1, ['func()', '{', '}', '----'])
4646
autocmd! CursorMovedI * call s:Highlight_Matching_Pair()
47-
call test_disable_char_avail(1)
47+
call test_override("char_avail", 1)
4848
exe "normal! 3Ga\<Down>X\<Esc>"
49-
call test_disable_char_avail(0)
49+
call test_override("char_avail", 0)
5050
call assert_equal('-X---', getline(4))
5151
autocmd! CursorMovedI *
5252
quit!

0 commit comments

Comments
 (0)