0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 7.4.2227

Problem:    Tab page tests are old style.
Solution:   Change into new style tests. (Hirohito Higashi)
This commit is contained in:
Bram Moolenaar
2016-08-18 22:11:42 +02:00
parent 3392883770
commit 1381d79147
7 changed files with 194 additions and 302 deletions

View File

@@ -2041,7 +2041,7 @@ test1 \
test30 test31 test32 test33 test34 test36 test37 test38 test39 \ test30 test31 test32 test33 test34 test36 test37 test38 test39 \
test40 test41 test42 test43 test44 test45 test46 test48 test49 \ test40 test41 test42 test43 test44 test45 test46 test48 test49 \
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \ test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
test60 test62 test64 test65 test66 test67 test68 test69 \ test60 test64 test65 test66 test67 test68 test69 \
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \ test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \ test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \
test90 test91 test92 test93 test94 test95 test97 test98 test99 \ test90 test91 test92 test93 test94 test95 test97 test98 test99 \
@@ -2122,6 +2122,7 @@ test_arglist \
test_syn_attr \ test_syn_attr \
test_syntax \ test_syntax \
test_tabline \ test_tabline \
test_tabpage \
test_tagjump \ test_tagjump \
test_textobjects \ test_textobjects \
test_timers \ test_timers \

View File

@@ -50,7 +50,6 @@ SCRIPTS_ALL = \
test56.out \ test56.out \
test57.out \ test57.out \
test60.out \ test60.out \
test62.out \
test64.out \ test64.out \
test65.out \ test65.out \
test66.out \ test66.out \

View File

