annotate src/testdir/test_getvar.vim @ 15525:3ef31ce9d9f9 v8.1.0770

patch 8.1.0770: inconsistent use of ELAPSED_FUNC commit https://github.com/vim/vim/commit/1ac56c2d11da5ffa44db23e1fd0c533d02ab2f66 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 17 22:28:22 2019 +0100 patch 8.1.0770: inconsistent use of ELAPSED_FUNC Problem: Inconsistent use of ELAPSED_FUNC. Solution: Consistently use ELAPSED_FUNC. Also turn ELAPSED_TYPE into a typedef. (Ozaki Kiichi, closes #3815)
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Jan 2019 22:30:06 +0100
parents 183dc24cf861
children 2b4c138bf8e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12019
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for getwinvar(), gettabvar() and gettabwinvar().
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 func Test_var()
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Use strings to test for memory leaks. First, check that in an empty
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " window, gettabvar() returns the correct value
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 let t:testvar='abcd'
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 call assert_equal('abcd', gettabvar(1, 'testvar'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call assert_equal('abcd', gettabvar(1, 'testvar'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " test for getwinvar()
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let w:var_str = "Dance"
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let def_str = "Chance"
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal('Dance', getwinvar(1, 'var_str'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 unlet w:var_str
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal({}, getwinvar(1, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal({}, getwinvar(1, '', def_str))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal('', getwinvar(9, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal('Chance', getwinvar(9, '', def_str))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal(0, getwinvar(1, '&nu'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(0, getwinvar(1, '&nu', 1))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 unlet def_str
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 " test for gettabvar()
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 tabnew
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 tabnew
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 let t:var_list = [1, 2, 3]
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 let t:other = 777
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 let def_list = [4, 5, 6, 7]
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 tabrewind
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal([1, 2, 3], gettabvar(3, 'var_list'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_equal({'var_list': [1, 2, 3], 'other': 777},
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 \ gettabvar(3, '', def_list))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 tablast
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 unlet t:var_list
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 tabrewind
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 call assert_equal([4, 5, 6, 7], gettabvar(3, 'var_list', def_list))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal('', gettabvar(9, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal([4, 5, 6, 7], gettabvar(9, '', def_list))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_equal('', gettabvar(3, '&nu'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal([4, 5, 6, 7], gettabvar(3, '&nu', def_list))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 unlet def_list
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 tabonly
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 " test for gettabwinvar()
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 tabnew
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 tabnew
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 tabprev
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 split
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 split
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 wincmd w
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 vert split
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 wincmd w
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 let w:var_dict = {'dict': 'tabwin'}
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 let def_dict = {'dict2': 'newval'}
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 wincmd b
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 tabrewind
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call assert_equal({'dict': 'tabwin'},
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 \ gettabwinvar(2, 3, 'var_dict', def_dict))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 call assert_equal({'var_dict': {'dict': 'tabwin'}},
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 \ gettabwinvar(2, 3, '', def_dict))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 tabnext
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 3wincmd w
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 unlet w:var_dict
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 tabrewind
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call assert_equal({'dict2': 'newval'},
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 \ gettabwinvar(2, 3, 'var_dict', def_dict))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call assert_equal({}, gettabwinvar(2, 3, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call assert_equal({}, gettabwinvar(2, 3, '', def_dict))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 call assert_equal("", gettabwinvar(2, 9, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 call assert_equal({'dict2': 'newval'}, gettabwinvar(2, 9, '', def_dict))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 call assert_equal('', gettabwinvar(9, 3, ''))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 call assert_equal({'dict2': 'newval'}, gettabwinvar(9, 3, '', def_dict))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 unlet def_dict
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 call assert_equal('', gettabwinvar(2, 3, '&nux'))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 tabonly
7d7835ab8b37 patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 endfunc
12564
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
89
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
90 " It was discovered that "gettabvar()" would fail if called from within the
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
91 " tabline when the user closed a window. This test confirms the fix.
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
92 func Test_gettabvar_in_tabline()
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
93 let t:var_str = 'value'
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
94
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
95 set tabline=%{assert_equal('value',gettabvar(1,'var_str'))}
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
96 set showtabline=2
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
97
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
98 " Simulate the user opening a split (which becomes window #1) and then
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
99 " closing the split, which triggers the redrawing of the tabline.
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
100 leftabove split
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
101 redrawstatus!
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
102 close
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
103 redrawstatus!
183dc24cf861 patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents: 12019
diff changeset
104 endfunc