diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-23 21:56:21 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-23 21:56:21 +0100 |
commit | dd29ea18050284526174b5685781469240f5bc4a (patch) | |
tree | 2dd4aa32dab187e6a6973303da6fcb13c4ba5d38 /src/testdir | |
parent | bf821bccf18453b01d25bee53e4954b02a5dd0e6 (diff) |
patch 8.1.0798: changing a blob while iterating over it works strangelyv8.1.0798
Problem: Changing a blob while iterating over it works strangely.
Solution: Make a copy of the Blob before iterating.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_blob.vim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim index 964ed22799..9eb2057740 100644 --- a/src/testdir/test_blob.vim +++ b/src/testdir/test_blob.vim @@ -154,6 +154,7 @@ func Test_blob_for_loop() call assert_equal(i, byte) let i += 1 endfor + call assert_equal(4, i) let blob = 0z00 call remove(blob, 0) @@ -161,6 +162,19 @@ func Test_blob_for_loop() for byte in blob call assert_error('loop over empty blob') endfor + + let blob = 0z0001020304 + let i = 0 + for byte in blob + call assert_equal(i, byte) + if i == 1 + call remove(blob, 0) + elseif i == 3 + call remove(blob, 3) + endif + let i += 1 + endfor + call assert_equal(5, i) endfunc func Test_blob_concatenate() |