forked from aniani/vim
patch 7.4.2095
Problem: Man test fails when run with the GUI. Solution: Adjust for different behavior of GUI. Add assert_inrange().
This commit is contained in:
parent
4658228262
commit
61c04493b0
@ -1,4 +1,4 @@
|
|||||||
*eval.txt* For Vim version 7.4. Last change: 2016 Jul 22
|
*eval.txt* For Vim version 7.4. Last change: 2016 Jul 23
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -1947,6 +1947,8 @@ assert_equal({exp}, {act} [, {msg}]) none assert {exp} is equal to {act}
|
|||||||
assert_exception({error} [, {msg}]) none assert {error} is in v:exception
|
assert_exception({error} [, {msg}]) none assert {error} is in v:exception
|
||||||
assert_fails({cmd} [, {error}]) none assert {cmd} fails
|
assert_fails({cmd} [, {error}]) none assert {cmd} fails
|
||||||
assert_false({actual} [, {msg}]) none assert {actual} is false
|
assert_false({actual} [, {msg}]) none assert {actual} is false
|
||||||
|
assert_inrange({lower}, {upper}, {actual} [, {msg}])
|
||||||
|
none assert {actual} is inside the range
|
||||||
assert_match({pat}, {text} [, {msg}]) none assert {pat} matches {text}
|
assert_match({pat}, {text} [, {msg}]) none assert {pat} matches {text}
|
||||||
assert_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
|
assert_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
|
||||||
assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text}
|
assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text}
|
||||||
@ -2478,8 +2480,16 @@ assert_false({actual} [, {msg}]) *assert_false()*
|
|||||||
|v:errors|, like with |assert_equal()|.
|
|v:errors|, like with |assert_equal()|.
|
||||||
A value is false when it is zero. When {actual} is not a
|
A value is false when it is zero. When {actual} is not a
|
||||||
number the assert fails.
|
number the assert fails.
|
||||||
When {msg} is omitted an error in the form "Expected False but
|
When {msg} is omitted an error in the form
|
||||||
got {actual}" is produced.
|
"Expected False but got {actual}" is produced.
|
||||||
|
|
||||||
|
assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
|
||||||
|
This asserts number values. When {actual} is lower than
|
||||||
|
{lower} or higher than {upper} an error message is added to
|
||||||
|
|v:errors|.
|
||||||
|
When {msg} is omitted an error in the form
|
||||||
|
"Expected range {lower} - {upper}, but got {actual}" is
|
||||||
|
produced.
|
||||||
|
|
||||||
*assert_match()*
|
*assert_match()*
|
||||||
assert_match({pattern}, {actual} [, {msg}])
|
assert_match({pattern}, {actual} [, {msg}])
|
||||||
@ -2494,8 +2504,8 @@ assert_match({pattern}, {actual} [, {msg}])
|
|||||||
Use "^" and "$" to match with the start and end of the text.
|
Use "^" and "$" to match with the start and end of the text.
|
||||||
Use both to match the whole text.
|
Use both to match the whole text.
|
||||||
|
|
||||||
When {msg} is omitted an error in the form "Pattern {pattern}
|
When {msg} is omitted an error in the form
|
||||||
does not match {actual}" is produced.
|
"Pattern {pattern} does not match {actual}" is produced.
|
||||||
Example: >
|
Example: >
|
||||||
assert_match('^f.*o$', 'foobar')
|
assert_match('^f.*o$', 'foobar')
|
||||||
< Will result in a string to be added to |v:errors|:
|
< Will result in a string to be added to |v:errors|:
|
||||||
|
33
src/eval.c
33
src/eval.c
@ -8992,6 +8992,39 @@ assert_match_common(typval_T *argvars, assert_type_T atype)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
assert_inrange(typval_T *argvars)
|
||||||
|
{
|
||||||
|
garray_T ga;
|
||||||
|
int error = FALSE;
|
||||||
|
varnumber_T lower = get_tv_number_chk(&argvars[0], &error);
|
||||||
|
varnumber_T upper = get_tv_number_chk(&argvars[1], &error);
|
||||||
|
varnumber_T actual = get_tv_number_chk(&argvars[2], &error);
|
||||||
|
char_u *tofree;
|
||||||
|
char msg[200];
|
||||||
|
char_u numbuf[NUMBUFLEN];
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return;
|
||||||
|
if (actual < lower || actual > upper)
|
||||||
|
{
|
||||||
|
prepare_assert_error(&ga);
|
||||||
|
if (argvars[3].v_type != VAR_UNKNOWN)
|
||||||
|
{
|
||||||
|
ga_concat(&ga, tv2string(&argvars[3], &tofree, numbuf, 0));
|
||||||
|
vim_free(tofree);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vim_snprintf(msg, 200, "Expected range %ld - %ld, but got %ld",
|
||||||
|
(long)lower, (long)upper, (long)actual);
|
||||||
|
ga_concat(&ga, (char_u *)msg);
|
||||||
|
}
|
||||||
|
assert_error(&ga);
|
||||||
|
ga_clear(&ga);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common for assert_true() and assert_false().
|
* Common for assert_true() and assert_false().
|
||||||
*/
|
*/
|
||||||
|
@ -48,6 +48,7 @@ static void f_assert_equal(typval_T *argvars, typval_T *rettv);
|
|||||||
static void f_assert_exception(typval_T *argvars, typval_T *rettv);
|
static void f_assert_exception(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_assert_fails(typval_T *argvars, typval_T *rettv);
|
static void f_assert_fails(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_assert_false(typval_T *argvars, typval_T *rettv);
|
static void f_assert_false(typval_T *argvars, typval_T *rettv);
|
||||||
|
static void f_assert_inrange(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_assert_match(typval_T *argvars, typval_T *rettv);
|
static void f_assert_match(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_assert_notequal(typval_T *argvars, typval_T *rettv);
|
static void f_assert_notequal(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_assert_notmatch(typval_T *argvars, typval_T *rettv);
|
static void f_assert_notmatch(typval_T *argvars, typval_T *rettv);
|
||||||
@ -460,6 +461,7 @@ static struct fst
|
|||||||
{"assert_exception", 1, 2, f_assert_exception},
|
{"assert_exception", 1, 2, f_assert_exception},
|
||||||
{"assert_fails", 1, 2, f_assert_fails},
|
{"assert_fails", 1, 2, f_assert_fails},
|
||||||
{"assert_false", 1, 2, f_assert_false},
|
{"assert_false", 1, 2, f_assert_false},
|
||||||
|
{"assert_inrange", 2, 3, f_assert_inrange},
|
||||||
{"assert_match", 2, 3, f_assert_match},
|
{"assert_match", 2, 3, f_assert_match},
|
||||||
{"assert_notequal", 2, 3, f_assert_notequal},
|
{"assert_notequal", 2, 3, f_assert_notequal},
|
||||||
{"assert_notmatch", 2, 3, f_assert_notmatch},
|
{"assert_notmatch", 2, 3, f_assert_notmatch},
|
||||||
@ -1277,6 +1279,15 @@ f_assert_false(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
assert_bool(argvars, FALSE);
|
assert_bool(argvars, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "assert_inrange(lower, upper[, msg])" function
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
f_assert_inrange(typval_T *argvars, typval_T *rettv UNUSED)
|
||||||
|
{
|
||||||
|
assert_inrange(argvars);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "assert_match(pattern, actual[, msg])" function
|
* "assert_match(pattern, actual[, msg])" function
|
||||||
*/
|
*/
|
||||||
|
@ -121,6 +121,7 @@ void prepare_assert_error(garray_T *gap);
|
|||||||
void assert_error(garray_T *gap);
|
void assert_error(garray_T *gap);
|
||||||
void assert_equal_common(typval_T *argvars, assert_type_T atype);
|
void assert_equal_common(typval_T *argvars, assert_type_T atype);
|
||||||
void assert_match_common(typval_T *argvars, assert_type_T atype);
|
void assert_match_common(typval_T *argvars, assert_type_T atype);
|
||||||
|
void assert_inrange(typval_T *argvars);
|
||||||
void assert_bool(typval_T *argvars, int isTrue);
|
void assert_bool(typval_T *argvars, int isTrue);
|
||||||
void assert_exception(typval_T *argvars);
|
void assert_exception(typval_T *argvars);
|
||||||
void assert_fails(typval_T *argvars);
|
void assert_fails(typval_T *argvars);
|
||||||
|
@ -105,6 +105,19 @@ func Test_assert_fail_fails()
|
|||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_assert_inrange()
|
||||||
|
call assert_inrange(7, 7, 7)
|
||||||
|
call assert_inrange(5, 7, 5)
|
||||||
|
call assert_inrange(5, 7, 6)
|
||||||
|
call assert_inrange(5, 7, 7)
|
||||||
|
|
||||||
|
call assert_inrange(5, 7, 4)
|
||||||
|
call assert_match("Expected range 5 - 7, but got 4", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
call assert_inrange(5, 7, 8)
|
||||||
|
call assert_match("Expected range 5 - 7, but got 8", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_user_is_happy()
|
func Test_user_is_happy()
|
||||||
smile
|
smile
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
runtime ftplugin/man.vim
|
runtime ftplugin/man.vim
|
||||||
|
|
||||||
function Test_g_ft_man_open_mode()
|
function Test_g_ft_man_open_mode()
|
||||||
let l:w = winwidth(1)
|
|
||||||
vnew
|
vnew
|
||||||
let l:h = winheight(1)
|
let l:h = winheight(1)
|
||||||
q
|
q
|
||||||
|
let l:w = winwidth(1)
|
||||||
|
|
||||||
" split horizontally
|
" split horizontally
|
||||||
let wincnt = winnr('$')
|
let wincnt = winnr('$')
|
||||||
Man 'vim'
|
Man vim
|
||||||
if wincnt == winnr('$')
|
if wincnt == winnr('$')
|
||||||
" Vim manual page cannot be found.
|
" Vim manual page cannot be found.
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call assert_equal(l:w, winwidth(1))
|
|
||||||
|
call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
|
||||||
call assert_true(l:h > winheight(1))
|
call assert_true(l:h > winheight(1))
|
||||||
call assert_equal(1, tabpagenr('$'))
|
call assert_equal(1, tabpagenr('$'))
|
||||||
call assert_equal(1, tabpagenr())
|
call assert_equal(1, tabpagenr())
|
||||||
@ -21,8 +22,8 @@ function Test_g_ft_man_open_mode()
|
|||||||
|
|
||||||
" split horizontally
|
" split horizontally
|
||||||
let g:ft_man_open_mode = "horz"
|
let g:ft_man_open_mode = "horz"
|
||||||
Man 'vim'
|
Man vim
|
||||||
call assert_equal(l:w, winwidth(1))
|
call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
|
||||||
call assert_true(l:h > winheight(1))
|
call assert_true(l:h > winheight(1))
|
||||||
call assert_equal(1, tabpagenr('$'))
|
call assert_equal(1, tabpagenr('$'))
|
||||||
call assert_equal(1, tabpagenr())
|
call assert_equal(1, tabpagenr())
|
||||||
@ -30,7 +31,7 @@ function Test_g_ft_man_open_mode()
|
|||||||
|
|
||||||
" split vertically
|
" split vertically
|
||||||
let g:ft_man_open_mode = "vert"
|
let g:ft_man_open_mode = "vert"
|
||||||
Man 'vim'
|
Man vim
|
||||||
call assert_true(l:w > winwidth(1))
|
call assert_true(l:w > winwidth(1))
|
||||||
call assert_equal(l:h, winheight(1))
|
call assert_equal(l:h, winheight(1))
|
||||||
call assert_equal(1, tabpagenr('$'))
|
call assert_equal(1, tabpagenr('$'))
|
||||||
@ -39,9 +40,9 @@ function Test_g_ft_man_open_mode()
|
|||||||
|
|
||||||
" separate tab
|
" separate tab
|
||||||
let g:ft_man_open_mode = "tab"
|
let g:ft_man_open_mode = "tab"
|
||||||
Man 'vim'
|
Man vim
|
||||||
call assert_equal(l:w, winwidth(1))
|
call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
|
||||||
call assert_equal(l:h, winheight(1))
|
call assert_inrange(l:h - 1, l:h + 1, winheight(1))
|
||||||
call assert_equal(2, tabpagenr('$'))
|
call assert_equal(2, tabpagenr('$'))
|
||||||
call assert_equal(2, tabpagenr())
|
call assert_equal(2, tabpagenr())
|
||||||
q
|
q
|
||||||
@ -49,7 +50,7 @@ endfunction
|
|||||||
|
|
||||||
function Test_nomodifiable()
|
function Test_nomodifiable()
|
||||||
let wincnt = winnr('$')
|
let wincnt = winnr('$')
|
||||||
Man 'vim'
|
Man vim
|
||||||
if wincnt == winnr('$')
|
if wincnt == winnr('$')
|
||||||
" Vim manual page cannot be found.
|
" Vim manual page cannot be found.
|
||||||
return
|
return
|
||||||
|
@ -758,6 +758,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2095,
|
||||||
/**/
|
/**/
|
||||||
2094,
|
2094,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user