Mercurial > vim
annotate src/testdir/test_blob.vim @ 22713:e871a824efc9 v8.2.1905
patch 8.2.1905: the wininfo list may contain stale entries
Commit: https://github.com/vim/vim/commit/4882d983397057ea91c584c5a54aaccf15016d18
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 25 17:55:09 2020 +0100
patch 8.2.1905: the wininfo list may contain stale entries
Problem: The wininfo list may contain stale entries.
Solution: When closing a window remove any other entry where the window
pointer is NULL.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 25 Oct 2020 18:00:04 +0100 |
parents | f140b9036aa5 |
children | 602e528a8e43 |
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 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 func TearDown() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 " Run garbage collection after every test |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 call test_garbagecollect_now() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 " Tests for Blob type |
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 " Blob creation from constant |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 func Test_blob_create() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 call assert_equal(v:t_blob, type(b)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 call assert_equal(4, len(b)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 call assert_equal(0xDE, b[0]) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 call assert_equal(0xAD, b[1]) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 call assert_equal(0xBE, b[2]) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 call assert_equal(0xEF, b[3]) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 call assert_fails('let x = b[4]') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 call assert_equal(0xDE, get(b, 0)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 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
|
23 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
24 call assert_fails('let b = 0z1', 'E973:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
25 call assert_fails('let b = 0z1x', 'E973:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
26 call assert_fails('let b = 0z12345', 'E973:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
27 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
28 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
|
29 |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
30 let b = 0z001122.33445566.778899.aabbcc.dd |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
31 call assert_equal(0z00112233445566778899aabbccdd, 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
|
32 call assert_fails('let b = 0z1.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
|
33 call assert_fails('let b = 0z.') |
99a4cc4782ac
patch 8.1.0765: string format of a Blob can't be parsed back
Bram Moolenaar <Bram@vim.org>
parents:
15496
diff
changeset
|
34 call assert_fails('let b = 0z001122.') |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15515
diff
changeset
|
35 call assert_fails('call get("", 1)', 'E896:') |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
36 call assert_equal(0, len(test_null_blob())) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 " assignment to a blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 func Test_blob_assign() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 let b2 = b[1:2] |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 call assert_equal(0zADBE, b2) |
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 let bcopy = b[:] |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 call assert_equal(b, bcopy) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 call assert_false(b is bcopy) |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
48 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
49 let b = 0zDEADBEEF |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
50 let b2 = b |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
51 call assert_true(b is b2) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
52 let b[:] = 0z11223344 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
53 call assert_equal(0z11223344, b) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
54 call assert_equal(0z11223344, b2) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
55 call assert_true(b is b2) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
56 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
57 let b = 0zDEADBEEF |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
58 let b[3:] = 0z66 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
59 call assert_equal(0zDEADBE66, b) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
60 let b[:1] = 0z8899 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
61 call assert_equal(0z8899BE66, b) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
62 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
63 call assert_fails('let b[2:3] = 0z112233', 'E972:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
64 call assert_fails('let b[2:3] = 0z11', 'E972:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
65 call assert_fails('let b[3:2] = 0z', 'E979:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
66 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
67 let b = 0zDEADBEEF |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
68 let b += 0z99 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
69 call assert_equal(0zDEADBEEF99, b) |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
70 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
71 call assert_fails('let b .= 0z33', 'E734:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
72 call assert_fails('let b .= "xx"', 'E734:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
73 call assert_fails('let b += "xx"', 'E734:') |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
74 call assert_fails('let b[1:1] .= 0z55', 'E734:') |
17344
a0eb2ff0f297
patch 8.1.1671: copying a blob may result in it being locked
Bram Moolenaar <Bram@vim.org>
parents:
15589
diff
changeset
|
75 |
a0eb2ff0f297
patch 8.1.1671: copying a blob may result in it being locked
Bram Moolenaar <Bram@vim.org>
parents:
15589
diff
changeset
|
76 let l = [0z12] |
a0eb2ff0f297
patch 8.1.1671: copying a blob may result in it being locked
Bram Moolenaar <Bram@vim.org>
parents:
15589
diff
changeset
|
77 let m = deepcopy(l) |
a0eb2ff0f297
patch 8.1.1671: copying a blob may result in it being locked
Bram Moolenaar <Bram@vim.org>
parents:
15589
diff
changeset
|
78 let m[0] = 0z34 " E742 or E741 should not occur. |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
79 endfunc |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
80 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
81 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
|
82 let b = 0z0011223344 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 |
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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 |
44ea60ca593b
patch 8.1.0802: negative index doesn't work for Blob
Bram Moolenaar <Bram@vim.org>
parents:
15581
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 call assert_equal('0z00112233', string(b)) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 func Test_blob_compare() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 let b1 = 0z0011 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 let b2 = 0z1100 |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
128 let b3 = 0z001122 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
129 call assert_true(b1 == b1) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 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
|
131 call assert_false(b1 == b3) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 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
|
133 call assert_true(b1 != b3) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 call assert_false(b1 is b2) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 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
|
140 call assert_true(b1 == b2) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 call assert_true(b1 isnot b2) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 call assert_fails('let x = b1 > b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 call assert_fails('let x = b1 < b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 call assert_fails('let x = b1 - b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 call assert_fails('let x = b1 / b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 call assert_fails('let x = b1 * b2') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 " test for range assign |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 func Test_blob_range_assign() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 let b = 0z00 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 let b[1] = 0x11 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 let b[2] = 0x22 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 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
|
163 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
|
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_for_loop() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 let blob = 0z00010203 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 let i = 0 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 for byte in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 call assert_equal(i, byte) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 let i += 1 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 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
|
173 call assert_equal(4, i) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 let blob = 0z00 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 call remove(blob, 0) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 call assert_equal(0, len(blob)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 for byte in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 call assert_error('loop over empty blob') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 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
|
181 |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 endif |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
191 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
|
192 endfor |
c2382f0d1279
patch 8.1.0798: changing a blob while iterating over it works strangely
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
193 call assert_equal(5, i) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 func Test_blob_concatenate() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 let b = 0z0011 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 let b += 0z2233 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 call assert_equal(0z00112233, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 call assert_fails('let b += "a"') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 call assert_fails('let b += 88') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 let b = 0zDEAD + 0zBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 call assert_equal(0zDEADBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 |
15468
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
208 func Test_blob_add() |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
209 let b = 0z0011 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
210 call add(b, 0x22) |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
211 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
|
212 call add(b, '51') |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
213 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
|
214 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
|
215 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
216 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
|
217 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
|
218 endfunc |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
219 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
220 func Test_blob_empty() |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
221 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
|
222 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
|
223 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
|
224 endfunc |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
225 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 " Test removing items in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 func Test_blob_func_remove() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 " Test removing 1 element |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 call assert_equal(0xDE, remove(b, 0)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 call assert_equal(0zADBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 call assert_equal(0xEF, remove(b, -1)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 call assert_equal(0zDEADBE, b) |
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 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 call assert_equal(0xAD, remove(b, 1)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 call assert_equal(0zDEBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 " Test removing range of element(s) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 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
|
244 call assert_equal(0zDEADEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 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
|
248 call assert_equal(0zDEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 " Test invalid cases |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 func Test_blob_read_write() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 call writefile(b, 'Xblob') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 let br = readfile('Xblob', 'B') |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 call assert_equal(b, br) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 call delete('Xblob') |
19930
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
267 |
80e663e91e1b
patch 8.2.0521: crash when reading a blob fails
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
268 " 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
|
269 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
|
270 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 " filter() item in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 " map() item in blob |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 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
|
286 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
|
287 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
|
288 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
|
289 |
19123
09f28c17ac58
patch 8.2.0121: filter() and map() on blob don't work
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
290 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
|
291 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 func Test_blob_index() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 call assert_equal(2, index(0zDEADBEEF, 0xBE)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15515
diff
changeset
|
304 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
|
305 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 func Test_blob_insert() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 call insert(b, 0x33) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 call assert_equal(0z33DEADBEEF, b) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 let b = 0zDEADBEEF |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 call insert(b, 0x33, 2) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 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
|
315 |
1550cc188ff6
patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents:
15456
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
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 func Test_blob_reverse() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 call assert_equal(0zBEADDE, reverse(0zDEADBE)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 call assert_equal(0zADDE, reverse(0zDEAD)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 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
|
330 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
|
331 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 func Test_blob_json_encode() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 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
|
335 call assert_equal('[]', json_encode(0z)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 endfunc |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
337 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
338 func Test_blob_lock() |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
339 let b = 0z112233 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
340 lockvar b |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
341 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
|
342 unlockvar b |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
343 let b = 0z44 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
344 endfunc |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
345 |
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
346 func Test_blob_sort() |
19251
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
347 if has('float') |
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
348 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
|
349 else |
158d4eeba201
patch 8.2.0184: blob test fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
350 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
|
351 endif |
15456
f01eb1aed348
patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
352 endfunc |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
353 |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
354 " vim: shiftwidth=2 sts=2 expandtab |