Mercurial > vim
annotate src/testdir/test_blob.vim @ 24473:b2484fa6cb02 v8.2.2776
patch 8.2.2776: :mksession uses current value of 'splitbelow' and 'splitright'
Commit: https://github.com/vim/vim/commit/0995c81f2ffe276669daa004f7778ecc6f5ee09d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 17 18:38:54 2021 +0200
patch 8.2.2776: :mksession uses current value of 'splitbelow' and 'splitright'
Problem: :mksession uses current value of 'splitbelow' and 'splitright'
even though "options" is not in 'sessionoptions'. (Maxim Kim)
Solution: Save and restore the values, instead of setting to the current
value. (closes #8119)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 17 Apr 2021 18:45:04 +0200 |
parents | 3e1886f1e875 |
children | 96905804bf5a |
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 |
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
|
3 source vim9.vim |
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())) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
40 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
|
41 call CheckLegacyAndVim9Success(lines) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 " assignment to a blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 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
|
49 call assert_equal(0zADBE, b2) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 |
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
|
51 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
|
52 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
|
53 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
|
54 |
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 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 |
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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 |
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
|
69 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
|
70 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
|
71 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
|
72 |
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 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
|
74 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
|
75 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
|
76 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
|
77 call CheckLegacyAndVim9Success(lines) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
22608
diff
changeset
|
78 |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
79 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
80 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
81 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
|
82 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
83 call CheckLegacyAndVim9Failure(lines, 'E972:') |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
84 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
85 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
86 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
87 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
|
88 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
89 call CheckLegacyAndVim9Failure(lines, 'E972:') |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
90 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
91 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
92 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
93 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
|
94 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
95 call CheckLegacyAndVim9Failure(lines, 'E979:') |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
96 |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
97 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
98 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
99 LET b ..= 0z33 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
100 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
101 call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
102 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
103 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
104 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
105 LET b ..= "xx" |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
106 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
107 call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
108 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
109 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
110 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
111 LET b += "xx" |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
112 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
113 call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
114 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
115 let lines =<< trim END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
116 VAR b = 0zDEADBEEF |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
117 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
|
118 END |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
119 call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
120 endfunc |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
121 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
122 func Test_blob_get_range() |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
123 let b = 0z0011223344 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
124 call assert_equal(0z2233, b[2:3]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
125 call assert_equal(0z223344, b[2:-1]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
126 call assert_equal(0z00, b[0:-5]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
127 call assert_equal(0z, b[0:-11]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
128 call assert_equal(0z44, b[-1:]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
129 call assert_equal(0z0011223344, b[:]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
130 call assert_equal(0z0011223344, b[:-1]) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
131 call assert_equal(0z, b[5:6]) |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19251
diff
changeset
|
132 call assert_equal(0z0011, b[-10:1]) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 |
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
|
135 func Test_blob_get() |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
136 let b = 0z0011223344 |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
137 call assert_equal(0x00, get(b, 0)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
138 call assert_equal(0x22, get(b, 2, 999)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
139 call assert_equal(0x44, get(b, 4)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
140 call assert_equal(0x44, get(b, -1)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
141 call assert_equal(-1, get(b, 5)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
142 call assert_equal(999, get(b, 5, 999)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
143 call assert_equal(-1, get(b, -8)) |
74a8f44b5322
patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents:
15468
diff
changeset
|
144 call assert_equal(999, get(b, -8, 999)) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
145 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
|
146 |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
147 call assert_equal(0x00, b[0]) |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
148 call assert_equal(0x22, b[2]) |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
149 call assert_equal(0x44, b[4]) |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
150 call assert_equal(0x44, b[-1]) |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
151 call assert_fails('echo b[5]', 'E979:') |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
152 call assert_fails('echo b[-8]', '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
|
153 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
|
154 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 func Test_blob_to_string() |
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
|
156 let b = 0z00112233445566778899aabbccdd |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
157 call assert_equal('0z00112233.44556677.8899AABB.CCDD', string(b)) |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
158 call assert_equal(b, eval(string(b))) |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
159 call remove(b, 4, -1) |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
160 call assert_equal('0z00112233', string(b)) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 call remove(b, 0, 3) |
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
|
162 call assert_equal('0z', string(b)) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
163 call assert_equal('0z', string(test_null_blob())) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 func Test_blob_compare() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 let b1 = 0z0011 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 let b2 = 0z1100 |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
169 let b3 = 0z001122 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
170 call assert_true(b1 == b1) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 call assert_false(b1 == b2) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
172 call assert_false(b1 == b3) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 call assert_true(b1 != b2) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
174 call assert_true(b1 != b3) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 call assert_true(b1 == 0z0011) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
176 call assert_fails('echo b1 == 9', 'E977:') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
177 call assert_fails('echo b1 != 9', 'E977:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 call assert_false(b1 is b2) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 let b2 = b1 |
15496
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
181 call assert_true(b1 == b2) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 call assert_true(b1 is b2) |
15496
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
183 let b2 = copy(b1) |
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
184 call assert_true(b1 == b2) |
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
185 call assert_false(b1 is b2) |
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
186 let b2 = b1[:] |
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
187 call assert_true(b1 == b2) |
f1c33409e908
patch 8.1.0756: copy() does not make a copy of a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15494
diff
changeset
|
188 call assert_false(b1 is b2) |
20156
49694eceaa55
patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents:
20128
diff
changeset
|
189 call assert_true(b1 isnot b2) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 call assert_fails('let x = b1 > b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 call assert_fails('let x = b1 < b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 call assert_fails('let x = b1 - b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 call assert_fails('let x = b1 / b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 call assert_fails('let x = b1 * b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 " test for range assign |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 func Test_blob_range_assign() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 let b = 0z00 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 let b[1] = 0x11 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 let b[2] = 0x22 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 call assert_equal(0z001122, b) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
204 call assert_fails('let b[4] = 0x33', 'E979:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 func Test_blob_for_loop() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 let blob = 0z00010203 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 let i = 0 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 for byte in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 call assert_equal(i, byte) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 let i += 1 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 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
|
214 call assert_equal(4, i) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 let blob = 0z00 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 call remove(blob, 0) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 call assert_equal(0, len(blob)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 for byte in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 call assert_error('loop over empty blob') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 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
|
222 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
223 let blob = 0z0001020304 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
224 let i = 0 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
225 for byte in blob |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
226 call assert_equal(i, byte) |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
227 if i == 1 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
228 call remove(blob, 0) |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
229 elseif i == 3 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
230 call remove(blob, 3) |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
231 endif |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
232 let i += 1 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
233 endfor |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
234 call assert_equal(5, i) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 func Test_blob_concatenate() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 let b = 0z0011 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 let b += 0z2233 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 call assert_equal(0z00112233, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 call assert_fails('let b += "a"') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 call assert_fails('let b += 88') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 let b = 0zDEAD + 0zBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 call assert_equal(0zDEADBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
249 func Test_blob_add() |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
250 let b = 0z0011 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
251 call add(b, 0x22) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
252 call assert_equal(0z001122, b) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
253 call add(b, '51') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
254 call assert_equal(0z00112233, 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
|
255 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
|
256 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
257 call assert_fails('call add(b, [9])', 'E745:') |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15515
diff
changeset
|
258 call assert_fails('call add("", 0x01)', 'E897:') |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
259 endfunc |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
260 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
261 func Test_blob_empty() |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
262 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
|
263 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
|
264 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
|
265 endfunc |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
266 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 " Test removing items in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 func Test_blob_func_remove() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 " Test removing 1 element |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 call assert_equal(0xDE, remove(b, 0)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 call assert_equal(0zADBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 call assert_equal(0xEF, remove(b, -1)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 call assert_equal(0zDEADBE, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 call assert_equal(0xAD, remove(b, 1)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 call assert_equal(0zDEBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 " Test removing range of element(s) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 call assert_equal(0zBE, remove(b, 2, 2)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 call assert_equal(0zDEADEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 call assert_equal(0zADBE, remove(b, 1, 2)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 call assert_equal(0zDEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 " Test invalid cases |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 call assert_fails("call remove(b, 5)", 'E979:') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 call assert_fails("call remove(b, 1, 5)", 'E979:') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 call assert_fails("call remove(b, 3, 2)", 'E979:') |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15515
diff
changeset
|
296 call assert_fails("call remove(1, 0)", 'E896:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 call assert_fails("call remove(b, b)", 'E974:') |
20941
505d97ea54da
patch 8.2.1022: various parts of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
298 call assert_fails("call remove(b, 1, [])", 'E745:') |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
299 call assert_fails("call remove(test_null_blob(), 1, 2)", 'E979:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 func Test_blob_read_write() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 call writefile(b, 'Xblob') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 let br = readfile('Xblob', 'B') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 call assert_equal(b, br) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 call delete('Xblob') |
19930
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
308 |
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
309 " 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
|
310 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
|
311 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 " filter() item in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 func Test_blob_filter() |
22608
f140b9036aa5
patch 8.2.1852: map() returing zero for NULL list is unexpected
Bram Moolenaar <Bram@vim.org>
parents:
20941
diff
changeset
|
315 call assert_equal(test_null_blob(), filter(test_null_blob(), '0')) |
19123
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
316 call assert_equal(0z, filter(0zDEADBEEF, '0')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
317 call assert_equal(0zADBEEF, filter(0zDEADBEEF, 'v:val != 0xDE')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
318 call assert_equal(0zDEADEF, filter(0zDEADBEEF, 'v:val != 0xBE')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
319 call assert_equal(0zDEADBE, filter(0zDEADBEEF, 'v:val != 0xEF')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
320 call assert_equal(0zDEADBEEF, filter(0zDEADBEEF, '1')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
321 call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
322 call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 " map() item in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 func Test_blob_map() |
19123
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
327 call assert_equal(0zDFAEBFF0, map(0zDEADBEEF, 'v:val + 1')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
328 call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) |
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
329 call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
330 |
19123
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
331 call assert_fails("call map(0z00, '[9]')", 'E978:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 func Test_blob_index() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 call assert_equal(2, index(0zDEADBEEF, 0xBE)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 call assert_equal(-1, index(0zDEADBEEF, 0)) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
337 call assert_equal(2, index(0z11111111, 0x11, 2)) |
17914
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17344
diff
changeset
|
338 call assert_equal(3, 0z11110111->index(0x11, 2)) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
339 call assert_equal(2, index(0z11111111, 0x11, -2)) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
340 call assert_equal(3, index(0z11110111, 0x11, -2)) |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
341 call assert_equal(0, index(0z11110111, 0x11, -10)) |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
342 call assert_fails("echo index(0z11110111, 0x11, [])", 'E745:') |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
343 call assert_equal(-1, index(test_null_blob(), 1)) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
344 |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15515
diff
changeset
|
345 call assert_fails('call index("asdf", 0)', 'E897:') |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 func Test_blob_insert() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 call insert(b, 0x33) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 call assert_equal(0z33DEADBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 call insert(b, 0x33, 2) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 call assert_equal(0zDEAD33BEEF, b) |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
356 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
357 call assert_fails('call insert(b, -1)', 'E475:') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
358 call assert_fails('call insert(b, 257)', 'E475:') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
359 call assert_fails('call insert(b, 0, [9])', 'E745:') |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19930
diff
changeset
|
360 call assert_fails('call insert(b, 0, -20)', 'E475:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19930
diff
changeset
|
361 call assert_fails('call insert(b, 0, 20)', 'E475:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19930
diff
changeset
|
362 call assert_fails('call insert(b, [])', 'E745:') |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
363 call assert_equal(0, insert(test_null_blob(), 0x33)) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 func Test_blob_reverse() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 call assert_equal(0zBEADDE, reverse(0zDEADBE)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 call assert_equal(0zADDE, reverse(0zDEAD)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 call assert_equal(0zDE, reverse(0zDE)) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
371 call assert_equal(0z, reverse(test_null_blob())) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 func Test_blob_json_encode() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 call assert_equal('[222,173,190,239]', json_encode(0zDEADBEEF)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 call assert_equal('[]', json_encode(0z)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 endfunc |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
378 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
379 func Test_blob_lock() |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
380 let b = 0z112233 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
381 lockvar b |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
382 call assert_fails('let b = 0z44', 'E741:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
383 unlockvar b |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
384 let b = 0z44 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
385 endfunc |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
386 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
387 func Test_blob_sort() |
19251
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
388 if has('float') |
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
389 call assert_fails('call sort([1.0, 0z11], "f")', 'E975:') |
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
390 else |
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
391 call assert_fails('call sort(["abc", 0z11], "f")', 'E702:') |
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
392 endif |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
393 endfunc |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
394 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
395 " vim: shiftwidth=2 sts=2 expandtab |