comparison src/testdir/test_blob.vim @ 15581:c2382f0d1279 v8.1.0798

patch 8.1.0798: changing a blob while iterating over it works strangely commit https://github.com/vim/vim/commit/dd29ea18050284526174b5685781469240f5bc4a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 23 21:56:21 2019 +0100 patch 8.1.0798: changing a blob while iterating over it works strangely Problem: Changing a blob while iterating over it works strangely. Solution: Make a copy of the Blob before iterating.
author Bram Moolenaar <Bram@vim.org>
date Wed, 23 Jan 2019 22:00:06 +0100
parents 4af72c724093
children 44ea60ca593b
comparison
equal deleted inserted replaced
15580:0bf6ce525d42 15581:c2382f0d1279
152 let i = 0 152 let i = 0
153 for byte in blob 153 for byte in blob
154 call assert_equal(i, byte) 154 call assert_equal(i, byte)
155 let i += 1 155 let i += 1
156 endfor 156 endfor
157 call assert_equal(4, i)
157 158
158 let blob = 0z00 159 let blob = 0z00
159 call remove(blob, 0) 160 call remove(blob, 0)
160 call assert_equal(0, len(blob)) 161 call assert_equal(0, len(blob))
161 for byte in blob 162 for byte in blob
162 call assert_error('loop over empty blob') 163 call assert_error('loop over empty blob')
163 endfor 164 endfor
165
166 let blob = 0z0001020304
167 let i = 0
168 for byte in blob
169 call assert_equal(i, byte)
170 if i == 1
171 call remove(blob, 0)
172 elseif i == 3
173 call remove(blob, 3)
174 endif
175 let i += 1
176 endfor
177 call assert_equal(5, i)
164 endfunc 178 endfunc
165 179
166 func Test_blob_concatenate() 180 func Test_blob_concatenate()
167 let b = 0z0011 181 let b = 0z0011
168 let b += 0z2233 182 let b += 0z2233