summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_blob.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-18 14:12:31 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-18 14:12:31 +0200
commitb7c21afef14bba0208f2c40d47c050a004eb2f34 (patch)
treed7ac8993ffa95c8e45240dd873eb04e00235f074 /src/testdir/test_blob.vim
parentd551d6c268e435e2fbba22775510fbd0a54477f6 (diff)
patch 8.2.2781: add() silently skips when adding to null list or blobv8.2.2781
Problem: Add() silently skips when adding to null list or blob. Solution: Give an error in Vim9 script. Allocate blob when it is NULL like with list and dict.
Diffstat (limited to 'src/testdir/test_blob.vim')
-rw-r--r--src/testdir/test_blob.vim56
1 files changed, 44 insertions, 12 deletions
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim
index fa482b432f..f54d7733f2 100644
--- a/src/testdir/test_blob.vim
+++ b/src/testdir/test_blob.vim
@@ -316,27 +316,59 @@ func Test_blob_for_loop()
endfunc
func Test_blob_concatenate()
- let b = 0z0011
- let b += 0z2233
- call assert_equal(0z00112233, b)
+ let lines =<< trim END
+ VAR b = 0z0011
+ LET b += 0z2233
+ call assert_equal(0z00112233, b)
+
+ LET b = 0zDEAD + 0zBEEF
+ call assert_equal(0zDEADBEEF, b)
+ END
+ call CheckLegacyAndVim9Success(lines)
- call assert_fails('let b += "a"')
- call assert_fails('let b += 88')
+ let lines =<< trim END
+ VAR b = 0z0011
+ LET b += "a"
+ END
+ call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
- let b = 0zDEAD + 0zBEEF
- call assert_equal(0zDEADBEEF, b)
+ let lines =<< trim END
+ VAR b = 0z0011
+ LET b += 88
+ END
+ call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
endfunc
func Test_blob_add()
+ let lines =<< trim END
+ VAR b = 0z0011
+ call add(b, 0x22)
+ call assert_equal(0z001122, b)
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ " Only works in legacy script
let b = 0z0011
- call add(b, 0x22)
- call assert_equal(0z001122, b)
call add(b, '51')
- call assert_equal(0z00112233, b)
+ call assert_equal(0z001133, b)
call assert_equal(1, add(test_null_blob(), 0x22))
- call assert_fails('call add(b, [9])', 'E745:')
- call assert_fails('call add("", 0x01)', 'E897:')
+ let lines =<< trim END
+ VAR b = 0z0011
+ call add(b, [9])
+ END
+ call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E745:'])
+
+ let lines =<< trim END
+ VAR b = 0z0011
+ call add("", 0x01)
+ END
+ call CheckLegacyAndVim9Failure(lines, 'E897:')
+
+ let lines =<< trim END
+ add(test_null_blob(), 0x22)
+ END
+ call CheckDefExecAndScriptFailure(lines, 'E1131:')
endfunc
func Test_blob_empty()