annotate src/testdir/test_blob.vim @ 15515:99a4cc4782ac v8.1.0765

patch 8.1.0765: string format of a Blob can't be parsed back commit https://github.com/vim/vim/commit/4131fd5509b283e978e8c6161f09643b64719787 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 17 16:32:53 2019 +0100 patch 8.1.0765: string format of a Blob can't be parsed back Problem: String format of a Blob can't be parsed back. Solution: Use 0z format.
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Jan 2019 16:45:06 +0100
parents f1c33409e908
children 4af72c724093
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.')
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 " assignment to a blob
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 func Test_blob_assign()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 let b2 = b[1:2]
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 call assert_equal(0zADBE, b2)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let bcopy = b[:]
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 call assert_equal(b, bcopy)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 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
46
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
47 let b = 0zDEADBEEF
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
48 let b2 = b
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
49 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
50 let b[:] = 0z11223344
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
51 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
52 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
53 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
54
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
55 let b = 0zDEADBEEF
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
56 let b[3:] = 0z66
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
57 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
58 let b[:1] = 0z8899
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
59 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
60
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
61 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
62 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
63 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
64
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
65 let b = 0zDEADBEEF
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
66 let b += 0z99
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
67 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
68
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
69 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
70 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
71 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
72 call assert_fails('let b[1:1] .= 0z55', 'E734:')
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
73 endfunc
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
74
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
75 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
76 let b = 0z0011223344
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 call assert_equal(0z, b[5:6])
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86
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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 call assert_equal(999, get(b, -8, 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
97 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
98
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 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
100 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
101 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
102 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
103 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
104 call assert_equal('0z00112233', string(b))
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 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
106 call assert_equal('0z', string(b))
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 func Test_blob_compare()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 let b1 = 0z0011
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 let b2 = 0z1100
15456
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
112 let b3 = 0z001122
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
113 call assert_true(b1 == b1)
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 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
115 call assert_false(b1 == b3)
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 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
117 call assert_true(b1 != b3)
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 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
119 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
120 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
121
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 call assert_false(b1 is b2)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 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
124 call assert_true(b1 == b2)
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 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
126 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
127 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
128 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
129 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
130 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
131 call assert_false(b1 is b2)
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 call assert_fails('let x = b1 > b2')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 call assert_fails('let x = b1 < b2')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 call assert_fails('let x = b1 - b2')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 call assert_fails('let x = b1 / b2')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 call assert_fails('let x = b1 * b2')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 " test for range assign
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 func Test_blob_range_assign()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 let b = 0z00
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 let b[1] = 0x11
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 let b[2] = 0x22
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 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
146 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
147 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 func Test_blob_for_loop()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 let blob = 0z00010203
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 let i = 0
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 for byte in blob
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 call assert_equal(i, byte)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 let i += 1
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 endfor
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 let blob = 0z00
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 call remove(blob, 0)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 call assert_equal(0, len(blob))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 for byte in blob
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 call assert_error('loop over empty blob')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 endfor
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 func Test_blob_concatenate()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 let b = 0z0011
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 let b += 0z2233
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 call assert_equal(0z00112233, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 call assert_fails('let b += "a"')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 call assert_fails('let b += 88')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 let b = 0zDEAD + 0zBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 call assert_equal(0zDEADBEEF, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176
15468
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
177 func Test_blob_add()
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
178 let b = 0z0011
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
179 call add(b, 0x22)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
180 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
181 call add(b, '51')
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
182 call assert_equal(0z00112233, b)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
183
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
184 call assert_fails('call add(b, [9])', 'E745:')
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
185 endfunc
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
186
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
187 func Test_blob_empty()
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
188 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
189 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
190 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
191 endfunc
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
192
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 " Test removing items in blob
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 func Test_blob_func_remove()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 " Test removing 1 element
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 call assert_equal(0xDE, remove(b, 0))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 call assert_equal(0zADBEEF, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 call assert_equal(0xEF, remove(b, -1))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 call assert_equal(0zDEADBE, b)
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 = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 call assert_equal(0xAD, remove(b, 1))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 call assert_equal(0zDEBEEF, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 " Test removing range of element(s)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 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
211 call assert_equal(0zDEADEF, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 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
215 call assert_equal(0zDEEF, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 " Test invalid cases
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 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
220 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
221 call assert_fails("call remove(b, 3, 2)", 'E979:')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 call assert_fails("call remove(1, 0)", 'E712:')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 call assert_fails("call remove(b, b)", 'E974:')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 func Test_blob_read_write()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 call writefile(b, 'Xblob')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 let br = readfile('Xblob', 'B')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 call assert_equal(b, br)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 call delete('Xblob')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 " filter() item in blob
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 func Test_blob_filter()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 call filter(b, 'v:val != 0xEF')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 call assert_equal(0zDEADBE, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 endfunc
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 " map() item in blob
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 func Test_blob_map()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 call map(b, 'v:val + 1')
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 call assert_equal(0zDFAEBFF0, b)
15468
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
246
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
247 call assert_fails("call map(b, '[9]')", 'E978:')
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 endfunc
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 func Test_blob_index()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 call assert_equal(2, index(0zDEADBEEF, 0xBE))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 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
253 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
254 call assert_equal(3, index(0z11110111, 0x11, 2))
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
255 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
256 call assert_equal(3, index(0z11110111, 0x11, -2))
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
257
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
258 call assert_fails('call index("asdf", 0)', 'E714:')
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_insert()
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 insert(b, 0x33)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 call assert_equal(0z33DEADBEEF, b)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 let b = 0zDEADBEEF
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 call insert(b, 0x33, 2)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 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
269
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
270 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
271 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
272 call assert_fails('call insert(b, 0, [9])', 'E745:')
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 endfunc
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 func Test_blob_reverse()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 call assert_equal(0zEFBEADDE, reverse(0zDEADBEEF))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 call assert_equal(0zBEADDE, reverse(0zDEADBE))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 call assert_equal(0zADDE, reverse(0zDEAD))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 call assert_equal(0zDE, reverse(0zDE))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 endfunc
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 func Test_blob_json_encode()
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 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
284 call assert_equal('[]', json_encode(0z))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 endfunc
15456
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
286
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
287 func Test_blob_lock()
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
288 let b = 0z112233
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
289 lockvar b
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
290 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
291 unlockvar b
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
292 let b = 0z44
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
293 endfunc
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
294
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
295 func Test_blob_sort()
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
296 call assert_fails('call sort([1.0, 0z11], "f")', 'E975:')
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
297 endfunc