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.
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index d89bd98..1b1f9e5 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -259,7 +259,7 @@
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')
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index e80e85f..f2d82e4 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -398,72 +398,69 @@
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 @@
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('.'))
diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim
index f122917..bcfcdd2 100644
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -90,7 +90,7 @@
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
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 5d5723c..3a43356 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -510,7 +510,7 @@
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'))
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 402a96d..f240398 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -517,7 +517,7 @@
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)
diff --git a/src/testdir/test_taglist.vim b/src/testdir/test_taglist.vim
index 9ddefc5..824adc0 100644
--- a/src/testdir/test_taglist.vim
+++ b/src/testdir/test_taglist.vim
@@ -13,7 +13,7 @@
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}))
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index 7b71d60..e8b36f4 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -646,7 +646,7 @@
" 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
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index 3eebad6..261be27 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -251,7 +251,7 @@
endfunc
func Interrupt(timer)
- call test_feedinput("\<C-C>")
+ eval "\<C-C>"->test_feedinput()
endfunc
func Test_timer_peek_and_get_char()
diff --git a/src/testdir/test_viminfo.vim b/src/testdir/test_viminfo.vim
index 306f54d..048ebac 100644
--- a/src/testdir/test_viminfo.vim
+++ b/src/testdir/test_viminfo.vim
@@ -171,7 +171,7 @@
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'")
diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim
index 8dc00f2..18790d2 100644
--- a/src/testdir/test_vimscript.vim
+++ b/src/testdir/test_vimscript.vim
@@ -1596,7 +1596,7 @@
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))
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index 9927e27..f2a9f17 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -485,7 +485,7 @@
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 @@
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 @@
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'))