diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-02-28 21:55:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-28 21:55:55 +0800 |
| commit | f289fc4abb8e7c02acfd2dfc834cc6447193a67e (patch) | |
| tree | 4790d7d0eb363611d524dad5b09e2687bec2a1ec /src/nvim/testdir/test_blob.vim | |
| parent | faa5d5be4b998427b3378d16ea5ce6ef6f5ddfd0 (diff) | |
| parent | 278aeee3aed753d1084597378e653395bd472c42 (diff) | |
| download | rneovim-f289fc4abb8e7c02acfd2dfc834cc6447193a67e.tar.gz rneovim-f289fc4abb8e7c02acfd2dfc834cc6447193a67e.tar.bz2 rneovim-f289fc4abb8e7c02acfd2dfc834cc6447193a67e.zip | |
Merge pull request #22456 from zeertzjq/vim-9.0.0430
vim-patch:8.2.{4668,4670},9.0.0430: cannot use repeat() with a blob
Diffstat (limited to 'src/nvim/testdir/test_blob.vim')
| -rw-r--r-- | src/nvim/testdir/test_blob.vim | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index f889da987a..2c145f2019 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -1,5 +1,6 @@ " Tests for the Blob types +source check.vim source vim9.vim func TearDown() @@ -714,6 +715,58 @@ func Test_blob2string() call assert_equal(v, string(b)) endfunc +func Test_blob_repeat() + call assert_equal(0z, repeat(0z00, 0)) + call assert_equal(0z00, repeat(0z00, 1)) + call assert_equal(0z0000, repeat(0z00, 2)) + call assert_equal(0z00000000, repeat(0z0000, 2)) + + call assert_equal(0z, repeat(0z12, 0)) + call assert_equal(0z, repeat(0z1234, 0)) + call assert_equal(0z1234, repeat(0z1234, 1)) + call assert_equal(0z12341234, repeat(0z1234, 2)) +endfunc + +" Test for blob allocation failure +func Test_blob_alloc_failure() + CheckFunction test_alloc_fail + " blob variable + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let v = 0z10', 'E342:') + + " blob slice + let v = 0z1020 + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = v[0:0]', 'E342:') + call assert_equal(0z1020, x) + + " blob remove() + let v = 0z10203040 + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = remove(v, 1, 2)', 'E342:') + call assert_equal(0, x) + + " list2blob() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let a = list2blob([1, 2, 4])', 'E342:') + call assert_equal(0, a) + + " mapnew() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = mapnew(0z1234, {_, v -> 1})', 'E342:') + call assert_equal(0, x) + + " copy() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = copy(v)', 'E342:') + call assert_equal(0z, x) + + " readblob() + call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) + call assert_fails('let x = readblob("test_blob.vim")', 'E342:') + call assert_equal(0, x) +endfunc + " Test for the indexof() function func Test_indexof() let b = 0zdeadbeef |