@@ -1,205 +0,0 @@
Tests for tab pages
STARTTEST
:so small.vim
:lang C
:" Simple test for opening and closing a tab page
:tabnew
:let nr = tabpagenr()
:q
:call append(line('$'), 'tab page ' . nr)
:unlet nr
:"
:" Open three tab pages and use ":tabdo"
:0tabnew
:1tabnew
:$tabnew
:tabdo call append(line('$'), 'this is tab page ' . tabpagenr())
:tabclose! 2
:tabrewind
:let line1 = getline('$')
:undo
:q
:tablast
:let line2 = getline('$')
:q!
:call append(line('$'), line1)
:call append(line('$'), line2)
:unlet line1 line2
:"
:" Test for settabvar() and gettabvar() functions. Open a new tab page and
:" set 3 variables to a number, string and a list. Verify that the variables
:" are correctly set.
:tabnew
:tabfirst
:call settabvar(2, 'val_num', 100)
:call settabvar(2, 'val_str', 'SetTabVar test')
:call settabvar(2, 'val_list', ['red', 'blue', 'green'])
:"
:let test_status = 'gettabvar: fail'
:if gettabvar(2, 'val_num') == 100 && gettabvar(2, 'val_str') == 'SetTabVar test' && gettabvar(2, 'val_list') == ['red', 'blue', 'green']
: let test_status = 'gettabvar: pass'
:endif
:call append(line('$'), test_status)
:"
:tabnext 2
:let test_status = 'settabvar: fail'
:if t:val_num == 100 && t:val_str == 'SetTabVar test' && t:val_list == ['red', 'blue', 'green']
: let test_status = 'settabvar: pass'
:endif
:tabclose
:call append(line('$'), test_status)
:"
:if has('gui') || has('clientserver')
:" Test for ":tab drop exist-file" to keep current window.
:sp test1
:tab drop test1
:let test_status = 'tab drop 1: fail'
:if tabpagenr('$') == 1 && winnr('$') == 2 && winnr() == 1
: let test_status = 'tab drop 1: pass'
:endif
:close
:call append(line('$'), test_status)
:"
:"
:" Test for ":tab drop new-file" to keep current window of tabpage 1.
:split
:tab drop newfile
:let test_status = 'tab drop 2: fail'
:if tabpagenr('$') == 2 && tabpagewinnr(1, '$') == 2 && tabpagewinnr(1) == 1
: let test_status = 'tab drop 2: pass'
:endif
:tabclose
:q
:call append(line('$'), test_status)
:"
:"
:" Test for ":tab drop multi-opend-file" to keep current tabpage and window.
:new test1
:tabnew
:new test1
:tab drop test1
:let test_status = 'tab drop 3: fail'
:if tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1
: let test_status = 'tab drop 3: pass'
:endif
:tabclose
:q
:call append(line('$'), test_status)
:else
:" :drop not supported
:call append(line('$'), 'tab drop 1: pass')
:call append(line('$'), 'tab drop 2: pass')
:call append(line('$'), 'tab drop 3: pass')
:endif
:"
:"
:for i in range(9) | tabnew | endfor
1gt
:$put =tabpagenr()
:tabmove 5
:$put =tabpagenr()
:.tabmove
:$put =tabpagenr()
:tabmove -
:$put =tabpagenr()
:tabmove +
:$put =tabpagenr()
:tabmove -2
:$put =tabpagenr()
:tabmove +4
:$put =tabpagenr()
:tabmove
:$put =tabpagenr()
:tabmove -20
:$put =tabpagenr()
:tabmove +20
:$put =tabpagenr()
:0tabmove
:$put =tabpagenr()
:$tabmove
:$put =tabpagenr()
:tabmove 0
:$put =tabpagenr()
:tabmove $
:$put =tabpagenr()
:3tabmove
:$put =tabpagenr()
:7tabmove 5
:$put =tabpagenr()
:let a='No error caught.'
:try
:tabmove foo
:catch E474
:let a='E474 caught.'
:endtry
:$put =a
:"
:" Test autocommands
:tabonly!
:let g:r=[]
:command -nargs=1 -bar C :call add(g:r, '=== ' . <q-args> . ' ===')|<args>
:function Test()
let hasau=has('autocmd')
if hasau
autocmd TabEnter * :call add(g:r, 'TabEnter')
autocmd WinEnter * :call add(g:r, 'WinEnter')
autocmd BufEnter * :call add(g:r, 'BufEnter')
autocmd TabLeave * :call add(g:r, 'TabLeave')
autocmd WinLeave * :call add(g:r, 'WinLeave')
autocmd BufLeave * :call add(g:r, 'BufLeave')
endif
let t:a='a'
C tab split
if !hasau
let g:r+=['WinLeave', 'TabLeave', 'WinEnter', 'TabEnter']
endif
let t:a='b'
C tabnew
if !hasau
let g:r+=['WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufLeave', 'BufEnter']
endif
let t:a='c'
call add(g:r, join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")')))
C call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)')
call add(g:r, join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")')))
let w:a='a'
C vsplit
if !hasau
let g:r+=['WinLeave', 'WinEnter']
endif
let w:a='a'
let tabn=tabpagenr()
let winr=range(1, winnr('$'))
C tabnext 1
if !hasau
let g:r+=['BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter']
endif
call add(g:r, join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")')))
C call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)')
call add(g:r, join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")')))
if hasau
augroup TabDestructive
autocmd TabEnter * :C tabnext 2 | C tabclose 3
augroup END
C tabnext 3
let g:r+=[tabpagenr().'/'.tabpagenr('$')]
autocmd! TabDestructive TabEnter
C tabnew
C tabnext 1
autocmd TabDestructive TabEnter * nested :C tabnext 2 | C tabclose 3
C tabnext 3
let g:r+=[tabpagenr().'/'.tabpagenr('$')]
else
let g:r+=["=== tabnext 3 ===","BufLeave","WinLeave","TabLeave","WinEnter","TabEnter","=== tabnext 2 ===","=== tabclose 3 ===","2/2","=== tabnew ===","WinLeave","TabLeave","WinEnter","TabEnter","BufLeave","BufEnter","=== tabnext 1 ===","BufLeave","WinLeave","TabLeave","WinEnter","TabEnter","BufEnter","=== tabnext 3 ===","BufLeave","WinLeave","TabLeave","WinEnter","TabEnter","=== tabnext 2 ===","BufLeave","WinLeave","TabLeave","WinEnter","TabEnter","=== tabnext 2 ===","=== tabclose 3 ===","BufEnter","=== tabclose 3 ===","2/2",]
endif
endfunction
:call Test()
:$ put =g:r
:"
:"
:/^Results/,$w! test.out
:qa!
ENDTEST
Results:

View File

@@ -1,95 +0,0 @@
Results:
tab page 2
this is tab page 3
this is tab page 1
this is tab page 4
gettabvar: pass
settabvar: pass
tab drop 1: pass
tab drop 2: pass
tab drop 3: pass
1
5
5
4
5
3
7
10
1
10
1
10
1
10
4
5
E474 caught.
=== tab split ===
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnew ===
WinLeave
TabLeave
WinEnter
TabEnter
BufLeave
BufEnter
a b c
=== call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)') ===
2 4 6
=== vsplit ===
WinLeave
WinEnter
=== tabnext 1 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
BufEnter
a a
=== call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)') ===
2 4
=== tabnext 3 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnext 2 ===
=== tabclose 3 ===
2/2
=== tabnew ===
WinLeave
TabLeave
WinEnter
TabEnter
BufLeave
BufEnter
=== tabnext 1 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
BufEnter
=== tabnext 3 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnext 2 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnext 2 ===
=== tabclose 3 ===
BufEnter
=== tabclose 3 ===
2/2

