Mercurial > vim
annotate src/testdir/test62.in @ 9151:d0f69d0bea7a v7.4.1859
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 29 16:44:26 2016 +0200
patch 7.4.1859
Problem: Cannot use a function reference for "exit_cb".
Solution: Use get_callback(). (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 May 2016 16:45:05 +0200 |
parents | c0bc9b60fb8a |
children |
rev | line source |
---|---|
856 | 1 Tests for tab pages |
2 | |
3 STARTTEST | |
4 :so small.vim | |
5846 | 5 :lang C |
856 | 6 :" Simple test for opening and closing a tab page |
7 :tabnew | |
8 :let nr = tabpagenr() | |
9 :q | |
10 :call append(line('$'), 'tab page ' . nr) | |
1405 | 11 :unlet nr |
856 | 12 :" |
13 :" Open three tab pages and use ":tabdo" | |
14 :0tabnew | |
15 :1tabnew | |
6472 | 16 :$tabnew |
856 | 17 :tabdo call append(line('$'), 'this is tab page ' . tabpagenr()) |
18 :tabclose! 2 | |
19 :tabrewind | |
20 :let line1 = getline('$') | |
21 :undo | |
22 :q | |
23 :tablast | |
24 :let line2 = getline('$') | |
25 :q! | |
26 :call append(line('$'), line1) | |
27 :call append(line('$'), line2) | |
1405 | 28 :unlet line1 line2 |
856 | 29 :" |
2240
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
30 :" Test for settabvar() and gettabvar() functions. Open a new tab page and |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
31 :" set 3 variables to a number, string and a list. Verify that the variables |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
32 :" are correctly set. |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
33 :tabnew |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
34 :tabfirst |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
35 :call settabvar(2, 'val_num', 100) |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
36 :call settabvar(2, 'val_str', 'SetTabVar test') |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
37 :call settabvar(2, 'val_list', ['red', 'blue', 'green']) |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
38 :" |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
39 :let test_status = 'gettabvar: fail' |
5194
45b2278e6f46
updated for version 7.4a.023
Bram Moolenaar <bram@vim.org>
parents:
5186
diff
changeset
|
40 :if gettabvar(2, 'val_num') == 100 && gettabvar(2, 'val_str') == 'SetTabVar test' && gettabvar(2, 'val_list') == ['red', 'blue', 'green'] |
2240
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
41 : let test_status = 'gettabvar: pass' |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
42 :endif |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
43 :call append(line('$'), test_status) |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
44 :" |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
45 :tabnext 2 |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
46 :let test_status = 'settabvar: fail' |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
47 :if t:val_num == 100 && t:val_str == 'SetTabVar test' && t:val_list == ['red', 'blue', 'green'] |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
48 : let test_status = 'settabvar: pass' |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
49 :endif |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
50 :tabclose |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
51 :call append(line('$'), test_status) |
6b4879aea261
Add test for gettabvar() and settabvar().
Bram Moolenaar <bram@vim.org>
parents:
1405
diff
changeset
|
52 :" |
3408 | 53 :if has('gui') || has('clientserver') |
3380 | 54 :" Test for ":tab drop exist-file" to keep current window. |
55 :sp test1 | |
56 :tab drop test1 | |
57 :let test_status = 'tab drop 1: fail' | |
58 :if tabpagenr('$') == 1 && winnr('$') == 2 && winnr() == 1 | |
59 : let test_status = 'tab drop 1: pass' | |
60 :endif | |
61 :close | |
62 :call append(line('$'), test_status) | |
63 :" | |
64 :" | |
65 :" Test for ":tab drop new-file" to keep current window of tabpage 1. | |
66 :split | |
67 :tab drop newfile | |
68 :let test_status = 'tab drop 2: fail' | |
69 :if tabpagenr('$') == 2 && tabpagewinnr(1, '$') == 2 && tabpagewinnr(1) == 1 | |
70 : let test_status = 'tab drop 2: pass' | |
71 :endif | |
72 :tabclose | |
73 :q | |
74 :call append(line('$'), test_status) | |
75 :" | |
76 :" | |
77 :" Test for ":tab drop multi-opend-file" to keep current tabpage and window. | |
78 :new test1 | |
79 :tabnew | |
80 :new test1 | |
81 :tab drop test1 | |
82 :let test_status = 'tab drop 3: fail' | |
83 :if tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1 | |
84 : let test_status = 'tab drop 3: pass' | |
85 :endif | |
86 :tabclose | |
87 :q | |
88 :call append(line('$'), test_status) | |
3408 | 89 :else |
90 :" :drop not supported | |
91 :call append(line('$'), 'tab drop 1: pass') | |
92 :call append(line('$'), 'tab drop 2: pass') | |
93 :call append(line('$'), 'tab drop 3: pass') | |
94 :endif | |
3380 | 95 :" |
96 :" | |
3662 | 97 :for i in range(9) | tabnew | endfor |
98 1gt | |
6775 | 99 :$put =tabpagenr() |
3662 | 100 :tabmove 5 |
6775 | 101 :$put =tabpagenr() |
102 :.tabmove | |
103 :$put =tabpagenr() | |
104 :tabmove - | |
105 :$put =tabpagenr() | |
106 :tabmove + | |
107 :$put =tabpagenr() | |
3662 | 108 :tabmove -2 |
6775 | 109 :$put =tabpagenr() |
3662 | 110 :tabmove +4 |
6775 | 111 :$put =tabpagenr() |
3662 | 112 :tabmove |
6775 | 113 :$put =tabpagenr() |
3662 | 114 :tabmove -20 |
6775 | 115 :$put =tabpagenr() |
3662 | 116 :tabmove +20 |
6775 | 117 :$put =tabpagenr() |
118 :0tabmove | |
119 :$put =tabpagenr() | |
120 :$tabmove | |
121 :$put =tabpagenr() | |
122 :tabmove 0 | |
123 :$put =tabpagenr() | |
124 :tabmove $ | |
125 :$put =tabpagenr() | |
3662 | 126 :3tabmove |
6775 | 127 :$put =tabpagenr() |
3662 | 128 :7tabmove 5 |
6775 | 129 :$put =tabpagenr() |
3662 | 130 :let a='No error caught.' |
131 :try | |
132 :tabmove foo | |
133 :catch E474 | |
134 :let a='E474 caught.' | |
135 :endtry | |
6775 | 136 :$put =a |
3662 | 137 :" |
4354 | 138 :" Test autocommands |
139 :tabonly! | |
140 :let g:r=[] | |
141 :command -nargs=1 -bar C :call add(g:r, '=== ' . <q-args> . ' ===')|<args> | |
142 :function Test() | |
143 let hasau=has('autocmd') | |
144 if hasau | |
145 autocmd TabEnter * :call add(g:r, 'TabEnter') | |
146 autocmd WinEnter * :call add(g:r, 'WinEnter') | |
147 autocmd BufEnter * :call add(g:r, 'BufEnter') | |
148 autocmd TabLeave * :call add(g:r, 'TabLeave') | |
149 autocmd WinLeave * :call add(g:r, 'WinLeave') | |
150 autocmd BufLeave * :call add(g:r, 'BufLeave') | |
151 endif | |
152 let t:a='a' | |
153 C tab split | |
154 if !hasau | |
155 let g:r+=['WinLeave', 'TabLeave', 'WinEnter', 'TabEnter'] | |
156 endif | |
157 let t:a='b' | |
158 C tabnew | |
159 if !hasau | |
160 let g:r+=['WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufLeave', 'BufEnter'] | |
161 endif | |
162 let t:a='c' | |
163 call add(g:r, join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")'))) | |
5186
bea5eb942011
updated for version 7.4a.019
Bram Moolenaar <bram@vim.org>
parents:
4354
diff
changeset
|
164 C call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)') |
4354 | 165 call add(g:r, join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")'))) |
166 let w:a='a' | |
167 C vsplit | |
168 if !hasau | |
169 let g:r+=['WinLeave', 'WinEnter'] | |
170 endif | |
171 let w:a='a' | |
172 let tabn=tabpagenr() | |
173 let winr=range(1, winnr('$')) | |
174 C tabnext 1 | |
175 if !hasau | |
176 let g:r+=['BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'] | |
177 endif | |
178 call add(g:r, join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")'))) | |
5186
bea5eb942011
updated for version 7.4a.019
Bram Moolenaar <bram@vim.org>
parents:
4354
diff
changeset
|
179 C call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)') |
4354 | 180 call add(g:r, join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")'))) |
181 if hasau | |
182 augroup TabDestructive | |
183 autocmd TabEnter * :C tabnext 2 | C tabclose 3 | |
184 augroup END | |
185 C tabnext 3 | |
186 let g:r+=[tabpagenr().'/'.tabpagenr('$')] | |
187 autocmd! TabDestructive TabEnter | |
188 C tabnew | |
189 C tabnext 1 | |
190 autocmd TabDestructive TabEnter * nested :C tabnext 2 | C tabclose 3 | |
191 C tabnext 3 | |
192 let g:r+=[tabpagenr().'/'.tabpagenr('$')] | |
193 else | |
194 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",] | |
195 endif | |
196 endfunction | |
197 :call Test() | |
198 :$ put =g:r | |
199 :" | |
3662 | 200 :" |
856 | 201 :/^Results/,$w! test.out |
202 :qa! | |
203 ENDTEST | |
204 | |
205 Results: |