mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Merge remote-tracking branch 'vim/master'
This commit is contained in:
@@ -2360,7 +2360,6 @@ tempname() String name for a temporary file
|
||||
test_alloc_fail({id}, {countdown}, {repeat})
|
||||
none make memory allocation fail
|
||||
test_autochdir() none enable 'autochdir' during startup
|
||||
test_disable_char_avail({expr}) none test without typeahead
|
||||
test_garbagecollect_now() none free memory right now for testing
|
||||
test_ignore_error({expr}) none ignore a specific error
|
||||
test_null_channel() Channel null value for testing
|
||||
@@ -2369,6 +2368,7 @@ test_null_job() Job null value for testing
|
||||
test_null_list() List null value for testing
|
||||
test_null_partial() Funcref null value for testing
|
||||
test_null_string() String null value for testing
|
||||
test_override({expr}, {val}) none test with Vim internal overrides
|
||||
test_settime({expr}) none set current time for testing
|
||||
timer_info([{id}]) List information about timers
|
||||
timer_pause({id}, {pause}) none pause or unpause a timer
|
||||
|
||||
@@ -2128,6 +2128,7 @@ test_arglist \
|
||||
test_digraph \
|
||||
test_functions \
|
||||
test_display \
|
||||
test_edit \
|
||||
test_ex_undo \
|
||||
test_execute_func \
|
||||
test_expand \
|
||||
|
||||
Vendored
+26
-7
@@ -4124,9 +4124,9 @@ if test "$GCC" = yes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for recent clang version" >&5
|
||||
$as_echo_n "checking for recent clang version... " >&6; }
|
||||
CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang version" >&5
|
||||
$as_echo_n "checking for clang version... " >&6; }
|
||||
CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
|
||||
if test x"$CLANG_VERSION_STRING" != x"" ; then
|
||||
CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*/\1/p'`
|
||||
CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/p'`
|
||||
@@ -4134,12 +4134,19 @@ if test x"$CLANG_VERSION_STRING" != x"" ; then
|
||||
CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG_VERSION" >&5
|
||||
$as_echo "$CLANG_VERSION" >&6; }
|
||||
if test "$CLANG_VERSION" -ge 500002075 ; then
|
||||
CFLAGS=`echo "$CFLAGS" | sed -n -e 's/-fno-strength-reduce/ /p'`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if clang supports -fno-strength-reduce" >&5
|
||||
$as_echo_n "checking if clang supports -fno-strength-reduce... " >&6; }
|
||||
if test "$CLANG_VERSION" -ge 500002075 ; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
fi
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: N/A" >&5
|
||||
$as_echo "N/A" >&6; }
|
||||
fi
|
||||
|
||||
CROSS_COMPILING=
|
||||
@@ -10218,6 +10225,18 @@ fi
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /proc/self/exe" >&5
|
||||
$as_echo_n "checking for /proc/self/exe... " >&6; }
|
||||
if test -L "/proc/self/exe"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
$as_echo "#define HAVE_PROC_SELF_EXE 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN or MSYS environment" >&5
|
||||
$as_echo_n "checking for CYGWIN or MSYS environment... " >&6; }
|
||||
case `uname` in
|
||||
|
||||
+16
-4
@@ -67,8 +67,8 @@ dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
|
||||
dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
|
||||
dnl the version number of the clang in use.
|
||||
dnl Note that this does not work to get the version of clang 3.1 or 3.2.
|
||||
AC_MSG_CHECKING(for recent clang version)
|
||||
CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang.*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
|
||||
AC_MSG_CHECKING(for clang version)
|
||||
CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[[^0-9]]*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
|
||||
if test x"$CLANG_VERSION_STRING" != x"" ; then
|
||||
CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
|
||||
CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
|
||||
@@ -79,11 +79,15 @@ if test x"$CLANG_VERSION_STRING" != x"" ; then
|
||||
dnl change the constant 500002075 below appropriately. To get the
|
||||
dnl integer corresponding to a version number, refer to the
|
||||
dnl definition of CLANG_VERSION above.
|
||||
AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
|
||||
if test "$CLANG_VERSION" -ge 500002075 ; then
|
||||
CFLAGS=`echo "$CFLAGS" | sed -n -e 's/-fno-strength-reduce/ /p'`
|
||||
AC_MSG_RESULT(no)
|
||||
CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_RESULT(N/A)
|
||||
fi
|
||||
|
||||
dnl If configure thinks we are cross compiling, there might be something
|
||||
@@ -3101,6 +3105,14 @@ dnl ---------------------------------------------------------------------------
|
||||
dnl end of GUI-checking
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
AC_MSG_CHECKING([for /proc/self/exe])
|
||||
if test -L "/proc/self/exe"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_PROC_SELF_EXE)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
dnl Check for Cygwin, which needs an extra source file if not using X11
|
||||
AC_MSG_CHECKING(for CYGWIN or MSYS environment)
|
||||
case `uname` in
|
||||
|
||||
+6
-1
@@ -977,7 +977,12 @@ ex_diffpatch(exarg_T *eap)
|
||||
{
|
||||
/* Build the patch command and execute it. Ignore errors. Switch to
|
||||
* cooked mode to allow the user to respond to prompts. */
|
||||
vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"",
|
||||
vim_snprintf((char *)buf, buflen,
|
||||
#ifdef UNIX
|
||||
"patch -o %s %s < '%s'",
|
||||
#else
|
||||
"patch -o %s %s < \"%s\"",
|
||||
#endif
|
||||
tmp_new, tmp_orig,
|
||||
# ifdef UNIX
|
||||
fullname != NULL ? fullname :
|
||||
|
||||
+4
-1
@@ -2271,7 +2271,10 @@ has_compl_option(int dict_opt)
|
||||
vim_beep(BO_COMPL);
|
||||
setcursor();
|
||||
out_flush();
|
||||
ui_delay(2000L, FALSE);
|
||||
#ifdef FEAT_EVAL
|
||||
if (!get_vim_var_nr(VV_TESTING))
|
||||
#endif
|
||||
ui_delay(2000L, FALSE);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+27
-5
@@ -390,7 +390,7 @@ static void f_tagfiles(typval_T *argvars, typval_T *rettv);
|
||||
static void f_tempname(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_override(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_ignore_error(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
@@ -828,7 +828,6 @@ static struct fst
|
||||
{"tempname", 0, 0, f_tempname},
|
||||
{"test_alloc_fail", 3, 3, f_test_alloc_fail},
|
||||
{"test_autochdir", 0, 0, f_test_autochdir},
|
||||
{"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
|
||||
{"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now},
|
||||
{"test_ignore_error", 1, 1, f_test_ignore_error},
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
@@ -841,6 +840,7 @@ static struct fst
|
||||
{"test_null_list", 0, 0, f_test_null_list},
|
||||
{"test_null_partial", 0, 0, f_test_null_partial},
|
||||
{"test_null_string", 0, 0, f_test_null_string},
|
||||
{"test_override", 2, 2, f_test_override},
|
||||
{"test_settime", 1, 1, f_test_settime},
|
||||
#ifdef FEAT_TIMERS
|
||||
{"timer_info", 0, 1, f_timer_info},
|
||||
@@ -12353,12 +12353,34 @@ f_test_autochdir(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
}
|
||||
|
||||
/*
|
||||
* "test_disable_char_avail({expr})" function
|
||||
* "test_disable({name}, {val})" function
|
||||
*/
|
||||
static void
|
||||
f_test_disable_char_avail(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
disable_char_avail_for_testing = (int)get_tv_number(&argvars[0]);
|
||||
char_u *name = (char_u *)"";
|
||||
int val;
|
||||
|
||||
if (argvars[0].v_type != VAR_STRING
|
||||
|| (argvars[1].v_type) != VAR_NUMBER)
|
||||
EMSG(_(e_invarg));
|
||||
else
|
||||
{
|
||||
name = get_tv_string_chk(&argvars[0]);
|
||||
val = (int)get_tv_number(&argvars[1]);
|
||||
|
||||
if (STRCMP(name, (char_u *)"redraw") == 0)
|
||||
disable_redraw_for_testing = val;
|
||||
else if (STRCMP(name, (char_u *)"char_avail") == 0)
|
||||
disable_char_avail_for_testing = val;
|
||||
else if (STRCMP(name, (char_u *)"ALL") == 0)
|
||||
{
|
||||
disable_char_avail_for_testing = FALSE;
|
||||
disable_redraw_for_testing = FALSE;
|
||||
}
|
||||
else
|
||||
EMSG2(_(e_invarg2), name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+8
-1
@@ -2905,8 +2905,15 @@ ex_argdelete(exarg_T *eap)
|
||||
if (eap->line2 > ARGCOUNT)
|
||||
eap->line2 = ARGCOUNT;
|
||||
n = eap->line2 - eap->line1 + 1;
|
||||
if (*eap->arg != NUL || n <= 0)
|
||||
if (*eap->arg != NUL)
|
||||
/* Can't have both a range and an argument. */
|
||||
EMSG(_(e_invarg));
|
||||
else if (n <= 0)
|
||||
{
|
||||
/* Don't give an error for ":%argdel" if the list is empty. */
|
||||
if (eap->line1 != 1 || eap->line2 != 0)
|
||||
EMSG(_(e_invrange));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = eap->line1; i <= eap->line2; ++i)
|
||||
|
||||
@@ -1652,7 +1652,9 @@ EXTERN int alloc_fail_countdown INIT(= -1);
|
||||
/* set by alloc_fail(), number of times alloc() returns NULL */
|
||||
EXTERN int alloc_fail_repeat INIT(= 0);
|
||||
|
||||
/* flags set by test_override() */
|
||||
EXTERN int disable_char_avail_for_testing INIT(= 0);
|
||||
EXTERN int disable_redraw_for_testing INIT(= 0);
|
||||
|
||||
EXTERN int in_free_unref_items INIT(= FALSE);
|
||||
#endif
|
||||
|
||||
@@ -4240,7 +4240,6 @@ set_init_3(void)
|
||||
options[idx3].def_val[VI_DEFAULT] = p_shcf;
|
||||
}
|
||||
|
||||
# ifdef WIN3264
|
||||
/* Somehow Win32 requires the quotes around the redirection too */
|
||||
idx3 = findoption((char_u *)"sxq");
|
||||
if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
|
||||
@@ -4248,14 +4247,6 @@ set_init_3(void)
|
||||
p_sxq = (char_u *)"\"";
|
||||
options[idx3].def_val[VI_DEFAULT] = p_sxq;
|
||||
}
|
||||
# else
|
||||
idx3 = findoption((char_u *)"shq");
|
||||
if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
|
||||
{
|
||||
p_shq = (char_u *)"\"";
|
||||
options[idx3].def_val[VI_DEFAULT] = p_shq;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
|
||||
{
|
||||
|
||||
+6
-1
@@ -10609,7 +10609,12 @@ fillchar_vsep(int *attr)
|
||||
int
|
||||
redrawing(void)
|
||||
{
|
||||
return (!RedrawingDisabled
|
||||
#ifdef FEAT_EVAL
|
||||
if (disable_redraw_for_testing)
|
||||
return 0;
|
||||
else
|
||||
#endif
|
||||
return (!RedrawingDisabled
|
||||
&& !(p_lz && char_avail() && !KeyTyped && !do_redraw));
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,7 @@ NEW_TESTS = test_arabic.res \
|
||||
test_diffmode.res \
|
||||
test_digraph.res \
|
||||
test_display.res \
|
||||
test_edit.res \
|
||||
test_farsi.res \
|
||||
test_fnameescape.res \
|
||||
test_fold.res \
|
||||
|
||||
@@ -7,10 +7,13 @@ if 1
|
||||
|
||||
set nomore
|
||||
|
||||
" The terminal size is restored at the end.
|
||||
" Clear out t_WS, we don't want to resize the actual terminal.
|
||||
let script = [
|
||||
\ 'let save_columns = &columns',
|
||||
\ 'let save_lines = &lines',
|
||||
\ 'let save_term = &term',
|
||||
\ 'set t_WS=',
|
||||
\ ]
|
||||
|
||||
/#define p_term
|
||||
|
||||
@@ -49,7 +49,7 @@ source setup.vim
|
||||
" This also enables use of line continuation.
|
||||
set nocp viminfo+=nviminfo
|
||||
|
||||
" Use utf-8 or latin1 be default, instead of whatever the system default
|
||||
" Use utf-8 or latin1 by default, instead of whatever the system default
|
||||
" happens to be. Individual tests can overrule this at the top of the file.
|
||||
if has('multi_byte')
|
||||
set encoding=utf-8
|
||||
@@ -96,6 +96,9 @@ function RunTheTest(test)
|
||||
" mode message.
|
||||
set noshowmode
|
||||
|
||||
" Clear any overrides.
|
||||
call test_override('ALL', 0)
|
||||
|
||||
if exists("*SetUp")
|
||||
try
|
||||
call SetUp()
|
||||
|
||||
@@ -6,6 +6,10 @@ func Test_argidx()
|
||||
call assert_equal(2, argidx())
|
||||
%argdelete
|
||||
call assert_equal(0, argidx())
|
||||
" doing it again doesn't result in an error
|
||||
%argdelete
|
||||
call assert_equal(0, argidx())
|
||||
call assert_fails('2argdelete', 'E16:')
|
||||
|
||||
args a b c
|
||||
call assert_equal(0, argidx())
|
||||
|
||||
@@ -127,6 +127,14 @@ func Test_assert_with_msg()
|
||||
call remove(v:errors, 0)
|
||||
endfunc
|
||||
|
||||
func Test_override()
|
||||
call test_override('char_avail', 1)
|
||||
call test_override('redraw', 1)
|
||||
call test_override('ALL', 0)
|
||||
call assert_fails("call test_override('xxx', 1)", 'E475')
|
||||
call assert_fails("call test_override('redraw', 'yes')", 'E474')
|
||||
endfunc
|
||||
|
||||
func Test_user_is_happy()
|
||||
smile
|
||||
sleep 300m
|
||||
|
||||
@@ -44,9 +44,9 @@ func Test_curswant_with_autocommand()
|
||||
new
|
||||
call setline(1, ['func()', '{', '}', '----'])
|
||||
autocmd! CursorMovedI * call s:Highlight_Matching_Pair()
|
||||
call test_disable_char_avail(1)
|
||||
call test_override("char_avail", 1)
|
||||
exe "normal! 3Ga\<Down>X\<Esc>"
|
||||
call test_disable_char_avail(0)
|
||||
call test_override("char_avail", 0)
|
||||
call assert_equal('-X---', getline(4))
|
||||
autocmd! CursorMovedI *
|
||||
quit!
|
||||
|
||||
@@ -318,9 +318,20 @@ func Test_diffpatch()
|
||||
bwipe!
|
||||
new
|
||||
call assert_fails('diffpatch Xpatch', 'E816:')
|
||||
call setline(1, ['1', '2', '3'])
|
||||
diffpatch Xpatch
|
||||
call assert_equal(['1', '2x', '3', '4'], getline(1, '$'))
|
||||
|
||||
for name in ['Xpatch', 'Xpatch$HOME']
|
||||
call setline(1, ['1', '2', '3'])
|
||||
if name != 'Xpatch'
|
||||
call rename('Xpatch', name)
|
||||
endif
|
||||
exe 'diffpatch ' . escape(name, '$')
|
||||
call assert_equal(['1', '2x', '3', '4'], getline(1, '$'))
|
||||
if name != 'Xpatch'
|
||||
call rename(name, 'Xpatch')
|
||||
endif
|
||||
bwipe!
|
||||
endfor
|
||||
|
||||
call delete('Xpatch')
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
" Test filename modifiers.
|
||||
|
||||
func Test_fnamemodify()
|
||||
let save_home = $HOME
|
||||
let save_shell = &shell
|
||||
let $HOME = fnamemodify('.', ':p:h:h')
|
||||
set shell=sh
|
||||
|
||||
@@ -39,7 +41,9 @@ func Test_fnamemodify()
|
||||
call assert_equal("'abc\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||
set shell=tcsh
|
||||
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||
set shell&
|
||||
|
||||
let $HOME = save_home
|
||||
let &shell = save_shell
|
||||
endfunc
|
||||
|
||||
func Test_expand()
|
||||
|
||||
@@ -27,6 +27,13 @@ func Test_empty()
|
||||
call assert_equal(1, empty(v:false))
|
||||
call assert_equal(0, empty(v:true))
|
||||
|
||||
if has('channel')
|
||||
call assert_equal(1, empty(test_null_channel()))
|
||||
endif
|
||||
if has('job')
|
||||
call assert_equal(1, empty(test_null_job()))
|
||||
endif
|
||||
|
||||
call assert_equal(0, empty(function('Test_empty')))
|
||||
endfunc
|
||||
|
||||
@@ -467,6 +474,247 @@ func Test_getbufvar()
|
||||
set fileformats&
|
||||
endfunc
|
||||
|
||||
func Test_bufexists()
|
||||
call assert_equal(0, bufexists('does_not_exist'))
|
||||
call assert_equal(1, bufexists(bufnr('%')))
|
||||
call assert_equal(0, bufexists(0))
|
||||
new Xfoo
|
||||
let bn = bufnr('%')
|
||||
call assert_equal(1, bufexists(bn))
|
||||
call assert_equal(1, bufexists('Xfoo'))
|
||||
call assert_equal(1, bufexists(getcwd() . '/Xfoo'))
|
||||
call assert_equal(1, bufexists(0))
|
||||
bw
|
||||
call assert_equal(0, bufexists(bn))
|
||||
call assert_equal(0, bufexists('Xfoo'))
|
||||
endfunc
|
||||
|
||||
func Test_last_buffer_nr()
|
||||
call assert_equal(bufnr('$'), last_buffer_nr())
|
||||
endfunc
|
||||
|
||||
func Test_stridx()
|
||||
call assert_equal(-1, stridx('', 'l'))
|
||||
call assert_equal(0, stridx('', ''))
|
||||
call assert_equal(0, stridx('hello', ''))
|
||||
call assert_equal(-1, stridx('hello', 'L'))
|
||||
call assert_equal(2, stridx('hello', 'l', -1))
|
||||
call assert_equal(2, stridx('hello', 'l', 0))
|
||||
call assert_equal(2, stridx('hello', 'l', 1))
|
||||
call assert_equal(3, stridx('hello', 'l', 3))
|
||||
call assert_equal(-1, stridx('hello', 'l', 4))
|
||||
call assert_equal(-1, stridx('hello', 'l', 10))
|
||||
call assert_equal(2, stridx('hello', 'll'))
|
||||
call assert_equal(-1, stridx('hello', 'hello world'))
|
||||
endfunc
|
||||
|
||||
func Test_strridx()
|
||||
call assert_equal(-1, strridx('', 'l'))
|
||||
call assert_equal(0, strridx('', ''))
|
||||
call assert_equal(5, strridx('hello', ''))
|
||||
call assert_equal(-1, strridx('hello', 'L'))
|
||||
call assert_equal(3, strridx('hello', 'l'))
|
||||
call assert_equal(3, strridx('hello', 'l', 10))
|
||||
call assert_equal(3, strridx('hello', 'l', 3))
|
||||
call assert_equal(2, strridx('hello', 'l', 2))
|
||||
call assert_equal(-1, strridx('hello', 'l', 1))
|
||||
call assert_equal(-1, strridx('hello', 'l', 0))
|
||||
call assert_equal(-1, strridx('hello', 'l', -1))
|
||||
call assert_equal(2, strridx('hello', 'll'))
|
||||
call assert_equal(-1, strridx('hello', 'hello world'))
|
||||
endfunc
|
||||
|
||||
func Test_matchend()
|
||||
call assert_equal(7, matchend('testing', 'ing'))
|
||||
call assert_equal(7, matchend('testing', 'ing', 2))
|
||||
call assert_equal(-1, matchend('testing', 'ing', 5))
|
||||
endfunc
|
||||
|
||||
func Test_nextnonblank_prevnonblank()
|
||||
new
|
||||
insert
|
||||
This
|
||||
|
||||
|
||||
is
|
||||
|
||||
a
|
||||
Test
|
||||
.
|
||||
call assert_equal(0, nextnonblank(-1))
|
||||
call assert_equal(0, nextnonblank(0))
|
||||
call assert_equal(1, nextnonblank(1))
|
||||
call assert_equal(4, nextnonblank(2))
|
||||
call assert_equal(4, nextnonblank(3))
|
||||
call assert_equal(4, nextnonblank(4))
|
||||
call assert_equal(6, nextnonblank(5))
|
||||
call assert_equal(6, nextnonblank(6))
|
||||
call assert_equal(7, nextnonblank(7))
|
||||
call assert_equal(0, nextnonblank(8))
|
||||
|
||||
call assert_equal(0, prevnonblank(-1))
|
||||
call assert_equal(0, prevnonblank(0))
|
||||
call assert_equal(1, prevnonblank(1))
|
||||
call assert_equal(1, prevnonblank(2))
|
||||
call assert_equal(1, prevnonblank(3))
|
||||
call assert_equal(4, prevnonblank(4))
|
||||
call assert_equal(4, prevnonblank(5))
|
||||
call assert_equal(6, prevnonblank(6))
|
||||
call assert_equal(7, prevnonblank(7))
|
||||
call assert_equal(0, prevnonblank(8))
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_byte2line_line2byte()
|
||||
new
|
||||
call setline(1, ['a', 'bc', 'd'])
|
||||
|
||||
set fileformat=unix
|
||||
call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
|
||||
\ map(range(-1, 8), 'byte2line(v:val)'))
|
||||
call assert_equal([-1, -1, 1, 3, 6, 8, -1],
|
||||
\ map(range(-1, 5), 'line2byte(v:val)'))
|
||||
|
||||
set fileformat=mac
|
||||
call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
|
||||
\ map(range(-1, 8), 'byte2line(v:val)'))
|
||||
call assert_equal([-1, -1, 1, 3, 6, 8, -1],
|
||||
\ map(range(-1, 5), 'line2byte(v:val)'))
|
||||
|
||||
set fileformat=dos
|
||||
call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1],
|
||||
\ map(range(-1, 11), 'byte2line(v:val)'))
|
||||
call assert_equal([-1, -1, 1, 4, 8, 11, -1],
|
||||
\ map(range(-1, 5), 'line2byte(v:val)'))
|
||||
|
||||
set fileformat&
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_count()
|
||||
let l = ['a', 'a', 'A', 'b']
|
||||
call assert_equal(2, count(l, 'a'))
|
||||
call assert_equal(1, count(l, 'A'))
|
||||
call assert_equal(1, count(l, 'b'))
|
||||
call assert_equal(0, count(l, 'B'))
|
||||
|
||||
call assert_equal(2, count(l, 'a', 0))
|
||||
call assert_equal(1, count(l, 'A', 0))
|
||||
call assert_equal(1, count(l, 'b', 0))
|
||||
call assert_equal(0, count(l, 'B', 0))
|
||||
|
||||
call assert_equal(3, count(l, 'a', 1))
|
||||
call assert_equal(3, count(l, 'A', 1))
|
||||
call assert_equal(1, count(l, 'b', 1))
|
||||
call assert_equal(1, count(l, 'B', 1))
|
||||
call assert_equal(0, count(l, 'c', 1))
|
||||
|
||||
call assert_equal(1, count(l, 'a', 0, 1))
|
||||
call assert_equal(2, count(l, 'a', 1, 1))
|
||||
call assert_fails('call count(l, "a", 0, 10)', 'E684:')
|
||||
|
||||
let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'}
|
||||
call assert_equal(2, count(d, 'a'))
|
||||
call assert_equal(1, count(d, 'A'))
|
||||
call assert_equal(1, count(d, 'b'))
|
||||
call assert_equal(0, count(d, 'B'))
|
||||
|
||||
call assert_equal(2, count(d, 'a', 0))
|
||||
call assert_equal(1, count(d, 'A', 0))
|
||||
call assert_equal(1, count(d, 'b', 0))
|
||||
call assert_equal(0, count(d, 'B', 0))
|
||||
|
||||
call assert_equal(3, count(d, 'a', 1))
|
||||
call assert_equal(3, count(d, 'A', 1))
|
||||
call assert_equal(1, count(d, 'b', 1))
|
||||
call assert_equal(1, count(d, 'B', 1))
|
||||
call assert_equal(0, count(d, 'c', 1))
|
||||
|
||||
call assert_fails('call count(d, "a", 0, 1)', 'E474:')
|
||||
call assert_fails('call count("a", "a")', 'E712:')
|
||||
endfunc
|
||||
|
||||
func Test_changenr()
|
||||
new Xchangenr
|
||||
call assert_equal(0, changenr())
|
||||
norm ifoo
|
||||
call assert_equal(1, changenr())
|
||||
set undolevels=10
|
||||
norm Sbar
|
||||
call assert_equal(2, changenr())
|
||||
undo
|
||||
call assert_equal(1, changenr())
|
||||
redo
|
||||
call assert_equal(2, changenr())
|
||||
bw!
|
||||
set undolevels&
|
||||
endfunc
|
||||
|
||||
func Test_filewritable()
|
||||
new Xfilewritable
|
||||
write!
|
||||
call assert_equal(1, filewritable('Xfilewritable'))
|
||||
|
||||
call assert_notequal(0, setfperm('Xfilewritable', 'r--r-----'))
|
||||
call assert_equal(0, filewritable('Xfilewritable'))
|
||||
|
||||
call assert_notequal(0, setfperm('Xfilewritable', 'rw-r-----'))
|
||||
call assert_equal(1, filewritable('Xfilewritable'))
|
||||
|
||||
call assert_equal(0, filewritable('doesnotexist'))
|
||||
|
||||
call delete('Xfilewritable')
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_hostname()
|
||||
let hostname_vim = hostname()
|
||||
if has('unix')
|
||||
let hostname_system = systemlist('uname -n')[0]
|
||||
call assert_equal(hostname_vim, hostname_system)
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func Test_getpid()
|
||||
" getpid() always returns the same value within a vim instance.
|
||||
call assert_equal(getpid(), getpid())
|
||||
if has('unix')
|
||||
call assert_equal(systemlist('echo $PPID')[0], string(getpid()))
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func Test_hlexists()
|
||||
call assert_equal(0, hlexists('does_not_exist'))
|
||||
call assert_equal(0, hlexists('Number'))
|
||||
call assert_equal(0, highlight_exists('does_not_exist'))
|
||||
call assert_equal(0, highlight_exists('Number'))
|
||||
syntax on
|
||||
call assert_equal(0, hlexists('does_not_exist'))
|
||||
call assert_equal(1, hlexists('Number'))
|
||||
call assert_equal(0, highlight_exists('does_not_exist'))
|
||||
call assert_equal(1, highlight_exists('Number'))
|
||||
syntax off
|
||||
endfunc
|
||||
|
||||
func Test_col()
|
||||
new
|
||||
call setline(1, 'abcdef')
|
||||
norm gg4|mx6|mY2|
|
||||
call assert_equal(2, col('.'))
|
||||
call assert_equal(7, col('$'))
|
||||
call assert_equal(4, col("'x"))
|
||||
call assert_equal(6, col("'Y"))
|
||||
call assert_equal(2, col([1, 2]))
|
||||
call assert_equal(7, col([1, '$']))
|
||||
|
||||
call assert_equal(0, col(''))
|
||||
call assert_equal(0, col('x'))
|
||||
call assert_equal(0, col([2, '$']))
|
||||
call assert_equal(0, col([1, 100]))
|
||||
call assert_equal(0, col([1]))
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_balloon_show()
|
||||
if has('balloon_eval')
|
||||
" This won't do anything but must not crash either.
|
||||
|
||||
@@ -71,11 +71,12 @@ endfunc
|
||||
|
||||
func Test_packadd_symlink_dir()
|
||||
if !has('unix')
|
||||
return
|
||||
return
|
||||
endif
|
||||
let top2_dir = s:topdir . '/Xdir2'
|
||||
let real_dir = s:topdir . '/Xsym'
|
||||
exec "silent !ln -s" real_dir top2_dir
|
||||
call mkdir(real_dir, 'p')
|
||||
exec "silent !ln -s Xsym" top2_dir
|
||||
let &rtp = top2_dir . ',' . top2_dir . '/after'
|
||||
let &packpath = &rtp
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ func Test_search_cmdline()
|
||||
endif
|
||||
" need to disable char_avail,
|
||||
" so that expansion of commandline works
|
||||
call test_disable_char_avail(1)
|
||||
call test_override("char_avail", 1)
|
||||
new
|
||||
call setline(1, [' 1', ' 2 these', ' 3 the', ' 4 their', ' 5 there', ' 6 their', ' 7 the', ' 8 them', ' 9 these', ' 10 foobar'])
|
||||
" Test 1
|
||||
@@ -194,7 +194,7 @@ func Test_search_cmdline()
|
||||
call assert_equal(' 3 the', getline('.'))
|
||||
|
||||
" clean up
|
||||
call test_disable_char_avail(0)
|
||||
call test_override("char_avail", 0)
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
@@ -204,7 +204,7 @@ func Test_search_cmdline2()
|
||||
endif
|
||||
" need to disable char_avail,
|
||||
" so that expansion of commandline works
|
||||
call test_disable_char_avail(1)
|
||||
call test_override("char_avail", 1)
|
||||
new
|
||||
call setline(1, [' 1', ' 2 these', ' 3 the theother'])
|
||||
" Test 1
|
||||
@@ -266,7 +266,7 @@ func Test_search_cmdline2()
|
||||
|
||||
" clean up
|
||||
set noincsearch
|
||||
call test_disable_char_avail(0)
|
||||
call test_override("char_avail", 0)
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
|
||||
@@ -779,6 +779,24 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
442,
|
||||
/**/
|
||||
441,
|
||||
/**/
|
||||
440,
|
||||
/**/
|
||||
439,
|
||||
/**/
|
||||
438,
|
||||
/**/
|
||||
437,
|
||||
/**/
|
||||
436,
|
||||
/**/
|
||||
435,
|
||||
/**/
|
||||
434,
|
||||
/**/
|
||||
433,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user