annotate src/testdir/test55.in @ 8418:89f38c77e11e v7.4.1500

commit https://github.com/vim/vim/commit/9ef00be261115acb5bae3b3ca45c1d86a19ba2c7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 6 14:58:28 2016 +0100 patch 7.4.1500 Problem: Should_free flag set to FALSE. Solution: Set it to TRUE. (Neovim 4415)
author Christian Brabandt <cb@256bit.org>
date Sun, 06 Mar 2016 15:00:05 +0100
parents 1805e45ce4d6
children 14ab6c685581
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
1 Tests for List and Dictionary types. vim: set ft=vim :
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
2
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
3 STARTTEST
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
4 :so small.vim
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
5 :fun Test(...)
4191
4dd43d6b3df7 updated for version 7.3.847
Bram Moolenaar <bram@vim.org>
parents: 3774
diff changeset
6 :lang C
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
7 :" Creating List directly with different types
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
8 :let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
9 :$put =string(l)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
10 :$put =string(l[-1])
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
11 :$put =string(l[-4])
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
12 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
13 : $put =string(l[-5])
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
14 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
15 : $put =v:exception[:14]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
16 :endtry
842
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
17 :" List slices
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
18 :$put =string(l[:])
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
19 :$put =string(l[1:])
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
20 :$put =string(l[:-2])
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
21 :$put =string(l[0:8])
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
22 :$put =string(l[8:-1])
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
23 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
24 :" List identity
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
25 :let ll = l
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
26 :let lx = copy(l)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
27 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
28 : $put =(l == ll) . (l isnot ll) . (l is ll) . (l == lx) . (l is lx) . (l isnot lx)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
29 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
30 : $put =v:exception
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
31 :endtry
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
32 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
33 :" Creating Dictionary directly with different types
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
34 :let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
35 :$put =string(d) . d.1
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
36 :$put =string(sort(keys(d)))
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
37 :$put =string (values(d))
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
38 :for [key, val] in items(d)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
39 : $put =key . ':' . string(val)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
40 : unlet key val
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
41 :endfor
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
42 :call extend (d, {3:33, 1:99})
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
43 :call extend(d, {'b':'bbb', 'c':'ccc'}, "keep")
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
44 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
45 : call extend(d, {3:333,4:444}, "error")
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
46 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
47 : $put =v:exception[:15] . v:exception[-1:-1]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
48 :endtry
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
49 :$put =string(d)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
50 :call filter(d, 'v:key =~ ''[ac391]''')
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
51 :$put =string(d)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
52 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
53 :" Dictionary identity
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
54 :let dd = d
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
55 :let dx = copy(d)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
56 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
57 : $put =(d == dd) . (d isnot dd) . (d is dd) . (d == dx) . (d is dx) . (d isnot dx)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
58 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
59 : $put =v:exception
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
60 :endtry
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
61 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
62 :" Changing var type should fail
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
63 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
64 : let d = []
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
65 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
66 : $put =v:exception[:14] . v:exception[-1:-1]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
67 :endtry
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
68 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
69 : let l = {}
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
70 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
71 : $put =v:exception[:14] . v:exception[-1:-1]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
72 :endtry
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
73 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
74 :" removing items with :unlet
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
75 :unlet l[2]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
76 :$put =string(l)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
77 :let l = range(8)
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
78 :try
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
79 :unlet l[:3]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
80 :unlet l[1:]
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
81 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
82 :$put =v:exception
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
83 :endtry
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
84 :$put =string(l)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
85 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
86 :unlet d.c
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
87 :unlet d[-1]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
88 :$put =string(d)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
89 :"
842
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
90 :" removing items out of range: silently skip items that don't exist
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
91 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
92 :unlet l[2:1]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
93 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
94 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
95 :unlet l[2:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
96 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
97 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
98 :unlet l[2:3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
99 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
100 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
101 :unlet l[2:4]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
102 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
103 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
104 :unlet l[2:5]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
105 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
106 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
107 :unlet l[-1:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
108 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
109 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
110 :unlet l[-2:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
111 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
112 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
113 :unlet l[-3:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
114 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
115 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
116 :unlet l[-4:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
117 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
118 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
119 :unlet l[-5:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
120 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
121 let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
122 :unlet l[-6:2]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
123 :$put =string(l)
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
124 :"
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
125 :" assignment to a list
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
126 :let l = [0, 1, 2, 3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
127 :let [va, vb] = l[2:3]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
128 :$put =va
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
129 :$put =vb
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
130 :try
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
131 : let [va, vb] = l
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
132 :catch
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
133 : $put =v:exception[:14]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
134 :endtry
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
135 :try
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
136 : let [va, vb] = l[1:1]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
137 :catch
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
138 : $put =v:exception[:14]
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
139 :endtry
a209672376fd updated for version 7.0f
vimboss
parents: 294
diff changeset
140 :"
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
141 :" manipulating a big Dictionary (hashtable.c has a border of 1000 entries)
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
142 :let d = {}
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
143 :for i in range(1500)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
144 : let d[i] = 3000 - i
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
145 :endfor
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
146 :$put =d[0] . ' ' . d[100] . ' ' . d[999] . ' ' . d[1400] . ' ' . d[1499]
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
147 :try
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
148 : let n = d[1500]
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
149 :catch
1539
b62965091b8d updated for version 7.1-254
vimboss
parents: 1405
diff changeset
150 : $put =substitute(v:exception, '\v(.{14}).*( \d{4}).*', '\1\2', '')
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
151 :endtry
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
152 :" lookup each items
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
153 :for i in range(1500)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
154 : if d[i] != 3000 - i
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
155 : $put =d[i]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
156 : endif
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
157 :endfor
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
158 : let i += 1
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
159 :" delete even items
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
160 :while i >= 2
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
161 : let i -= 2
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
162 : unlet d[i]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
163 :endwhile
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
164 :$put =get(d, 1500 - 100, 'NONE') . ' ' . d[1]
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
165 :" delete odd items, checking value, one intentionally wrong
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
166 :let d[33] = 999
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
167 :let i = 1
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
168 :while i < 1500
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
169 : if d[i] != 3000 - i
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
170 : $put =i . '=' . d[i]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
171 : else
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
172 : unlet d[i]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
173 : endif
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
174 : let i += 2
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
175 :endwhile
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
176 :$put =string(d) " must be almost empty now
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
177 :unlet d
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
178 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
179 :" Dictionary function
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
180 :let dict = {}
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
181 :func dict.func(a) dict
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
182 : $put =a:a . len(self.data)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
183 :endfunc
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
184 :let dict.data = [1,2,3]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
185 :call dict.func("len: ")
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
186 :let x = dict.func("again: ")
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
187 :try
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
188 : let Fn = dict.func
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
189 : call Fn('xxx')
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
190 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
191 : $put =v:exception[:15]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
192 :endtry
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
193 :"
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
194 :" Function in script-local List or Dict
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
195 :let g:dict = {}
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
196 :function g:dict.func() dict
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
197 : $put ='g:dict.func'.self.foo[1].self.foo[0]('asdf')
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
198 :endfunc
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
199 :let g:dict.foo = ['-', 2, 3]
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
200 :call insert(g:dict.foo, function('strlen'))
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
201 :call g:dict.func()
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
202 :"
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
203 :" Nasty: remove func from Dict that's being called (works)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
204 :let d = {1:1}
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
205 :func d.func(a)
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
206 : return "a:". a:a
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
207 :endfunc
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
208 :$put =d.func(string(remove(d, 'func')))
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
209 :"
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
210 :" Nasty: deepcopy() dict that refers to itself (fails when noref used)
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
211 :let d = {1:1, 2:2}
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
212 :let l = [4, d, 6]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
213 :let d[3] = l
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
214 :let dc = deepcopy(d)
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
215 :try
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
216 : let dc = deepcopy(d, 1)
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
217 :catch
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
218 : $put =v:exception[:14]
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
219 :endtry
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
220 :let l2 = [0, l, l, 3]
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
221 :let l[1] = l2
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
222 :let l3 = deepcopy(l2)
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
223 :$put ='same list: ' . (l3[1] is l3[2])
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
224 :"
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
225 :" Locked variables
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
226 :for depth in range(5)
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
227 : $put ='depth is ' . depth
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
228 : for u in range(3)
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
229 : unlet l
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
230 : let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
231 : exe "lockvar " . depth . " l"
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
232 : if u == 1
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
233 : exe "unlockvar l"
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
234 : elseif u == 2
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
235 : exe "unlockvar " . depth . " l"
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
236 : endif
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
237 : let ps = islocked("l").islocked("l[1]").islocked("l[1][1]").islocked("l[1][1][0]").'-'.islocked("l[2]").islocked("l[2]['6']").islocked("l[2]['6'][7]")
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
238 : $put =ps
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
239 : let ps = ''
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
240 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
241 : let l[1][1][0] = 99
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
242 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
243 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
244 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
245 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
246 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
247 : let l[1][1] = [99]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
248 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
249 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
250 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
251 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
252 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
253 : let l[1] = [99]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
254 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
255 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
256 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
257 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
258 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
259 : let l[2]['6'][7] = 99
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
260 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
261 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
262 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
263 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
264 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
265 : let l[2][6] = {99: 99}
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
266 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
267 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
268 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
269 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
270 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
271 : let l[2] = {99: 99}
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
272 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
273 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
274 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
275 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
276 : try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
277 : let l = [99]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
278 : let ps .= 'p'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
279 : catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
280 : let ps .= 'F'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
281 : endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
282 : $put =ps
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
283 : endfor
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
284 :endfor
6751
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
285 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
286 :" Unletting locked variables
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
287 :$put ='Unletting:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
288 :for depth in range(5)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
289 : $put ='depth is ' . depth
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
290 : for u in range(3)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
291 : unlet l
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
292 : let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
293 : exe "lockvar " . depth . " l"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
294 : if u == 1
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
295 : exe "unlockvar l"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
296 : elseif u == 2
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
297 : exe "unlockvar " . depth . " l"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
298 : endif
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
299 : let ps = islocked("l").islocked("l[1]").islocked("l[1][1]").islocked("l[1][1][0]").'-'.islocked("l[2]").islocked("l[2]['6']").islocked("l[2]['6'][7]")
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
300 : $put =ps
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
301 : let ps = ''
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
302 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
303 : unlet l[2]['6'][7]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
304 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
305 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
306 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
307 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
308 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
309 : unlet l[2][6]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
310 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
311 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
312 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
313 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
314 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
315 : unlet l[2]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
316 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
317 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
318 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
319 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
320 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
321 : unlet l[1][1][0]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
322 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
323 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
324 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
325 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
326 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
327 : unlet l[1][1]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
328 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
329 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
330 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
331 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
332 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
333 : unlet l[1]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
334 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
335 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
336 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
337 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
338 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
339 : unlet l
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
340 : let ps .= 'p'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
341 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
342 : let ps .= 'F'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
343 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
344 : $put =ps
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
345 : endfor
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
346 :endfor
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
347 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
348 :" Locked variables and :unlet or list / dict functions
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
349 :$put ='Locks and commands or functions:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
350 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
351 :$put ='No :unlet after lock on dict:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
352 :unlet! d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
353 :let d = {'a': 99, 'b': 100}
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
354 :lockvar 1 d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
355 :try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
356 : unlet d.a
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
357 : $put ='did :unlet'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
358 :catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
359 : $put =v:exception[:16]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
360 :endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
361 :$put =string(d)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
362 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
363 :$put =':unlet after lock on dict item:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
364 :unlet! d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
365 :let d = {'a': 99, 'b': 100}
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
366 :lockvar d.a
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
367 :try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
368 : unlet d.a
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
369 : $put ='did :unlet'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
370 :catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
371 : $put =v:exception[:16]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
372 :endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
373 :$put =string(d)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
374 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
375 :$put ='filter() after lock on dict item:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
376 :unlet! d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
377 :let d = {'a': 99, 'b': 100}
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
378 :lockvar d.a
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
379 :try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
380 : call filter(d, 'v:key != "a"')
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
381 : $put ='did filter()'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
382 :catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
383 : $put =v:exception[:16]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
384 :endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
385 :$put =string(d)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
386 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
387 :$put ='map() after lock on dict:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
388 :unlet! d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
389 :let d = {'a': 99, 'b': 100}
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
390 :lockvar 1 d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
391 :try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
392 : call map(d, 'v:val + 200')
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
393 : $put ='did map()'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
394 :catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
395 : $put =v:exception[:16]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
396 :endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
397 :$put =string(d)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
398 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
399 :$put ='No extend() after lock on dict item:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
400 :unlet! d
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
401 :let d = {'a': 99, 'b': 100}
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
402 :lockvar d.a
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
403 :try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
404 : $put =string(extend(d, {'a': 123}))
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
405 : $put ='did extend()'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
406 :catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
407 : $put =v:exception[:14]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
408 :endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
409 :$put =string(d)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
410 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
411 :$put ='No remove() of write-protected scope-level variable:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
412 :fun! Tfunc(this_is_a_loooooooooong_parameter_name)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
413 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
414 : $put =string(remove(a:, 'this_is_a_loooooooooong_parameter_name'))
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
415 : $put ='did remove()'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
416 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
417 : $put =v:exception[:14]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
418 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
419 :endfun
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
420 :call Tfunc('testval')
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
421 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
422 :$put ='No extend() of write-protected scope-level variable:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
423 :fun! Tfunc(this_is_a_loooooooooong_parameter_name)
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
424 : try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
425 : $put =string(extend(a:, {'this_is_a_loooooooooong_parameter_name': 1234}))
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
426 : $put ='did extend()'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
427 : catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
428 : $put =v:exception[:14]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
429 : endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
430 :endfun
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
431 :call Tfunc('testval')
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
432 :"
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
433 :$put ='No :unlet of variable in locked scope:'
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
434 :let b:testvar = 123
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
435 :lockvar 1 b:
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
436 :try
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
437 : unlet b:testvar
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
438 : $put ='b:testvar was :unlet: '. (!exists('b:testvar'))
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
439 :catch
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
440 : $put =v:exception[:16]
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
441 :endtry
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
442 :unlockvar 1 b:
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
443 :unlet! b:testvar
f5b262981753 patch 7.4.698
Bram Moolenaar <bram@vim.org>
parents: 6422
diff changeset
444 :"
6791
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
445 :$put ='No :let += of locked list variable:'
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
446 :let l = ['a', 'b', 3]
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
447 :lockvar 1 l
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
448 :try
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
449 : let l += ['x']
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
450 : $put ='did :let +='
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
451 :catch
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
452 : $put =v:exception[:14]
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
453 :endtry
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
454 :$put =string(l)
1805e45ce4d6 patch 7.4.717
Bram Moolenaar <bram@vim.org>
parents: 6751
diff changeset
455 :"
6166
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
456 :unlet l
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
457 :let l = [1, 2, 3, 4]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
458 :lockvar! l
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
459 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
460 :unlockvar l[1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
461 :unlet l[0:1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
462 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
463 :unlet l[1:2]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
464 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
465 :unlockvar l[1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
466 :let l[0:1] = [0, 1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
467 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
468 :let l[1:2] = [0, 1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
469 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
470 :unlet l
5604
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
471 :" :lockvar/islocked() triggering script autoloading
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
472 :set rtp+=./sautest
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
473 :lockvar g:footest#x
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
474 :unlockvar g:footest#x
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
475 :$put ='locked g:footest#x:'.islocked('g:footest#x')
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
476 :$put ='exists g:footest#x:'.exists('g:footest#x')
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
477 :$put ='g:footest#x: '.g:footest#x
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
478 :"
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
479 :" a:000 function argument
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
480 :" first the tests that should fail
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
481 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
482 : let a:000 = [1, 2]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
483 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
484 : $put ='caught a:000'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
485 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
486 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
487 : let a:000[0] = 9
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
488 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
489 : $put ='caught a:000[0]'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
490 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
491 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
492 : let a:000[2] = [9, 10]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
493 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
494 : $put ='caught a:000[2]'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
495 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
496 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
497 : let a:000[3] = {9: 10}
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
498 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
499 : $put ='caught a:000[3]'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
500 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
501 :" now the tests that should pass
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
502 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
503 : let a:000[2][1] = 9
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
504 : call extend(a:000[2], [5, 6])
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
505 : let a:000[3][5] = 8
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
506 : let a:000[3]['a'] = 12
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
507 : $put =string(a:000)
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
508 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
509 : $put ='caught ' . v:exception
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
510 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
511 :"
5747
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
512 :" reverse(), sort(), uniq()
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
513 :let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
514 :$put =string(uniq(copy(l)))
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
515 :$put =string(reverse(l))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
516 :$put =string(reverse(reverse(l)))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
517 :$put =string(sort(l))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
518 :$put =string(reverse(sort(l)))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
519 :$put =string(sort(reverse(sort(l))))
5747
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
520 :$put =string(uniq(sort(l)))
6022
f9ec944e4474 updated for version 7.4.351
Bram Moolenaar <bram@vim.org>
parents: 6014
diff changeset
521 :let l=[7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four']
6014
a162d41f10e1 updated for version 7.4.347
Bram Moolenaar <bram@vim.org>
parents: 6001
diff changeset
522 :$put =string(sort(copy(l), 'n'))
6022
f9ec944e4474 updated for version 7.4.351
Bram Moolenaar <bram@vim.org>
parents: 6014
diff changeset
523 :let l=[7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []]
6001
adc4a84f72eb updated for version 7.4.341
Bram Moolenaar <bram@vim.org>
parents: 5747
diff changeset
524 :$put =string(sort(copy(l), 1))
adc4a84f72eb updated for version 7.4.341
Bram Moolenaar <bram@vim.org>
parents: 5747
diff changeset
525 :$put =string(sort(copy(l), 'i'))
adc4a84f72eb updated for version 7.4.341
Bram Moolenaar <bram@vim.org>
parents: 5747
diff changeset
526 :$put =string(sort(copy(l)))
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
527 :"
283
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
528 :" splitting a string to a List
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
529 :$put =string(split(' aa bb '))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
530 :$put =string(split(' aa bb ', '\W\+', 0))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
531 :$put =string(split(' aa bb ', '\W\+', 1))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
532 :$put =string(split(' aa bb ', '\W', 1))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
533 :$put =string(split(':aa::bb:', ':', 0))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
534 :$put =string(split(':aa::bb:', ':', 1))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
535 :$put =string(split('aa,,bb, cc,', ',\s*', 1))
294
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 283
diff changeset
536 :$put =string(split('abc', '\zs'))
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 283
diff changeset
537 :$put =string(split('abc', '\zs', 1))
283
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
538 :"
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
539 :" compare recursively linked list and dict
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
540 :let l = [1, 2, 3, 4]
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
541 :let d = {'1': 1, '2': l, '3': 3}
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
542 :let l[1] = d
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
543 :$put =(l == l)
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
544 :$put =(d == d)
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
545 :$put =(l != deepcopy(l))
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
546 :$put =(d != deepcopy(d))
2634
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
547 :"
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
548 :" compare complex recursively linked list and dict
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
549 :let l = []
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
550 :call add(l, l)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
551 :let dict4 = {"l": l}
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
552 :call add(dict4.l, dict4)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
553 :let lcopy = deepcopy(l)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
554 :let dict4copy = deepcopy(dict4)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
555 :$put =(l == lcopy)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
556 :$put =(dict4 == dict4copy)
3508
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
557 :"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
558 :" Pass the same List to extend()
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
559 :let l = [1, 2, 3, 4, 5]
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
560 :call extend(l, l)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
561 :$put =string(l)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
562 :"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
563 :" Pass the same Dict to extend()
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
564 :let d = { 'a': {'b': 'B'}}
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
565 :call extend(d, d)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
566 :$put =string(d)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
567 :"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
568 :" Pass the same Dict to extend() with "error"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
569 :try
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
570 : call extend(d, d, "error")
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
571 :catch
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
572 : $put =v:exception[:15] . v:exception[-1:-1]
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
573 :endtry
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
574 :$put =string(d)
6422
9fbb9c60ab41 updated for version 7.4.541
Bram Moolenaar <bram@vim.org>
parents: 6166
diff changeset
575 :"
9fbb9c60ab41 updated for version 7.4.541
Bram Moolenaar <bram@vim.org>
parents: 6166
diff changeset
576 :" test for range assign
9fbb9c60ab41 updated for version 7.4.541
Bram Moolenaar <bram@vim.org>
parents: 6166
diff changeset
577 :let l = [0]
9fbb9c60ab41 updated for version 7.4.541
Bram Moolenaar <bram@vim.org>
parents: 6166
diff changeset
578 :let l[:] = [1, 2]
9fbb9c60ab41 updated for version 7.4.541
Bram Moolenaar <bram@vim.org>
parents: 6166
diff changeset
579 :$put =string(l)
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
580 :endfun
2634
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
581 :"
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
582 :call Test(1, 2, [3, 4], {5: 6}) " This may take a while
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
583 :"
1405
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
584 :delfunc Test
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
585 :unlet dict
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
586 :call garbagecollect(1)
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
587 :"
3774
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
588 :" test for patch 7.3.637
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
589 :let a = 'No error caught'
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
590 :try|foldopen|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
591 o=a :"
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
592 :lang C
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
593 :redir => a
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
594 :try|foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
595 :redir END
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
596 o=a :"
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
597 :"
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
598 :/^start:/,$wq! test.out
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
599 ENDTEST
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
600
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
601 start: