Mercurial > vim
annotate src/testdir/test62.in @ 6272:9d5b8b015e5f v7.4.470
updated for version 7.4.470
Problem: Test 11 and 100 do not work properly on Windows.
Solution: Avoid using feedkeys(). (Ken Takata)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 09 Oct 2014 15:37:06 +0200 |
parents | 8f84e906d454 |
children | 22f95a018b13 |
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 | |
16 :888tabnew | |
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 | |
99 Go=tabpagenr() | |
100 :tabmove 5 | |
101 i=tabpagenr() | |
102 :tabmove -2 | |
103 i=tabpagenr() | |
104 :tabmove +4 | |
105 i=tabpagenr() | |
106 :tabmove | |
107 i=tabpagenr() | |
108 :tabmove -20 | |
109 i=tabpagenr() | |
110 :tabmove +20 | |
111 i=tabpagenr() | |
112 :3tabmove | |
113 i=tabpagenr() | |
114 :7tabmove 5 | |
115 i=tabpagenr() | |
116 :let a='No error caught.' | |
117 :try | |
118 :tabmove foo | |
119 :catch E474 | |
120 :let a='E474 caught.' | |
121 :endtry | |
122 i=a | |
123 :" | |
4354 | 124 :" Test autocommands |
125 :tabonly! | |
126 :let g:r=[] | |
127 :command -nargs=1 -bar C :call add(g:r, '=== ' . <q-args> . ' ===')|<args> | |
128 :function Test() | |
129 let hasau=has('autocmd') | |
130 if hasau | |
131 autocmd TabEnter * :call add(g:r, 'TabEnter') | |
132 autocmd WinEnter * :call add(g:r, 'WinEnter') | |
133 autocmd BufEnter * :call add(g:r, 'BufEnter') | |
134 autocmd TabLeave * :call add(g:r, 'TabLeave') | |
135 autocmd WinLeave * :call add(g:r, 'WinLeave') | |
136 autocmd BufLeave * :call add(g:r, 'BufLeave') | |
137 endif | |
138 let t:a='a' | |
139 C tab split | |
140 if !hasau | |
141 let g:r+=['WinLeave', 'TabLeave', 'WinEnter', 'TabEnter'] | |
142 endif | |
143 let t:a='b' | |
144 C tabnew | |
145 if !hasau | |
146 let g:r+=['WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufLeave', 'BufEnter'] | |
147 endif | |
148 let t:a='c' | |
149 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
|
150 C call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)') |
4354 | 151 call add(g:r, join(map(range(1, tabpagenr('$')), 'gettabvar(v:val, "a")'))) |
152 let w:a='a' | |
153 C vsplit | |
154 if !hasau | |
155 let g:r+=['WinLeave', 'WinEnter'] | |
156 endif | |
157 let w:a='a' | |
158 let tabn=tabpagenr() | |
159 let winr=range(1, winnr('$')) | |
160 C tabnext 1 | |
161 if !hasau | |
162 let g:r+=['BufLeave', 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'] | |
163 endif | |
164 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
|
165 C call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)') |
4354 | 166 call add(g:r, join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")'))) |
167 if hasau | |
168 augroup TabDestructive | |
169 autocmd TabEnter * :C tabnext 2 | C tabclose 3 | |
170 augroup END | |
171 C tabnext 3 | |
172 let g:r+=[tabpagenr().'/'.tabpagenr('$')] | |
173 autocmd! TabDestructive TabEnter | |
174 C tabnew | |
175 C tabnext 1 | |
176 autocmd TabDestructive TabEnter * nested :C tabnext 2 | C tabclose 3 | |
177 C tabnext 3 | |
178 let g:r+=[tabpagenr().'/'.tabpagenr('$')] | |
179 else | |
180 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",] | |
181 endif | |
182 endfunction | |
183 :call Test() | |
184 :$ put =g:r | |
185 :" | |
3662 | 186 :" |
856 | 187 :/^Results/,$w! test.out |
188 :qa! | |
189 ENDTEST | |
190 | |
191 Results: |