View File

@@ -34,6 +34,7 @@ source test_sort.vim
source test_statusline.vim source test_statusline.vim
source test_syn_attr.vim source test_syn_attr.vim
source test_tabline.vim source test_tabline.vim
source test_tabpage.vim
source test_tagjump.vim source test_tagjump.vim
source test_timers.vim source test_timers.vim
source test_true_false.vim source test_true_false.vim

View File

@@ -0,0 +1,189 @@
" Tests for tabpage
function Test_tabpage()
bw!
" Simple test for opening and closing a tab page
tabnew
call assert_equal(2, tabpagenr())
quit
" Open three tab pages and use ":tabdo"
0tabnew
1tabnew
$tabnew
tabdo call append(line('$'), tabpagenr())
tabclose! 2
tabrewind
let line1 = getline('$')
undo
q
tablast
let line2 = getline('$')
q!
call append(line('$'), line1)
call append(line('$'), line2)
unlet line1 line2
call assert_equal(['', '3', '1', '4'], getline(1, '$'))
"
" Test for settabvar() and gettabvar() functions. Open a new tab page and
" set 3 variables to a number, string and a list. Verify that the variables
" are correctly set.
tabnew
tabfirst
call settabvar(2, 'val_num', 100)
call settabvar(2, 'val_str', 'SetTabVar test')
call settabvar(2, 'val_list', ['red', 'blue', 'green'])
"
call assert_true(gettabvar(2, 'val_num') == 100 && gettabvar(2, 'val_str') == 'SetTabVar test' && gettabvar(2, 'val_list') == ['red', 'blue', 'green'])
tabnext 2
call assert_true(t:val_num == 100 && t:val_str == 'SetTabVar test' && t:val_list == ['red', 'blue', 'green'])
tabclose
if has('gui') || has('clientserver')
" Test for ":tab drop exist-file" to keep current window.
sp test1
tab drop test1
call assert_true(tabpagenr('$') == 1 && winnr('$') == 2 && winnr() == 1)
close
"
"
" Test for ":tab drop new-file" to keep current window of tabpage 1.
split
tab drop newfile
call assert_true(tabpagenr('$') == 2 && tabpagewinnr(1, '$') == 2 && tabpagewinnr(1) == 1)
tabclose
q
"
"
" Test for ":tab drop multi-opend-file" to keep current tabpage and window.
new test1
tabnew
new test1
tab drop test1
call assert_true(tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1)
tabclose
q
endif
"
"
for i in range(9) | tabnew | endfor
normal! 1gt
call assert_equal(1, tabpagenr())
tabmove 5
call assert_equal(5, tabpagenr())
.tabmove
call assert_equal(5, tabpagenr())
tabmove -
call assert_equal(4, tabpagenr())
tabmove +
call assert_equal(5, tabpagenr())
tabmove -2
call assert_equal(3, tabpagenr())
tabmove +4
call assert_equal(7, tabpagenr())
tabmove
call assert_equal(10, tabpagenr())
tabmove -20
call assert_equal(1, tabpagenr())
tabmove +20
call assert_equal(10, tabpagenr())
0tabmove
call assert_equal(1, tabpagenr())
$tabmove
call assert_equal(10, tabpagenr())
tabmove 0
call assert_equal(1, tabpagenr())
tabmove $
call assert_equal(10, tabpagenr())
3tabmove
call assert_equal(4, tabpagenr())
7tabmove 5
call assert_equal(5, tabpagenr())
call assert_fails("tabmove foo", 'E474:')
endfunc
" Test autocommands
function Test_tabpage_with_autocmd()
if !has('autocmd')
return
endif
tabonly!
command -nargs=1 -bar C :call add(s:li, '=== ' . <q-args> . ' ===')|<args>
augroup TestTabpageGroup
au!
autocmd TabEnter * call add(s:li, 'TabEnter')
autocmd WinEnter * call add(s:li, 'WinEnter')
autocmd BufEnter * call add(s:li, 'BufEnter')
autocmd TabLeave * call add(s:li, 'TabLeave')
autocmd WinLeave * call add(s:li, 'WinLeave')
autocmd BufLeave * call add(s:li, 'BufLeave')
augroup END
let s:li = []
let t:a='a'
C tab split
call assert_equal(['=== tab split ===', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter'], s:li)
let s:li = []
let t:a='b'
C tabnew
call assert_equal(['=== tabnew ===', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufLeave', 'BufEnter'], s:li)
let t:a='c'
let s:li = split(join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")')) , '\s\+')
call assert_equal(['a', 'b', 'c'], s:li)
let s:li = []
C call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)')
call assert_equal(["=== call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)') ==="], s:li)
let s:li = split(join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")')) , '\s\+')
call assert_equal(['2', '4', '6'], s:li)
let s:li = []
let w:a='a'
C vsplit
call assert_equal(['=== vsplit ===', 'WinLeave', 'WinEnter'], s:li)
let s:li = []
let w:a='a'
let tabn=tabpagenr()
let winr=range(1, winnr('$'))
C tabnext 1
call assert_equal(['=== tabnext 1 ===', 'BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li)
let s:li = split(join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")')), '\s\+')
call assert_equal(['a', 'a'], s:li)
let s:li = []
C call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)')
let s:li = split(join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")')), '\s\+')
call assert_equal(['2', '4'], s:li)
augroup TabDestructive
autocmd TabEnter * :C tabnext 2 | C tabclose 3
augroup END
let s:li = []
C tabnext 3
call assert_equal(['=== tabnext 3 ===', 'BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', '=== tabnext 2 ===', '=== tabclose 3 ==='], s:li)
call assert_equal(['2/2'], [tabpagenr().'/'.tabpagenr('$')])
autocmd! TabDestructive TabEnter
let s:li = []
C tabnew
call assert_equal(['=== tabnew ===', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufLeave', 'BufEnter'], s:li)
let s:li = []
C tabnext 1
call assert_equal(['=== tabnext 1 ===', 'BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li)
autocmd TabDestructive TabEnter * nested :C tabnext 2 | C tabclose 3
let s:li = []
C tabnext 3
call assert_equal(['=== tabnext 3 ===', 'BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', '=== tabnext 2 ===', 'BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', '=== tabnext 2 ===', '=== tabclose 3 ===', 'BufEnter', '=== tabclose 3 ==='], s:li)
call assert_equal(['2/2'], [tabpagenr().'/'.tabpagenr('$')])
delcommand C
autocmd! TabDestructive
augroup! TabDestructive
autocmd! TestTabpageGroup
augroup! TestTabpageGroup
tabonly!
bw!
endfunction
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -763,6 +763,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 */
/**/
2227,
/**/ /**/
2226, 2226,
/**/ /**/