Mercurial > vim
annotate src/testdir/test_getvar.vim @ 21060:89aba7895bb2 v8.2.1081
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Commit: https://github.com/vim/vim/commit/a1f9f8666ed3a462eb8a518e78418c57dc41bbd4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 28 22:41:26 2020 +0200
patch 8.2.1081: Lua: cannot use table.insert() and table.remove()
Problem: Lua: cannot use table.insert() and table.remove().
Solution: Add the list functions. (Prabir Shrestha, closes https://github.com/vim/vim/issues/6353)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Jun 2020 22:45:04 +0200 |
parents | 94f05de75e9f |
children | 08940efa6b4e |
rev | line source |
---|---|
17534
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
1 " Tests for getwinvar(), gettabvar(), gettabwinvar() and get(). |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
2 |
12019
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 func Test_var() |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " 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
|
5 " window, gettabvar() returns the correct value |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 let t:testvar='abcd' |
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 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
|
9 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 " test for getwinvar() |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 let w:var_str = "Dance" |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 let def_str = "Chance" |
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')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal('Dance', getwinvar(1, 'var_str', def_str)) |
17912
9fac6d0de69a
patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17857
diff
changeset
|
15 call assert_equal({'var_str': 'Dance'}, 1->getwinvar('')) |
9fac6d0de69a
patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17857
diff
changeset
|
16 call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str)) |
12019
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 unlet w:var_str |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 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
|
19 call assert_equal({}, getwinvar(1, '')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 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
|
21 call assert_equal('', getwinvar(9, '')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 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
|
23 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
|
24 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
|
25 unlet def_str |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " test for gettabvar() |
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 tabnew |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 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
|
31 let t:other = 777 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 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
|
33 tabrewind |
17857
4935244c1128
patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17534
diff
changeset
|
34 call assert_equal([1, 2, 3], 3->gettabvar('var_list')) |
12019
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 \ gettabvar(3, '', def_list)) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 tablast |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 unlet t:var_list |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 tabrewind |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 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
|
44 call assert_equal('', gettabvar(9, '')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 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
|
46 call assert_equal('', gettabvar(3, '&nu')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 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
|
48 unlet def_list |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 tabonly |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 " test for gettabwinvar() |
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 tabnew |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 tabprev |
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 split |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 wincmd w |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 vert split |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 wincmd w |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 let w:var_dict = {'dict': 'tabwin'} |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 let def_dict = {'dict2': 'newval'} |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 wincmd b |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 tabrewind |
17857
4935244c1128
patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17534
diff
changeset
|
64 call assert_equal({'dict': 'tabwin'}, 2->gettabwinvar(3, 'var_dict')) |
12019
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 call assert_equal({'dict': 'tabwin'}, |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 \ 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
|
67 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
|
68 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
|
69 \ gettabwinvar(2, 3, '', def_dict)) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 tabnext |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 3wincmd w |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 unlet w:var_dict |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 tabrewind |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 call assert_equal({'dict2': 'newval'}, |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 \ 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
|
77 call assert_equal({}, gettabwinvar(2, 3, '')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 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
|
79 call assert_equal("", gettabwinvar(2, 9, '')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 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
|
81 call assert_equal('', gettabwinvar(9, 3, '')) |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 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
|
83 |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 unlet def_dict |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 |
19114
3856047f2211
patch 8.2.0117: crash when using gettabwinvar() with invalid arguments
Bram Moolenaar <Bram@vim.org>
parents:
17912
diff
changeset
|
86 call assert_equal("", gettabwinvar(9, 2020, '')) |
12019
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 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
|
88 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
|
89 tabonly |
7d7835ab8b37
patch 8.0.0890: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 endfunc |
12564
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12019
diff
changeset
|
91 |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12019
diff
changeset
|
92 " 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
|
93 " 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
|
94 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
|
95 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
|
96 |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12019
diff
changeset
|
97 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
|
98 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
|
99 |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12019
diff
changeset
|
100 " 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
|
101 " 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
|
102 leftabove split |
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 close |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12019
diff
changeset
|
105 redrawstatus! |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12019
diff
changeset
|
106 endfunc |
17534
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
107 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
108 " Test get() function using default value. |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
109 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
110 " get({dict}, {key} [, {default}]) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
111 func Test_get_dict() |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
112 let d = {'foo': 42} |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
113 call assert_equal(42, get(d, 'foo', 99)) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
114 call assert_equal(999, get(d, 'bar', 999)) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
115 endfunc |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
116 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
117 " get({list}, {idx} [, {default}]) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
118 func Test_get_list() |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
119 let l = [1,2,3] |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
120 call assert_equal(1, get(l, 0, 999)) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
121 call assert_equal(3, get(l, -1, 999)) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
122 call assert_equal(999, get(l, 3, 999)) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
123 endfunc |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
124 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
125 " get({blob}, {idx} [, {default}]) - in test_blob.vim |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
126 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
127 " get({lambda}, {what} [, {default}]) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
128 func Test_get_lambda() |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
129 let l:L = {-> 42} |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
130 call assert_match('^<lambda>', get(l:L, 'name')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
131 call assert_equal(l:L, get(l:L, 'func')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
132 call assert_equal({'lambda has': 'no dict'}, get(l:L, 'dict', {'lambda has': 'no dict'})) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
133 call assert_equal(0, get(l:L, 'dict')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
134 call assert_equal([], get(l:L, 'args')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
135 endfunc |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
136 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
137 " get({func}, {what} [, {default}]) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
138 func Test_get_func() |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
139 let l:F = function('tr') |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
140 call assert_equal('tr', get(l:F, 'name')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
141 call assert_equal(l:F, get(l:F, 'func')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
142 call assert_equal({'func has': 'no dict'}, get(l:F, 'dict', {'func has': 'no dict'})) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
143 call assert_equal(0, get(l:F, 'dict')) |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
144 call assert_equal([], get(l:F, 'args')) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
19114
diff
changeset
|
145 let NF = test_null_function() |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
19114
diff
changeset
|
146 call assert_equal('', get(NF, 'name')) |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
19114
diff
changeset
|
147 call assert_equal(NF, get(NF, 'func')) |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
19114
diff
changeset
|
148 call assert_equal(0, get(NF, 'dict')) |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
19114
diff
changeset
|
149 call assert_equal([], get(NF, 'args')) |
17534
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
150 endfunc |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
151 |
2b4c138bf8e9
patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
12564
diff
changeset
|
152 " get({partial}, {what} [, {default}]) - in test_partial.vim |