Mercurial > vim
comparison src/testdir/test_bufwintabinfo.vim @ 18767:068337e86133 v8.1.2373
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Commit: https://github.com/vim/vim/commit/5a4c3082d7ab51b3d448a91578479c96c1ab0ad3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 1 15:23:11 2019 +0100
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Problem: Cannot build with +popupwin but without +quickfix. (John Marriott)
Solution: Adjust #ifdefs.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Dec 2019 15:30:04 +0100 |
parents | 18d7337b6837 |
children | cf051bdefb3f |
comparison
equal
deleted
inserted
replaced
18766:3cc0ddf2abd0 | 18767:068337e86133 |
---|---|
1 " Tests for the getbufinfo(), getwininfo() and gettabinfo() functions | 1 " Tests for the getbufinfo(), getwininfo() and gettabinfo() functions |
2 source check.vim | |
2 | 3 |
3 function Test_getbufwintabinfo() | 4 func Test_getbufwintabinfo() |
4 edit Xtestfile1 | 5 CheckFeature quickfix |
5 edit Xtestfile2 | |
6 let buflist = getbufinfo() | |
7 call assert_equal(2, len(buflist)) | |
8 call assert_match('Xtestfile1', buflist[0].name) | |
9 call assert_match('Xtestfile2', getbufinfo('Xtestfile2')[0].name) | |
10 call assert_equal([], getbufinfo(2016)) | |
11 edit Xtestfile1 | |
12 hide edit Xtestfile2 | |
13 hide enew | |
14 call assert_equal(3, len(getbufinfo({'bufloaded':1}))) | |
15 | 6 |
16 set tabstop&vim | 7 edit Xtestfile1 |
17 let b:editor = 'vim' | 8 edit Xtestfile2 |
9 let buflist = getbufinfo() | |
10 call assert_equal(2, len(buflist)) | |
11 call assert_match('Xtestfile1', buflist[0].name) | |
12 call assert_match('Xtestfile2', getbufinfo('Xtestfile2')[0].name) | |
13 call assert_equal([], getbufinfo(2016)) | |
14 edit Xtestfile1 | |
15 hide edit Xtestfile2 | |
16 hide enew | |
17 call assert_equal(3, len(getbufinfo({'bufloaded':1}))) | |
18 | |
19 set tabstop&vim | |
20 let b:editor = 'vim' | |
21 let l = getbufinfo('%') | |
22 call assert_equal(bufnr('%'), l[0].bufnr) | |
23 call assert_equal('vim', l[0].variables.editor) | |
24 call assert_notequal(-1, index(l[0].windows, '%'->bufwinid())) | |
25 | |
26 " Test for getbufinfo() with 'bufmodified' | |
27 call assert_equal(0, len(getbufinfo({'bufmodified' : 1}))) | |
28 call setbufline('Xtestfile1', 1, ["Line1"]) | |
29 let l = getbufinfo({'bufmodified' : 1}) | |
30 call assert_equal(1, len(l)) | |
31 call assert_equal(bufnr('Xtestfile1'), l[0].bufnr) | |
32 | |
33 if has('signs') | |
34 call append(0, ['Linux', 'Windows', 'Mac']) | |
35 sign define Mark text=>> texthl=Search | |
36 exe "sign place 2 line=3 name=Mark buffer=" . bufnr('%') | |
18 let l = getbufinfo('%') | 37 let l = getbufinfo('%') |
19 call assert_equal(bufnr('%'), l[0].bufnr) | 38 call assert_equal(2, l[0].signs[0].id) |
20 call assert_equal('vim', l[0].variables.editor) | 39 call assert_equal(3, l[0].signs[0].lnum) |
21 call assert_notequal(-1, index(l[0].windows, '%'->bufwinid())) | 40 call assert_equal('Mark', l[0].signs[0].name) |
41 sign unplace * | |
42 sign undefine Mark | |
43 enew! | |
44 endif | |
22 | 45 |
23 " Test for getbufinfo() with 'bufmodified' | 46 only |
24 call assert_equal(0, len(getbufinfo({'bufmodified' : 1}))) | 47 let w1_id = win_getid() |
25 call setbufline('Xtestfile1', 1, ["Line1"]) | 48 new |
26 let l = getbufinfo({'bufmodified' : 1}) | 49 let w2_id = win_getid() |
27 call assert_equal(1, len(l)) | 50 tabnew | let w3_id = win_getid() |
28 call assert_equal(bufnr('Xtestfile1'), l[0].bufnr) | 51 new | let w4_id = win_getid() |
52 vert new | let w5_id = win_getid() | |
53 eval 'green'->setwinvar(0, 'signal') | |
54 tabfirst | |
55 let winlist = getwininfo() | |
56 call assert_equal(5, len(winlist)) | |
57 call assert_equal(winwidth(1), winlist[0].width) | |
58 call assert_equal(1, winlist[0].wincol) | |
59 " tabline adds one row in terminal, not in GUI | |
60 let tablineheight = winlist[0].winrow == 2 ? 1 : 0 | |
61 call assert_equal(tablineheight + 1, winlist[0].winrow) | |
29 | 62 |
30 if has('signs') | 63 call assert_equal(winbufnr(2), winlist[1].bufnr) |
31 call append(0, ['Linux', 'Windows', 'Mac']) | 64 call assert_equal(winheight(2), winlist[1].height) |
32 sign define Mark text=>> texthl=Search | 65 call assert_equal(1, winlist[1].wincol) |
33 exe "sign place 2 line=3 name=Mark buffer=" . bufnr('%') | 66 call assert_equal(tablineheight + winheight(1) + 2, winlist[1].winrow) |
34 let l = getbufinfo('%') | |
35 call assert_equal(2, l[0].signs[0].id) | |
36 call assert_equal(3, l[0].signs[0].lnum) | |
37 call assert_equal('Mark', l[0].signs[0].name) | |
38 sign unplace * | |
39 sign undefine Mark | |
40 enew! | |
41 endif | |
42 | 67 |
43 only | 68 call assert_equal(1, winlist[2].winnr) |
44 let w1_id = win_getid() | 69 call assert_equal(tablineheight + 1, winlist[2].winrow) |
45 new | 70 call assert_equal(1, winlist[2].wincol) |
46 let w2_id = win_getid() | |
47 tabnew | let w3_id = win_getid() | |
48 new | let w4_id = win_getid() | |
49 vert new | let w5_id = win_getid() | |
50 eval 'green'->setwinvar(0, 'signal') | |
51 tabfirst | |
52 let winlist = getwininfo() | |
53 call assert_equal(5, len(winlist)) | |
54 call assert_equal(winwidth(1), winlist[0].width) | |
55 call assert_equal(1, winlist[0].wincol) | |
56 " tabline adds one row in terminal, not in GUI | |
57 let tablineheight = winlist[0].winrow == 2 ? 1 : 0 | |
58 call assert_equal(tablineheight + 1, winlist[0].winrow) | |
59 | 71 |
60 call assert_equal(winbufnr(2), winlist[1].bufnr) | 72 call assert_equal(winlist[2].width + 2, winlist[3].wincol) |
61 call assert_equal(winheight(2), winlist[1].height) | 73 call assert_equal(1, winlist[4].wincol) |
62 call assert_equal(1, winlist[1].wincol) | |
63 call assert_equal(tablineheight + winheight(1) + 2, winlist[1].winrow) | |
64 | 74 |
65 call assert_equal(1, winlist[2].winnr) | 75 call assert_equal(1, winlist[0].tabnr) |
66 call assert_equal(tablineheight + 1, winlist[2].winrow) | 76 call assert_equal(1, winlist[1].tabnr) |
67 call assert_equal(1, winlist[2].wincol) | 77 call assert_equal(2, winlist[2].tabnr) |
78 call assert_equal(2, winlist[3].tabnr) | |
79 call assert_equal(2, winlist[4].tabnr) | |
68 | 80 |
69 call assert_equal(winlist[2].width + 2, winlist[3].wincol) | 81 call assert_equal('green', winlist[2].variables.signal) |
70 call assert_equal(1, winlist[4].wincol) | 82 call assert_equal(w4_id, winlist[3].winid) |
83 let winfo = w5_id->getwininfo()[0] | |
84 call assert_equal(2, winfo.tabnr) | |
85 call assert_equal([], getwininfo(3)) | |
71 | 86 |
72 call assert_equal(1, winlist[0].tabnr) | 87 call settabvar(1, 'space', 'build') |
73 call assert_equal(1, winlist[1].tabnr) | 88 let tablist = gettabinfo() |
74 call assert_equal(2, winlist[2].tabnr) | 89 call assert_equal(2, len(tablist)) |
75 call assert_equal(2, winlist[3].tabnr) | 90 call assert_equal(3, len(tablist[1].windows)) |
76 call assert_equal(2, winlist[4].tabnr) | 91 call assert_equal(2, tablist[1].tabnr) |
92 call assert_equal('build', tablist[0].variables.space) | |
93 call assert_equal(w2_id, tablist[0].windows[0]) | |
94 call assert_equal([], 3->gettabinfo()) | |
77 | 95 |
78 call assert_equal('green', winlist[2].variables.signal) | 96 tabonly | only |
79 call assert_equal(w4_id, winlist[3].winid) | |
80 let winfo = w5_id->getwininfo()[0] | |
81 call assert_equal(2, winfo.tabnr) | |
82 call assert_equal([], getwininfo(3)) | |
83 | 97 |
84 call settabvar(1, 'space', 'build') | 98 lexpr '' |
85 let tablist = gettabinfo() | 99 lopen |
86 call assert_equal(2, len(tablist)) | 100 copen |
87 call assert_equal(3, len(tablist[1].windows)) | 101 let winlist = getwininfo() |
88 call assert_equal(2, tablist[1].tabnr) | 102 call assert_false(winlist[0].quickfix) |
89 call assert_equal('build', tablist[0].variables.space) | 103 call assert_false(winlist[0].loclist) |
90 call assert_equal(w2_id, tablist[0].windows[0]) | 104 call assert_true(winlist[1].quickfix) |
91 call assert_equal([], 3->gettabinfo()) | 105 call assert_true(winlist[1].loclist) |
92 | 106 call assert_true(winlist[2].quickfix) |
93 tabonly | only | 107 call assert_false(winlist[2].loclist) |
94 | 108 wincmd t | only |
95 lexpr '' | 109 endfunc |
96 lopen | |
97 copen | |
98 let winlist = getwininfo() | |
99 call assert_false(winlist[0].quickfix) | |
100 call assert_false(winlist[0].loclist) | |
101 call assert_true(winlist[1].quickfix) | |
102 call assert_true(winlist[1].loclist) | |
103 call assert_true(winlist[2].quickfix) | |
104 call assert_false(winlist[2].loclist) | |
105 wincmd t | only | |
106 endfunction | |
107 | 110 |
108 function Test_get_buf_options() | 111 function Test_get_buf_options() |
109 let opts = bufnr()->getbufvar('&') | 112 let opts = bufnr()->getbufvar('&') |
110 call assert_equal(v:t_dict, type(opts)) | 113 call assert_equal(v:t_dict, type(opts)) |
111 call assert_equal(8, opts.tabstop) | 114 call assert_equal(8, opts.tabstop) |