mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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.
d551d6c268
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
66c384d4e8
commit
0ded757c31
@ -283,33 +283,36 @@ func Test_blob_index_assign()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_for_loop()
|
func Test_blob_for_loop()
|
||||||
let blob = 0z00010203
|
let lines =<< trim END
|
||||||
let i = 0
|
VAR blob = 0z00010203
|
||||||
for byte in blob
|
VAR i = 0
|
||||||
call assert_equal(i, byte)
|
for byte in blob
|
||||||
let i += 1
|
call assert_equal(i, byte)
|
||||||
endfor
|
LET i += 1
|
||||||
call assert_equal(4, i)
|
endfor
|
||||||
|
call assert_equal(4, i)
|
||||||
|
|
||||||
let blob = 0z00
|
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
|
|
||||||
call remove(blob, 0)
|
call remove(blob, 0)
|
||||||
elseif i == 3
|
call assert_equal(0, len(blob))
|
||||||
call remove(blob, 3)
|
for byte in blob
|
||||||
endif
|
call assert_report('loop over empty blob')
|
||||||
let i += 1
|
endfor
|
||||||
endfor
|
|
||||||
call assert_equal(5, i)
|
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
|
endfunc
|
||||||
|
|
||||||
func Test_blob_concatenate()
|
func Test_blob_concatenate()
|
||||||
|
Loading…
Reference in New Issue
Block a user