annotate src/testdir/test55.in @ 6166:0a42938f449c v7.4.419

updated for version 7.4.419 Problem: Whan part of a list is locked it's possible to make changes. Solution: Check if any of the list items is locked before make a change. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Fri, 29 Aug 2014 09:46:10 +0200
parents f9ec944e4474
children 9fbb9c60ab41
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
6166
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
285 :unlet l
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
286 :let l = [1, 2, 3, 4]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
287 :lockvar! l
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
288 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
289 :unlockvar l[1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
290 :unlet l[0:1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
291 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
292 :unlet l[1:2]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
293 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
294 :unlockvar l[1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
295 :let l[0:1] = [0, 1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
296 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
297 :let l[1:2] = [0, 1]
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
298 :$put =string(l)
0a42938f449c updated for version 7.4.419
Bram Moolenaar <bram@vim.org>
parents: 6022
diff changeset
299 :unlet l
5604
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
300 :" :lockvar/islocked() triggering script autoloading
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
301 :set rtp+=./sautest
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
302 :lockvar g:footest#x
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
303 :unlockvar g:footest#x
b43363a7b4c7 updated for version 7.4.149
Bram Moolenaar <bram@vim.org>
parents: 4191
diff changeset
304 :$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
305 :$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
306 :$put ='g:footest#x: '.g:footest#x
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
307 :"
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
308 :" a:000 function argument
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
309 :" first the tests that should fail
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
310 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
311 : let a:000 = [1, 2]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
312 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
313 : $put ='caught a:000'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
314 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
315 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
316 : let a:000[0] = 9
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
317 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
318 : $put ='caught a:000[0]'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
319 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
320 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
321 : let a:000[2] = [9, 10]
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
322 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
323 : $put ='caught a:000[2]'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
324 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
325 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
326 : let a:000[3] = {9: 10}
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
327 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
328 : $put ='caught a:000[3]'
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
329 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
330 :" now the tests that should pass
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
331 :try
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
332 : let a:000[2][1] = 9
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
333 : call extend(a:000[2], [5, 6])
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
334 : let a:000[3][5] = 8
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
335 : let a:000[3]['a'] = 12
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
336 : $put =string(a:000)
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
337 :catch
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
338 : $put ='caught ' . v:exception
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
339 :endtry
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
340 :"
5747
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
341 :" reverse(), sort(), uniq()
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
342 :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
343 :$put =string(uniq(copy(l)))
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
344 :$put =string(reverse(l))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
345 :$put =string(reverse(reverse(l)))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
346 :$put =string(sort(l))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
347 :$put =string(reverse(sort(l)))
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
348 :$put =string(sort(reverse(sort(l))))
5747
ddc3f32a4b21 updated for version 7.4.218
Bram Moolenaar <bram@vim.org>
parents: 5604
diff changeset
349 :$put =string(uniq(sort(l)))
6022
f9ec944e4474 updated for version 7.4.351
Bram Moolenaar <bram@vim.org>
parents: 6014
diff changeset
350 :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
351 :$put =string(sort(copy(l), 'n'))
6022
f9ec944e4474 updated for version 7.4.351
Bram Moolenaar <bram@vim.org>
parents: 6014
diff changeset
352 :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
353 :$put =string(sort(copy(l), 1))
adc4a84f72eb updated for version 7.4.341
Bram Moolenaar <bram@vim.org>
parents: 5747
diff changeset
354 :$put =string(sort(copy(l), 'i'))
adc4a84f72eb updated for version 7.4.341
Bram Moolenaar <bram@vim.org>
parents: 5747
diff changeset
355 :$put =string(sort(copy(l)))
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 148
diff changeset
356 :"
283
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
357 :" splitting a string to a List
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
358 :$put =string(split(' aa bb '))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
359 :$put =string(split(' aa bb ', '\W\+', 0))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
360 :$put =string(split(' aa bb ', '\W\+', 1))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
361 :$put =string(split(' aa bb ', '\W', 1))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
362 :$put =string(split(':aa::bb:', ':', 0))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
363 :$put =string(split(':aa::bb:', ':', 1))
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
364 :$put =string(split('aa,,bb, cc,', ',\s*', 1))
294
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 283
diff changeset
365 :$put =string(split('abc', '\zs'))
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 283
diff changeset
366 :$put =string(split('abc', '\zs', 1))
283
a2ff714de3db updated for version 7.0075
vimboss
parents: 164
diff changeset
367 :"
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
368 :" compare recursively linked list and dict
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
369 :let l = [1, 2, 3, 4]
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
370 :let d = {'1': 1, '2': l, '3': 3}
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
371 :let l[1] = d
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
372 :$put =(l == l)
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
373 :$put =(d == d)
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
374 :$put =(l != deepcopy(l))
96cd8222a819 updated for version 7.1a
vimboss
parents: 842
diff changeset
375 :$put =(d != deepcopy(d))
2634
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
376 :"
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
377 :" compare complex recursively linked list and dict
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
378 :let l = []
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
379 :call add(l, l)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
380 :let dict4 = {"l": l}
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
381 :call add(dict4.l, dict4)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
382 :let lcopy = deepcopy(l)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
383 :let dict4copy = deepcopy(dict4)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
384 :$put =(l == lcopy)
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
385 :$put =(dict4 == dict4copy)
3508
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
386 :"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
387 :" Pass the same List to extend()
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
388 :let l = [1, 2, 3, 4, 5]
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
389 :call extend(l, l)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
390 :$put =string(l)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
391 :"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
392 :" Pass the same Dict to extend()
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
393 :let d = { 'a': {'b': 'B'}}
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
394 :call extend(d, d)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
395 :$put =string(d)
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
396 :"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
397 :" Pass the same Dict to extend() with "error"
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
398 :try
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
399 : call extend(d, d, "error")
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
400 :catch
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
401 : $put =v:exception[:15] . v:exception[-1:-1]
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
402 :endtry
02440d1fcc9a updated for version 7.3.516
Bram Moolenaar <bram@vim.org>
parents: 2634
diff changeset
403 :$put =string(d)
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
404 :endfun
2634
fcb916bed51a updated for version 7.3.055
Bram Moolenaar <bram@vim.org>
parents: 1539
diff changeset
405 :"
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
406 :call Test(1, 2, [3, 4], {5: 6}) " This may take a while
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
407 :"
1405
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
408 :delfunc Test
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
409 :unlet dict
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
410 :call garbagecollect(1)
b63792dadc23 updated for version 7.1-120
vimboss
parents: 1125
diff changeset
411 :"
3774
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
412 :" test for patch 7.3.637
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
413 :let a = 'No error caught'
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
414 :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
415 o=a :"
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
416 :lang C
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
417 :redir => a
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
418 :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
419 :redir END
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
420 o=a :"
1810ee914648 updated for version 7.3.645
Bram Moolenaar <bram@vim.org>
parents: 3508
diff changeset
421 :"
119
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
422 :/^start:/,$wq! test.out
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
423 ENDTEST
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
424
e8f07016e34d updated for version 7.0042
vimboss
parents:
diff changeset
425 start: