Mercurial > vim
comparison src/testdir/test_blob.vim @ 24480:943e9b1d2d16 v8.2.2780
patch 8.2.2780: Vim9: for loop over blob doesn't work
Commit: https://github.com/vim/vim/commit/d551d6c268e435e2fbba22775510fbd0a54477f6
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 18 13:15:58 2021 +0200
patch 8.2.2780: Vim9: for loop over blob doesn't work
Problem: Vim9: for loop over blob doesn't work.
Solution: Make it work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Apr 2021 13:30:03 +0200 |
parents | 96905804bf5a |
children | 3d5a66e478f8 |
comparison
equal
deleted
inserted
replaced
24479:22651692d78e | 24480:943e9b1d2d16 |
---|---|
281 END | 281 END |
282 call CheckLegacyAndVim9Failure(lines, 'E979:') | 282 call CheckLegacyAndVim9Failure(lines, 'E979:') |
283 endfunc | 283 endfunc |
284 | 284 |
285 func Test_blob_for_loop() | 285 func Test_blob_for_loop() |
286 let blob = 0z00010203 | 286 let lines =<< trim END |
287 let i = 0 | 287 VAR blob = 0z00010203 |
288 for byte in blob | 288 VAR i = 0 |
289 call assert_equal(i, byte) | 289 for byte in blob |
290 let i += 1 | 290 call assert_equal(i, byte) |
291 endfor | 291 LET i += 1 |
292 call assert_equal(4, i) | 292 endfor |
293 | 293 call assert_equal(4, i) |
294 let blob = 0z00 | 294 |
295 call remove(blob, 0) | 295 LET blob = 0z00 |
296 call assert_equal(0, len(blob)) | |
297 for byte in blob | |
298 call assert_error('loop over empty blob') | |
299 endfor | |
300 | |
301 let blob = 0z0001020304 | |
302 let i = 0 | |
303 for byte in blob | |
304 call assert_equal(i, byte) | |
305 if i == 1 | |
306 call remove(blob, 0) | 296 call remove(blob, 0) |
307 elseif i == 3 | 297 call assert_equal(0, len(blob)) |
308 call remove(blob, 3) | 298 for byte in blob |
309 endif | 299 call assert_report('loop over empty blob') |
310 let i += 1 | 300 endfor |
311 endfor | 301 |
312 call assert_equal(5, i) | 302 LET blob = 0z0001020304 |
303 LET i = 0 | |
304 for byte in blob | |
305 call assert_equal(i, byte) | |
306 if i == 1 | |
307 call remove(blob, 0) | |
308 elseif i == 3 | |
309 call remove(blob, 3) | |
310 endif | |
311 LET i += 1 | |
312 endfor | |
313 call assert_equal(5, i) | |
314 END | |
315 call CheckLegacyAndVim9Success(lines) | |
313 endfunc | 316 endfunc |
314 | 317 |
315 func Test_blob_concatenate() | 318 func Test_blob_concatenate() |
316 let b = 0z0011 | 319 let b = 0z0011 |
317 let b += 0z2233 | 320 let b += 0z2233 |