annotate src/testdir/test_blob.vim @ 27457:4c16acb2525f v8.2.4257

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