blob: 1e514cd21a6b6903ad9fa52670946027b4c34e7a [file] [log] [blame]
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00001Tests for tab pages
2
3STARTTEST
4:so small.vim
5:" Simple test for opening and closing a tab page
6:tabnew
7:let nr = tabpagenr()
8:q
9:call append(line('$'), 'tab page ' . nr)
Bram Moolenaar9d2c8c12007-09-25 16:00:00 +000010:unlet nr
Bram Moolenaarc9b4b052006-04-30 18:54:39 +000011:"
12:" Open three tab pages and use ":tabdo"
13:0tabnew
14:1tabnew
15:888tabnew
16:tabdo call append(line('$'), 'this is tab page ' . tabpagenr())
17:tabclose! 2
18:tabrewind
19:let line1 = getline('$')
20:undo
21:q
22:tablast
23:let line2 = getline('$')
24:q!
25:call append(line('$'), line1)
26:call append(line('$'), line2)
Bram Moolenaar9d2c8c12007-09-25 16:00:00 +000027:unlet line1 line2
Bram Moolenaarc9b4b052006-04-30 18:54:39 +000028:"
Bram Moolenaar20a825a2010-05-31 21:27:30 +020029:" Test for settabvar() and gettabvar() functions. Open a new tab page and
30:" set 3 variables to a number, string and a list. Verify that the variables
31:" are correctly set.
32:tabnew
33:tabfirst
34:call settabvar(2, 'val_num', 100)
35:call settabvar(2, 'val_str', 'SetTabVar test')
36:call settabvar(2, 'val_list', ['red', 'blue', 'green'])
37:"
38:let test_status = 'gettabvar: fail'
39:if gettabvar(2, 'val_num') == 100 && gettabvar(2, 'val_str') == 'SetTabVar test') && gettabvar(2, 'val_list') == ['red', 'blue', 'green'])
40: let test_status = 'gettabvar: pass'
41:endif
42:call append(line('$'), test_status)
43:"
44:tabnext 2
45:let test_status = 'settabvar: fail'
46:if t:val_num == 100 && t:val_str == 'SetTabVar test' && t:val_list == ['red', 'blue', 'green']
47: let test_status = 'settabvar: pass'
48:endif
49:tabclose
50:call append(line('$'), test_status)
51:"
Bram Moolenaar7c578d32012-03-07 22:55:20 +010052:if has('gui') || has('clientserver')
Bram Moolenaar52379ea2012-02-22 19:13:08 +010053:" Test for ":tab drop exist-file" to keep current window.
54:sp test1
55:tab drop test1
56:let test_status = 'tab drop 1: fail'
57:if tabpagenr('$') == 1 && winnr('$') == 2 && winnr() == 1
58: let test_status = 'tab drop 1: pass'
59:endif
60:close
61:call append(line('$'), test_status)
62:"
63:"
64:" Test for ":tab drop new-file" to keep current window of tabpage 1.
65:split
66:tab drop newfile
67:let test_status = 'tab drop 2: fail'
68:if tabpagenr('$') == 2 && tabpagewinnr(1, '$') == 2 && tabpagewinnr(1) == 1
69: let test_status = 'tab drop 2: pass'
70:endif
71:tabclose
72:q
73:call append(line('$'), test_status)
74:"
75:"
76:" Test for ":tab drop multi-opend-file" to keep current tabpage and window.
77:new test1
78:tabnew
79:new test1
80:tab drop test1
81:let test_status = 'tab drop 3: fail'
82:if tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1
83: let test_status = 'tab drop 3: pass'
84:endif
85:tabclose
86:q
87:call append(line('$'), test_status)
Bram Moolenaar7c578d32012-03-07 22:55:20 +010088:else
89:" :drop not supported
90:call append(line('$'), 'tab drop 1: pass')
91:call append(line('$'), 'tab drop 2: pass')
92:call append(line('$'), 'tab drop 3: pass')
93:endif
Bram Moolenaar52379ea2012-02-22 19:13:08 +010094:"
95:"
Bram Moolenaarc9b4b052006-04-30 18:54:39 +000096:/^Results/,$w! test.out
97:qa!
98ENDTEST
99
100Results: