0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

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.
This commit is contained in:
Bram Moolenaar
2021-04-18 13:15:58 +02:00
parent f7e92aae15
commit d551d6c268
4 changed files with 71 additions and 32 deletions

View File

@@ -283,33 +283,36 @@ func Test_blob_index_assign()
endfunc
func Test_blob_for_loop()
let blob = 0z00010203
let i = 0
for byte in blob
call assert_equal(i, byte)
let i += 1
endfor
call assert_equal(4, i)
let lines =<< trim END
VAR blob = 0z00010203
VAR i = 0
for byte in blob
call assert_equal(i, byte)
LET i += 1
endfor
call assert_equal(4, i)
let blob = 0z00
call remove(blob, 0)
call assert_equal(0, len(blob))
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
LET blob = 0z00
call remove(blob, 0)
elseif i == 3
call remove(blob, 3)
endif
let i += 1
endfor
call assert_equal(5, i)
call assert_equal(0, len(blob))
for byte in blob
call assert_report('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)
END
call CheckLegacyAndVim9Success(lines)
endfunc
func Test_blob_concatenate()