Patch 7.4.2095
Problem: Man test fails when run with the GUI.
Solution: Adjust for different behavior of GUI. Add assert_inrange().
Files: src/eval.c, src/evalfunc.c, src/proto/eval.pro,
src/testdir/test_assert.vim, src/testdir/test_man.vim,
runtime/doc/eval.txt
*** ../vim-7.4.2094/src/eval.c 2016-07-22 21:49:36.674031468 +0200
--- src/eval.c 2016-07-23 15:09:49.983697027 +0200
***************
*** 8992,8997 ****
--- 8992,9030 ----
}
}
+ 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().
*/
*** ../vim-7.4.2094/src/evalfunc.c 2016-07-22 21:49:36.678031435 +0200
--- src/evalfunc.c 2016-07-23 14:58:29.214012839 +0200
***************
*** 48,53 ****
--- 48,54 ----
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_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_notequal(typval_T *argvars, typval_T *rettv);
static void f_assert_notmatch(typval_T *argvars, typval_T *rettv);
***************
*** 460,465 ****
--- 461,467 ----
{"assert_exception", 1, 2, f_assert_exception},
{"assert_fails", 1, 2, f_assert_fails},
{"assert_false", 1, 2, f_assert_false},
+ {"assert_inrange", 2, 3, f_assert_inrange},
{"assert_match", 2, 3, f_assert_match},
{"assert_notequal", 2, 3, f_assert_notequal},
{"assert_notmatch", 2, 3, f_assert_notmatch},
***************
*** 1278,1283 ****
--- 1280,1294 ----
}
/*
+ * "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
*/
static void
*** ../vim-7.4.2094/src/proto/eval.pro 2016-07-19 19:10:48.020177776 +0200
--- src/proto/eval.pro 2016-07-23 15:09:08.680079611 +0200
***************
*** 121,126 ****
--- 121,127 ----
void assert_error(garray_T *gap);
void assert_equal_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_exception(typval_T *argvars);
void assert_fails(typval_T *argvars);
*** ../vim-7.4.2094/src/testdir/test_assert.vim 2016-04-03 20:57:17.009726516
+0200
--- src/testdir/test_assert.vim 2016-07-23 15:13:09.173853012 +0200
***************
*** 105,110 ****
--- 105,123 ----
call remove(v:errors, 0)
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()
smile
*** ../vim-7.4.2094/src/testdir/test_man.vim 2016-06-20 11:21:37.048520929
+0200
--- src/testdir/test_man.vim 2016-07-23 15:27:51.857700234 +0200
***************
*** 1,19 ****
runtime ftplugin/man.vim
function Test_g_ft_man_open_mode()
- let l:w = winwidth(1)
vnew
let l:h = winheight(1)
q
" split horizontally
let wincnt = winnr('$')
! Man 'vim'
if wincnt == winnr('$')
" Vim manual page cannot be found.
return
endif
! call assert_equal(l:w, winwidth(1))
call assert_true(l:h > winheight(1))
call assert_equal(1, tabpagenr('$'))
call assert_equal(1, tabpagenr())
--- 1,20 ----
runtime ftplugin/man.vim
function Test_g_ft_man_open_mode()
vnew
let l:h = winheight(1)
q
+ let l:w = winwidth(1)
" split horizontally
let wincnt = winnr('$')
! Man vim
if wincnt == winnr('$')
" Vim manual page cannot be found.
return
endif
!
! call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
call assert_true(l:h > winheight(1))
call assert_equal(1, tabpagenr('$'))
call assert_equal(1, tabpagenr())
***************
*** 21,28 ****
" split horizontally
let g:ft_man_open_mode = "horz"
! Man 'vim'
! call assert_equal(l:w, winwidth(1))
call assert_true(l:h > winheight(1))
call assert_equal(1, tabpagenr('$'))
call assert_equal(1, tabpagenr())
--- 22,29 ----
" split horizontally
let g:ft_man_open_mode = "horz"
! Man vim
! call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
call assert_true(l:h > winheight(1))
call assert_equal(1, tabpagenr('$'))
call assert_equal(1, tabpagenr())
***************
*** 30,36 ****
" split vertically
let g:ft_man_open_mode = "vert"
! Man 'vim'
call assert_true(l:w > winwidth(1))
call assert_equal(l:h, winheight(1))
call assert_equal(1, tabpagenr('$'))
--- 31,37 ----
" split vertically
let g:ft_man_open_mode = "vert"
! Man vim
call assert_true(l:w > winwidth(1))
call assert_equal(l:h, winheight(1))
call assert_equal(1, tabpagenr('$'))
***************
*** 39,47 ****
" separate tab
let g:ft_man_open_mode = "tab"
! Man 'vim'
! call assert_equal(l:w, winwidth(1))
! call assert_equal(l:h, winheight(1))
call assert_equal(2, tabpagenr('$'))
call assert_equal(2, tabpagenr())
q
--- 40,48 ----
" separate tab
let g:ft_man_open_mode = "tab"
! Man vim
! call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
! call assert_inrange(l:h - 1, l:h + 1, winheight(1))
call assert_equal(2, tabpagenr('$'))
call assert_equal(2, tabpagenr())
q
***************
*** 49,55 ****
function Test_nomodifiable()
let wincnt = winnr('$')
! Man 'vim'
if wincnt == winnr('$')
" Vim manual page cannot be found.
return
--- 50,56 ----
function Test_nomodifiable()
let wincnt = winnr('$')
! Man vim
if wincnt == winnr('$')
" Vim manual page cannot be found.
return
*** ../vim-7.4.2094/runtime/doc/eval.txt 2016-07-22 21:49:36.682031402
+0200
--- runtime/doc/eval.txt 2016-07-23 15:23:37.264048822 +0200
***************
*** 1928,1940 ****
assert_exception({error} [, {msg}]) none assert {error} is in
v:exception
assert_fails({cmd} [, {error}]) none assert {cmd} fails
assert_false({actual} [, {msg}]) none assert {actual} is false
assert_match({pat}, {text} [, {msg}]) none assert {pat} matches {text}
assert_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text}
assert_true({actual} [, {msg}]) none assert {actual} is true
asin({expr}) Float arc sine of {expr}
atan({expr}) Float arc tangent of {expr}
! atan2({expr}, {expr}) Float arc tangent of {expr1} / {expr2}
browse({save}, {title}, {initdir}, {default})
String put up a file requester
browsedir({title}, {initdir}) String put up a directory requester
--- 1947,1961 ----
assert_exception({error} [, {msg}]) none assert {error} is in
v:exception
assert_fails({cmd} [, {error}]) none assert {cmd} fails
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_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text}
assert_true({actual} [, {msg}]) none assert {actual} is true
asin({expr}) Float arc sine of {expr}
atan({expr}) Float arc tangent of {expr}
! atan2({expr}, {expr}) Float arc tangent of {expr1} / {expr2}
browse({save}, {title}, {initdir}, {default})
String put up a file requester
browsedir({title}, {initdir}) String put up a directory requester
***************
*** 2459,2466 ****
|v:errors|, like with |assert_equal()|.
A value is false when it is zero. When {actual} is not a
number the assert fails.
! When {msg} is omitted an error in the form "Expected False but
! got {actual}" is produced.
*assert_match()*
assert_match({pattern}, {actual} [, {msg}])
--- 2480,2495 ----
|v:errors|, like with |assert_equal()|.
A value is false when it is zero. When {actual} is not a
number the assert fails.
! When {msg} is omitted an error in the form
! "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({pattern}, {actual} [, {msg}])
*** ../vim-7.4.2094/src/version.c 2016-07-23 14:35:04.063079009 +0200
--- src/version.c 2016-07-23 15:33:03.882801480 +0200
***************
*** 760,761 ****
--- 760,763 ----
{ /* Add new patch number below this line */
+ /**/
+ 2095,
/**/
--
Be nice to your kids... they'll be the ones choosing your nursing home.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.