Mercurial > vim
annotate src/testdir/test_blob.vim @ 30007:4123e4bd1708 v9.0.0341
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Commit: https://github.com/vim/vim/commit/92a3d20682d46359bb50a452b4f831659e799155
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed Aug 31 16:40:17 2022 +0100
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Problem: mapset() does not restore <Nop> mapping properly.
Solution: Use an empty string for <Nop>. (closes https://github.com/vim/vim/issues/11022)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 31 Aug 2022 17:45:03 +0200 |
parents | cadc9851377d |
children | ba22d5536d3e |
rev | line source |
---|---|
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Tests for the Blob types |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
3 import './vim9.vim' as v9 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
4 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 func TearDown() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 " Run garbage collection after every test |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 call test_garbagecollect_now() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 " Tests for Blob type |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 " Blob creation from constant |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 func Test_blob_create() |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
14 let lines =<< trim END |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
15 VAR b = 0zDEADBEEF |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
16 call assert_equal(v:t_blob, type(b)) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
17 call assert_equal(4, len(b)) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
18 call assert_equal(0xDE, b[0]) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
19 call assert_equal(0xAD, b[1]) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
20 call assert_equal(0xBE, b[2]) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
21 call assert_equal(0xEF, b[3]) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
22 call assert_fails('VAR x = b[4]') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
24 call assert_equal(0xDE, get(b, 0)) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
25 call assert_equal(0xEF, get(b, 3)) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
26 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
27 call assert_fails('VAR b = 0z1', 'E973:') |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
28 call assert_fails('VAR b = 0z1x', 'E973:') |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
29 call assert_fails('VAR b = 0z12345', 'E973:') |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
30 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
31 call assert_equal(0z, test_null_blob()) |
15515
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
32 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
33 LET b = 0z001122.33445566.778899.aabbcc.dd |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
34 call assert_equal(0z00112233445566778899aabbccdd, b) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
35 call assert_fails('VAR b = 0z1.1') |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
36 call assert_fails('VAR b = 0z.') |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
37 call assert_fails('VAR b = 0z001122.') |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
38 call assert_fails('call get("", 1)', 'E896:') |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
39 call assert_equal(0, len(test_null_blob())) |
26759
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
40 call assert_equal(0z, copy(test_null_blob())) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
41 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
42 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 " assignment to a blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 func Test_blob_assign() |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
47 let lines =<< trim END |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
48 VAR b = 0zDEADBEEF |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
49 VAR b2 = b[1 : 2] |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
50 call assert_equal(0zADBE, b2) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
52 VAR bcopy = b[:] |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
53 call assert_equal(b, bcopy) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
54 call assert_false(b is bcopy) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
55 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
56 LET b = 0zDEADBEEF |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
57 LET b2 = b |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
58 call assert_true(b is b2) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
59 LET b[:] = 0z11223344 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
60 call assert_equal(0z11223344, b) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
61 call assert_equal(0z11223344, b2) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
62 call assert_true(b is b2) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
63 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
64 LET b = 0zDEADBEEF |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
65 LET b[3 :] = 0z66 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
66 call assert_equal(0zDEADBE66, b) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
67 LET b[: 1] = 0z8899 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
68 call assert_equal(0z8899BE66, b) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
69 |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
70 LET b = 0zDEADBEEF |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
71 LET b += 0z99 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
72 call assert_equal(0zDEADBEEF99, b) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
73 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
74 VAR l = [0z12] |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
75 VAR m = deepcopy(l) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
76 LET m[0] = 0z34 #" E742 or E741 should not occur. |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
77 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
78 call v9.CheckLegacyAndVim9Success(lines) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
79 |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
80 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
81 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
82 LET b[2 : 3] = 0z112233 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
83 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
84 call v9.CheckLegacyAndVim9Failure(lines, 'E972:') |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
85 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
86 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
87 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
88 LET b[2 : 3] = 0z11 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
89 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
90 call v9.CheckLegacyAndVim9Failure(lines, 'E972:') |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
91 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
92 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
93 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
94 LET b[3 : 2] = 0z |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
95 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
96 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
97 |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
98 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
99 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
100 LET b ..= 0z33 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
101 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
102 call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
103 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
104 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
105 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
106 LET b ..= "xx" |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
107 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
108 call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
109 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
110 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
111 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
112 LET b += "xx" |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
113 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
114 call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
115 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
116 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
117 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
118 LET b[1 : 1] ..= 0z55 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
119 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
120 call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
121 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
122 call assert_fails('let b = readblob("a1b2c3")', 'E484:') |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
123 endfunc |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
124 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
125 func Test_blob_get_range() |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
126 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
127 VAR b = 0z0011223344 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
128 call assert_equal(0z2233, b[2 : 3]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
129 call assert_equal(0z223344, b[2 : -1]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
130 call assert_equal(0z00, b[0 : -5]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
131 call assert_equal(0z, b[0 : -11]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
132 call assert_equal(0z44, b[-1 :]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
133 call assert_equal(0z0011223344, b[:]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
134 call assert_equal(0z0011223344, b[: -1]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
135 call assert_equal(0z, b[5 : 6]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
136 call assert_equal(0z0011, b[-10 : 1]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
137 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
138 call v9.CheckLegacyAndVim9Success(lines) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
139 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
140 " legacy script white space |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
141 let b = 0z0011223344 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
142 call assert_equal(0z2233, b[2:3]) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 |
15494
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
145 func Test_blob_get() |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
146 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
147 VAR b = 0z0011223344 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
148 call assert_equal(0x00, get(b, 0)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
149 call assert_equal(0x22, get(b, 2, 999)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
150 call assert_equal(0x44, get(b, 4)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
151 call assert_equal(0x44, get(b, -1)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
152 call assert_equal(-1, get(b, 5)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
153 call assert_equal(999, get(b, 5, 999)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
154 call assert_equal(-1, get(b, -8)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
155 call assert_equal(999, get(b, -8, 999)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
156 call assert_equal(10, get(test_null_blob(), 2, 10)) |
15589
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
157 |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
158 call assert_equal(0x00, b[0]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
159 call assert_equal(0x22, b[2]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
160 call assert_equal(0x44, b[4]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
161 call assert_equal(0x44, b[-1]) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
162 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
163 call v9.CheckLegacyAndVim9Success(lines) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
164 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
165 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
166 VAR b = 0z0011223344 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
167 echo b[5] |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
168 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
169 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
170 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
171 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
172 VAR b = 0z0011223344 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
173 echo b[-8] |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
174 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
175 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
15494
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
176 endfunc |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
177 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 func Test_blob_to_string() |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
179 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
180 VAR b = 0z00112233445566778899aabbccdd |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
181 call assert_equal('0z00112233.44556677.8899AABB.CCDD', string(b)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
182 call assert_equal(b, eval(string(b))) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
183 call remove(b, 4, -1) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
184 call assert_equal('0z00112233', string(b)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
185 call remove(b, 0, 3) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
186 call assert_equal('0z', string(b)) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
187 call assert_equal('0z', string(test_null_blob())) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
188 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
189 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 func Test_blob_compare() |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
193 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
194 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
195 VAR b2 = 0z1100 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
196 VAR b3 = 0z001122 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
197 call assert_true(b1 == b1) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
198 call assert_false(b1 == b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
199 call assert_false(b1 == b3) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
200 call assert_true(b1 != b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
201 call assert_true(b1 != b3) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
202 call assert_true(b1 == 0z0011) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
203 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
204 call assert_false(b1 is b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
205 LET b2 = b1 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
206 call assert_true(b1 == b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
207 call assert_true(b1 is b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
208 LET b2 = copy(b1) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
209 call assert_true(b1 == b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
210 call assert_false(b1 is b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
211 LET b2 = b1[:] |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
212 call assert_true(b1 == b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
213 call assert_false(b1 is b2) |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
214 call assert_true(b1 isnot b2) |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
215 call assert_true(0z != 0z10) |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
216 call assert_true(0z10 != 0z) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
217 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
218 call v9.CheckLegacyAndVim9Success(lines) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
219 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
220 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
221 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
222 echo b1 == 9 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
223 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
224 call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
226 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
227 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
228 echo b1 != 9 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
229 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
230 call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
231 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
232 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
233 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
234 VAR b2 = 0z1100 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
235 VAR x = b1 > b2 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
236 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
237 call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
238 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
239 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
240 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
241 VAR b2 = 0z1100 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
242 VAR x = b1 < b2 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
243 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
244 call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
246 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
247 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
248 VAR b2 = 0z1100 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
249 VAR x = b1 - b2 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
250 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
251 call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
252 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
253 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
254 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
255 VAR b2 = 0z1100 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
256 VAR x = b1 / b2 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
257 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
258 call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
259 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
260 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
261 VAR b1 = 0z0011 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
262 VAR b2 = 0z1100 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
263 VAR x = b1 * b2 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
264 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
265 call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
268 func Test_blob_index_assign() |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
269 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
270 VAR b = 0z00 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
271 LET b[1] = 0x11 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
272 LET b[2] = 0x22 |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
273 LET b[0] = 0x33 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
274 call assert_equal(0z331122, b) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
275 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
276 call v9.CheckLegacyAndVim9Success(lines) |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
277 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
278 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
279 VAR b = 0z00 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
280 LET b[2] = 0x33 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
281 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
282 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
24475
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
283 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
284 let lines =<< trim END |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
285 VAR b = 0z00 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
286 LET b[-2] = 0x33 |
96905804bf5a
patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents:
24450
diff
changeset
|
287 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
288 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
289 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
290 let lines =<< trim END |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
291 VAR b = 0z00010203 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
292 LET b[0 : -1] = 0z33 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
293 END |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
294 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
295 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
296 let lines =<< trim END |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
297 VAR b = 0z00010203 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
298 LET b[3 : 4] = 0z3344 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
299 END |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
300 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 func Test_blob_for_loop() |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
304 let lines =<< trim END |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
305 VAR blob = 0z00010203 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
306 VAR i = 0 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
307 for byte in blob |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
308 call assert_equal(i, byte) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
309 LET i += 1 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
310 endfor |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
311 call assert_equal(4, i) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
313 LET blob = 0z00 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
314 call remove(blob, 0) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
315 call assert_equal(0, len(blob)) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
316 for byte in blob |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
317 call assert_report('loop over empty blob') |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
318 endfor |
15581
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
319 |
24480
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
320 LET blob = 0z0001020304 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
321 LET i = 0 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
322 for byte in blob |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
323 call assert_equal(i, byte) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
324 if i == 1 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
325 call remove(blob, 0) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
326 elseif i == 3 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
327 call remove(blob, 3) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
328 endif |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
329 LET i += 1 |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
330 endfor |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
331 call assert_equal(5, i) |
943e9b1d2d16
patch 8.2.2780: Vim9: for loop over blob doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24475
diff
changeset
|
332 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
333 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 func Test_blob_concatenate() |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
337 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
338 VAR b = 0z0011 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
339 LET b += 0z2233 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
340 call assert_equal(0z00112233, b) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
341 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
342 LET b = 0zDEAD + 0zBEEF |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
343 call assert_equal(0zDEADBEEF, b) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
344 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
345 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
347 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
348 VAR b = 0z0011 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
349 LET b += "a" |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
350 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
351 call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
353 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
354 VAR b = 0z0011 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
355 LET b += 88 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
356 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
357 call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
360 func Test_blob_add() |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
361 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
362 VAR b = 0z0011 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
363 call add(b, 0x22) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
364 call assert_equal(0z001122, b) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
365 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
366 call v9.CheckLegacyAndVim9Success(lines) |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
367 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
368 " Only works in legacy script |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
369 let b = 0z0011 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
370 call add(b, '51') |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
371 call assert_equal(0z001133, b) |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
372 call assert_equal(1, add(test_null_blob(), 0x22)) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
373 |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
374 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
375 VAR b = 0z0011 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
376 call add(b, [9]) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
377 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
378 call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:']) |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
379 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
380 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
381 VAR b = 0z0011 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
382 call add("", 0x01) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
383 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
384 call v9.CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:']) |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
385 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
386 let lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
387 add(test_null_blob(), 0x22) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24480
diff
changeset
|
388 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
389 call v9.CheckDefExecAndScriptFailure(lines, 'E1131:') |
26759
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
390 |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
391 let lines =<< trim END |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
392 let b = 0zDEADBEEF |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
393 lockvar b |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
394 call add(b, 0) |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
395 unlockvar b |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
396 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
397 call v9.CheckScriptFailure(lines, 'E741:') |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
398 endfunc |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
399 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
400 func Test_blob_empty() |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
401 call assert_false(empty(0z001122)) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
402 call assert_true(empty(0z)) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
403 call assert_true(empty(test_null_blob())) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
404 endfunc |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
405 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 " Test removing items in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 func Test_blob_func_remove() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
408 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
409 #" Test removing 1 element |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
410 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
411 call assert_equal(0xDE, remove(b, 0)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
412 call assert_equal(0zADBEEF, b) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
414 LET b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
415 call assert_equal(0xEF, remove(b, -1)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
416 call assert_equal(0zDEADBE, b) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
418 LET b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
419 call assert_equal(0xAD, remove(b, 1)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
420 call assert_equal(0zDEBEEF, b) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
422 #" Test removing range of element(s) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
423 LET b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
424 call assert_equal(0zBE, remove(b, 2, 2)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
425 call assert_equal(0zDEADEF, b) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
427 LET b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
428 call assert_equal(0zADBE, remove(b, 1, 2)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
429 call assert_equal(0zDEEF, b) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
430 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
431 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 " Test invalid cases |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
434 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
435 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
436 call remove(b, 5) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
437 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
438 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
439 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
440 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
441 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
442 call remove(b, 1, 5) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
443 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
444 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
445 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
446 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
447 VAR b = 0zDEADBEEF |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
448 call remove(b, -10) |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
449 END |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
450 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
451 |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
452 let lines =<< trim END |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
453 VAR b = 0zDEADBEEF |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
454 call remove(b, 3, 2) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
455 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
456 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
457 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
458 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
459 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
460 call remove(test_null_blob(), 1, 2) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
461 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
462 call v9.CheckLegacyAndVim9Failure(lines, 'E979:') |
25495
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
463 |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
464 let lines =<< trim END |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
465 let b = 0zDEADBEEF |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
466 lockvar b |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
467 call remove(b, 0) |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
468 unlockvar b |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
469 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
470 call v9.CheckScriptFailure(lines, 'E741:') |
25495
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
471 |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
472 " can only check at script level, not in a :def function |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
473 let lines =<< trim END |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
474 vim9script |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
475 var b = 0zDEADBEEF |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
476 lockvar b |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
477 remove(b, 0) |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
478 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
479 call v9.CheckScriptFailure(lines, 'E741:') |
26759
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
480 |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
481 call assert_fails('echo remove(0z1020, [])', 'E745:') |
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
482 call assert_fails('echo remove(0z1020, 0, [])', 'E745:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 func Test_blob_read_write() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
486 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
487 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
488 call writefile(b, 'Xblob') |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
489 VAR br = readfile('Xblob', 'B') |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
490 call assert_equal(b, br) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
491 call delete('Xblob') |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
492 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
493 call v9.CheckLegacyAndVim9Success(lines) |
19930
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
494 |
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
495 " This was crashing when calling readfile() with a directory. |
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
496 call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 " filter() item in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 func Test_blob_filter() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
501 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
502 call assert_equal(test_null_blob(), filter(test_null_blob(), '0')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
503 call assert_equal(0z, filter(0zDEADBEEF, '0')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
504 call assert_equal(0zADBEEF, filter(0zDEADBEEF, 'v:val != 0xDE')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
505 call assert_equal(0zDEADEF, filter(0zDEADBEEF, 'v:val != 0xBE')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
506 call assert_equal(0zDEADBE, filter(0zDEADBEEF, 'v:val != 0xEF')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
507 call assert_equal(0zDEADBEEF, filter(0zDEADBEEF, '1')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
508 call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
509 call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
510 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
511 call v9.CheckLegacyAndVim9Success(lines) |
26759
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
512 call assert_fails('echo filter(0z10, "a10")', 'E121:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 " map() item in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 func Test_blob_map() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
517 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
518 call assert_equal(0zDFAEBFF0, map(0zDEADBEEF, 'v:val + 1')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
519 call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
520 call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
521 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
522 call v9.CheckLegacyAndVim9Success(lines) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
523 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
524 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
525 call map(0z00, '[9]') |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
526 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
527 call v9.CheckLegacyAndVim9Failure(lines, 'E978:') |
26759
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
528 call assert_fails('echo map(0z10, "a10")', 'E121:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 func Test_blob_index() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
532 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
533 call assert_equal(2, index(0zDEADBEEF, 0xBE)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
534 call assert_equal(-1, index(0zDEADBEEF, 0)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
535 call assert_equal(2, index(0z11111111, 0x11, 2)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
536 call assert_equal(3, 0z11110111->index(0x11, 2)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
537 call assert_equal(2, index(0z11111111, 0x11, -2)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
538 call assert_equal(3, index(0z11110111, 0x11, -2)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
539 call assert_equal(0, index(0z11110111, 0x11, -10)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
540 call assert_equal(-1, index(test_null_blob(), 1)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
541 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
542 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 func Test_blob_insert() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
546 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
547 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
548 call insert(b, 0x33) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
549 call assert_equal(0z33DEADBEEF, b) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
550 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
551 LET b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
552 call insert(b, 0x33, 2) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
553 call assert_equal(0zDEAD33BEEF, b) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
554 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
555 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
557 " only works in legacy script |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
558 call assert_equal(0, insert(test_null_blob(), 0x33)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
559 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
560 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
561 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
562 call insert(b, -1) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
563 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
564 call v9.CheckLegacyAndVim9Failure(lines, 'E475:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
565 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
566 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
567 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
568 call insert(b, 257) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
569 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
570 call v9.CheckLegacyAndVim9Failure(lines, 'E475:') |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
571 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
572 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
573 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
574 call insert(b, 0, [9]) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
575 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
576 call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
577 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
578 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
579 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
580 call insert(b, 0, -20) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
581 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
582 call v9.CheckLegacyAndVim9Failure(lines, 'E475:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
583 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
584 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
585 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
586 call insert(b, 0, 20) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
587 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
588 call v9.CheckLegacyAndVim9Failure(lines, 'E475:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
589 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
590 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
591 VAR b = 0zDEADBEEF |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
592 call insert(b, []) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
593 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
594 call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
595 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
596 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
597 insert(test_null_blob(), 0x33) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
598 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
599 call v9.CheckDefExecAndScriptFailure(lines, 'E1131:') |
25495
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
600 |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
601 let lines =<< trim END |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
602 let b = 0zDEADBEEF |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
603 lockvar b |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
604 call insert(b, 3) |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
605 unlockvar b |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
606 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
607 call v9.CheckScriptFailure(lines, 'E741:') |
25495
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
608 |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
609 let lines =<< trim END |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
610 vim9script |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
611 var b = 0zDEADBEEF |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
612 lockvar b |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
613 insert(b, 3) |
7144d2ffc86b
patch 8.2.3284: no error for insert() or remove() changing a locked blob
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
614 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
615 call v9.CheckScriptFailure(lines, 'E741:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 func Test_blob_reverse() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
619 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
620 call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
621 call assert_equal(0zBEADDE, reverse(0zDEADBE)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
622 call assert_equal(0zADDE, reverse(0zDEAD)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
623 call assert_equal(0zDE, reverse(0zDE)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
624 call assert_equal(0z, reverse(test_null_blob())) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
625 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
626 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 func Test_blob_json_encode() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
630 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
631 call assert_equal('[222,173,190,239]', json_encode(0zDEADBEEF)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
632 call assert_equal('[]', json_encode(0z)) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
633 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
634 call v9.CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 endfunc |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
636 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
637 func Test_blob_lock() |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
638 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
639 let b = 0z112233 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
640 lockvar b |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
641 unlockvar b |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
642 let b = 0z44 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
643 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
644 call v9.CheckScriptSuccess(lines) |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
645 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
646 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
647 vim9script |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
648 var b = 0z112233 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
649 lockvar b |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
650 unlockvar b |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
651 b = 0z44 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
652 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
653 call v9.CheckScriptSuccess(lines) |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
654 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
655 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
656 let b = 0z112233 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
657 lockvar b |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
658 let b = 0z44 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
659 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
660 call v9.CheckScriptFailure(lines, 'E741:') |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
661 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
662 let lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
663 vim9script |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
664 var b = 0z112233 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
665 lockvar b |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
666 b = 0z44 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
667 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
668 call v9.CheckScriptFailure(lines, 'E741:') |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
669 endfunc |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
670 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
671 func Test_blob_sort() |
19251
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
672 if has('float') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
673 call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') |
19251
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
674 endif |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
675 call v9.CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
676 endfunc |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
677 |
25806
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
678 " Tests for the blob2list() function |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
679 func Test_blob2list() |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
680 call assert_fails('let v = blob2list(10)', 'E1238: Blob required for argument 1') |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
681 eval 0zFFFF->blob2list()->assert_equal([255, 255]) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
682 let tests = [[0z0102, [1, 2]], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
683 \ [0z00, [0]], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
684 \ [0z, []], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
685 \ [0z00000000, [0, 0, 0, 0]], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
686 \ [0zAABB.CCDD, [170, 187, 204, 221]]] |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
687 for t in tests |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
688 call assert_equal(t[0]->blob2list(), t[1]) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
689 endfor |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
690 exe 'let v = 0z' .. repeat('000102030405060708090A0B0C0D0E0F', 64) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
691 call assert_equal(1024, blob2list(v)->len()) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
692 call assert_equal([4, 8, 15], [v[100], v[1000], v[1023]]) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
693 call assert_equal([], blob2list(test_null_blob())) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
694 endfunc |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
695 |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
696 " Tests for the list2blob() function |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
697 func Test_list2blob() |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
698 call assert_fails('let b = list2blob(0z10)', 'E1211: List required for argument 1') |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
699 let tests = [[[1, 2], 0z0102], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
700 \ [[0], 0z00], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
701 \ [[], 0z], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
702 \ [[0, 0, 0, 0], 0z00000000], |
25822
42723b535ab3
patch 8.2.3446: not enough tests for empty string arguments
Bram Moolenaar <Bram@vim.org>
parents:
25806
diff
changeset
|
703 \ [[255, 255], 0zFFFF], |
25806
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
704 \ [[170, 187, 204, 221], 0zAABB.CCDD], |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
705 \ ] |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
706 for t in tests |
25822
42723b535ab3
patch 8.2.3446: not enough tests for empty string arguments
Bram Moolenaar <Bram@vim.org>
parents:
25806
diff
changeset
|
707 call assert_equal(t[1], t[0]->list2blob()) |
25806
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
708 endfor |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
709 call assert_fails('let b = list2blob([1, []])', 'E745:') |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
710 call assert_fails('let b = list2blob([-1])', 'E1239:') |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
711 call assert_fails('let b = list2blob([256])', 'E1239:') |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
712 let b = range(16)->repeat(64)->list2blob() |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
713 call assert_equal(1024, b->len()) |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
714 call assert_equal([4, 8, 15], [b[100], b[1000], b[1023]]) |
26394
43d196ca5e7a
patch 8.2.3728: internal error when passing range() to list2blob()
Bram Moolenaar <Bram@vim.org>
parents:
25822
diff
changeset
|
715 |
25806
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
716 call assert_equal(0z, list2blob(test_null_list())) |
26394
43d196ca5e7a
patch 8.2.3728: internal error when passing range() to list2blob()
Bram Moolenaar <Bram@vim.org>
parents:
25822
diff
changeset
|
717 call assert_equal(0z00010203, list2blob(range(4))) |
25806
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
718 endfunc |
8d55e978f95b
patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents:
25495
diff
changeset
|
719 |
26652
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
720 " The following used to cause an out-of-bounds memory access |
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
721 func Test_blob2string() |
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
722 let v = '0z' .. repeat('01010101.', 444) |
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
723 let v ..= '01' |
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
724 exe 'let b = ' .. v |
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
725 call assert_equal(v, string(b)) |
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26394
diff
changeset
|
726 endfunc |
26394
43d196ca5e7a
patch 8.2.3728: internal error when passing range() to list2blob()
Bram Moolenaar <Bram@vim.org>
parents:
25822
diff
changeset
|
727 |
28289
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
728 " Test for blob allocation failure |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
729 func Test_blob_alloc_failure() |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
730 " blob variable |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
731 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
732 call assert_fails('let v = 0z10', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
733 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
734 " blob slice |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
735 let v = 0z1020 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
736 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
737 call assert_fails('let x = v[0:0]', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
738 call assert_equal(0z1020, x) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
739 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
740 " blob remove() |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
741 let v = 0z10203040 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
742 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
743 call assert_fails('let x = remove(v, 1, 2)', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
744 call assert_equal(0, x) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
745 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
746 " list2blob() |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
747 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
748 call assert_fails('let a = list2blob([1, 2, 4])', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
749 call assert_equal(0, a) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
750 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
751 " mapnew() |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
752 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
753 call assert_fails('let x = mapnew(0z1234, {_, v -> 1})', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
754 call assert_equal(0, x) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
755 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
756 " copy() |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
757 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
758 call assert_fails('let x = copy(v)', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
759 call assert_equal(0z, x) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
760 |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
761 " readblob() |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
762 call test_alloc_fail(GetAllocId('blob_alloc'), 0, 0) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
763 call assert_fails('let x = readblob("test_blob.vim")', 'E342:') |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
764 call assert_equal(0, x) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
765 endfunc |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
766 |
29712
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
767 " Test for the indexof() function |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
768 func Test_indexof() |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
769 let b = 0zdeadbeef |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
770 call assert_equal(0, indexof(b, {i, v -> v == 0xde})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
771 call assert_equal(3, indexof(b, {i, v -> v == 0xef})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
772 call assert_equal(-1, indexof(b, {i, v -> v == 0x1})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
773 call assert_equal(1, indexof(b, "v:val == 0xad")) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
774 call assert_equal(-1, indexof(b, "v:val == 0xff")) |
29728
cadc9851377d
patch 9.0.0204: indexof() may leak memory
Bram Moolenaar <Bram@vim.org>
parents:
29712
diff
changeset
|
775 call assert_equal(-1, indexof(b, {_, v -> "v == 0xad"})) |
29712
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
776 |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
777 call assert_equal(-1, indexof(0z, "v:val == 0x0")) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
778 call assert_equal(-1, indexof(test_null_blob(), "v:val == 0xde")) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
779 call assert_equal(-1, indexof(b, test_null_string())) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
780 call assert_equal(-1, indexof(b, test_null_function())) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
781 |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
782 let b = 0z01020102 |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
783 call assert_equal(1, indexof(b, "v:val == 0x02", #{startidx: 0})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
784 call assert_equal(2, indexof(b, "v:val == 0x01", #{startidx: -2})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
785 call assert_equal(-1, indexof(b, "v:val == 0x01", #{startidx: 5})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
786 call assert_equal(0, indexof(b, "v:val == 0x01", #{startidx: -5})) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
787 call assert_equal(0, indexof(b, "v:val == 0x01", test_null_dict())) |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
788 |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
789 " failure cases |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
790 call assert_fails('let i = indexof(b, "val == 0xde")', 'E121:') |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
791 call assert_fails('let i = indexof(b, {})', 'E1256:') |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
792 endfunc |
bdb31515f78b
patch 9.0.0196: finding value in list may require a for loop
Bram Moolenaar <Bram@vim.org>
parents:
28570
diff
changeset
|
793 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
794 " vim: shiftwidth=2 sts=2 expandtab |