Skip to content

Commit fa8b2e1

Browse files
committed
patch 7.4.1661
Problem: No test for special characters in channel eval command. Solution: Testing sending and receiving text with special characters.
1 parent 819821c commit fa8b2e1

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/testdir/test_channel.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,28 @@ def handle(self):
8585
print("sending: {0}".format(cmd))
8686
self.request.sendall(cmd.encode('utf-8'))
8787
response = "ok"
88+
elif decoded[1] == 'eval-special':
89+
# Send an eval request. We ignore the response.
90+
cmd = '["expr","\\"foo\x7f\x10\x01bar\\"", -2]'
91+
print("sending: {0}".format(cmd))
92+
self.request.sendall(cmd.encode('utf-8'))
93+
response = "ok"
94+
elif decoded[1] == 'eval-getline':
95+
# Send an eval request. We ignore the response.
96+
cmd = '["expr","getline(3)", -3]'
97+
print("sending: {0}".format(cmd))
98+
self.request.sendall(cmd.encode('utf-8'))
99+
response = "ok"
88100
elif decoded[1] == 'eval-fails':
89101
# Send an eval request that will fail.
90-
cmd = '["expr","xxx", -2]'
102+
cmd = '["expr","xxx", -4]'
91103
print("sending: {0}".format(cmd))
92104
self.request.sendall(cmd.encode('utf-8'))
93105
response = "ok"
94106
elif decoded[1] == 'eval-error':
95107
# Send an eval request that works but the result can't
96108
# be encoded.
97-
cmd = '["expr","function(\\"tr\\")", -3]'
109+
cmd = '["expr","function(\\"tr\\")", -5]'
98110
print("sending: {0}".format(cmd))
99111
self.request.sendall(cmd.encode('utf-8'))
100112
response = "ok"

src/testdir/test_channel.vim

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,31 @@ func s:communicate(port)
192192
sleep 10m
193193
call assert_equal([-1, 'foo123'], ch_evalexpr(handle, 'eval-result'))
194194

195+
" Send an eval request with special characters.
196+
call assert_equal('ok', ch_evalexpr(handle, 'eval-special'))
197+
sleep 10m
198+
call assert_equal([-2, "foo\x7f\x10\x01bar"], ch_evalexpr(handle, 'eval-result'))
199+
200+
" Send an eval request to get a line with special characters.
201+
call setline(3, "a\nb\<CR>c\x01d\x7fe")
202+
call assert_equal('ok', ch_evalexpr(handle, 'eval-getline'))
203+
sleep 10m
204+
call assert_equal([-3, "a\nb\<CR>c\x01d\x7fe"], ch_evalexpr(handle, 'eval-result'))
205+
195206
" Send an eval request that fails.
196207
call assert_equal('ok', ch_evalexpr(handle, 'eval-fails'))
197208
sleep 10m
198-
call assert_equal([-2, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
209+
call assert_equal([-4, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
199210

200211
" Send an eval request that works but can't be encoded.
201212
call assert_equal('ok', ch_evalexpr(handle, 'eval-error'))
202213
sleep 10m
203-
call assert_equal([-3, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
214+
call assert_equal([-5, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
204215

205216
" Send a bad eval request. There will be no response.
206217
call assert_equal('ok', ch_evalexpr(handle, 'eval-bad'))
207218
sleep 10m
208-
call assert_equal([-3, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
219+
call assert_equal([-5, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
209220

210221
" Send an expr request
211222
call assert_equal('ok', ch_evalexpr(handle, 'an expr'))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1661,
751753
/**/
752754
1660,
753755
/**/

0 commit comments

Comments
 (0)