summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_blob.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_blob.vim')
-rw-r--r--src/testdir/test_blob.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim
index cccecb7..f0e8209 100644
--- a/src/testdir/test_blob.vim
+++ b/src/testdir/test_blob.vim
@@ -74,6 +74,13 @@ func Test_blob_assign()
VAR l = [0z12]
VAR m = deepcopy(l)
LET m[0] = 0z34 #" E742 or E741 should not occur.
+
+ VAR blob1 = 0z10
+ LET blob1 += test_null_blob()
+ call assert_equal(0z10, blob1)
+ LET blob1 = test_null_blob()
+ LET blob1 += 0z20
+ call assert_equal(0z20, blob1)
END
call v9.CheckLegacyAndVim9Success(lines)
@@ -97,6 +104,18 @@ func Test_blob_assign()
let lines =<< trim END
VAR b = 0zDEADBEEF
+ LET b[0 : 1] = 0x1122
+ END
+ call v9.CheckLegacyAndVim9Failure(lines, ['E709:', 'E1012:', 'E709:'])
+
+ let lines =<< trim END
+ VAR b = 0zDEADBEEF
+ LET b[0] = 0z11
+ END
+ call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E974:', 'E1012:'])
+
+ let lines =<< trim END
+ VAR b = 0zDEADBEEF
LET b ..= 0z33
END
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:'])
@@ -331,6 +350,17 @@ func Test_blob_for_loop()
call assert_equal(5, i)
END
call v9.CheckLegacyAndVim9Success(lines)
+
+ " Test for skipping the loop var assignment in a for loop
+ let lines =<< trim END
+ VAR blob = 0z998877
+ VAR c = 0
+ for _ in blob
+ LET c += 1
+ endfor
+ call assert_equal(3, c)
+ END
+ call v9.CheckLegacyAndVim9Success(lines)
endfunc
func Test_blob_concatenate()
@@ -819,6 +849,7 @@ func Test_indexof()
call assert_equal(-1, indexof(test_null_blob(), "v:val == 0xde"))
call assert_equal(-1, indexof(b, test_null_string()))
call assert_equal(-1, indexof(b, test_null_function()))
+ call assert_equal(-1, indexof(b, ""))
let b = 0z01020102
call assert_equal(1, indexof(b, "v:val == 0x02", #{startidx: 0}))
@@ -830,6 +861,7 @@ func Test_indexof()
" failure cases
call assert_fails('let i = indexof(b, "val == 0xde")', 'E121:')
call assert_fails('let i = indexof(b, {})', 'E1256:')
+ call assert_fails('let i = indexof(b, " ")', 'E15:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab