forked from aniani/vim
patch 8.1.2011: more functions can be used as methods
Problem: More functions can be used as methods. Solution: Make various functions usable as a method. Make the window command test faster.
This commit is contained in:
@@ -754,11 +754,11 @@ static funcentry_T global_functions[] =
|
||||
{"synstack", 2, 2, 0, f_synstack},
|
||||
{"system", 1, 2, FEARG_1, f_system},
|
||||
{"systemlist", 1, 2, FEARG_1, f_systemlist},
|
||||
{"tabpagebuflist", 0, 1, 0, f_tabpagebuflist},
|
||||
{"tabpagebuflist", 0, 1, FEARG_1, f_tabpagebuflist},
|
||||
{"tabpagenr", 0, 1, 0, f_tabpagenr},
|
||||
{"tabpagewinnr", 1, 2, 0, f_tabpagewinnr},
|
||||
{"tabpagewinnr", 1, 2, FEARG_1, f_tabpagewinnr},
|
||||
{"tagfiles", 0, 0, 0, f_tagfiles},
|
||||
{"taglist", 1, 2, 0, f_taglist},
|
||||
{"taglist", 1, 2, FEARG_1, f_taglist},
|
||||
#ifdef FEAT_FLOAT
|
||||
{"tan", 1, 1, FEARG_1, f_tan},
|
||||
{"tanh", 1, 1, FEARG_1, f_tanh},
|
||||
@@ -793,13 +793,13 @@ static funcentry_T global_functions[] =
|
||||
{"term_start", 1, 2, 0, f_term_start},
|
||||
{"term_wait", 1, 2, 0, f_term_wait},
|
||||
#endif
|
||||
{"test_alloc_fail", 3, 3, 0, f_test_alloc_fail},
|
||||
{"test_alloc_fail", 3, 3, FEARG_1, f_test_alloc_fail},
|
||||
{"test_autochdir", 0, 0, 0, f_test_autochdir},
|
||||
{"test_feedinput", 1, 1, 0, f_test_feedinput},
|
||||
{"test_garbagecollect_now", 0, 0, 0, f_test_garbagecollect_now},
|
||||
{"test_garbagecollect_soon", 0, 0, 0, f_test_garbagecollect_soon},
|
||||
{"test_getvalue", 1, 1, 0, f_test_getvalue},
|
||||
{"test_ignore_error", 1, 1, 0, f_test_ignore_error},
|
||||
{"test_feedinput", 1, 1, FEARG_1, f_test_feedinput},
|
||||
{"test_garbagecollect_now", 0, 0, 0, f_test_garbagecollect_now},
|
||||
{"test_garbagecollect_soon", 0, 0, 0, f_test_garbagecollect_soon},
|
||||
{"test_getvalue", 1, 1, FEARG_1, f_test_getvalue},
|
||||
{"test_ignore_error", 1, 1, FEARG_1, f_test_ignore_error},
|
||||
{"test_null_blob", 0, 0, 0, f_test_null_blob},
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
{"test_null_channel", 0, 0, 0, f_test_null_channel},
|
||||
@@ -811,16 +811,16 @@ static funcentry_T global_functions[] =
|
||||
{"test_null_list", 0, 0, 0, f_test_null_list},
|
||||
{"test_null_partial", 0, 0, 0, f_test_null_partial},
|
||||
{"test_null_string", 0, 0, 0, f_test_null_string},
|
||||
{"test_option_not_set", 1, 1, 0, f_test_option_not_set},
|
||||
{"test_override", 2, 2, 0, f_test_override},
|
||||
{"test_refcount", 1, 1, 0, f_test_refcount},
|
||||
{"test_option_not_set", 1, 1, FEARG_1, f_test_option_not_set},
|
||||
{"test_override", 2, 2, FEARG_2, f_test_override},
|
||||
{"test_refcount", 1, 1, FEARG_1, f_test_refcount},
|
||||
#ifdef FEAT_GUI
|
||||
{"test_scrollbar", 3, 3, 0, f_test_scrollbar},
|
||||
{"test_scrollbar", 3, 3, FEARG_2, f_test_scrollbar},
|
||||
#endif
|
||||
#ifdef FEAT_MOUSE
|
||||
{"test_setmouse", 2, 2, 0, f_test_setmouse},
|
||||
#endif
|
||||
{"test_settime", 1, 1, 0, f_test_settime},
|
||||
{"test_settime", 1, 1, FEARG_1, f_test_settime},
|
||||
#ifdef FEAT_TIMERS
|
||||
{"timer_info", 0, 1, 0, f_timer_info},
|
||||
{"timer_pause", 2, 2, 0, f_timer_pause},
|
||||
|
@@ -259,7 +259,7 @@ endfunc
|
||||
|
||||
func Test_override()
|
||||
call test_override('char_avail', 1)
|
||||
call test_override('redraw', 1)
|
||||
eval 1->test_override('redraw')
|
||||
call test_override('ALL', 0)
|
||||
call assert_fails("call test_override('xxx', 1)", 'E475')
|
||||
call assert_fails("call test_override('redraw', 'yes')", 'E474')
|
||||
|
@@ -398,72 +398,69 @@ func Test_set_guifont()
|
||||
endfunc
|
||||
|
||||
func Test_set_guifontset()
|
||||
CheckFeature xfontset
|
||||
let skipped = ''
|
||||
|
||||
if !has('xfontset')
|
||||
let skipped = g:not_supported . 'xfontset'
|
||||
else
|
||||
let ctype_saved = v:ctype
|
||||
let ctype_saved = v:ctype
|
||||
|
||||
" First, since XCreateFontSet(3) is very sensitive to locale, fonts must
|
||||
" be chosen meticulously.
|
||||
let font_head = '-misc-fixed-medium-r-normal--14'
|
||||
" First, since XCreateFontSet(3) is very sensitive to locale, fonts must
|
||||
" be chosen meticulously.
|
||||
let font_head = '-misc-fixed-medium-r-normal--14'
|
||||
|
||||
let font_aw70 = font_head . '-130-75-75-c-70'
|
||||
let font_aw140 = font_head . '-130-75-75-c-140'
|
||||
let font_aw70 = font_head . '-130-75-75-c-70'
|
||||
let font_aw140 = font_head . '-130-75-75-c-140'
|
||||
|
||||
let font_jisx0201 = font_aw70 . '-jisx0201.1976-0'
|
||||
let font_jisx0208 = font_aw140 . '-jisx0208.1983-0'
|
||||
let font_jisx0201 = font_aw70 . '-jisx0201.1976-0'
|
||||
let font_jisx0208 = font_aw140 . '-jisx0208.1983-0'
|
||||
|
||||
let full_XLFDs = join([ font_jisx0208, font_jisx0201 ], ',')
|
||||
let short_XLFDs = join([ font_aw140, font_aw70 ], ',')
|
||||
let singleton = font_head . '-*'
|
||||
let aliases = 'k14,r14'
|
||||
let full_XLFDs = join([ font_jisx0208, font_jisx0201 ], ',')
|
||||
let short_XLFDs = join([ font_aw140, font_aw70 ], ',')
|
||||
let singleton = font_head . '-*'
|
||||
let aliases = 'k14,r14'
|
||||
|
||||
" Second, among 'locales', look up such a locale that gets 'set
|
||||
" guifontset=' to work successfully with every fontset specified with
|
||||
" 'fontsets'.
|
||||
let locales = [ 'ja_JP.UTF-8', 'ja_JP.eucJP', 'ja_JP.SJIS' ]
|
||||
let fontsets = [ full_XLFDs, short_XLFDs, singleton, aliases ]
|
||||
" Second, among 'locales', look up such a locale that gets 'set
|
||||
" guifontset=' to work successfully with every fontset specified with
|
||||
" 'fontsets'.
|
||||
let locales = [ 'ja_JP.UTF-8', 'ja_JP.eucJP', 'ja_JP.SJIS' ]
|
||||
let fontsets = [ full_XLFDs, short_XLFDs, singleton, aliases ]
|
||||
|
||||
let feasible = 0
|
||||
for locale in locales
|
||||
let feasible = 0
|
||||
for locale in locales
|
||||
try
|
||||
exec 'language ctype' locale
|
||||
catch /^Vim\%((\a\+)\)\=:E197/
|
||||
continue
|
||||
endtry
|
||||
let done = 0
|
||||
for fontset in fontsets
|
||||
try
|
||||
exec 'language ctype' locale
|
||||
catch /^Vim\%((\a\+)\)\=:E197/
|
||||
continue
|
||||
exec 'set guifontset=' . fontset
|
||||
catch /^Vim\%((\a\+)\)\=:E\%(250\|252\|234\|597\|598\)/
|
||||
break
|
||||
endtry
|
||||
let done = 0
|
||||
for fontset in fontsets
|
||||
try
|
||||
exec 'set guifontset=' . fontset
|
||||
catch /^Vim\%((\a\+)\)\=:E\%(250\|252\|234\|597\|598\)/
|
||||
break
|
||||
endtry
|
||||
let done += 1
|
||||
endfor
|
||||
if done == len(fontsets)
|
||||
let feasible = 1
|
||||
break
|
||||
endif
|
||||
let done += 1
|
||||
endfor
|
||||
|
||||
" Third, give a set of tests if it is found feasible.
|
||||
if !feasible
|
||||
let skipped = g:not_hosted
|
||||
else
|
||||
" N.B. 'v:ctype' has already been set to an appropriate value in the
|
||||
" previous loop.
|
||||
for fontset in fontsets
|
||||
exec 'set guifontset=' . fontset
|
||||
call assert_equal(fontset, &guifontset)
|
||||
endfor
|
||||
if done == len(fontsets)
|
||||
let feasible = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Finally, restore ctype.
|
||||
exec 'language ctype' ctype_saved
|
||||
" Third, give a set of tests if it is found feasible.
|
||||
if !feasible
|
||||
let skipped = g:not_hosted
|
||||
else
|
||||
" N.B. 'v:ctype' has already been set to an appropriate value in the
|
||||
" previous loop.
|
||||
for fontset in fontsets
|
||||
exec 'set guifontset=' . fontset
|
||||
call assert_equal(fontset, &guifontset)
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Finally, restore ctype.
|
||||
exec 'language ctype' ctype_saved
|
||||
|
||||
if !empty(skipped)
|
||||
throw skipped
|
||||
endif
|
||||
@@ -677,7 +674,7 @@ func Test_scrollbars()
|
||||
set guioptions+=rlb
|
||||
|
||||
" scroll to move line 11 at top, moves the cursor there
|
||||
call test_scrollbar('left', 10, 0)
|
||||
eval 10->test_scrollbar('left', 0)
|
||||
redraw
|
||||
call assert_equal(1, winline())
|
||||
call assert_equal(11, line('.'))
|
||||
|
@@ -90,7 +90,7 @@ func Test_echoerr()
|
||||
if has('float')
|
||||
call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
|
||||
endif
|
||||
call test_ignore_error('<lambda>')
|
||||
eval '<lambda>'->test_ignore_error()
|
||||
call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
|
||||
call test_ignore_error('RESET')
|
||||
endfunc
|
||||
|
@@ -510,7 +510,7 @@ func Test_shortmess_F2()
|
||||
call assert_true(empty(execute('bn', '')))
|
||||
call assert_false(test_getvalue('need_fileinfo'))
|
||||
call assert_true(empty(execute('bn', '')))
|
||||
call assert_false(test_getvalue('need_fileinfo'))
|
||||
call assert_false('need_fileinfo'->test_getvalue())
|
||||
set hidden
|
||||
call assert_true(empty(execute('bn', '')))
|
||||
call assert_false(test_getvalue('need_fileinfo'))
|
||||
|
@@ -517,7 +517,7 @@ func Test_nomem()
|
||||
call test_alloc_fail(GetAllocId('qf_dirname_start'), 0, 0)
|
||||
call assert_fails('vimgrep vim runtest.vim', 'E342:')
|
||||
|
||||
call test_alloc_fail(GetAllocId('qf_dirname_now'), 0, 0)
|
||||
call GetAllocId('qf_dirname_now')->test_alloc_fail(0, 0)
|
||||
call assert_fails('vimgrep vim runtest.vim', 'E342:')
|
||||
|
||||
call test_alloc_fail(GetAllocId('qf_namebuf'), 0, 0)
|
||||
|
@@ -13,7 +13,7 @@ func Test_taglist()
|
||||
split Xtext
|
||||
|
||||
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
|
||||
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name}))
|
||||
call assert_equal(['FFoo', 'BFoo'], map("Foo"->taglist("Xtext"), {i, v -> v.name}))
|
||||
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
|
||||
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
|
||||
|
||||
|
@@ -646,7 +646,7 @@ func Test_term_rgb_response()
|
||||
|
||||
" response to t_RB, 4 digits, dark
|
||||
set background=light
|
||||
call test_option_not_set('background')
|
||||
eval 'background'->test_option_not_set()
|
||||
let red = 0x29
|
||||
let green = 0x4a
|
||||
let blue = 0x6b
|
||||
|
@@ -251,7 +251,7 @@ func FeedAndPeek(timer)
|
||||
endfunc
|
||||
|
||||
func Interrupt(timer)
|
||||
call test_feedinput("\<C-C>")
|
||||
eval "\<C-C>"->test_feedinput()
|
||||
endfunc
|
||||
|
||||
func Test_timer_peek_and_get_char()
|
||||
|
@@ -171,7 +171,7 @@ func Test_cmdline_history_order()
|
||||
|
||||
call histdel(':')
|
||||
" items go before and after
|
||||
call test_settime(8)
|
||||
eval 8->test_settime()
|
||||
call histadd(':', "echo '8'")
|
||||
call test_settime(39)
|
||||
call histadd(':', "echo '39'")
|
||||
|
@@ -1596,7 +1596,7 @@ func Test_refcount()
|
||||
call assert_equal(1, test_refcount(x))
|
||||
|
||||
let x = {}
|
||||
call assert_equal(1, test_refcount(x))
|
||||
call assert_equal(1, x->test_refcount())
|
||||
|
||||
let x = 0zff
|
||||
call assert_equal(1, test_refcount(x))
|
||||
|
@@ -485,7 +485,7 @@ func Test_window_newtab()
|
||||
wincmd T
|
||||
call assert_equal(2, tabpagenr('$'))
|
||||
call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)'))
|
||||
call assert_equal(['Xc' ], map(tabpagebuflist(2), 'bufname(v:val)'))
|
||||
call assert_equal(['Xc' ], map(2->tabpagebuflist(), 'bufname(v:val)'))
|
||||
|
||||
%bw!
|
||||
endfunc
|
||||
@@ -598,8 +598,11 @@ endfunc
|
||||
|
||||
func Fun_RenewFile()
|
||||
" Need to wait a bit for the timestamp to be older.
|
||||
sleep 2
|
||||
silent execute '!echo "1" > tmp.txt'
|
||||
let old_ftime = getftime("tmp.txt")
|
||||
while getftime("tmp.txt") == old_ftime
|
||||
sleep 100m
|
||||
silent execute '!echo "1" > tmp.txt'
|
||||
endwhile
|
||||
sp
|
||||
wincmd p
|
||||
edit! tmp.txt
|
||||
@@ -835,7 +838,7 @@ func Test_winnr()
|
||||
|
||||
tabnew
|
||||
call assert_equal(8, tabpagewinnr(1, 'j'))
|
||||
call assert_equal(2, tabpagewinnr(1, 'k'))
|
||||
call assert_equal(2, 1->tabpagewinnr('k'))
|
||||
call assert_equal(4, tabpagewinnr(1, 'h'))
|
||||
call assert_equal(6, tabpagewinnr(1, 'l'))
|
||||
|
||||
|
@@ -757,6 +757,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2011,
|
||||
/**/
|
||||
2010,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user